use of org.apache.commons.configuration.Configuration in project chassis by Kixeye.
the class ConfigurationBuilderTest method zookeeperHappy.
@Test
public void zookeeperHappy() throws Exception {
String key = ZOOKEEPER_CONFIG_ROOT + "/" + MODULE_1_KEY_1;
curatorFramework.create().creatingParentsIfNeeded().forPath(key, MODULE_1_VALUE_1.getBytes());
Assert.assertEquals(MODULE_1_VALUE_1, new String(curatorFramework.getData().forPath(key)));
configurationBuilder.withConfigurationProvider(new ZookeeperConfigurationProvider(zookeeperServer.getConnectString()));
Configuration configuration = configurationBuilder.build();
Assert.assertEquals(MODULE_1_VALUE_1, configuration.getString(MODULE_1_KEY_1));
}
use of org.apache.commons.configuration.Configuration in project chassis by Kixeye.
the class ConfigurationBuilderTest method applicationConfigurationsWithEnvironmentConfiguration.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void applicationConfigurationsWithEnvironmentConfiguration() {
TestUtils.writePropertiesToFile(TEST_APP_CONFIG_PROPERTIES, filesCreated, new SimpleEntry(MODULE_1_KEY_2, MODULE_1_VALUE_2 + "-override"), new SimpleEntry(MODULE_1_KEY_3, MODULE_1_VALUE_3 + "-override"));
TestUtils.writePropertiesToFile(TEST_APP_CONFIG_PROPERTIES.replace(".properties", "." + ENVIRONMENT + ".properties"), filesCreated, new SimpleEntry(MODULE_1_KEY_2, MODULE_1_VALUE_2 + "-override"));
configurationBuilder.withApplicationProperties("file://" + TEST_APP_CONFIG_PROPERTIES);
Configuration configuration = configurationBuilder.build();
Assert.assertEquals(MODULE_1_VALUE_1, configuration.getString(MODULE_1_KEY_1));
Assert.assertEquals(MODULE_1_VALUE_2 + "-override", configuration.getString(MODULE_1_KEY_2));
Assert.assertEquals(MODULE_1_VALUE_3 + "-override", configuration.getString(MODULE_1_KEY_3));
}
use of org.apache.commons.configuration.Configuration in project chassis by Kixeye.
the class ConfigurationBuilderTest method buildConfigurationInAws.
@Test
public void buildConfigurationInAws() {
String az = "testaz";
String instanceId = RandomStringUtils.randomAlphabetic(10);
String region = Regions.DEFAULT_REGION.getName();
ServerInstanceContext serverInstanceContext = EasyMock.createMock(ServerInstanceContext.class);
EasyMock.expect(serverInstanceContext.getAvailabilityZone()).andReturn(az);
EasyMock.expect(serverInstanceContext.getInstanceId()).andReturn(instanceId);
EasyMock.expect(serverInstanceContext.getRegion()).andReturn(region);
EasyMock.expect(serverInstanceContext.getPrivateIp()).andReturn("127.0.0.1");
EasyMock.expect(serverInstanceContext.getPublicIp()).andReturn(null);
EasyMock.replay(serverInstanceContext);
Configuration configuration = configurationBuilder.withServerInstanceContext(serverInstanceContext).build();
Assert.assertEquals(az, configuration.getString(BootstrapConfigKeys.AWS_INSTANCE_AVAILABILITY_ZONE.getPropertyName()));
Assert.assertEquals(instanceId, configuration.getString(BootstrapConfigKeys.AWS_INSTANCE_ID.getPropertyName()));
Assert.assertEquals(region, configuration.getString(BootstrapConfigKeys.AWS_INSTANCE_REGION.getPropertyName()));
Assert.assertEquals("127.0.0.1", configuration.getString(BootstrapConfigKeys.AWS_INSTANCE_PRIVATE_IP.getPropertyName()));
Assert.assertEquals(null, configuration.getString(BootstrapConfigKeys.AWS_INSTANCE_PUBLIC_IP.getPropertyName()));
EasyMock.verify(serverInstanceContext);
}
use of org.apache.commons.configuration.Configuration in project chassis by Kixeye.
the class ConfigurationBuilderTest method defaultModuleConfigurations.
@Test
public void defaultModuleConfigurations() {
Configuration configuration = configurationBuilder.build();
Assert.assertEquals(MODULE_1_VALUE_1, configuration.getString(MODULE_1_KEY_1));
Assert.assertEquals(MODULE_1_VALUE_2, configuration.getString(MODULE_1_KEY_2));
Assert.assertEquals(MODULE_1_VALUE_3, configuration.getString(MODULE_1_KEY_3));
}
use of org.apache.commons.configuration.Configuration in project chassis by Kixeye.
the class ConfigurationBuilderTest method fetchFromArchaius.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void fetchFromArchaius() {
TestUtils.writePropertiesToFile(TEST_APP_CONFIG_PROPERTIES, filesCreated, new SimpleEntry(MODULE_1_KEY_2, MODULE_1_VALUE_2 + "-override"), new SimpleEntry(MODULE_1_KEY_3, MODULE_1_VALUE_3 + "-override"));
TestUtils.writePropertiesToFile(TEST_APP_CONFIG_PROPERTIES.replace(".properties", "." + ENVIRONMENT + ".properties"), filesCreated, new SimpleEntry(MODULE_1_KEY_2, MODULE_1_VALUE_2 + "-override"));
configurationBuilder.withApplicationProperties(TEST_APP_CONFIG_PROPERTIES_SPRING_PATH);
Configuration configuration = configurationBuilder.build();
Assert.assertEquals(MODULE_1_VALUE_1, configuration.getString(MODULE_1_KEY_1));
Assert.assertEquals(MODULE_1_VALUE_2 + "-override", configuration.getString(MODULE_1_KEY_2));
Assert.assertEquals(MODULE_1_VALUE_3 + "-override", configuration.getString(MODULE_1_KEY_3));
Assert.assertEquals(MODULE_1_VALUE_1, DynamicPropertyFactory.getInstance().getStringProperty(MODULE_1_KEY_1, null).getValue());
Assert.assertEquals(MODULE_1_VALUE_2 + "-override", DynamicPropertyFactory.getInstance().getStringProperty(MODULE_1_KEY_2, null).getValue());
Assert.assertEquals(MODULE_1_VALUE_3 + "-override", DynamicPropertyFactory.getInstance().getStringProperty(MODULE_1_KEY_3, null).getValue());
}
Aggregations