Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
akang31 committed Jul 17, 2023
1 parent 36f7465 commit b0e3a0c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@
public class ConcurrentCompositeConfiguration extends ConcurrentMapConfiguration
implements AggregatedConfiguration, ConfigurationListener, Cloneable {

private static final String ENABLE_STACK_TRACE = "archaius_enable_stack_trace";
private static final String ENABLE_INSTRUMENTATION = "archaius_enable_instrumentation";
public static final String ENABLE_STACK_TRACE = "archaius_enable_stack_trace";
public static final String ENABLE_INSTRUMENTATION = "archaius_enable_instrumentation";
private final boolean enableStackTrace = Boolean.parseBoolean(System.getProperty(ENABLE_STACK_TRACE));
private final boolean enableInstrumentation = Boolean.parseBoolean(System.getProperty(ENABLE_INSTRUMENTATION));

Expand Down Expand Up @@ -543,7 +543,7 @@ public Object getPropertyUninstrumented(String key) {
*
* @return object associated with the given configuration key. null if it does not exist.
*/
public Object getProperty(String key, boolean instrument)
private Object getProperty(String key, boolean instrument)
{
if (overrideProperties.containsKey(key)) {
return overrideProperties.getProperty(key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,23 @@ public void testProperties() {
config.clearProperty("prop3");
assertEquals("prop3", prop3.get());
assertEquals("prop3", config.getProperty("prop3"));
assertTrue(config.getUsedProperties().isEmpty());
}

@Test
public void testInstrumentation() {
System.setProperty(ConcurrentCompositeConfiguration.ENABLE_INSTRUMENTATION, "true");
ConcurrentCompositeConfiguration config = new ConcurrentCompositeConfiguration();
config.addProperty("prop1", "val1");
config.addProperty("prop2", "val2");
assertEquals(config.getProperty("prop1"), "val1");
assertEquals(config.getUsedProperties().size(), 1);
assertEquals(config.getUsedProperties().iterator().next(), "prop1");
assertEquals(config.getPropertyUninstrumented("prop2"), "val2");
assertEquals(config.getUsedProperties().size(), 1);
assertEquals(config.getUsedProperties().iterator().next(), "prop1");

System.clearProperty(ConcurrentCompositeConfiguration.ENABLE_INSTRUMENTATION);
}

@Test
Expand Down

0 comments on commit b0e3a0c

Please sign in to comment.