]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-926 Optimize computation of file inclusion/exclusion
authorJulien HENRY <julien.henry@sonarsource.com>
Mon, 10 Feb 2014 11:31:25 +0000 (12:31 +0100)
committerJulien HENRY <julien.henry@sonarsource.com>
Mon, 10 Feb 2014 11:31:25 +0000 (12:31 +0100)
  * only browse FS once for both MAIN and TEST
  * put patterns in cache
  * don't build InputFile if file is excluded

sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ExclusionFilters.java
sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileIndex.java
sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/PathPattern.java
sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ExclusionFiltersTest.java

index b9b57adae693700b85f606462865422389f6926e..6ad98102a675499d5f0284926a425dc331fc204b 100644 (file)
@@ -34,15 +34,24 @@ import java.util.List;
 public class ExclusionFilters implements BatchComponent {
   private final FileExclusions exclusionSettings;
 
+  private PathPattern[] sourceInclusions;
+  private PathPattern[] sourceExclusions;
+  private PathPattern[] testInclusions;
+  private PathPattern[] testExclusions;
+
   public ExclusionFilters(FileExclusions exclusions) {
     this.exclusionSettings = exclusions;
   }
 
-  public void logConfiguration(ModuleFileSystem fs) {
-    log("Included sources: ", sourceInclusions(fs));
-    log("Excluded sources: ", sourceExclusions());
-    log("Included tests: ", testInclusions(fs));
-    log("Excluded tests: ", testExclusions());
+  public void prepare(ModuleFileSystem fs) {
+    sourceInclusions = computeSourceInclusions(fs);
+    sourceExclusions = computeSourceExclusions();
+    testInclusions = computeTestInclusions(fs);
+    testExclusions = computeTestExclusions();
+    log("Included sources: ", sourceInclusions);
+    log("Excluded sources: ", sourceExclusions);
+    log("Included tests: ", testInclusions);
+    log("Excluded tests: ", testExclusions);
   }
 
   private void log(String title, PathPattern[] patterns) {
@@ -55,21 +64,20 @@ public class ExclusionFilters implements BatchComponent {
     }
   }
 
-  public boolean accept(InputFile inputFile, ModuleFileSystem fs) {
-    String type = inputFile.attribute(InputFile.ATTRIBUTE_TYPE);
+  public boolean accept(File ioFile, String relativePathFromBasedir, String type) {
     PathPattern[] inclusionPatterns = null;
     PathPattern[] exclusionPatterns = null;
     if (InputFile.TYPE_MAIN.equals(type)) {
-      inclusionPatterns = sourceInclusions(fs);
-      exclusionPatterns = sourceExclusions();
+      inclusionPatterns = sourceInclusions;
+      exclusionPatterns = sourceExclusions;
     } else if (InputFile.TYPE_TEST.equals(type)) {
-      inclusionPatterns = testInclusions(fs);
-      exclusionPatterns = testExclusions();
+      inclusionPatterns = testInclusions;
+      exclusionPatterns = testExclusions;
     }
     boolean matchInclusion = false;
     if (inclusionPatterns != null && inclusionPatterns.length > 0) {
       for (PathPattern pattern : inclusionPatterns) {
-        matchInclusion |= pattern.match(inputFile);
+        matchInclusion |= pattern.match(ioFile, relativePathFromBasedir);
       }
       if (!matchInclusion) {
         return false;
@@ -77,7 +85,7 @@ public class ExclusionFilters implements BatchComponent {
     }
     if (exclusionPatterns != null && exclusionPatterns.length > 0) {
       for (PathPattern pattern : exclusionPatterns) {
-        if (pattern.match(inputFile)) {
+        if (pattern.match(ioFile, relativePathFromBasedir)) {
           return false;
         }
       }
@@ -85,7 +93,7 @@ public class ExclusionFilters implements BatchComponent {
     return matchInclusion;
   }
 
-  PathPattern[] sourceInclusions(ModuleFileSystem fs) {
+  PathPattern[] computeSourceInclusions(ModuleFileSystem fs) {
     if (exclusionSettings.sourceInclusions().length > 0) {
       // User defined params
       return PathPattern.create(exclusionSettings.sourceInclusions());
@@ -99,7 +107,7 @@ public class ExclusionFilters implements BatchComponent {
     return PathPattern.create(sourcePattern.toArray(new String[sourcePattern.size()]));
   }
 
-  PathPattern[] testInclusions(ModuleFileSystem fs) {
+  PathPattern[] computeTestInclusions(ModuleFileSystem fs) {
     if (exclusionSettings.testInclusions().length > 0) {
       // User defined params
       return PathPattern.create(exclusionSettings.testInclusions());
@@ -113,11 +121,11 @@ public class ExclusionFilters implements BatchComponent {
     return PathPattern.create(testPatterns.toArray(new String[testPatterns.size()]));
   }
 
-  PathPattern[] sourceExclusions() {
+  PathPattern[] computeSourceExclusions() {
     return PathPattern.create(exclusionSettings.sourceExclusions());
   }
 
-  PathPattern[] testExclusions() {
+  PathPattern[] computeTestExclusions() {
     return PathPattern.create(exclusionSettings.testExclusions());
   }
 }
index 07e0e8a82cd70a0055d4245310ccc0f24fcdad74..1a0f0a9d08ba88cee04d4c2c4048f09c26c9bc4c 100644 (file)
@@ -43,9 +43,14 @@ import org.sonar.api.utils.SonarException;
 
 import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
+
 import java.io.File;
 import java.nio.charset.Charset;
-import java.util.*;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 /**
  * Index input files into {@link InputFileCache}.
@@ -104,7 +109,7 @@ public class FileIndex implements BatchComponent {
       return;
     }
     logger.info("Index files");
-    exclusionFilters.logConfiguration(fileSystem);
+    exclusionFilters.prepare(fileSystem);
     // TODO log configuration too (replace FileSystemLogger)
 
     Progress progress = new Progress(fileCache.fileRelativePaths(fileSystem.moduleKey()));
@@ -115,8 +120,7 @@ public class FileIndex implements BatchComponent {
       indexFiles(fileSystem, progress, fileSystem.testFiles(), InputFile.TYPE_TEST);
     } else if (fileSystem.baseDir() != null) {
       // index from basedir
-      indexDirectory(fileSystem, progress, fileSystem.baseDir(), InputFile.TYPE_MAIN);
-      indexDirectory(fileSystem, progress, fileSystem.baseDir(), InputFile.TYPE_TEST);
+      indexDirectory(fileSystem, progress, fileSystem.baseDir());
     }
 
     // Remove files that have been removed since previous indexation
@@ -136,7 +140,9 @@ public class FileIndex implements BatchComponent {
           "File '%s' is not declared in module basedir %s", sourceFile.getAbsoluteFile(), fileSystem.baseDir()
           ));
       } else {
-        indexFile(fileSystem, progress, sourceFile, type);
+        if (exclusionFilters.accept(sourceFile, path, type)) {
+          indexFile(fileSystem, progress, sourceFile, path, type);
+        }
       }
     }
   }
@@ -160,23 +166,30 @@ public class FileIndex implements BatchComponent {
     return DefaultInputDir.create(ioFile, path, attributes);
   }
 
-  private void indexDirectory(DefaultModuleFileSystem fileSystem, Progress status, File dirToIndex, String type) {
+  private void indexDirectory(DefaultModuleFileSystem fileSystem, Progress status, File dirToIndex) {
     Collection<File> files = FileUtils.listFiles(dirToIndex, FILE_FILTER, DIR_FILTER);
-    for (File file : files) {
-      indexFile(fileSystem, status, file, type);
+    for (File sourceFile : files) {
+      String path = pathResolver.relativePath(fileSystem.baseDir(), sourceFile);
+      if (path == null) {
+        LoggerFactory.getLogger(getClass()).warn(String.format(
+          "File '%s' is not declared in module basedir %s", sourceFile.getAbsoluteFile(), fileSystem.baseDir()
+          ));
+      } else {
+        if (exclusionFilters.accept(sourceFile, path, InputFile.TYPE_MAIN)) {
+          indexFile(fileSystem, status, sourceFile, path, InputFile.TYPE_MAIN);
+        }
+        if (exclusionFilters.accept(sourceFile, path, InputFile.TYPE_TEST)) {
+          indexFile(fileSystem, status, sourceFile, path, InputFile.TYPE_TEST);
+        }
+      }
     }
   }
 
-  private void indexFile(DefaultModuleFileSystem fileSystem, Progress status, File file, String type) {
-    String path = computeFilePath(fileSystem, file);
-    if (path == null) {
-      LoggerFactory.getLogger(getClass()).warn(String.format("File '%s' is not in basedir '%s'", file.getAbsolutePath(), fileSystem.baseDir()));
-    } else {
-      InputFile input = newInputFile(fileSystem, type, file, path);
-      if (input != null && accept(input, fileSystem)) {
-        fileCache.put(fileSystem.moduleKey(), input);
-        status.markAsIndexed(path);
-      }
+  private void indexFile(DefaultModuleFileSystem fileSystem, Progress status, File file, String path, String type) {
+    InputFile input = newInputFile(fileSystem, type, file, path);
+    if (input != null && accept(input)) {
+      fileCache.put(fileSystem.moduleKey(), input);
+      status.markAsIndexed(path);
     }
   }
 
@@ -246,11 +259,8 @@ public class FileIndex implements BatchComponent {
     }
   }
 
-  private boolean accept(InputFile inputFile, ModuleFileSystem fs) {
-    if (!exclusionFilters.accept(inputFile, fs)) {
-      return false;
-    }
-    // Other InputFileFilter extensions
+  private boolean accept(InputFile inputFile) {
+    // InputFileFilter extensions
     for (InputFileFilter filter : filters) {
       if (!filter.accept(inputFile)) {
         return false;
index 917ae1597a678f558ea2ec2125be90a2ec347c28..d5ed358339374b71a5728b4934df64e8a201aa9a 100644 (file)
@@ -27,6 +27,8 @@ import org.sonar.api.resources.Resource;
 import org.sonar.api.scan.filesystem.InputFile;
 import org.sonar.api.utils.WildcardPattern;
 
+import java.io.File;
+
 abstract class PathPattern {
 
   private static final Logger LOG = LoggerFactory.getLogger(PathPattern.class);
@@ -41,6 +43,8 @@ abstract class PathPattern {
 
   abstract boolean match(InputFile inputFile);
 
+  abstract boolean match(File ioFile, String relativePathFromBasedir);
+
   abstract boolean match(InputFile inputFile, boolean caseSensitiveFileExtension);
 
   abstract boolean supportResource();
@@ -71,6 +75,12 @@ abstract class PathPattern {
       super(pattern);
     }
 
+    @Override
+    boolean match(File ioFile, String relativePathFromBasedir) {
+      String path = ioFile.getAbsolutePath();
+      return pattern.match(path);
+    }
+
     @Override
     boolean match(InputFile inputFile) {
       return match(inputFile, true);
@@ -113,6 +123,11 @@ abstract class PathPattern {
       super(pattern);
     }
 
+    @Override
+    boolean match(File ioFile, String relativePathFromBasedir) {
+      return relativePathFromBasedir != null && pattern.match(relativePathFromBasedir);
+    }
+
     @Override
     boolean match(InputFile inputFile) {
       return match(inputFile, true);
index 47f2dc661276b908c7568c12cc680980bd720b70..70f00226796a209e1ddbb2f1dadcb3372c2497ee 100644 (file)
@@ -19,8 +19,6 @@
  */
 package org.sonar.batch.scan.filesystem;
 
-import com.google.common.base.Charsets;
-import com.google.common.collect.ImmutableMap;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
@@ -30,7 +28,6 @@ import org.sonar.api.config.Settings;
 import org.sonar.api.scan.filesystem.FileExclusions;
 import org.sonar.api.scan.filesystem.InputFile;
 import org.sonar.api.scan.filesystem.ModuleFileSystem;
-import org.sonar.api.scan.filesystem.internal.DefaultInputFile;
 
 import java.io.File;
 import java.io.IOException;
@@ -59,22 +56,16 @@ public class ExclusionFiltersTest {
     Settings settings = new Settings();
     settings.setProperty(CoreProperties.PROJECT_INCLUSIONS_PROPERTY, "**/*Dao.java");
     ExclusionFilters filter = new ExclusionFilters(new FileExclusions(settings));
+    filter.prepare(fs);
 
     java.io.File file = temp.newFile();
-    InputFile inputFile = DefaultInputFile.create(file, Charsets.UTF_8, "src/main/java/com/mycompany/Foo.java", ImmutableMap.of(
-      InputFile.ATTRIBUTE_TYPE, InputFile.TYPE_MAIN
-      ));
 
-    assertThat(filter.accept(inputFile, fs)).isFalse();
+    assertThat(filter.accept(file, "src/main/java/com/mycompany/Foo.java", InputFile.TYPE_MAIN)).isFalse();
 
-    inputFile = DefaultInputFile.create(file, Charsets.UTF_8, "src/main/java/com/mycompany/FooDao.java", ImmutableMap.of(
-      InputFile.ATTRIBUTE_TYPE, InputFile.TYPE_MAIN));
-    assertThat(filter.accept(inputFile, fs)).isTrue();
+    assertThat(filter.accept(file, "src/main/java/com/mycompany/FooDao.java", InputFile.TYPE_MAIN)).isTrue();
 
     // test are excluded by default if no sonar.tests nor sonar.test.inclusions
-    inputFile = DefaultInputFile.create(file, Charsets.UTF_8, "src/main/java/com/mycompany/Foo.java", ImmutableMap.of(
-      InputFile.ATTRIBUTE_TYPE, InputFile.TYPE_TEST));
-    assertThat(filter.accept(inputFile, fs)).isFalse();
+    assertThat(filter.accept(file, "src/main/java/com/mycompany/Foo.java", InputFile.TYPE_TEST)).isFalse();
   }
 
   @Test
@@ -83,23 +74,16 @@ public class ExclusionFiltersTest {
     ExclusionFilters filter = new ExclusionFilters(new FileExclusions(settings));
     when(fs.sourceDirs()).thenReturn(Arrays.asList(new File(basedir, "src/main/java")));
 
-    filter.logConfiguration(fs);
+    filter.prepare(fs);
 
     java.io.File file = temp.newFile();
-    InputFile inputFile = DefaultInputFile.create(file, Charsets.UTF_8, "src/main/java/com/mycompany/Foo.java", ImmutableMap.of(
-      InputFile.ATTRIBUTE_TYPE, InputFile.TYPE_MAIN
-      ));
 
-    assertThat(filter.accept(inputFile, fs)).isTrue();
+    assertThat(filter.accept(file, "src/main/java/com/mycompany/Foo.java", InputFile.TYPE_MAIN)).isTrue();
 
-    inputFile = DefaultInputFile.create(file, Charsets.UTF_8, "src/main/java2/com/mycompany/FooDao.java", ImmutableMap.of(
-      InputFile.ATTRIBUTE_TYPE, InputFile.TYPE_MAIN));
-    assertThat(filter.accept(inputFile, fs)).isFalse();
+    assertThat(filter.accept(file, "src/main/java2/com/mycompany/FooDao.java", InputFile.TYPE_MAIN)).isFalse();
 
     // source inclusions do not apply to tests
-    inputFile = DefaultInputFile.create(file, Charsets.UTF_8, "src/main/java/com/mycompany/Foo.java", ImmutableMap.of(
-      InputFile.ATTRIBUTE_TYPE, InputFile.TYPE_TEST));
-    assertThat(filter.accept(inputFile, fs)).isFalse();
+    assertThat(filter.accept(file, "src/main/java/com/mycompany/Foo.java", InputFile.TYPE_TEST)).isFalse();
   }
 
   @Test
@@ -109,22 +93,15 @@ public class ExclusionFiltersTest {
     when(fs.sourceDirs()).thenReturn(Arrays.asList(new File(basedir, "src/main/java")));
     when(fs.testDirs()).thenReturn(Arrays.asList(new File(basedir, "src/test/java")));
 
-    filter.logConfiguration(fs);
+    filter.prepare(fs);
 
     java.io.File file = temp.newFile();
-    InputFile inputFile = DefaultInputFile.create(file, Charsets.UTF_8, "src/main/java/com/mycompany/Foo.java", ImmutableMap.of(
-      InputFile.ATTRIBUTE_TYPE, InputFile.TYPE_MAIN
-      ));
 
-    assertThat(filter.accept(inputFile, fs)).isTrue();
+    assertThat(filter.accept(file, "src/main/java/com/mycompany/Foo.java", InputFile.TYPE_MAIN)).isTrue();
 
-    inputFile = DefaultInputFile.create(file, Charsets.UTF_8, "src/main/java/com/mycompany/Foo.java", ImmutableMap.of(
-      InputFile.ATTRIBUTE_TYPE, InputFile.TYPE_TEST));
-    assertThat(filter.accept(inputFile, fs)).isFalse();
+    assertThat(filter.accept(file, "src/main/java/com/mycompany/Foo.java", InputFile.TYPE_TEST)).isFalse();
 
-    inputFile = DefaultInputFile.create(file, Charsets.UTF_8, "src/test/java/com/mycompany/Foo.java", ImmutableMap.of(
-      InputFile.ATTRIBUTE_TYPE, InputFile.TYPE_TEST));
-    assertThat(filter.accept(inputFile, fs)).isTrue();
+    assertThat(filter.accept(file, "src/test/java/com/mycompany/Foo.java", InputFile.TYPE_TEST)).isTrue();
   }
 
   @Test
@@ -134,23 +111,16 @@ public class ExclusionFiltersTest {
     ExclusionFilters filter = new ExclusionFilters(new FileExclusions(settings));
     when(fs.sourceDirs()).thenReturn(Arrays.asList(new File(basedir, "src/main/java")));
 
-    filter.logConfiguration(fs);
+    filter.prepare(fs);
 
     java.io.File file = temp.newFile();
-    InputFile inputFile = DefaultInputFile.create(file, Charsets.UTF_8, "src/main/java/com/mycompany/Foo.java", ImmutableMap.of(
-      InputFile.ATTRIBUTE_TYPE, InputFile.TYPE_MAIN
-      ));
 
-    assertThat(filter.accept(inputFile, fs)).isFalse();
+    assertThat(filter.accept(file, "src/main/java/com/mycompany/Foo.java", InputFile.TYPE_MAIN)).isFalse();
 
-    inputFile = DefaultInputFile.create(file, Charsets.UTF_8, "src/main/java2/com/mycompany/FooDao.java", ImmutableMap.of(
-      InputFile.ATTRIBUTE_TYPE, InputFile.TYPE_MAIN));
-    assertThat(filter.accept(inputFile, fs)).isTrue();
+    assertThat(filter.accept(file, "src/main/java2/com/mycompany/FooDao.java", InputFile.TYPE_MAIN)).isTrue();
 
     // source inclusions do not apply to tests
-    inputFile = DefaultInputFile.create(file, Charsets.UTF_8, "src/main/java/com/mycompany/Foo.java", ImmutableMap.of(
-      InputFile.ATTRIBUTE_TYPE, InputFile.TYPE_TEST));
-    assertThat(filter.accept(inputFile, fs)).isFalse();
+    assertThat(filter.accept(file, "src/main/java/com/mycompany/Foo.java", InputFile.TYPE_TEST)).isFalse();
   }
 
   @Test
@@ -159,23 +129,16 @@ public class ExclusionFiltersTest {
     ExclusionFilters filter = new ExclusionFilters(new FileExclusions(settings));
     when(fs.testDirs()).thenReturn(Arrays.asList(new File(basedir, "src/test/java")));
 
-    filter.logConfiguration(fs);
+    filter.prepare(fs);
 
     java.io.File file = temp.newFile();
-    InputFile inputFile = DefaultInputFile.create(file, Charsets.UTF_8, "src/test/java/com/mycompany/Foo.java", ImmutableMap.of(
-      InputFile.ATTRIBUTE_TYPE, InputFile.TYPE_MAIN
-      ));
 
     // test inclusions do not apply to main code
-    assertThat(filter.accept(inputFile, fs)).isFalse();
+    assertThat(filter.accept(file, "src/test/java/com/mycompany/Foo.java", InputFile.TYPE_MAIN)).isFalse();
 
-    inputFile = DefaultInputFile.create(file, Charsets.UTF_8, "src/test2/java/com/mycompany/FooTest.java", ImmutableMap.of(
-      InputFile.ATTRIBUTE_TYPE, InputFile.TYPE_TEST));
-    assertThat(filter.accept(inputFile, fs)).isFalse();
+    assertThat(filter.accept(file, "src/test2/java/com/mycompany/FooTest.java", InputFile.TYPE_TEST)).isFalse();
 
-    inputFile = DefaultInputFile.create(file, Charsets.UTF_8, "src/test/java/com/mycompany/Foo.java", ImmutableMap.of(
-      InputFile.ATTRIBUTE_TYPE, InputFile.TYPE_TEST));
-    assertThat(filter.accept(inputFile, fs)).isTrue();
+    assertThat(filter.accept(file, "src/test/java/com/mycompany/Foo.java", InputFile.TYPE_TEST)).isTrue();
   }
 
   @Test
@@ -184,17 +147,13 @@ public class ExclusionFiltersTest {
     settings.setProperty(CoreProperties.PROJECT_INCLUSIONS_PROPERTY, "**/*Dao.java,**/*Dto.java");
     ExclusionFilters filter = new ExclusionFilters(new FileExclusions(settings));
 
+    filter.prepare(fs);
+
     java.io.File file = temp.newFile();
-    InputFile inputFile = DefaultInputFile.create(file, Charsets.UTF_8, "src/main/java/com/mycompany/Foo.java", ImmutableMap.of(
-      InputFile.ATTRIBUTE_TYPE, InputFile.TYPE_MAIN
-      ));
 
-    assertThat(filter.accept(inputFile, fs)).isFalse();
+    assertThat(filter.accept(file, "src/main/java/com/mycompany/Foo.java", InputFile.TYPE_MAIN)).isFalse();
 
-    inputFile = DefaultInputFile.create(file, Charsets.UTF_8, "src/main/java/com/mycompany/FooDto.java", ImmutableMap.of(
-      InputFile.ATTRIBUTE_TYPE, InputFile.TYPE_MAIN
-      ));
-    assertThat(filter.accept(inputFile, fs)).isTrue();
+    assertThat(filter.accept(file, "src/main/java/com/mycompany/FooDto.java", InputFile.TYPE_MAIN)).isTrue();
   }
 
   @Test
@@ -205,20 +164,15 @@ public class ExclusionFiltersTest {
     settings.setProperty(CoreProperties.PROJECT_EXCLUSIONS_PROPERTY, "**/*Dao.java");
     ExclusionFilters filter = new ExclusionFilters(new FileExclusions(settings));
 
+    filter.prepare(fs);
+
     java.io.File file = temp.newFile();
-    InputFile inputFile = DefaultInputFile.create(file, Charsets.UTF_8, "src/main/java/com/mycompany/FooDao.java", ImmutableMap.of(
-      InputFile.ATTRIBUTE_TYPE, InputFile.TYPE_MAIN
-      ));
-    assertThat(filter.accept(inputFile, fs)).isFalse();
+    assertThat(filter.accept(file, "src/main/java/com/mycompany/FooDao.java", InputFile.TYPE_MAIN)).isFalse();
 
-    inputFile = DefaultInputFile.create(file, Charsets.UTF_8, "src/main/java/com/mycompany/Foo.java", ImmutableMap.of(
-      InputFile.ATTRIBUTE_TYPE, InputFile.TYPE_MAIN));
-    assertThat(filter.accept(inputFile, fs)).isTrue();
+    assertThat(filter.accept(file, "src/main/java/com/mycompany/Foo.java", InputFile.TYPE_MAIN)).isTrue();
 
     // source exclusions do not apply to tests
-    inputFile = DefaultInputFile.create(file, Charsets.UTF_8, "src/test/java/com/mycompany/FooDao.java", ImmutableMap.of(
-      InputFile.ATTRIBUTE_TYPE, InputFile.TYPE_TEST));
-    assertThat(filter.accept(inputFile, fs)).isTrue();
+    assertThat(filter.accept(file, "src/test/java/com/mycompany/FooDao.java", InputFile.TYPE_TEST)).isTrue();
   }
 
   @Test
@@ -231,15 +185,11 @@ public class ExclusionFiltersTest {
     settings.setProperty(CoreProperties.PROJECT_EXCLUSIONS_PROPERTY, "file:" + excludedFile.getCanonicalPath());
     ExclusionFilters filter = new ExclusionFilters(new FileExclusions(settings));
 
-    InputFile includedInput = DefaultInputFile.create(includedFile, Charsets.UTF_8, "src/main/java/org/bar/Foo.java", ImmutableMap.of(
-      InputFile.ATTRIBUTE_TYPE, InputFile.TYPE_MAIN
-      ));
-    assertThat(filter.accept(includedInput, fs)).isTrue();
+    filter.prepare(fs);
+
+    assertThat(filter.accept(includedFile, "src/main/java/org/bar/Foo.java", InputFile.TYPE_MAIN)).isTrue();
 
-    InputFile excludedInput = DefaultInputFile.create(excludedFile, Charsets.UTF_8, "src/main/java/org/bar/Bar.java", ImmutableMap.of(
-      InputFile.ATTRIBUTE_TYPE, InputFile.TYPE_MAIN
-      ));
-    assertThat(filter.accept(excludedInput, fs)).isFalse();
+    assertThat(filter.accept(excludedFile, "src/main/java/org/bar/Bar.java", InputFile.TYPE_MAIN)).isFalse();
   }
 
   @Test
@@ -248,7 +198,7 @@ public class ExclusionFiltersTest {
     settings.setProperty(CoreProperties.PROJECT_EXCLUSIONS_PROPERTY, "   **/*Dao.java   ");
     ExclusionFilters filter = new ExclusionFilters(new FileExclusions(settings));
 
-    assertThat(filter.sourceExclusions()[0].toString()).isEqualTo("**/*Dao.java");
+    assertThat(filter.computeSourceExclusions()[0].toString()).isEqualTo("**/*Dao.java");
   }
 
 }