aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api/src/test
diff options
context:
space:
mode:
authorsimonbrandhof <simon.brandhof@gmail.com>2010-09-26 21:46:58 +0000
committersimonbrandhof <simon.brandhof@gmail.com>2010-09-26 21:46:58 +0000
commit36e81898a5a6e2b2029a2279a257d2ac06345f73 (patch)
treeb52bf836e5698b1e4f2df79b2d144ad8e23ea64e /sonar-plugin-api/src/test
parent1723690eeb56a709c9ba87c0be94117186cead2a (diff)
downloadsonarqube-36e81898a5a6e2b2029a2279a257d2ac06345f73.tar.gz
sonarqube-36e81898a5a6e2b2029a2279a257d2ac06345f73.zip
SONAR-1711 Allow to exclude sources from code analysis based on cutoff date
Diffstat (limited to 'sonar-plugin-api/src/test')
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/resources/DefaultProjectFileSystemTest.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/resources/DefaultProjectFileSystemTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/resources/DefaultProjectFileSystemTest.java
index 82e6574c544..4aa606b97e4 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/resources/DefaultProjectFileSystemTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/resources/DefaultProjectFileSystemTest.java
@@ -19,12 +19,14 @@
*/
package org.sonar.api.resources;
+import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.SystemUtils;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;
import org.junit.Before;
import org.junit.Test;
+import org.sonar.api.batch.FileFilter;
import org.sonar.api.test.MavenTestUtils;
import java.io.File;
@@ -32,6 +34,7 @@ import java.util.List;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.Matchers.hasItem;
+import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertThat;
public class DefaultProjectFileSystemTest {
@@ -156,6 +159,22 @@ public class DefaultProjectFileSystemTest {
}
}
+
+ @Test
+ public void shouldAddExtendedFilters() {
+ DefaultProjectFileSystem fs = new DefaultProjectFileSystem(project);
+ assertThat(fs.getSourceFiles().size(), is(2));
+ assertThat(fs.getSourceFiles(), hasItem(named("Bar.java")));
+
+ fs.addFileFilter(new FileFilter() {
+ public boolean accept(File file) {
+ return !StringUtils.equals(file.getName(), "Bar.java");
+ }
+ });
+ assertThat(fs.getSourceFiles().size(), is(1));
+ assertThat(fs.getSourceFiles(), not(hasItem(named("Bar.java"))));
+ }
+
private static Matcher<java.io.File> named(final String name) {
return new TypeSafeMatcher<java.io.File>() {
java.io.File fileTested;