Example usage for org.apache.commons.configuration2 BaseConfiguration BaseConfiguration

List of usage examples for org.apache.commons.configuration2 BaseConfiguration BaseConfiguration

Introduction

In this page you can find the example usage for org.apache.commons.configuration2 BaseConfiguration BaseConfiguration.

Prototype

BaseConfiguration

Source Link

Usage

From source file:com.pnf.jebauto.AutoClient.java

/**
 * Initialize a core. Create a context within that core. Then, for each input artifact, a
 * project is created and the artifact is loaded within that project.
 * //from   w w  w. j a v  a2s  .  c  om
 * @param files
 * @throws Exception
 */
public static void test(List<File> files) throws Exception {
    // create or retrieve a core context (engines container)
    ICoreContext core = JebCoreService.getInstance(licenseKey);

    // create an engines context (project container)
    IFileDatabase projectdb = new JEB2FileDatabase(baseDir);
    IFileStore filestore = new SimpleFSFileStore(baseDir);
    BaseConfiguration cfg = new BaseConfiguration();

    // TODO: customize (alternative is to read your configuration from .cfg file)
    cfg.setProperty(".DevPluginClasspath", "...");

    // TODO: customize
    cfg.setProperty(".DevPluginClassnames", "...");

    IConfiguration config = new CommonsConfigurationWrapper(cfg);
    IDataProvider dataProvider = new DataProvider(null, projectdb, filestore, null, null, config);
    IEnginesContext engctx = core.createEnginesContext(dataProvider, null);

    int i = 0;
    for (File file : files) {
        i++;
        logger.info("Testing file %d/%d : %s ...", i, files.size(), file.getName());

        // create or load a project (artifact container)
        IRuntimeProject prj = engctx.loadProject("ProjectTest" + i);

        // process the artifact, get units
        ILiveArtifact art = prj.processArtifact(new Artifact(file.getName(), new FileInput(file)));

        // proceed with the units
        List<IUnit> units = art.getUnits();

        // TODO: CUSTOMIZE -- this is the important part
        // Basic tests go here
        // example:
        for (IUnit unit : units) {
            logger.info("Unit: %s", unit);
            //if(unit instanceof Xyz) {
            // ...
            //}
        }

        engctx.unloadProject(prj.getKey());
    }

    // close the engines
    JebCoreService.getInstance().closeEnginesContext(engctx);
}

From source file:eu.larkc.csparql.common.config.Config.java

private Config() {
    try {/*  w  w  w .ja v  a2  s . co  m*/
        List<FileLocationStrategy> subs = Arrays.asList(new BasePathLocationStrategy(),
                new FileSystemLocationStrategy(), new ClasspathLocationStrategy());

        FileLocationStrategy strategy = new CombinedLocationStrategy(subs);

        FileBasedConfigurationBuilder<FileBasedConfiguration> builder = new FileBasedConfigurationBuilder<FileBasedConfiguration>(
                PropertiesConfiguration.class);
        Parameters params = new Parameters();

        builder.configure(params.fileBased().setFileName("csparql.properties").setLocationStrategy(strategy));

        config = builder.getConfiguration();
        logger.debug("Configuration file successfully lodead");
    } catch (ConfigurationException e) {
        logger.error("Error while lading the configuration file; default config will be used", e);
        config = new BaseConfiguration();
        config.addProperty("esper.externaltime.enabled", false);
        config.addProperty("esper.externaltime.tick", 0);
    }
}

From source file:org.aksw.mlbenchmark.BenchmarkRunnerTest.java

@BeforeClass
public static void setUpClass() throws ConfigLoaderException {
    // set up mock class
    configMock = mock(BenchmarkConfig.class);
    when(configMock.getLearningSystems()).thenReturn(learningSystem);
    when(configMock.getSeed()).thenReturn(seed);
    when(configMock.getCrossValidationFolds()).thenReturn(crossValidationFolds);
    when(configMock.isLeaveOneOut()).thenReturn(leaveOneOut);
    when(configMock.getThreadsCount()).thenReturn(threadsCount);
    when(configMock.getMexOutputFile()).thenReturn(mexOutputFile);
    when(configMock.getScenarios()).thenReturn(scenarios);
    when(configMock.getLearningSystemConfiguration(any(LearningSystemInfo.class)))
            .thenReturn(new BaseConfiguration());
    when(configMock.getLearningTaskConfiguration(anyString())).thenReturn(new BaseConfiguration());
    when(configMock.getLearningProblemConfiguration(any(Scenario.class))).thenReturn(new BaseConfiguration());
    when(configMock.getConfig()).thenReturn(new BaseHierarchicalConfiguration());
    // create instance
    instance = new BenchmarkRunner(configMock);
}

From source file:org.eclipse.winery.repository.backend.filebased.ConfigurationBasedNamespaceManagerTest.java

@BeforeEach
public void initializeNamespaceManager() {
    this.configurationBasedNamespaceManager = new ConfigurationBasedNamespaceManager(new BaseConfiguration());
}

From source file:org.linqs.psl.config.Config.java

/**
 * (Re)create and populate the initial config.
 *///from  ww  w  .  j a  v  a  2  s .  c om
public static void init() {
    config = new DataConfiguration(new BaseConfiguration());

    // Load maven project properties.
    InputStream stream = ClassLoader.getSystemClassLoader().getResourceAsStream(PROJECT_PROPS);
    if (stream != null) {
        loadResource(stream, PROJECT_PROPS);
    }

    // Load the configuration file directly if the path exists.
    String path = OptionConverter.getSystemProperty(PSL_CONFIG, PSL_CONFIG_DEFAULT);
    if ((new File(path)).isFile()) {
        loadResource(path);
        return;
    }

    // Try to get a resource URL from the system (if we have a property key instead of a path).
    stream = ClassLoader.getSystemClassLoader().getResourceAsStream(path);
    if (stream != null) {
        loadResource(stream, PSL_CONFIG);
        return;
    }

    log.debug("PSL configuration {} file not found."
            + " Only default values will be used unless additional properties are specified.", path);
}