use of com.ctrip.framework.apollo.internals.PropertiesCompatibleFileConfigRepository in project apollo by ctripcorp.
the class DefaultConfigFactory method createPropertiesCompatibleFileConfigRepository.
PropertiesCompatibleFileConfigRepository createPropertiesCompatibleFileConfigRepository(String namespace, ConfigFileFormat format) {
String actualNamespaceName = trimNamespaceFormat(namespace, format);
PropertiesCompatibleConfigFile configFile = (PropertiesCompatibleConfigFile) ConfigService.getConfigFile(actualNamespaceName, format);
return new PropertiesCompatibleFileConfigRepository(configFile);
}
use of com.ctrip.framework.apollo.internals.PropertiesCompatibleFileConfigRepository 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