Search in sources :

Example 1 with FileConfiguration

use of org.apache.commons.configuration.FileConfiguration in project grakn by graknlabs.

the class GraknSparkComputer method main.

public static void main(final String[] args) throws Exception {
    final FileConfiguration configuration = new PropertiesConfiguration(args[0]);
    new GraknSparkComputer(HadoopGraph.open(configuration)).program(VertexProgram.createVertexProgram(HadoopGraph.open(configuration), configuration)).submit().get();
}
Also used : FileConfiguration(org.apache.commons.configuration.FileConfiguration) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration)

Example 2 with FileConfiguration

use of org.apache.commons.configuration.FileConfiguration in project bookkeeper by apache.

the class ConfigurationSubscription method initConfig.

private boolean initConfig() {
    if (fileConfigs.isEmpty()) {
        try {
            for (FileConfigurationBuilder fileConfigBuilder : fileConfigBuilders) {
                FileConfiguration fileConfig = fileConfigBuilder.getConfiguration();
                FileChangedReloadingStrategy reloadingStrategy = new FileChangedReloadingStrategy();
                reloadingStrategy.setRefreshDelay(0);
                fileConfig.setReloadingStrategy(reloadingStrategy);
                fileConfigs.add(fileConfig);
            }
        } catch (ConfigurationException ex) {
            if (!fileNotFound(ex)) {
                LOG.error("Config init failed {}", ex);
            }
        }
    }
    return !fileConfigs.isEmpty();
}
Also used : FileConfiguration(org.apache.commons.configuration.FileConfiguration) FileChangedReloadingStrategy(org.apache.commons.configuration.reloading.FileChangedReloadingStrategy) ConfigurationException(org.apache.commons.configuration.ConfigurationException)

Example 3 with FileConfiguration

use of org.apache.commons.configuration.FileConfiguration in project zaproxy by zaproxy.

the class ExtensionPassiveScan method addPluginPassiveScannerImpl.

private boolean addPluginPassiveScannerImpl(PluginPassiveScanner scanner) {
    if (scanner instanceof RegexAutoTagScanner) {
        return false;
    }
    boolean added = false;
    try {
        FileConfiguration config = this.getModel().getOptionsParam().getConfig();
        scanner.setConfig(config);
        added = addPassiveScannerImpl(scanner);
        if (hasView()) {
            getPolicyPanel().getPassiveScanTableModel().addScanner(scanner);
        }
        logger.info("loaded passive scan rule: {}", scanner.getName());
        if (scanner.getPluginId() == -1) {
            logger.error("The passive scan rule \"{}\" [{}] does not have a defined ID.", scanner.getName(), scanner.getClass().getCanonicalName());
        }
    } catch (Exception e) {
        logger.error("Failed to load passive scan rule {}", scanner.getName(), e);
    }
    return added;
}
Also used : RegexAutoTagScanner(org.zaproxy.zap.extension.pscan.scanner.RegexAutoTagScanner) FileConfiguration(org.apache.commons.configuration.FileConfiguration)

Example 4 with FileConfiguration

use of org.apache.commons.configuration.FileConfiguration in project zaproxy by zaproxy.

the class OptionsParamApiUnitTest method shouldParseLoadedFileConfiguration.

@Test
void shouldParseLoadedFileConfiguration() {
    // Given
    OptionsParamApi param = new OptionsParamApi();
    FileConfiguration config = createTestConfig();
    // When
    param.load(config);
    // Then
    assertThat(param.isEnabled(), is(equalTo(false)));
    assertThat(param.isSecureOnly(), is(equalTo(true)));
    assertThat(param.isDisableKey(), is(equalTo(true)));
    assertThat(param.isIncErrorDetails(), is(equalTo(true)));
    assertThat(param.isAutofillKey(), is(equalTo(true)));
    assertThat(param.isEnableJSONP(), is(equalTo(true)));
    assertThat(param.getRealKey(), is(equalTo("ApiKey")));
}
Also used : FileConfiguration(org.apache.commons.configuration.FileConfiguration) Test(org.junit.jupiter.api.Test)

Example 5 with FileConfiguration

use of org.apache.commons.configuration.FileConfiguration in project zaproxy by zaproxy.

the class OptionsParamApiUnitTest method shouldHaveLoadedConfigsAfterCloning.

@Test
void shouldHaveLoadedConfigsAfterCloning() {
    // Given
    OptionsParamApi param = new OptionsParamApi();
    FileConfiguration config = createTestConfig();
    param.load(config);
    // When
    OptionsParamApi clone = param.clone();
    // Then
    assertThat(clone, is(notNullValue()));
    assertThat(param.isEnabled(), is(equalTo(false)));
    assertThat(param.isSecureOnly(), is(equalTo(true)));
    assertThat(param.isDisableKey(), is(equalTo(true)));
    assertThat(param.isIncErrorDetails(), is(equalTo(true)));
    assertThat(param.isAutofillKey(), is(equalTo(true)));
    assertThat(param.isEnableJSONP(), is(equalTo(true)));
    assertThat(param.getRealKey(), is(equalTo("ApiKey")));
}
Also used : FileConfiguration(org.apache.commons.configuration.FileConfiguration) Test(org.junit.jupiter.api.Test)

Aggregations

FileConfiguration (org.apache.commons.configuration.FileConfiguration)18 Test (org.junit.jupiter.api.Test)11 ConfigurationException (org.apache.commons.configuration.ConfigurationException)4 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 FileNotFoundException (java.io.FileNotFoundException)2 Iterator (java.util.Iterator)2 PropertiesConfiguration (org.apache.commons.configuration.PropertiesConfiguration)2 FileChangedReloadingStrategy (org.apache.commons.configuration.reloading.FileChangedReloadingStrategy)2 File (java.io.File)1 HashMap (java.util.HashMap)1 ReloadingStrategy (org.apache.commons.configuration.reloading.ReloadingStrategy)1 RegexAutoTagScanner (org.zaproxy.zap.extension.pscan.scanner.RegexAutoTagScanner)1 ZapXmlConfiguration (org.zaproxy.zap.utils.ZapXmlConfiguration)1