use of org.sonar.api.scan.filesystem.FileExclusions in project sonarqube by SonarSource.
the class ExclusionFiltersTest method match_exclusion_by_absolute_path.
@Test
public void match_exclusion_by_absolute_path() throws IOException {
File excludedFile = new File(moduleBaseDir.toString(), "src/main/java/org/bar/Bar.java");
Settings settings = new MapSettings();
settings.setProperty(CoreProperties.PROJECT_INCLUSIONS_PROPERTY, "src/main/java/**/*");
settings.setProperty(CoreProperties.PROJECT_EXCLUSIONS_PROPERTY, "file:" + excludedFile.getAbsolutePath());
ExclusionFilters filter = new ExclusionFilters(new FileExclusions(settings));
filter.prepare();
IndexedFile indexedFile = new DefaultIndexedFile("foo", moduleBaseDir, "src/main/java/org/bar/Foo.java");
assertThat(filter.accept(indexedFile, InputFile.Type.MAIN)).isTrue();
indexedFile = new DefaultIndexedFile("foo", moduleBaseDir, "src/main/java/org/bar/Bar.java");
assertThat(filter.accept(indexedFile, InputFile.Type.MAIN)).isFalse();
}
Aggregations