List of usage examples for java.util Properties get
@Override
public Object get(Object key)
From source file:eu.java.pg.jsonb.types.JSONBUserType.java
@Override public void setParameterValues(Properties parameters) { final String clazz = (String) parameters.get(CLASS); jsonClassType = classLoaderService.classForName(clazz); }
From source file:com.aurel.track.teamgeist.TeamgeistServicesTest.java
/** * This method returns Teamgeist source path till Services.cpp. * The source base directory is provided by: buildwin or buildux properties (Windows or mac) * @return//from ww w. ja v a 2 s . c om */ private String getSrcPath() { String propertiesFileName = null; if (System.getProperty("os.name").toLowerCase().contains("windows")) { propertiesFileName = "buildwin.properties"; } else if (System.getProperty("os.name").toLowerCase().contains("mac") || System.getProperty("os.name").toLowerCase().contains("linux")) { propertiesFileName = "buildux.properties"; } else { return null; } final String COM_TRACKPLUS_RELATIVE_PATH = "/com.trackplus/" + propertiesFileName; File file = new java.io.File(""); String propertiesPath = file.getAbsoluteFile().getParentFile().getAbsolutePath(); String srcPath = null; if (propertiesPath.contains("\\")) { propertiesPath = propertiesPath.replace("\\", "/"); if (propertiesPath.lastIndexOf("/") == propertiesPath.length() - 1) { propertiesPath = propertiesPath.substring(0, propertiesPath.length() - 1); } } propertiesPath += COM_TRACKPLUS_RELATIVE_PATH; try { final String RELATIVE_PART_OF_PATH = "/services/Services.cpp"; System.err.println(propertiesPath); InputStream input = new FileInputStream(propertiesPath); Properties prop = new Properties(); prop.load(input); srcPath = prop.get("teamgeist.srcAbsolutePath").toString(); srcPath = srcPath.replace("\\", "/"); if (srcPath.lastIndexOf("/") == srcPath.length() - 1) { srcPath = srcPath.substring(0, srcPath.length() - 1); } srcPath += RELATIVE_PART_OF_PATH; } catch (Exception ex) { LOGGER.error(ExceptionUtils.getStackTrace(ex)); } System.out.println("Using Teamgeist source from " + srcPath); return srcPath; }
From source file:net.sf.jabb.util.db.impl.DbcpDataSourceProvider.java
public DataSource createDataSource(String source, String config) { String[] cfgs = config.split(PropertiesLoader.DELIMITERS, 2); if (cfgs.length != 2) { log.warn("Wrong configuration format for '" + source + "' : " + config); return null; }/*from w w w.ja va 2 s .co m*/ DataSource ds = null; try { DirectDataSourceConfiguration lowerConfig = new DirectDataSourceConfiguration(cfgs[0]); Class.forName(lowerConfig.getDriverClassName()); Properties props = propLoader.load(cfgs[1]); Properties connProps = lowerConfig.getConnectionProperties(); props.put("username", connProps.get("user")); connProps.remove("user"); props.put("password", connProps.get("password")); connProps.remove("password"); props.put("url", lowerConfig.getUrl()); props.put("driverClassName", lowerConfig.getDriverClassName()); StringBuilder sb = new StringBuilder(); String oldConnProp = props.getProperty("connectionProperties"); if (oldConnProp != null) { sb.append(oldConnProp.trim()); } for (Map.Entry<Object, Object> p : connProps.entrySet()) { if (sb.length() > 0 && sb.charAt(sb.length() - 1) != ';') { sb.append(';'); } sb.append(p.getKey().toString()); sb.append('='); sb.append(p.getValue().toString()); } props.put("connectionProperties", sb.toString()); ds = BasicDataSourceFactory.createDataSource(props); } catch (InvalidPropertiesFormatException e) { log.warn( "Wrong configuration properties file format for '" + source + "' with configuration: " + config, e); } catch (IOException e) { log.warn("Error loading configuration file for '" + source + "' with configuration: " + config, e); } catch (ClassNotFoundException e) { log.warn("Driver class not found for '" + source + "' with configuration: " + config, e); } catch (Exception e) { log.warn("Error creating data source for '" + source + "' with configuration: " + config, e); } return ds; }
From source file:org.cloudfoundry.identity.uaa.config.YamlPropertiesFactoryBeanTests.java
@Test public void testLoadResource() throws Exception { YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean(); factory.setResources(new Resource[] { new ByteArrayResource("foo: bar\nspam:\n foo: baz".getBytes()) }); Properties properties = factory.getObject(); assertEquals("bar", properties.get("foo")); assertEquals("baz", properties.get("spam.foo")); }
From source file:org.cloudfoundry.identity.uaa.config.YamlPropertiesFactoryBeanTests.java
@Test public void testLoadNull() throws Exception { YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean(); factory.setResources(new Resource[] { new ByteArrayResource("foo: bar\nspam:".getBytes()) }); Properties properties = factory.getObject(); assertEquals("bar", properties.get("foo")); assertEquals("", properties.get("spam")); }
From source file:org.cloudfoundry.identity.uaa.config.YamlPropertiesFactoryBeanTests.java
@Test @Ignore // We can't fail on duplicate keys because the Map is created by the YAML library public void testLoadResourcesWithInternalOverride() throws Exception { YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean(); factory.setResources(/*ww w . ja va 2 s .c o m*/ new Resource[] { new ByteArrayResource("foo: bar\nspam:\n foo: baz\nfoo: bucket".getBytes()) }); Properties properties = factory.getObject(); assertEquals("bar", properties.get("foo")); }
From source file:org.cloudfoundry.identity.uaa.config.YamlPropertiesFactoryBeanTests.java
@Test public void testLoadResourceWithMultipleDocuments() throws Exception { YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean(); factory.setResources(// ww w. jav a2s . c o m new Resource[] { new ByteArrayResource("foo: bar\nspam: baz\n---\nfoo: bag".getBytes()) }); Properties properties = factory.getObject(); assertEquals("bag", properties.get("foo")); assertEquals("baz", properties.get("spam")); }
From source file:org.cloudfoundry.identity.uaa.config.YamlPropertiesFactoryBeanTests.java
@Test public void testLoadArrayOfString() throws Exception { YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean(); factory.setResources(new Resource[] { new ByteArrayResource("foo:\n- bar\n- baz".getBytes()) }); Properties properties = factory.getObject(); assertEquals("bar", properties.get("foo[0]")); assertEquals("baz", properties.get("foo[1]")); assertEquals("bar,baz", properties.get("foo")); }
From source file:org.cloudfoundry.identity.uaa.config.YamlPropertiesFactoryBeanTests.java
@Test public void testLoadResourcesWithOverride() throws Exception { YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean(); factory.setResources(new Resource[] { new ByteArrayResource("foo: bar\nspam:\n foo: baz".getBytes()), new ByteArrayResource("foo:\n bar: spam".getBytes()) }); Properties properties = factory.getObject(); assertEquals("bar", properties.get("foo")); assertEquals("baz", properties.get("spam.foo")); assertEquals("spam", properties.get("foo.bar")); }
From source file:org.cloudfoundry.identity.uaa.config.YamlPropertiesFactoryBeanTests.java
@Test @Ignore // We can't fail on duplicate keys because the Map is created by the YAML library public void testLoadResourcesWithNestedInternalOverride() throws Exception { YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean(); factory.setResources(new Resource[] { new ByteArrayResource("foo:\n bar: spam\n foo: baz\nbreak: it\nfoo: bucket".getBytes()) }); Properties properties = factory.getObject(); assertEquals("spam", properties.get("foo.bar")); }