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

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

Introduction

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

Prototype

@Override
    public final void setProperty(final String key, final Object value) 

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. ja v a  2  s . c  o  m
 * @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);
}