Skip to content

Commit

Permalink
Merge pull request #571 from elandau/bugfix/bridge_interpolation
Browse files Browse the repository at this point in the history
Interpolation not properly bridged when bridging archaius1 to archaius2.
  • Loading branch information
elandau authored Jan 16, 2019
2 parents 6ea5999 + 47f3ec1 commit dc55e24
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,8 @@ public void onConfigUpdated(Config config) {
}
});
}

public Object resolve(String value) {
return config.resolve(value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,16 @@ protected void addPropertyDirect(String key, Object value) {
delegate.addPropertyDirect(key, value);
}

@Override
protected String interpolate(String base) {
return delegate.resolve(base).toString();
}

@Override
protected Object interpolate(Object value) {
return delegate.resolve(value.toString());
}

@Override
protected void clearPropertyDirect(String key) {
delegate.clearProperty(key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,4 +244,19 @@ public void testCommonConfigurationListener() {
Mockito.verify(listener, Mockito.times(2)).configurationChanged(Mockito.any());

}

@Test
public void verifyValueInterpollation() {
AbstractConfiguration config = ConfigurationManager.getConfigInstance();
config.setProperty("foo", "${ABC:true}");
boolean value = config.getBoolean("foo");
Assert.assertTrue(value);
}

@Test
public void verifyMissingProperty() {
AbstractConfiguration config = ConfigurationManager.getConfigInstance();
Boolean value = config.getBoolean("foo", null);
Assert.assertNull(value);
}
}

0 comments on commit dc55e24

Please sign in to comment.