forked from apolloconfig/apollo
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. add log output to console for config and admin service 2. remove dev, lpt, tooling logic 3. add default 2 seconds of initial delay to long polling
- Loading branch information
Showing
10 changed files
with
225 additions
and
22 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
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
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
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
176 changes: 176 additions & 0 deletions
176
apollo-client/src/test/java/com/ctrip/framework/apollo/util/ConfigUtilTest.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,176 @@ | ||
package com.ctrip.framework.apollo.util; | ||
|
||
import com.ctrip.framework.apollo.core.ConfigConsts; | ||
|
||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* @author Jason Song([email protected]) | ||
*/ | ||
public class ConfigUtilTest { | ||
@After | ||
public void tearDown() throws Exception { | ||
System.clearProperty(ConfigConsts.APOLLO_CLUSTER_KEY); | ||
System.clearProperty("apollo.connectTimeout"); | ||
System.clearProperty("apollo.readTimeout"); | ||
System.clearProperty("apollo.refreshInterval"); | ||
System.clearProperty("apollo.loadConfigQPS"); | ||
System.clearProperty("apollo.longPollQPS"); | ||
System.clearProperty("apollo.configCacheSize"); | ||
System.clearProperty("apollo.longPollingInitialDelayInMills"); | ||
} | ||
|
||
@Test | ||
public void testApolloCluster() throws Exception { | ||
String someCluster = "someCluster"; | ||
System.setProperty(ConfigConsts.APOLLO_CLUSTER_KEY, someCluster); | ||
|
||
ConfigUtil configUtil = new ConfigUtil(); | ||
|
||
assertEquals(someCluster, configUtil.getCluster()); | ||
} | ||
|
||
@Test | ||
public void testCustomizeConnectTimeout() throws Exception { | ||
int someConnectTimeout = 1; | ||
System.setProperty("apollo.connectTimeout", String.valueOf(someConnectTimeout)); | ||
|
||
ConfigUtil configUtil = new ConfigUtil(); | ||
|
||
assertEquals(someConnectTimeout, configUtil.getConnectTimeout()); | ||
} | ||
|
||
@Test | ||
public void testCustomizeInvalidConnectTimeout() throws Exception { | ||
String someInvalidConnectTimeout = "a"; | ||
System.setProperty("apollo.connectTimeout", someInvalidConnectTimeout); | ||
|
||
ConfigUtil configUtil = new ConfigUtil(); | ||
|
||
assertTrue(configUtil.getConnectTimeout() > 0); | ||
} | ||
|
||
@Test | ||
public void testCustomizeReadTimeout() throws Exception { | ||
int someReadTimeout = 1; | ||
System.setProperty("apollo.readTimeout", String.valueOf(someReadTimeout)); | ||
|
||
ConfigUtil configUtil = new ConfigUtil(); | ||
|
||
assertEquals(someReadTimeout, configUtil.getReadTimeout()); | ||
} | ||
|
||
@Test | ||
public void testCustomizeInvalidReadTimeout() throws Exception { | ||
String someInvalidReadTimeout = "a"; | ||
System.setProperty("apollo.readTimeout", someInvalidReadTimeout); | ||
|
||
ConfigUtil configUtil = new ConfigUtil(); | ||
|
||
assertTrue(configUtil.getReadTimeout() > 0); | ||
} | ||
|
||
@Test | ||
public void testCustomizeRefreshInterval() throws Exception { | ||
int someRefreshInterval = 1; | ||
System.setProperty("apollo.refreshInterval", String.valueOf(someRefreshInterval)); | ||
|
||
ConfigUtil configUtil = new ConfigUtil(); | ||
|
||
assertEquals(someRefreshInterval, configUtil.getRefreshInterval()); | ||
} | ||
|
||
@Test | ||
public void testCustomizeInvalidRefreshInterval() throws Exception { | ||
String someInvalidRefreshInterval = "a"; | ||
System.setProperty("apollo.refreshInterval", someInvalidRefreshInterval); | ||
|
||
ConfigUtil configUtil = new ConfigUtil(); | ||
|
||
assertTrue(configUtil.getRefreshInterval() > 0); | ||
} | ||
|
||
@Test | ||
public void testCustomizeLoadConfigQPS() throws Exception { | ||
int someQPS = 1; | ||
System.setProperty("apollo.loadConfigQPS", String.valueOf(someQPS)); | ||
|
||
ConfigUtil configUtil = new ConfigUtil(); | ||
|
||
assertEquals(someQPS, configUtil.getLoadConfigQPS()); | ||
} | ||
|
||
@Test | ||
public void testCustomizeInvalidLoadConfigQPS() throws Exception { | ||
String someInvalidQPS = "a"; | ||
System.setProperty("apollo.loadConfigQPS", someInvalidQPS); | ||
|
||
ConfigUtil configUtil = new ConfigUtil(); | ||
|
||
assertTrue(configUtil.getLoadConfigQPS() > 0); | ||
} | ||
|
||
@Test | ||
public void testCustomizeLongPollQPS() throws Exception { | ||
int someQPS = 1; | ||
System.setProperty("apollo.longPollQPS", String.valueOf(someQPS)); | ||
|
||
ConfigUtil configUtil = new ConfigUtil(); | ||
|
||
assertEquals(someQPS, configUtil.getLongPollQPS()); | ||
} | ||
|
||
@Test | ||
public void testCustomizeInvalidLongPollQPS() throws Exception { | ||
String someInvalidQPS = "a"; | ||
System.setProperty("apollo.longPollQPS", someInvalidQPS); | ||
|
||
ConfigUtil configUtil = new ConfigUtil(); | ||
|
||
assertTrue(configUtil.getLongPollQPS() > 0); | ||
} | ||
|
||
@Test | ||
public void testCustomizeMaxConfigCacheSize() throws Exception { | ||
long someCacheSize = 1; | ||
System.setProperty("apollo.configCacheSize", String.valueOf(someCacheSize)); | ||
|
||
ConfigUtil configUtil = new ConfigUtil(); | ||
|
||
assertEquals(someCacheSize, configUtil.getMaxConfigCacheSize()); | ||
} | ||
|
||
@Test | ||
public void testCustomizeInvalidMaxConfigCacheSize() throws Exception { | ||
String someInvalidCacheSize = "a"; | ||
System.setProperty("apollo.configCacheSize", someInvalidCacheSize); | ||
|
||
ConfigUtil configUtil = new ConfigUtil(); | ||
|
||
assertTrue(configUtil.getMaxConfigCacheSize() > 0); | ||
} | ||
|
||
@Test | ||
public void testCustomizeLongPollingInitialDelayInMills() throws Exception { | ||
long someLongPollingDelayInMills = 1; | ||
System.setProperty("apollo.longPollingInitialDelayInMills", String.valueOf(someLongPollingDelayInMills)); | ||
|
||
ConfigUtil configUtil = new ConfigUtil(); | ||
|
||
assertEquals(someLongPollingDelayInMills, configUtil.getLongPollingInitialDelayInMills()); | ||
} | ||
|
||
@Test | ||
public void testCustomizeInvalidLongPollingInitialDelayInMills() throws Exception { | ||
String someInvalidLongPollingDelayInMills = "a"; | ||
System.setProperty("apollo.longPollingInitialDelayInMills", someInvalidLongPollingDelayInMills); | ||
|
||
ConfigUtil configUtil = new ConfigUtil(); | ||
|
||
assertTrue(configUtil.getLongPollingInitialDelayInMills() > 0); | ||
} | ||
} |
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