use of com.ctrip.framework.apollo.internals.SimpleConfig in project apollo by ctripcorp.
the class XmlConfigPlaceholderAutoUpdateTest method testAutoUpdateDisabled.
@Test
public void testAutoUpdateDisabled() throws Exception {
int initialTimeout = 1000;
int initialBatch = 2000;
int newTimeout = 1001;
int newBatch = 2001;
MockConfigUtil mockConfigUtil = new MockConfigUtil();
mockConfigUtil.setAutoUpdateInjectedSpringProperties(false);
MockInjector.setInstance(ConfigUtil.class, mockConfigUtil);
Properties properties = assembleProperties(TIMEOUT_PROPERTY, String.valueOf(initialTimeout), BATCH_PROPERTY, String.valueOf(initialBatch));
SimpleConfig config = prepareConfig(ConfigConsts.NAMESPACE_APPLICATION, properties);
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/XmlConfigPlaceholderTest1.xml");
TestXmlBean bean = context.getBean(TestXmlBean.class);
assertEquals(initialTimeout, bean.getTimeout());
assertEquals(initialBatch, bean.getBatch());
Properties newProperties = assembleProperties(TIMEOUT_PROPERTY, String.valueOf(newTimeout), BATCH_PROPERTY, String.valueOf(newBatch));
config.onRepositoryChange(ConfigConsts.NAMESPACE_APPLICATION, newProperties);
TimeUnit.MILLISECONDS.sleep(100);
assertEquals(initialTimeout, bean.getTimeout());
assertEquals(initialBatch, bean.getBatch());
}
use of com.ctrip.framework.apollo.internals.SimpleConfig in project apollo by ctripcorp.
the class XmlConfigPlaceholderAutoUpdateTest method testAutoUpdateWithMultipleNamespacesWithSamePropertiesDeleted.
@Test
public void testAutoUpdateWithMultipleNamespacesWithSamePropertiesDeleted() throws Exception {
int someTimeout = 1000;
int someBatch = 2000;
int anotherBatch = 3000;
Properties applicationProperties = assembleProperties(BATCH_PROPERTY, String.valueOf(someBatch));
Properties fxApolloProperties = assembleProperties(TIMEOUT_PROPERTY, String.valueOf(someTimeout), BATCH_PROPERTY, String.valueOf(anotherBatch));
SimpleConfig applicationConfig = prepareConfig(ConfigConsts.NAMESPACE_APPLICATION, applicationProperties);
prepareConfig(FX_APOLLO_NAMESPACE, fxApolloProperties);
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/XmlConfigPlaceholderTest3.xml");
TestXmlBean bean = context.getBean(TestXmlBean.class);
assertEquals(someTimeout, bean.getTimeout());
assertEquals(someBatch, bean.getBatch());
Properties newProperties = new Properties();
applicationConfig.onRepositoryChange(ConfigConsts.NAMESPACE_APPLICATION, newProperties);
TimeUnit.MILLISECONDS.sleep(100);
assertEquals(someTimeout, bean.getTimeout());
assertEquals(anotherBatch, bean.getBatch());
}
use of com.ctrip.framework.apollo.internals.SimpleConfig in project apollo by ctripcorp.
the class AbstractSpringIntegrationTest method prepareConfig.
protected SimpleConfig prepareConfig(String namespaceName, Properties properties) {
ConfigRepository configRepository = mock(ConfigRepository.class);
when(configRepository.getConfig()).thenReturn(properties);
SimpleConfig config = new SimpleConfig(ConfigConsts.NAMESPACE_APPLICATION, configRepository);
mockConfig(namespaceName, config);
return config;
}
Aggregations