Search in sources :

Example 1 with FilteringFolder

use of spoon.support.compiler.FilteringFolder in project spoon by INRIA.

the class ResourceTest method testFilteringFolder.

@Test
public void testFilteringFolder() throws Exception {
    // contract: one can filter input files
    // the core of this test is the removeIfMatches at the end
    // all files
    SpoonModelBuilder mb = new Launcher().getModelBuilder();
    FilteringFolder resources = new FilteringFolder();
    resources.addFolder(new FileSystemFolder("src/test/java/spoon/test/visibility/"));
    mb.addInputSource(resources);
    mb.build();
    int nbAll = mb.getFactory().getModel().getAllTypes().size();
    assertEquals(12, nbAll);
    SpoonModelBuilder mb2 = new Launcher().getModelBuilder();
    FilteringFolder resources2 = new FilteringFolder();
    resources2.addFolder(new FileSystemFolder("src/test/java/spoon/test/visibility/packageprotected/"));
    mb2.addInputSource(resources2);
    mb2.build();
    int nbPackageProtected = mb2.getFactory().getModel().getAllTypes().size();
    assertEquals(2, nbPackageProtected);
    // now the core of this test
    SpoonModelBuilder mb3 = new Launcher().getModelBuilder();
    FilteringFolder resources3 = new FilteringFolder();
    resources3.addFolder(new FileSystemFolder("src/test/java/spoon/test/visibility/"));
    // we remove a number of input resources
    resources3.removeAllThatMatch(".*packageprotected.*");
    mb3.addInputSource(resources3);
    mb3.build();
    assertEquals(nbAll - nbPackageProtected, mb3.getFactory().getModel().getAllTypes().size());
}
Also used : SpoonModelBuilder(spoon.SpoonModelBuilder) Launcher(spoon.Launcher) FilteringFolder(spoon.support.compiler.FilteringFolder) FileSystemFolder(spoon.support.compiler.FileSystemFolder) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 Launcher (spoon.Launcher)1 SpoonModelBuilder (spoon.SpoonModelBuilder)1 FileSystemFolder (spoon.support.compiler.FileSystemFolder)1 FilteringFolder (spoon.support.compiler.FilteringFolder)1