org.apache.commons.configuration.AbstractFileConfiguration Java Examples

The following examples show how to use org.apache.commons.configuration.AbstractFileConfiguration. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HugeConfig.java    From hugegraph-common with Apache License 2.0 5 votes vote down vote up
private void reloadIfNeed(Configuration conf) {
    if (!(conf instanceof AbstractFileConfiguration)) {
        return;
    }

    AbstractFileConfiguration fileConfig = (AbstractFileConfiguration) conf;

    File file = fileConfig.getFile();
    if (file != null) {
        // May need to use the original file
        this.setFile(file);
    }

    if (!fileConfig.isDelimiterParsingDisabled()) {
        /*
         * PropertiesConfiguration will parse the containing comma
         * config options into list directly, but we want to do
         * this work by ourselves, so reload it and parse into `String`
         */
        fileConfig.setDelimiterParsingDisabled(true);
        try {
            fileConfig.refresh();
        } catch (ConfigurationException e) {
            throw new ConfigException("Unable to load config file: %s",
                                      e, file);
        }
    }
}
 
Example #2
Source File: TestOptions.java    From artifactory_ssh_proxy with Apache License 2.0 5 votes vote down vote up
@Test(dataProvider = "overrides")
public void testFindConfigFile(String override, String expected) throws Exception {
    SshdSettingsBuilder testBuilder = new SshdSettingsBuilder();
    Configuration config = testBuilder.findPropertiesConfiguration(override);

    AbstractFileConfiguration fileConfiguration = (AbstractFileConfiguration) config;

    // we need to create expected from a new file.
    // because it's a complete filename.
    File expectedFile = new File(expected);
    String expectedPath = "file://" + expectedFile.getAbsolutePath();
    Assert.assertEquals(fileConfiguration.getFileName(), expectedPath);
}