PropertiesWrapper { public PropertiesWrapper(Properties properties, PropertiesKeyMapper propertiesKeyMapper) { this.properties = properties; this.propertiesKeyMapper = propertiesKeyMapper; } PropertiesWrapper(Properties properties, PropertiesKeyMapper propertiesKeyMapper); boolean exist(String key); String getProperty(String key); String getProperty(String key, String defaultValue); int getPropertyInt(String key, int defaultValue); boolean getPropertyBoolean(String key, boolean defaultValue); void addProperty(String key, String value); int getPropertyInt(String key); long getPropertyLong(String key); boolean getPropertyBoolean(String key);  }
@Test public void testPropertiesWrapper() { Properties prop = new Properties(); prop.put("key1", "1"); prop.put("key2", "value2"); PropertiesWrapper propWrapper = new PropertiesWrapper(prop, PropertiesKeyMapper.create("agent-properties.map")); propWrapper.addProperty("key3", "3"); propWrapper.addProperty("key4", "value4"); int value1 = propWrapper.getPropertyInt("key1"); assertThat(value1, is(1)); int value3 = propWrapper.getPropertyInt("key3"); assertThat(value3, is(3)); try { int noValue = propWrapper.getPropertyInt("NoValueKey"); fail("should cause IllegalArgumentException"); } catch (IllegalArgumentException e) { } String value2 = propWrapper.getProperty("key2", "null"); assertThat(value2, is("value2")); String value4 = propWrapper.getProperty("key4", "null"); assertThat(value4, is("value4")); String nullValueStr = propWrapper.getProperty("NoValueKey", "null"); assertThat(nullValueStr, is("null")); String newValue4 = propWrapper.getProperty("key4"); assertThat(newValue4, is("value4")); nullValueStr = propWrapper.getProperty("NoValueKey", "null"); assertThat(nullValueStr, is("null")); prop.put("BoolKey", "true"); boolean boolVal = propWrapper.getPropertyBoolean("BoolKey"); assertThat(boolVal, is(true)); propWrapper.addProperty("hello_world", "wow"); assertThat(propWrapper.getProperty("hello_world"), is("wow")); }