Search in sources :

Example 46 with Configuration

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));
}
Also used : Configuration(org.apache.commons.configuration.Configuration) ZookeeperConfigurationProvider(com.kixeye.chassis.bootstrap.configuration.zookeeper.ZookeeperConfigurationProvider) Test(org.junit.Test)

Example 47 with Configuration

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));
}
Also used : Configuration(org.apache.commons.configuration.Configuration) SimpleEntry(java.util.AbstractMap.SimpleEntry) Test(org.junit.Test)

Example 48 with Configuration

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);
}
Also used : ServerInstanceContext(com.kixeye.chassis.bootstrap.aws.ServerInstanceContext) Configuration(org.apache.commons.configuration.Configuration) Test(org.junit.Test)

Example 49 with Configuration

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));
}
Also used : Configuration(org.apache.commons.configuration.Configuration) Test(org.junit.Test)

Example 50 with Configuration

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());
}
Also used : Configuration(org.apache.commons.configuration.Configuration) SimpleEntry(java.util.AbstractMap.SimpleEntry) Test(org.junit.Test)

Aggregations

Configuration (org.apache.commons.configuration.Configuration)169 Test (org.junit.Test)42 PropertiesConfiguration (org.apache.commons.configuration.PropertiesConfiguration)39 ZapXmlConfiguration (org.zaproxy.zap.utils.ZapXmlConfiguration)23 Test (org.testng.annotations.Test)22 File (java.io.File)13 AbstractConfiguration (org.apache.commons.configuration.AbstractConfiguration)13 MidpointConfiguration (com.evolveum.midpoint.common.configuration.api.MidpointConfiguration)11 Properties (java.util.Properties)10 AtlasException (org.apache.atlas.AtlasException)9 ZkUtils (kafka.utils.ZkUtils)8 IndexLoadingConfigMetadata (com.linkedin.pinot.common.metadata.segment.IndexLoadingConfigMetadata)7 HashMap (java.util.HashMap)7 CompositeConfiguration (org.apache.commons.configuration.CompositeConfiguration)7 ArrayList (java.util.ArrayList)6 AtlasClient (org.apache.atlas.AtlasClient)6 BeforeClass (org.testng.annotations.BeforeClass)6 IOException (java.io.IOException)5 SimpleEntry (java.util.AbstractMap.SimpleEntry)5 ConfigurationException (org.apache.commons.configuration.ConfigurationException)5