Search in sources :

Example 71 with Configuration

use of org.apache.commons.configuration.Configuration in project incubator-atlas by apache.

the class AtlasTopicCreatorTest method shouldNotCreateTopicIfItAlreadyExists.

@Test
public void shouldNotCreateTopicIfItAlreadyExists() {
    Configuration configuration = mock(Configuration.class);
    when(configuration.getBoolean(AtlasTopicCreator.ATLAS_NOTIFICATION_CREATE_TOPICS_KEY, true)).thenReturn(true);
    when(configuration.getString("atlas.authentication.method.kerberos")).thenReturn("false");
    final ZkUtils zookeeperUtils = mock(ZkUtils.class);
    final boolean[] topicExistsCalled = new boolean[] { false };
    final boolean[] createTopicCalled = new boolean[] { false };
    AtlasTopicCreator atlasTopicCreator = new AtlasTopicCreator() {

        @Override
        protected boolean ifTopicExists(String topicName, ZkUtils zkUtils) {
            topicExistsCalled[0] = true;
            return true;
        }

        @Override
        protected ZkUtils createZkUtils(Configuration atlasProperties) {
            return zookeeperUtils;
        }

        @Override
        protected void createTopic(Configuration atlasProperties, String topicName, ZkUtils zkUtils) {
            createTopicCalled[0] = true;
        }
    };
    atlasTopicCreator.createAtlasTopic(configuration, "ATLAS_HOOK");
    assertTrue(topicExistsCalled[0]);
    assertFalse(createTopicCalled[0]);
}
Also used : Configuration(org.apache.commons.configuration.Configuration) ZkUtils(kafka.utils.ZkUtils) Test(org.testng.annotations.Test)

Example 72 with Configuration

use of org.apache.commons.configuration.Configuration in project incubator-atlas by apache.

the class AtlasTopicCreatorTest method shouldNotProcessTopicCreationIfSecurityFails.

@Test
public void shouldNotProcessTopicCreationIfSecurityFails() {
    Configuration configuration = mock(Configuration.class);
    when(configuration.getBoolean(AtlasTopicCreator.ATLAS_NOTIFICATION_CREATE_TOPICS_KEY, true)).thenReturn(true);
    final ZkUtils zookeeperUtils = mock(ZkUtils.class);
    final Map<String, Boolean> createdTopics = new HashMap<>();
    createdTopics.put("ATLAS_HOOK", false);
    createdTopics.put("ATLAS_ENTITIES", false);
    AtlasTopicCreator atlasTopicCreator = new AtlasTopicCreator() {

        @Override
        protected boolean ifTopicExists(String topicName, ZkUtils zkUtils) {
            return false;
        }

        @Override
        protected ZkUtils createZkUtils(Configuration atlasProperties) {
            return zookeeperUtils;
        }

        @Override
        protected void createTopic(Configuration atlasProperties, String topicName, ZkUtils zkUtils) {
            createdTopics.put(topicName, true);
        }

        @Override
        protected boolean handleSecurity(Configuration atlasProperties) {
            return false;
        }
    };
    atlasTopicCreator.createAtlasTopic(configuration, "ATLAS_HOOK", "ATLAS_ENTITIES");
    assertFalse(createdTopics.get("ATLAS_HOOK"));
    assertFalse(createdTopics.get("ATLAS_ENTITIES"));
}
Also used : Configuration(org.apache.commons.configuration.Configuration) HashMap(java.util.HashMap) ZkUtils(kafka.utils.ZkUtils) Test(org.testng.annotations.Test)

Example 73 with Configuration

use of org.apache.commons.configuration.Configuration in project incubator-atlas by apache.

the class AtlasTopicCreatorTest method shouldCloseResources.

@Test
public void shouldCloseResources() {
    Configuration configuration = mock(Configuration.class);
    when(configuration.getBoolean(AtlasTopicCreator.ATLAS_NOTIFICATION_CREATE_TOPICS_KEY, true)).thenReturn(true);
    when(configuration.getString("atlas.authentication.method.kerberos")).thenReturn("false");
    final ZkUtils zookeeperUtils = mock(ZkUtils.class);
    AtlasTopicCreator atlasTopicCreator = new AtlasTopicCreator() {

        @Override
        protected boolean ifTopicExists(String topicName, ZkUtils zkUtils) {
            return false;
        }

        @Override
        protected ZkUtils createZkUtils(Configuration atlasProperties) {
            return zookeeperUtils;
        }

        @Override
        protected void createTopic(Configuration atlasProperties, String topicName, ZkUtils zkUtils) {
        }
    };
    atlasTopicCreator.createAtlasTopic(configuration, "ATLAS_HOOK", "ATLAS_ENTITIES");
    verify(zookeeperUtils, times(1)).close();
}
Also used : Configuration(org.apache.commons.configuration.Configuration) ZkUtils(kafka.utils.ZkUtils) Test(org.testng.annotations.Test)

Example 74 with Configuration

use of org.apache.commons.configuration.Configuration in project incubator-atlas by apache.

the class ApplicationPropertiesTest method testVariables.

@Test
public void testVariables() throws Exception {
    Configuration properties = ApplicationProperties.get(ApplicationProperties.APPLICATION_PROPERTIES);
    //plain property without variables
    assertEquals(properties.getString("atlas.service"), "atlas");
    //property containing system property
    String data = System.getProperty("user.dir") + "/target/data";
    assertEquals(properties.getString("atlas.data"), data);
    //property referencing other property
    assertEquals(properties.getString("atlas.graph.data"), data + "/graph");
    //invalid system property - not substituted
    assertEquals(properties.getString("atlas.db"), "${atlasdb}");
}
Also used : Configuration(org.apache.commons.configuration.Configuration) Test(org.testng.annotations.Test)

Example 75 with Configuration

use of org.apache.commons.configuration.Configuration in project midpoint by Evolveum.

the class SqlRepositoryServiceImpl method postInit.

@Override
public void postInit(OperationResult result) throws SchemaException {
    SystemConfigurationType systemConfiguration;
    try {
        systemConfiguration = getObject(SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value(), null, result).asObjectable();
    } catch (ObjectNotFoundException e) {
        // ok, no problem e.g. for tests or initial startup
        LOGGER.debug("System configuration not found, exiting postInit method.");
        return;
    }
    SystemConfigurationHolder.setCurrentConfiguration(systemConfiguration);
    Configuration systemConfigFromFile = midpointConfiguration.getConfiguration(MidpointConfiguration.SYSTEM_CONFIGURATION_SECTION);
    if (systemConfigFromFile != null && systemConfigFromFile.getBoolean(LoggingConfigurationManager.SYSTEM_CONFIGURATION_SKIP_REPOSITORY_LOGGING_SETTINGS, false)) {
        LOGGER.warn("Skipping application of repository logging configuration because {}=true", LoggingConfigurationManager.SYSTEM_CONFIGURATION_SKIP_REPOSITORY_LOGGING_SETTINGS);
    } else {
        LoggingConfigurationType loggingConfig = ProfilingConfigurationManager.checkSystemProfilingConfiguration(systemConfiguration.asPrismObject());
        if (loggingConfig != null) {
            LoggingConfigurationManager.configure(loggingConfig, systemConfiguration.getVersion(), result);
        }
    }
    applyFullTextSearchConfiguration(systemConfiguration.getFullTextSearch());
}
Also used : MidpointConfiguration(com.evolveum.midpoint.common.configuration.api.MidpointConfiguration) Configuration(org.apache.commons.configuration.Configuration) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException)

Aggregations

Configuration (org.apache.commons.configuration.Configuration)185 Test (org.junit.Test)51 PropertiesConfiguration (org.apache.commons.configuration.PropertiesConfiguration)44 ZapXmlConfiguration (org.zaproxy.zap.utils.ZapXmlConfiguration)23 Test (org.testng.annotations.Test)22 File (java.io.File)14 AbstractConfiguration (org.apache.commons.configuration.AbstractConfiguration)13 MidpointConfiguration (com.evolveum.midpoint.common.configuration.api.MidpointConfiguration)11 Properties (java.util.Properties)10 HashMap (java.util.HashMap)9 AtlasException (org.apache.atlas.AtlasException)9 CompositeConfiguration (org.apache.commons.configuration.CompositeConfiguration)9 ArrayList (java.util.ArrayList)8 ZkUtils (kafka.utils.ZkUtils)8 ConfigurationException (org.apache.commons.configuration.ConfigurationException)8 IndexLoadingConfigMetadata (com.linkedin.pinot.common.metadata.segment.IndexLoadingConfigMetadata)7 AtlasClient (org.apache.atlas.AtlasClient)6 BeforeClass (org.testng.annotations.BeforeClass)6 MockResponse (com.github.bordertech.wcomponents.util.mock.MockResponse)5 IOException (java.io.IOException)5