]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-3758 Test exclusion patterns
authorDavid Gageot <david@gageot.net>
Fri, 5 Oct 2012 15:11:30 +0000 (17:11 +0200)
committerDavid Gageot <david@gageot.net>
Fri, 5 Oct 2012 15:18:44 +0000 (17:18 +0200)
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java
sonar-plugin-api/src/main/java/org/sonar/api/resources/JavaFile.java
sonar-plugin-api/src/test/java/org/sonar/api/resources/JavaFileTest.java

index b65f646aa3a6a28ab5265becc5f01190f101a7f3..5476f7eb6f7301b44e2156df048e9754b1a41e9a 100644 (file)
@@ -185,7 +185,8 @@ import java.util.List;
     name = "Global test exclusions",
     description = "Exclude tests from code analysis. Applies to every project. Cannot be overriden. Changes will be applied during next code analysis.",
     multiValues = true,
-    category = CoreProperties.CATEGORY_EXCLUSIONS),
+    category = CoreProperties.CATEGORY_EXCLUSIONS,
+    defaultValue = "**/package-info.java"),
   @Property(
     key = CoreProperties.PROJECT_EXCLUSIONS_PROPERTY,
     name = "Exclusions",
index cd142ae6ce2c729d9abf88903a68d87e0b480bd3..fb4bde7518907f50eca6ed7241b2fc08ddca4967 100644 (file)
@@ -174,9 +174,6 @@ public class JavaFile extends Resource<JavaPackage> {
    */
   @Override
   public boolean matchFilePattern(String antPattern) {
-    if (unitTest) {
-      return false;
-    }
     String fileKey = getKey();
     if (!fileKey.endsWith(".java")) {
       fileKey += ".java";
index afe33c33f22cf095e75fc2d921e96e18a5fdd75f..72187079486362196cee4322287ea9d9ae47b5a7 100644 (file)
@@ -210,16 +210,16 @@ public class JavaFileTest {
    * See http://jira.codehaus.org/browse/SONAR-1449
    */
   @Test
-  public void doNotMatchAjPattern() {
+  public void doNotMatchAPattern() {
     JavaFile file = new JavaFile("org.sonar.commons.Foo");
     assertFalse(file.matchFilePattern("**/*.aj"));
     assertTrue(file.matchFilePattern("**/*.java"));
   }
 
   @Test
-  public void doNotExcludeTestFiles() {
+  public void should_exclude_test_files() {
     JavaFile unitTest = new JavaFile("org.sonar.commons.FooTest", true);
-    assertFalse(unitTest.matchFilePattern("**/*"));
+    assertTrue(unitTest.matchFilePattern("**/*"));
   }
 
   private File newDir(String dirName) {