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]);
}
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"));
}
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();
}
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}");
}
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());
}
Aggregations