use of com.ctrip.framework.apollo.internals.DefaultConfig in project apollo by ctripcorp.
the class DefaultConfigFactoryTest method testCreate.
@Test
public void testCreate() throws Exception {
String someNamespace = "someName";
Properties someProperties = new Properties();
String someKey = "someKey";
String someValue = "someValue";
someProperties.setProperty(someKey, someValue);
LocalFileConfigRepository someLocalConfigRepo = mock(LocalFileConfigRepository.class);
when(someLocalConfigRepo.getConfig()).thenReturn(someProperties);
doReturn(someLocalConfigRepo).when(defaultConfigFactory).createConfigRepository(someNamespace);
Config result = defaultConfigFactory.create(someNamespace);
assertThat("DefaultConfigFactory should create DefaultConfig", result, is(instanceOf(DefaultConfig.class)));
assertEquals(someValue, result.getProperty(someKey, null));
}
use of com.ctrip.framework.apollo.internals.DefaultConfig in project apollo by ctripcorp.
the class DefaultConfigFactoryTest method testCreatePropertiesCompatibleFileConfigRepository.
@Test
public void testCreatePropertiesCompatibleFileConfigRepository() throws Exception {
ConfigFileFormat somePropertiesCompatibleFormat = ConfigFileFormat.YML;
String someNamespace = "someName" + "." + somePropertiesCompatibleFormat;
Properties someProperties = new Properties();
String someKey = "someKey";
String someValue = "someValue";
someProperties.setProperty(someKey, someValue);
PropertiesCompatibleFileConfigRepository someRepository = mock(PropertiesCompatibleFileConfigRepository.class);
when(someRepository.getConfig()).thenReturn(someProperties);
doReturn(someRepository).when(defaultConfigFactory).createPropertiesCompatibleFileConfigRepository(someNamespace, somePropertiesCompatibleFormat);
Config result = defaultConfigFactory.create(someNamespace);
assertThat("DefaultConfigFactory should create DefaultConfig", result, is(instanceOf(DefaultConfig.class)));
assertEquals(someValue, result.getProperty(someKey, null));
}
Aggregations