Skip to content

Commit

Permalink
Merge pull request Netflix#467 from howardyuan/2.x
Browse files Browse the repository at this point in the history
Add property deletion to Archaius1 -> Archaius2 bridge
  • Loading branch information
howardyuan authored Dec 7, 2016
2 parents c9abdd5 + 70271ff commit 1ece777
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ protected void addPropertyDirect(String key, Object value) {
settable.setProperty(key, value);
}

@Override
protected void clearPropertyDirect(String key) {
settable.clearProperty(key);
}

@Override
public void addConfiguration(AbstractConfiguration config) {
addConfiguration(config, "Config-" + libNameCounter.incrementAndGet());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@ protected void addPropertyDirect(String key, Object value) {
delegate.addPropertyDirect(key, value);
}

@Override
protected void clearPropertyDirect(String key) {
delegate.clearProperty(key);
}

@Override
public void addConfigurationListener(PropertyListener expandedPropertyListener) {
if (delegate == null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.netflix.archaius.bridge;

import com.netflix.archaius.api.Config;
import org.apache.commons.configuration.AbstractConfiguration;
import org.junit.Assert;
import org.junit.Test;

Expand Down Expand Up @@ -62,4 +64,19 @@ public void testInterpolation() {
Assert.assertEquals("value", prop.get());

}

@Test
public void testPropertyDeletion() {
Injector injector = Guice.createInjector(new ArchaiusModule(), new StaticArchaiusBridgeModule());
AbstractConfiguration config1 = ConfigurationManager.getConfigInstance();
Config config2 = injector.getInstance(Config.class);
config1.setProperty("libA.loaded", "true");
Assert.assertTrue(config1.getBoolean("libA.loaded", false));
Assert.assertTrue(config2.getBoolean("libA.loaded", false));

config1.clearProperty("libA.loaded");
Assert.assertFalse(config1.getBoolean("libA.loaded", false));
Assert.assertFalse(config2.getBoolean("libA.loaded", false));

}
}

0 comments on commit 1ece777

Please sign in to comment.