Search in sources :

Example 6 with OrderedProperties

use of com.ctrip.framework.apollo.util.OrderedProperties in project apollo by ctripcorp.

the class DefaultConfigTest method testGetPropertyNamesWithOrderedProperties.

@Test
public void testGetPropertyNamesWithOrderedProperties() {
    String someKeyPrefix = "someKey";
    String someValuePrefix = "someValue";
    when(propertiesFactory.getPropertiesInstance()).thenAnswer(new Answer<Properties>() {

        @Override
        public Properties answer(InvocationOnMock invocation) {
            return new OrderedProperties();
        }
    });
    // set up config repo
    someProperties = new OrderedProperties();
    for (int i = 0; i < 10; i++) {
        someProperties.setProperty(someKeyPrefix + i, someValuePrefix + i);
    }
    when(configRepository.getConfig()).thenReturn(someProperties);
    DefaultConfig defaultConfig = new DefaultConfig(someNamespace, configRepository);
    Set<String> propertyNames = defaultConfig.getPropertyNames();
    assertEquals(10, propertyNames.size());
    assertEquals(someProperties.stringPropertyNames(), propertyNames);
}
Also used : InvocationOnMock(org.mockito.invocation.InvocationOnMock) OrderedProperties(com.ctrip.framework.apollo.util.OrderedProperties) OrderedProperties(com.ctrip.framework.apollo.util.OrderedProperties) Properties(java.util.Properties) Test(org.junit.Test)

Aggregations

OrderedProperties (com.ctrip.framework.apollo.util.OrderedProperties)6 Test (org.junit.Test)6 Properties (java.util.Properties)4 InvocationOnMock (org.mockito.invocation.InvocationOnMock)4 ApolloConfig (com.ctrip.framework.apollo.core.dto.ApolloConfig)3 BaseIntegrationTest (com.ctrip.framework.apollo.BaseIntegrationTest)2 Config (com.ctrip.framework.apollo.Config)2 ContextHandler (org.eclipse.jetty.server.handler.ContextHandler)2 PropertiesFactory (com.ctrip.framework.apollo.util.factory.PropertiesFactory)1 YamlParser (com.ctrip.framework.apollo.util.yaml.YamlParser)1