SystemPropOverridingJSONProvider implements JSONProvider { @Override public JSONObject get() throws JSONException { return includeSystemProperties(jsonProvider.get()); } SystemPropOverridingJSONProvider(JSONProvider jsonProvider); @Override JSONObject get();  }
@Test(groups = "fast") public void testNewProps() throws Exception { System.setProperty(KEY3, "propvalue1"); System.setProperty(KEY4, "propvalue2"); JSONObject jsonObject = jsonProvider.get(); Assert.assertEquals(jsonObject.getString(KEY1), "value1"); Assert.assertEquals(jsonObject.getString(KEY2), "value2"); Assert.assertEquals(jsonObject.getString(KEY3), "propvalue1"); Assert.assertEquals(jsonObject.getString(KEY4), "propvalue2"); }
@Test(groups = "fast") public void testOverride() throws Exception { System.setProperty(KEY3, "propvalue1"); System.setProperty(KEY2, "propvalue2"); JSONObject jsonObject = jsonProvider.get(); Assert.assertEquals(jsonObject.getString(KEY1), "value1"); Assert.assertEquals(jsonObject.getString(KEY2), "propvalue2"); Assert.assertEquals(jsonObject.getString(KEY3), "propvalue1"); }
@Test(groups = "fast") public void testValueAsJSON() throws Exception { System.setProperty(KEY5, "{nested_key : nested_value}"); JSONObject jsonObject = jsonProvider.get(); JSONObject nestedJSONObject = jsonObject.getJSONObject(KEY5); Assert.assertEquals(nestedJSONObject.get("nested_key"), "nested_value"); }