use of com.ctrip.framework.apollo.util.factory.PropertiesFactory in project apollo by ctripcorp.
the class DefaultConfigTest method setUp.
@Before
public void setUp() throws Exception {
MockInjector.setInstance(ConfigUtil.class, new MockConfigUtil());
propertiesFactory = mock(PropertiesFactory.class);
when(propertiesFactory.getPropertiesInstance()).thenAnswer(new Answer<Properties>() {
@Override
public Properties answer(InvocationOnMock invocation) {
return new Properties();
}
});
MockInjector.setInstance(PropertiesFactory.class, propertiesFactory);
someResourceDir = new File(ClassLoaderUtil.getClassPath() + "/META-INF/config");
someResourceDir.mkdirs();
someNamespace = "someName";
configRepository = mock(ConfigRepository.class);
}
use of com.ctrip.framework.apollo.util.factory.PropertiesFactory in project apollo by ctripcorp.
the class LocalFileConfigRepositoryTest method setUp.
@Before
public void setUp() throws Exception {
someBaseDir = new File("src/test/resources/config-cache");
someBaseDir.mkdir();
someNamespace = "someName";
someProperties = new Properties();
defaultKey = "defaultKey";
defaultValue = "defaultValue";
someProperties.setProperty(defaultKey, defaultValue);
someSourceType = ConfigSourceType.REMOTE;
upstreamRepo = mock(ConfigRepository.class);
when(upstreamRepo.getConfig()).thenReturn(someProperties);
when(upstreamRepo.getSourceType()).thenReturn(someSourceType);
MockInjector.setInstance(ConfigUtil.class, new MockConfigUtil());
PropertiesFactory propertiesFactory = mock(PropertiesFactory.class);
when(propertiesFactory.getPropertiesInstance()).thenAnswer(new Answer<Properties>() {
@Override
public Properties answer(InvocationOnMock invocation) {
return new Properties();
}
});
MockInjector.setInstance(PropertiesFactory.class, propertiesFactory);
}
use of com.ctrip.framework.apollo.util.factory.PropertiesFactory in project apollo by ctripcorp.
the class YamlParserTest method testOrderProperties.
@Test
public void testOrderProperties() throws IOException {
String yamlContent = loadYaml("orderedcase.yaml");
Properties nonOrderedProperties = parser.yamlToProperties(yamlContent);
PropertiesFactory propertiesFactory = mock(PropertiesFactory.class);
when(propertiesFactory.getPropertiesInstance()).thenAnswer(new Answer<Properties>() {
@Override
public Properties answer(InvocationOnMock invocation) {
return new OrderedProperties();
}
});
MockInjector.setInstance(PropertiesFactory.class, propertiesFactory);
parser = new YamlParser();
Properties orderedProperties = parser.yamlToProperties(yamlContent);
assertTrue(orderedProperties instanceof OrderedProperties);
checkPropertiesEquals(nonOrderedProperties, orderedProperties);
String[] propertyNames = orderedProperties.stringPropertyNames().toArray(new String[0]);
assertEquals("k2", propertyNames[0]);
assertEquals("k4", propertyNames[1]);
assertEquals("k1", propertyNames[2]);
}
Aggregations