use of com.ctrip.framework.apollo.internals.ConfigRepository in project apollo by ctripcorp.
the class DefaultConfigFactoryFileCachePropertyTest method testCreateFileDisableConfigRepository.
@Test
public void testCreateFileDisableConfigRepository() throws Exception {
RemoteConfigRepository someRemoteConfigRepository = mock(RemoteConfigRepository.class);
when(someConfigUtil.isPropertyFileCacheEnabled()).thenReturn(false);
doReturn(someRemoteConfigRepository).when(configFactory).createRemoteConfigRepository(someNamespace);
ConfigRepository configRepository = configFactory.createConfigRepository(someNamespace);
assertSame(someRemoteConfigRepository, configRepository);
verify(configFactory, never()).createLocalConfigRepository(someNamespace);
verify(configFactory, times(1)).createRemoteConfigRepository(someNamespace);
}
use of com.ctrip.framework.apollo.internals.ConfigRepository in project apollo by ctripcorp.
the class DefaultConfigFactory method create.
@Override
public Config create(String namespace) {
ConfigFileFormat format = determineFileFormat(namespace);
ConfigRepository configRepository = null;
// for ConfigFileFormat.Properties
if (ConfigFileFormat.isPropertiesCompatible(format) && format != ConfigFileFormat.Properties) {
configRepository = createPropertiesCompatibleFileConfigRepository(namespace, format);
} else {
configRepository = createConfigRepository(namespace);
}
logger.debug("Created a configuration repository of type [{}] for namespace [{}]", configRepository.getClass().getName(), namespace);
return this.createRepositoryConfig(namespace, configRepository);
}
use of com.ctrip.framework.apollo.internals.ConfigRepository in project apollo by ctripcorp.
the class DefaultConfigFactoryFileCachePropertyTest method testCreateFileEnableConfigRepository.
@Test
public void testCreateFileEnableConfigRepository() throws Exception {
LocalFileConfigRepository someLocalConfigRepository = mock(LocalFileConfigRepository.class);
when(someConfigUtil.isPropertyFileCacheEnabled()).thenReturn(true);
doReturn(someLocalConfigRepository).when(configFactory).createLocalConfigRepository(someNamespace);
ConfigRepository configRepository = configFactory.createConfigRepository(someNamespace);
assertSame(someLocalConfigRepository, configRepository);
verify(configFactory, times(1)).createLocalConfigRepository(someNamespace);
verify(configFactory, never()).createRemoteConfigRepository(someNamespace);
}
use of com.ctrip.framework.apollo.internals.ConfigRepository 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;
}
use of com.ctrip.framework.apollo.internals.ConfigRepository in project apollo by ctripcorp.
the class AbstractSpringIntegrationTest method prepareYamlConfigFile.
protected static YamlConfigFile prepareYamlConfigFile(String namespaceNameWithFormat, Properties properties) {
ConfigRepository configRepository = mock(ConfigRepository.class);
when(configRepository.getConfig()).thenReturn(properties);
// spy it for testing after
YamlConfigFile configFile = spy(new YamlConfigFile(namespaceNameWithFormat, configRepository));
mockConfigFile(namespaceNameWithFormat, configFile);
return configFile;
}
Aggregations