Author: jdcasey
Date: Fri Feb  3 16:53:32 2012
New Revision: 1240241

URL: http://svn.apache.org/viewvc?rev=1240241&view=rev
Log:
[SUREFIRE-828] Fixing problems with missing empty-string check on 
groups/excludedGroups, especially in TestNG...this is the fixed code for 
TestNG, along with tests. The fix is disabled until I verify that the tests 
fail.

Added:
    
maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire828EmptyGroupExprIT.java
   (with props)
    
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/
    
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/pom.xml
   (with props)
    
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/
    
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/
    
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/
    
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/
    
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/BasicTest.java
   (with props)
    
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/CategoryA.java
   (with props)
    
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/CategoryB.java
   (with props)
    
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/CategoryC.java
   (with props)
    
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/CategoryCTest.java
   (with props)
    
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/NoCategoryTest.java
   (with props)
    
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-testng/
    
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-testng/pom.xml
   (with props)
    
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-testng/src/
    
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-testng/src/test/
    
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-testng/src/test/java/
    
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-testng/src/test/java/testng/
    
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-testng/src/test/java/testng/BasicTest.java
   (with props)
    
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-testng/src/test/java/testng/CategoryCTest.java
   (with props)
    
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-testng/src/test/java/testng/NoCategoryTest.java
   (with props)
Modified:
    
maven/surefire/trunk/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/GroupMatcherMethodSelector.java

Added: 
maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire828EmptyGroupExprIT.java
URL: 
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire828EmptyGroupExprIT.java?rev=1240241&view=auto
==============================================================================
--- 
maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire828EmptyGroupExprIT.java
 (added)
+++ 
maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire828EmptyGroupExprIT.java
 Fri Feb  3 16:53:32 2012
@@ -0,0 +1,76 @@
+package org.apache.maven.surefire.its.jiras;
+
+import org.apache.maven.surefire.its.fixture.OutputValidator;
+import org.apache.maven.surefire.its.fixture.SurefireIntegrationTestCase;
+import org.apache.maven.surefire.its.fixture.SurefireLauncher;
+
+public class Surefire828EmptyGroupExprIT
+    extends SurefireIntegrationTestCase
+{
+    // !CategoryC
+    public void testJUnitRunEmptyGroups()
+    {
+        OutputValidator validator = unpackJUnit().addD( "profile", 
"emptyGroups" ).executeTest();
+        validator.verifyErrorFreeLog();
+        validator.assertTestSuiteResults( 2, 0, 0, 0 );
+        validator.verifyTextInLog( "catA: 1" );
+        validator.verifyTextInLog( "catB: 1" );
+        validator.verifyTextInLog( "catC: 0" );
+        validator.verifyTextInLog( "catNone: 0" );
+        validator.verifyTextInLog( "mA: 1" );
+        validator.verifyTextInLog( "mB: 1" );
+        validator.verifyTextInLog( "mC: 0" );
+    }
+
+    // CategoryA && CategoryB
+    public void testJUnitRunEmptyExcludeGroups()
+    {
+        OutputValidator validator = unpackJUnit().addD( "profile", 
"emptyExcludedGroups" ).executeTest();
+        validator.verifyErrorFreeLog();
+        validator.assertTestSuiteResults( 2, 0, 0, 0 );
+        validator.verifyTextInLog( "catA: 1" );
+        validator.verifyTextInLog( "catB: 1" );
+        validator.verifyTextInLog( "catC: 0" );
+        validator.verifyTextInLog( "catNone: 0" );
+        validator.verifyTextInLog( "mA: 1" );
+        validator.verifyTextInLog( "mB: 1" );
+        validator.verifyTextInLog( "mC: 0" );
+    }
+
+    // CategoryA && CategoryB
+    public void testTestNGRunEmptyExcludeGroups()
+    {
+        OutputValidator validator = unpackTestNG().addD( "profile", 
"emptyExcludedGroups" ).executeTest();
+        validator.verifyErrorFreeLog();
+        validator.assertTestSuiteResults( 2, 0, 0, 0 );
+        validator.verifyTextInLog( "BasicTest.testInCategoriesAB()" );
+        validator.verifyTextInLog( "CategoryCTest.testInCategoriesAB()" );
+    }
+
+    // !CategoryC
+    public void testTestNGRunEmptyGroups()
+    {
+        OutputValidator validator = unpackTestNG().addD( "profile", 
"emptyGroups" ).executeTest();
+        validator.verifyErrorFreeLog();
+        validator.assertTestSuiteResults( 8, 0, 0, 0 );
+        validator.verifyTextInLog( "catA: 2" );
+        validator.verifyTextInLog( "catB: 2" );
+        validator.verifyTextInLog( "catC: 0" );
+        validator.verifyTextInLog( "catNone: 1" );
+        validator.verifyTextInLog( "mA: 2" );
+        validator.verifyTextInLog( "mB: 2" );
+        validator.verifyTextInLog( "mC: 0" );
+        validator.verifyTextInLog( "NoCategoryTest.CatNone: 1" );
+    }
+
+    private SurefireLauncher unpackJUnit()
+    {
+        return unpack( "surefire-828-emptyGroupExpr-junit48" );
+    }
+
+    private SurefireLauncher unpackTestNG()
+    {
+        return unpack( "surefire-828-emptyGroupExpr-testng" );
+    }
+
+}

Propchange: 
maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire828EmptyGroupExprIT.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/pom.xml?rev=1240241&view=auto
==============================================================================
--- 
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/pom.xml
 (added)
+++ 
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/pom.xml
 Fri Feb  3 16:53:32 2012
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0";
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.plugins.surefire</groupId>
+  <artifactId>junit4</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <name>Test for JUnit 4.8.1</name>
+
+
+  <properties>
+    <junitVersion>4.8.1</junitVersion>
+      <groups>junit4.CategoryA,junit4.CategoryB</groups>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>${junitVersion}</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <source>1.5</source>
+          <target>1.5</target>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <version>${surefire.version}</version>
+        <configuration>
+          <groups>${groups}</groups>
+          <excludedGroups>${excludedGroups}</excludedGroups>
+        </configuration>
+        <dependencies>
+          <dependency>
+            <groupId>org.apache.maven.surefire</groupId>
+            <artifactId>surefire-junit47</artifactId>
+            <version>${surefire.version}</version>
+          </dependency>
+        </dependencies>
+      </plugin>
+    </plugins>
+  </build>
+  
+  <profiles>
+    <profile>
+      <id>emptyGroups</id>
+      <activation>
+        <property>
+          <name>profile</name>
+          <value>emptyGroups</value>
+        </property>
+      </activation>
+      <properties>
+        <groups></groups>
+        <excludedGroups>junit4.CategoryC</excludedGroups>
+      </properties>
+    </profile>
+    <profile>
+      <id>emptyExcludedGroups</id>
+      <activation>
+        <property>
+          <name>profile</name>
+          <value>emptyExcludedGroups</value>
+        </property>
+      </activation>
+      <properties>
+        <groups>junit4.CategoryA && junit4.CategoryB</groups>
+        <excludedGroups></excludedGroups>
+      </properties>
+    </profile>
+  </profiles>
+
+</project>

Propchange: 
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/BasicTest.java
URL: 
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/BasicTest.java?rev=1240241&view=auto
==============================================================================
--- 
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/BasicTest.java
 (added)
+++ 
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/BasicTest.java
 Fri Feb  3 16:53:32 2012
@@ -0,0 +1,88 @@
+package junit4;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TestName;
+
+
+public class BasicTest
+{
+    static int catACount = 0;
+    static int catBCount = 0;
+    static int catCCount = 0;
+    static int catNoneCount = 0;
+    
+    @Rule
+    public TestName testName = new TestName();
+    
+    @Before
+    public void testName()
+    {
+        System.out.println( "Running " + getClass().getName() + "." + 
testName.getMethodName() );
+    }
+    
+    @Test
+    @Category(CategoryA.class)
+    public void testInCategoryA()
+    {
+        catACount++;
+    }
+
+    @Test
+    @Category(CategoryB.class)
+    public void testInCategoryB()
+    {
+        catBCount++;
+    }
+
+    @Test
+    @Category({CategoryA.class, CategoryB.class})
+    public void testInCategoryAB()
+    {
+        catACount++;
+        catBCount++;
+    }
+
+    @Test
+    @Category(CategoryC.class)
+    public void testInCategoryC()
+    {
+        catCCount++;
+    }
+
+    @Test
+    public void testInNoCategory()
+    {
+        catNoneCount++;
+    }
+
+    @AfterClass
+    public static void oneTimeTearDown()
+    {
+        System.out.println("catA: " + catACount + "\n" +
+            "catB: " + catBCount + "\n" +
+            "catC: " + catCCount + "\n" +
+            "catNone: " + catNoneCount);
+    }
+}

Propchange: 
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/BasicTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/CategoryA.java
URL: 
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/CategoryA.java?rev=1240241&view=auto
==============================================================================
--- 
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/CategoryA.java
 (added)
+++ 
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/CategoryA.java
 Fri Feb  3 16:53:32 2012
@@ -0,0 +1,3 @@
+package junit4;
+
+interface CategoryA {}

Propchange: 
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/CategoryA.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/CategoryB.java
URL: 
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/CategoryB.java?rev=1240241&view=auto
==============================================================================
--- 
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/CategoryB.java
 (added)
+++ 
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/CategoryB.java
 Fri Feb  3 16:53:32 2012
@@ -0,0 +1,3 @@
+package junit4;
+
+interface CategoryB {}

Propchange: 
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/CategoryB.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/CategoryC.java
URL: 
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/CategoryC.java?rev=1240241&view=auto
==============================================================================
--- 
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/CategoryC.java
 (added)
+++ 
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/CategoryC.java
 Fri Feb  3 16:53:32 2012
@@ -0,0 +1,3 @@
+package junit4;
+
+interface CategoryC {}

Propchange: 
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/CategoryC.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/CategoryCTest.java
URL: 
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/CategoryCTest.java?rev=1240241&view=auto
==============================================================================
--- 
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/CategoryCTest.java
 (added)
+++ 
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/CategoryCTest.java
 Fri Feb  3 16:53:32 2012
@@ -0,0 +1,80 @@
+package junit4;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TestName;
+
+
+@Category(CategoryC.class)
+public class CategoryCTest
+{
+    static int catACount = 0;
+    static int catBCount = 0;
+    static int catCCount = 0;
+
+    @Rule
+    public TestName testName = new TestName();
+    
+    @Before
+    public void testName()
+    {
+        System.out.println( "Running " + getClass().getName() + "." + 
testName.getMethodName() );
+    }
+    
+    @Test
+    @Category( CategoryA.class )
+    public void testInCategoryA()
+    {
+        catACount++;
+    }
+
+    @Test
+    @Category(CategoryB.class)
+    public void testInCategoryB()
+    {
+        catBCount++;
+    }
+
+    @Test
+    @Category({CategoryA.class, CategoryB.class})
+    public void testInCategoriesAB()
+    {
+        catACount++;
+        catBCount++;
+    }
+
+    @Test
+    public void testInCategoryC()
+    {
+        catCCount++;
+    }
+
+    @AfterClass
+    public static void oneTimeTearDown()
+    {
+        System.out.println("mA: " + catACount + "\n" +
+            "mB: " + catBCount + "\n" +
+            "mC: " + catCCount );
+    }
+}

Propchange: 
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/CategoryCTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/NoCategoryTest.java
URL: 
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/NoCategoryTest.java?rev=1240241&view=auto
==============================================================================
--- 
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/NoCategoryTest.java
 (added)
+++ 
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/NoCategoryTest.java
 Fri Feb  3 16:53:32 2012
@@ -0,0 +1,38 @@
+package junit4;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.junit.AfterClass;
+import org.junit.Test;
+
+public class NoCategoryTest {
+  static int catNoneCount = 0;
+
+  @Test
+  public void testInNoCategory()
+  {
+      catNoneCount++;
+  }
+
+  @AfterClass
+  public static void oneTimeTearDown()
+  {
+      System.out.println("NoCategoryTest.CatNone: " + catNoneCount);
+  }
+}

Propchange: 
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/src/test/java/junit4/NoCategoryTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-testng/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-testng/pom.xml?rev=1240241&view=auto
==============================================================================
--- 
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-testng/pom.xml
 (added)
+++ 
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-testng/pom.xml
 Fri Feb  3 16:53:32 2012
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="UTF-8"?>
+    <!--
+        ~ Licensed to the Apache Software Foundation (ASF) under one ~ or more 
contributor license agreements. See the NOTICE file ~
+        distributed with this work for additional information ~ regarding 
copyright ownership. The ASF licenses this file ~ to you under
+        the Apache License, Version 2.0 (the ~ "License"); you may not use 
this file except in compliance ~ with the License. You may
+        obtain a copy of the License at ~ ~ 
http://www.apache.org/licenses/LICENSE-2.0 ~ ~ Unless required by applicable 
law or agreed
+        to in writing, ~ software distributed under the License is distributed 
on an ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+        OF ANY ~ KIND, either express or implied. See the License for the ~ 
specific language governing permissions and limitations ~
+        under the License.
+    -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>org.apache.maven.plugins.surefire</groupId>
+    <artifactId>testng-group-expressions</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <name>TestNG group expressions tests</name>
+    <dependencies>
+        <dependency>
+            <groupId>org.testng</groupId>
+            <artifactId>testng</artifactId>
+            <version>5.8</version>
+            <classifier>jdk15</classifier>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+  
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <version>${surefire.version}</version>
+                <configuration>
+                  <groups>${groups}</groups>
+                  <excludedGroups>${excludedGroups}</excludedGroups>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <groups>${groups}</groups>
+                    <source>1.5</source>
+                    <target>1.5</target>
+                </configuration>
+            </plugin>
+      </plugins>
+  </build>
+  
+  <profiles>
+    <profile>
+      <id>emptyGroups</id>
+      <activation>
+        <property>
+          <name>profile</name>
+          <value>emptyGroups</value>
+        </property>
+      </activation>
+      <properties>
+        <groups></groups>
+        <excludedGroups>CategoryC</excludedGroups>
+      </properties>
+    </profile>
+    <profile>
+      <id>emptyExcludedGroups</id>
+      <activation>
+        <property>
+          <name>profile</name>
+          <value>emptyExcludedGroups</value>
+        </property>
+      </activation>
+      <properties>
+        <groups>CategoryA && CategoryB</groups>
+        <excludedGroups></excludedGroups>
+      </properties>
+    </profile>
+  </profiles>
+</project>

Propchange: 
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-testng/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-testng/src/test/java/testng/BasicTest.java
URL: 
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-testng/src/test/java/testng/BasicTest.java?rev=1240241&view=auto
==============================================================================
--- 
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-testng/src/test/java/testng/BasicTest.java
 (added)
+++ 
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-testng/src/test/java/testng/BasicTest.java
 Fri Feb  3 16:53:32 2012
@@ -0,0 +1,72 @@
+package testng;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.Test;
+
+
+public class BasicTest
+{
+    static int catACount = 0;
+    static int catBCount = 0;
+    static int catCCount = 0;
+    static int catNoneCount = 0;
+    
+    @Test( groups = "CategoryA" )
+    public void testInCategoryA()
+    {
+        catACount++;
+    }
+
+    @Test( groups = "CategoryB" )
+    public void testInCategoryB()
+    {
+        catBCount++;
+    }
+
+    @Test( groups = { "CategoryA", "CategoryB" } )
+    public void testInCategoryAB()
+    {
+        System.out.println( getClass().getSimpleName() + 
".testInCategoriesAB()" );
+        catACount++;
+        catBCount++;
+    }
+
+    @Test( groups = "CategoryC" )
+    public void testInCategoryC()
+    {
+        catCCount++;
+    }
+
+    @Test
+    public void testInNoCategory()
+    {
+        catNoneCount++;
+    }
+
+    @AfterClass
+    public static void oneTimeTearDown()
+    {
+        System.out.println("catA: " + catACount + "\n" +
+            "catB: " + catBCount + "\n" +
+            "catC: " + catCCount + "\n" +
+            "catNone: " + catNoneCount);
+    }
+}

Propchange: 
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-testng/src/test/java/testng/BasicTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-testng/src/test/java/testng/CategoryCTest.java
URL: 
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-testng/src/test/java/testng/CategoryCTest.java?rev=1240241&view=auto
==============================================================================
--- 
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-testng/src/test/java/testng/CategoryCTest.java
 (added)
+++ 
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-testng/src/test/java/testng/CategoryCTest.java
 Fri Feb  3 16:53:32 2012
@@ -0,0 +1,63 @@
+package testng;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.Test;
+
+public class CategoryCTest
+{
+    static int catACount = 0;
+    static int catBCount = 0;
+    static int catCCount = 0;
+
+    @Test( groups = "CategoryA" )
+    public void testInCategoryA()
+    {
+        catACount++;
+    }
+
+    @Test( groups = "CategoryB" )
+    public void testInCategoryB()
+    {
+        catBCount++;
+    }
+
+    @Test( groups = { "CategoryA", "CategoryB" } )
+    public void testInCategoriesAB()
+    {
+        System.out.println( getClass().getSimpleName() + 
".testInCategoriesAB()" );
+        catACount++;
+        catBCount++;
+    }
+
+    @Test( groups="CategoryC" )
+    public void testInCategoryC()
+    {
+        catCCount++;
+    }
+
+    @AfterClass
+    public static void oneTimeTearDown()
+    {
+        System.out.println("mA: " + catACount + "\n" +
+            "mB: " + catBCount + "\n" +
+            "mC: " + catCCount );
+    }
+}

Propchange: 
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-testng/src/test/java/testng/CategoryCTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-testng/src/test/java/testng/NoCategoryTest.java
URL: 
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-testng/src/test/java/testng/NoCategoryTest.java?rev=1240241&view=auto
==============================================================================
--- 
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-testng/src/test/java/testng/NoCategoryTest.java
 (added)
+++ 
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-testng/src/test/java/testng/NoCategoryTest.java
 Fri Feb  3 16:53:32 2012
@@ -0,0 +1,38 @@
+package testng;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.Test;
+
+public class NoCategoryTest {
+  static int catNoneCount = 0;
+
+  @Test
+  public void testInNoCategory()
+  {
+      catNoneCount++;
+  }
+
+  @AfterClass
+  public static void oneTimeTearDown()
+  {
+      System.out.println("NoCategoryTest.CatNone: " + catNoneCount);
+  }
+}

Propchange: 
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-testng/src/test/java/testng/NoCategoryTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 
maven/surefire/trunk/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/GroupMatcherMethodSelector.java
URL: 
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/GroupMatcherMethodSelector.java?rev=1240241&r1=1240240&r2=1240241&view=diff
==============================================================================
--- 
maven/surefire/trunk/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/GroupMatcherMethodSelector.java
 (original)
+++ 
maven/surefire/trunk/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/GroupMatcherMethodSelector.java
 Fri Feb  3 16:53:32 2012
@@ -59,13 +59,23 @@ public class GroupMatcherMethodSelector
         try
         {
             AndGroupMatcher matcher = new AndGroupMatcher();
-            GroupMatcher in = groups == null ? null : new GroupMatcherParser( 
groups ).parse();
+            GroupMatcher in = null;
+            if ( groups != null /* && groups.trim().length() > 0 */)
+            {
+                in = new GroupMatcherParser( groups ).parse();
+            }
+
             if ( in != null )
             {
                 matcher.addMatcher( in );
             }
 
-            GroupMatcher ex = excludedGroups == null ? null : new 
GroupMatcherParser( excludedGroups ).parse();
+            GroupMatcher ex = null;
+            if ( excludedGroups != null/* && excludedGroups.trim().length() > 
0 */)
+            {
+                ex = new GroupMatcherParser( excludedGroups ).parse();
+            }
+
             if ( ex != null )
             {
                 matcher.addMatcher( new InverseGroupMatcher( ex ) );


Reply via email to