List of usage examples for java.util Properties containsKey
@Override public boolean containsKey(Object key)
From source file:com.adaptris.core.services.metadata.WriteMetadataToFilesystemTest.java
public void testService_OutputXml() throws Exception { String subDir = new GuidGenerator().getUUID().replaceAll(":", "").replaceAll("-", ""); AdaptrisMessage msg = createMessage(); WriteMetadataToFilesystem service = createService(subDir); service.setOutputStyle(OutputStyle.XML); File parentDir = FsHelper// w w w .j a va2s .c o m .createFileReference(FsHelper.createUrlFromString(PROPERTIES.getProperty(BASE_DIR), true)); String propsFilename = parentDir.getCanonicalPath() + "/" + subDir + "/" + msg.getUniqueId(); execute(service, msg); Properties p = readProperties(new File(propsFilename), true); assertTrue(p.containsKey("key5")); assertEquals("v5", p.getProperty("key5")); }
From source file:com.adaptris.core.services.metadata.WriteMetadataToFilesystemTest.java
public void testService_OutputUnknown() throws Exception { String subDir = new GuidGenerator().getUUID().replaceAll(":", "").replaceAll("-", ""); AdaptrisMessage msg = createMessage(); WriteMetadataToFilesystem service = createService(subDir); File parentDir = FsHelper//from w w w.j av a 2 s . c o m .createFileReference(FsHelper.createUrlFromString(PROPERTIES.getProperty(BASE_DIR), true)); String propsFilename = parentDir.getCanonicalPath() + "/" + subDir + "/" + msg.getUniqueId(); execute(service, msg); Properties p = readProperties(new File(propsFilename), false); assertTrue(p.containsKey("key5")); assertEquals("v5", p.getProperty("key5")); }
From source file:com.adaptris.core.services.metadata.WriteMetadataToFilesystemTest.java
public void testService_OverwriteFalseFileNonExistent() throws Exception { String subDir = new GuidGenerator().getUUID().replaceAll(":", "").replaceAll("-", ""); AdaptrisMessage msg = createMessage(); WriteMetadataToFilesystem service = createService(subDir); service.setOverwriteIfExists(false); File parentDir = FsHelper/* w w w . j ava 2 s . c om*/ .createFileReference(FsHelper.createUrlFromString(PROPERTIES.getProperty(BASE_DIR), true)); String propsFilename = parentDir.getCanonicalPath() + "/" + subDir + "/" + msg.getUniqueId(); execute(service, msg); Properties p = readProperties(new File(propsFilename), false); assertTrue(p.containsKey("key5")); assertEquals("v5", p.getProperty("key5")); }
From source file:com.adaptris.core.services.metadata.WriteMetadataToFilesystemTest.java
public void testService_OverwriteTrueFileNonExistent() throws Exception { String subDir = new GuidGenerator().getUUID().replaceAll(":", "").replaceAll("-", ""); AdaptrisMessage msg = createMessage(); WriteMetadataToFilesystem service = createService(subDir); service.setOverwriteIfExists(true);//ww w .j a v a 2s . c om File parentDir = FsHelper .createFileReference(FsHelper.createUrlFromString(PROPERTIES.getProperty(BASE_DIR), true)); String propsFilename = parentDir.getCanonicalPath() + "/" + subDir + "/" + msg.getUniqueId(); execute(service, msg); Properties p = readProperties(new File(propsFilename), false); assertTrue(p.containsKey("key5")); assertEquals("v5", p.getProperty("key5")); }
From source file:com.adaptris.core.services.metadata.WriteMetadataToFilesystemTest.java
public void testService_OverwriteTrueFileExists() throws Exception { String subDir = new GuidGenerator().getUUID().replaceAll(":", "").replaceAll("-", ""); AdaptrisMessage msg = createMessage(); WriteMetadataToFilesystem service = createService(subDir); service.setOverwriteIfExists(true);/* ww w.j av a 2s .c o m*/ File parentDir = FsHelper .createFileReference(FsHelper.createUrlFromString(PROPERTIES.getProperty(BASE_DIR), true)); String propsFilename = parentDir.getCanonicalPath() + "/" + subDir + "/" + msg.getUniqueId(); createEmptyFile(new File(propsFilename)); execute(service, msg); Properties p = readProperties(new File(propsFilename), false); assertTrue(p.containsKey("key5")); assertEquals("v5", p.getProperty("key5")); }
From source file:com.adaptris.core.services.metadata.WriteMetadataToFilesystemTest.java
public void testService_Filter() throws Exception { String subDir = new GuidGenerator().getUUID().replaceAll(":", "").replaceAll("-", ""); AdaptrisMessage msg = createMessage(); WriteMetadataToFilesystem service = createService(subDir); RegexMetadataFilter filter = new RegexMetadataFilter(); filter.addIncludePattern("alt_key.*"); filter.addExcludePattern("^key.*"); service.setMetadataFilter(filter);/*from ww w. j a va 2 s . c o m*/ File parentDir = FsHelper .createFileReference(FsHelper.createUrlFromString(PROPERTIES.getProperty(BASE_DIR), true)); String propsFilename = parentDir.getCanonicalPath() + "/" + subDir + "/" + msg.getUniqueId(); execute(service, msg); Properties p = readProperties(new File(propsFilename), false); assertFalse(p.containsKey("key5")); assertTrue(p.containsKey("alt_key5")); assertEquals("av5", p.getProperty("alt_key5")); }
From source file:gobblin.util.jdbc.DataSourceProvider.java
@Inject public DataSourceProvider(@Named("dataSourceProperties") Properties properties) { this.basicDataSource = new BasicDataSource(); this.basicDataSource.setDriverClassName(properties.getProperty(CONN_DRIVER, DEFAULT_CONN_DRIVER)); this.basicDataSource.setUrl(properties.getProperty(CONN_URL)); if (properties.containsKey(USERNAME) && properties.containsKey(PASSWORD)) { this.basicDataSource.setUsername(properties.getProperty(USERNAME)); this.basicDataSource.setPassword( PasswordManager.getInstance(properties).readPassword(properties.getProperty(PASSWORD))); }//from w w w . j a v a 2s. c om if (properties.containsKey(MAX_IDLE_CONNS)) { this.basicDataSource.setMaxIdle(Integer.parseInt(properties.getProperty(MAX_IDLE_CONNS))); } if (properties.containsKey(MAX_ACTIVE_CONNS)) { this.basicDataSource.setMaxActive(Integer.parseInt(properties.getProperty(MAX_ACTIVE_CONNS))); } }
From source file:org.neo4j.jdbc.http.driver.CypherExecutor.java
private CredentialsProvider getCredentialsProvider(String host, Integer port, Properties properties) { if (properties.containsKey("password")) { String user = properties.getProperty("user", properties.getProperty("username", "neo4j")); CredentialsProvider credsProvider = new BasicCredentialsProvider(); UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(user, properties.getProperty("password")); credsProvider.setCredentials(new AuthScope(host, port), credentials); return credsProvider; }/* w w w . j ava 2s . c o m*/ return null; }
From source file:com.cisco.oss.foundation.logging.FoundationLogger.java
private static void setUpPropFileReloading(final Logger logger, final String logPropFile, final Properties properties) { int fileReloadDelay = FILE_RELOAD_DELAY; if (properties.containsKey(Foundation_FILE_RELOAD_DELAY)) { final String fileReloadDelayStr = properties.getProperty(Foundation_FILE_RELOAD_DELAY); try {/* ww w.java2 s . com*/ fileReloadDelay = Integer.parseInt(fileReloadDelayStr); } catch (NumberFormatException e) { logger.error("Can not format to integer the property: " + Foundation_FILE_RELOAD_DELAY + ". using default of: " + FILE_RELOAD_DELAY); } } PropertyConfigurator.configureAndWatch(logPropFile, fileReloadDelay); }
From source file:it.scoppelletti.sdk.schemaupdate.RoleCreator.java
/** * Crea una coppia (ruolo, descrizione). * /*from w w w . j ava 2s. co m*/ * @param file File di proprietà. * @param desc Descrizione. */ private void createRole(File file, String desc) { Properties props; OutputStream out = null; ProgramResources res = new ProgramResources(); props = loadProperties(file); if (props.containsKey(myCode)) { myUI.display(MessageType.WARNING, res.getRoleAlreadyExistException(myCode, file)); return; } props.setProperty(myCode, desc); try { out = new FileOutputStream(file); props.store(out, null); } catch (IOException ex) { throw new IOOperationException(ex); } finally { if (out != null) { IOUtils.close(out); out = null; } } myUI.display(MessageType.INFORMATION, res.getRoleSavedMessage(myCode, desc, file)); }