-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #421 from elandau/bugfix/overrides
config: Fix isLoaded not set in the correct order
- Loading branch information
Showing
3 changed files
with
79 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
ribbon-core/src/test/java/com/netflix/client/config/ReloadableClientConfigTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.netflix.client.config; | ||
|
||
import com.netflix.config.ConfigurationManager; | ||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.TestName; | ||
|
||
public class ReloadableClientConfigTest { | ||
@Rule | ||
public TestName testName = new TestName(); | ||
|
||
private CommonClientConfigKey<Integer> testKey; | ||
|
||
@Before | ||
public void before() { | ||
this.testKey = new CommonClientConfigKey<Integer>(testName.getMethodName(), -1) {}; | ||
} | ||
|
||
@Test | ||
public void testOverrideLoadedConfig() { | ||
final DefaultClientConfigImpl overrideconfig = new DefaultClientConfigImpl(); | ||
overrideconfig.set(testKey, 123); | ||
|
||
final DefaultClientConfigImpl config = new DefaultClientConfigImpl(); | ||
config.loadDefaultValues(); | ||
config.applyOverride(overrideconfig); | ||
|
||
Assert.assertEquals(123, config.get(testKey).intValue()); | ||
} | ||
|
||
@Test | ||
public void setBeforeLoading() { | ||
ConfigurationManager.getConfigInstance().setProperty("ribbon." + testKey.key(), "123"); | ||
|
||
final DefaultClientConfigImpl config = new DefaultClientConfigImpl(); | ||
config.loadProperties("foo"); | ||
|
||
Assert.assertEquals(123, config.get(testKey).intValue()); | ||
} | ||
|
||
@Test | ||
public void setAfterLoading() { | ||
final DefaultClientConfigImpl config = new DefaultClientConfigImpl(); | ||
config.loadProperties("foo"); | ||
config.set(testKey, 456); | ||
|
||
ConfigurationManager.getConfigInstance().setProperty("ribbon." + testKey.key(), "123"); | ||
|
||
Assert.assertEquals(123, config.get(testKey).intValue()); | ||
} | ||
} |