use of com.ctrip.framework.apollo.core.dto.ApolloConfig in project apollo by ctripcorp.
the class ConfigIntegrationTest method testOrderGetConfigWithLocalFileAndWithRemoteConfig.
@Test
public void testOrderGetConfigWithLocalFileAndWithRemoteConfig() throws Exception {
String someKey = "someKey";
String someValue = "someValue";
String anotherValue = "anotherValue";
String someKey1 = "someKey1";
String someValue1 = "someValue1";
String anotherValue1 = "anotherValue1";
String someKey2 = "someKey2";
String someValue2 = "someValue2";
setPropertiesOrderEnabled(true);
Properties properties = new OrderedProperties();
properties.put(someKey, someValue);
properties.put(someKey1, someValue1);
properties.put(someKey2, someValue2);
createLocalCachePropertyFile(properties);
Map<String, String> configurations = new LinkedHashMap<>();
configurations.put(someKey, anotherValue);
configurations.put(someKey1, anotherValue1);
configurations.put(someKey2, someValue2);
ApolloConfig apolloConfig = assembleApolloConfig(ImmutableMap.copyOf(configurations));
ContextHandler handler = mockConfigServerHandler(HttpServletResponse.SC_OK, apolloConfig);
startServerWithHandlers(handler);
Config config = ConfigService.getAppConfig();
assertEquals(anotherValue, config.getProperty(someKey, null));
Set<String> propertyNames = config.getPropertyNames();
Iterator<String> it = propertyNames.iterator();
assertEquals(someKey, it.next());
assertEquals(someKey1, it.next());
assertEquals(someKey2, it.next());
assertEquals(anotherValue1, config.getProperty(someKey1, ""));
}
use of com.ctrip.framework.apollo.core.dto.ApolloConfig in project apollo by ctripcorp.
the class ConfigIntegrationTest method testGetConfigWithNoLocalFileAndRemoteMetaServiceRetry.
@Test
public void testGetConfigWithNoLocalFileAndRemoteMetaServiceRetry() throws Exception {
String someKey = "someKey";
String someValue = "someValue";
ApolloConfig apolloConfig = assembleApolloConfig(ImmutableMap.of(someKey, someValue));
ContextHandler configHandler = mockConfigServerHandler(HttpServletResponse.SC_OK, apolloConfig);
boolean failAtFirstTime = true;
ContextHandler metaServerHandler = mockMetaServerHandler(failAtFirstTime);
startServerWithHandlers(metaServerHandler, configHandler);
Config config = ConfigService.getAppConfig();
assertEquals(someValue, config.getProperty(someKey, null));
}
Aggregations