@Test public void loadSystemProperties() { ConfigurationManager cm = new ConfigurationManager(); assertThat(System.getProperty("exam.test.key1"), is(nullValue())); assertThat(System.getProperty("exam.test.key2"), is(nullValue())); String cp = System.getProperty("java.class.path"); cm.loadSystemProperties("exam.test.props"); assertThat(System.getProperty("exam.test.key1"), is("value1")); assertThat(System.getProperty("exam.test.key2"), is("value2")); assertThat(System.getProperty("java.class.path"), is(cp)); }
public void loadSystemProperties(String configurationKey) { String propertyRef = getProperty(configurationKey); if (propertyRef == null) { return; } if (propertyRef.startsWith("env:")) { propertyRef = propertyRef.substring(4); propertyRef = System.getenv(propertyRef); } if (!propertyRef.startsWith("/")) { propertyRef = "/" + propertyRef; } try { URL url = getClass().getResource(propertyRef); if (url == null) { url = new URL(propertyRef); } Properties props = System.getProperties(); props.load(url.openStream()); System.setProperties(props); } catch (IOException exc) { throw new TestContainerException(exc); } }
ConfigurationManager { public void loadSystemProperties(String configurationKey) { String propertyRef = getProperty(configurationKey); if (propertyRef == null) { return; } if (propertyRef.startsWith("env:")) { propertyRef = propertyRef.substring(4); propertyRef = System.getenv(propertyRef); } if (!propertyRef.startsWith("/")) { propertyRef = "/" + propertyRef; } try { URL url = getClass().getResource(propertyRef); if (url == null) { url = new URL(propertyRef); } Properties props = System.getProperties(); props.load(url.openStream()); System.setProperties(props); } catch (IOException exc) { throw new TestContainerException(exc); } } }
ConfigurationManager { public void loadSystemProperties(String configurationKey) { String propertyRef = getProperty(configurationKey); if (propertyRef == null) { return; } if (propertyRef.startsWith("env:")) { propertyRef = propertyRef.substring(4); propertyRef = System.getenv(propertyRef); } if (!propertyRef.startsWith("/")) { propertyRef = "/" + propertyRef; } try { URL url = getClass().getResource(propertyRef); if (url == null) { url = new URL(propertyRef); } Properties props = System.getProperties(); props.load(url.openStream()); System.setProperties(props); } catch (IOException exc) { throw new TestContainerException(exc); } } ConfigurationManager(); }
ConfigurationManager { public void loadSystemProperties(String configurationKey) { String propertyRef = getProperty(configurationKey); if (propertyRef == null) { return; } if (propertyRef.startsWith("env:")) { propertyRef = propertyRef.substring(4); propertyRef = System.getenv(propertyRef); } if (!propertyRef.startsWith("/")) { propertyRef = "/" + propertyRef; } try { URL url = getClass().getResource(propertyRef); if (url == null) { url = new URL(propertyRef); } Properties props = System.getProperties(); props.load(url.openStream()); System.setProperties(props); } catch (IOException exc) { throw new TestContainerException(exc); } } ConfigurationManager(); String getProperty(String key); String getProperty(String key, String defaultValue); void loadSystemProperties(String configurationKey); }
ConfigurationManager { public void loadSystemProperties(String configurationKey) { String propertyRef = getProperty(configurationKey); if (propertyRef == null) { return; } if (propertyRef.startsWith("env:")) { propertyRef = propertyRef.substring(4); propertyRef = System.getenv(propertyRef); } if (!propertyRef.startsWith("/")) { propertyRef = "/" + propertyRef; } try { URL url = getClass().getResource(propertyRef); if (url == null) { url = new URL(propertyRef); } Properties props = System.getProperties(); props.load(url.openStream()); System.setProperties(props); } catch (IOException exc) { throw new TestContainerException(exc); } } ConfigurationManager(); String getProperty(String key); String getProperty(String key, String defaultValue); void loadSystemProperties(String configurationKey);  }