EnvironmentVariablesPropertiesSource implements PropertiesSource { @Override public Map<String,String> getProperties() { Map<String,String> envVars = System.getenv(); if (!Collections.isEmpty(envVars)) { return new LinkedHashMap<String, String>(envVars); } return java.util.Collections.emptyMap(); }  @Override Map<String,String> getProperties();  }
@Test public void testGetProperties() { Map<String, String> mockProps = new HashMap<String, String>(); mockProps.put("my_special_key", "my_special_value"); mockStaticPartial(System.class, "getenv"); expect(System.getenv()).andReturn(mockProps); replayAll(); Map<String, String> props = new EnvironmentVariablesPropertiesSource().getProperties(); assertEquals(props.get("my_special_key"), "my_special_value"); }
@Test public void testGetPropertiesEmpty() { mockStaticPartial(System.class, "getenv"); expect(System.getenv()).andReturn(null); replayAll(); Map<String, String> props = new EnvironmentVariablesPropertiesSource().getProperties(); assertEquals(props.size(), 0); }