Author: jdcasey Date: Fri Feb 3 16:53:44 2012 New Revision: 1240242 URL: http://svn.apache.org/viewvc?rev=1240242&view=rev Log: [SUREFIRE-828] Enable code to test for empty groups/excludedGroups strings, both for junit and testng. Also, minor corrections to the tests to get them running. Finally, shift the site-plugin configuration to a profile to keep it from interfering with snapshot building.
Modified: maven/surefire/trunk/pom.xml maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire828EmptyGroupExprIT.java maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/pom.xml maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-testng/pom.xml maven/surefire/trunk/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/FilterFactory.java maven/surefire/trunk/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/GroupMatcherMethodSelector.java Modified: maven/surefire/trunk/pom.xml URL: http://svn.apache.org/viewvc/maven/surefire/trunk/pom.xml?rev=1240242&r1=1240241&r2=1240242&view=diff ============================================================================== --- maven/surefire/trunk/pom.xml (original) +++ maven/surefire/trunk/pom.xml Fri Feb 3 16:53:44 2012 @@ -259,33 +259,47 @@ <artifactId>maven-plugin-plugin</artifactId> <version>2.8</version> </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-site-plugin</artifactId> - <version>3.0</version> - <configuration> - <reportPlugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-surefire-plugin</artifactId> - <version>${shadedVersion}</version> - </plugin> - </reportPlugins> - </configuration> - <dependencies> - <dependency> - <groupId>org.apache.maven.surefire</groupId> - <artifactId>surefire-shadefire</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> - </plugin> </plugins> </pluginManagement> </build> <profiles> <profile> + <id>reporting</id> + <build> + <pluginManagement> + <plugins> + <!-- Moving to a profile, since these dependencies won't exist the first + time a new snapshot version is built. This prevents the first + snapshot build from proceeding beyond the build for the top-level + Surefire parent POM. + --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-site-plugin</artifactId> + <version>3.0</version> + <configuration> + <reportPlugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>${shadedVersion}</version> + </plugin> + </reportPlugins> + </configuration> + <dependencies> + <dependency> + <groupId>org.apache.maven.surefire</groupId> + <artifactId>surefire-shadefire</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> + </plugin> + </plugins> + </pluginManagement> + </build> + </profile> + <profile> <id>m2e</id> <properties> <m2BuildDirectory>target</m2BuildDirectory> Modified: 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=1240242&r1=1240241&r2=1240242&view=diff ============================================================================== --- maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire828EmptyGroupExprIT.java (original) +++ maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire828EmptyGroupExprIT.java Fri Feb 3 16:53:44 2012 @@ -12,14 +12,12 @@ public class Surefire828EmptyGroupExprIT { OutputValidator validator = unpackJUnit().addD( "profile", "emptyGroups" ).executeTest(); validator.verifyErrorFreeLog(); - validator.assertTestSuiteResults( 2, 0, 0, 0 ); - validator.verifyTextInLog( "catA: 1" ); - validator.verifyTextInLog( "catB: 1" ); + validator.assertTestSuiteResults( 5, 0, 0, 0 ); + validator.verifyTextInLog( "catA: 2" ); + validator.verifyTextInLog( "catB: 2" ); validator.verifyTextInLog( "catC: 0" ); - validator.verifyTextInLog( "catNone: 0" ); - validator.verifyTextInLog( "mA: 1" ); - validator.verifyTextInLog( "mB: 1" ); - validator.verifyTextInLog( "mC: 0" ); + validator.verifyTextInLog( "catNone: 1" ); + validator.verifyTextInLog( "NoCategoryTest.CatNone: 1" ); } // CategoryA && CategoryB Modified: 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=1240242&r1=1240241&r2=1240242&view=diff ============================================================================== --- maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/pom.xml (original) +++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-junit48/pom.xml Fri Feb 3 16:53:44 2012 @@ -95,7 +95,7 @@ </property> </activation> <properties> - <groups>junit4.CategoryA && junit4.CategoryB</groups> + <groups>junit4.CategoryA && junit4.CategoryB</groups> <excludedGroups></excludedGroups> </properties> </profile> Modified: 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=1240242&r1=1240241&r2=1240242&view=diff ============================================================================== --- maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-testng/pom.xml (original) +++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-828-emptyGroupExpr-testng/pom.xml Fri Feb 3 16:53:44 2012 @@ -73,7 +73,7 @@ </property> </activation> <properties> - <groups>CategoryA && CategoryB</groups> + <groups>CategoryA && CategoryB</groups> <excludedGroups></excludedGroups> </properties> </profile> Modified: maven/surefire/trunk/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/FilterFactory.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/FilterFactory.java?rev=1240242&r1=1240241&r2=1240242&view=diff ============================================================================== --- maven/surefire/trunk/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/FilterFactory.java (original) +++ maven/surefire/trunk/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/FilterFactory.java Fri Feb 3 16:53:44 2012 @@ -57,7 +57,7 @@ public class FilterFactory String excludedGroups = providerProperties.getProperty( ProviderParameterNames.TESTNG_EXCLUDEDGROUPS_PROP ); GroupMatcher included = null; - if ( groups != null ) + if ( groups != null && groups.trim().length() > 0 ) { try { @@ -71,7 +71,7 @@ public class FilterFactory } GroupMatcher excluded = null; - if ( excludedGroups != null ) + if ( excludedGroups != null && excludedGroups.trim().length() > 0 ) { try { 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=1240242&r1=1240241&r2=1240242&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:44 2012 @@ -3,12 +3,12 @@ package org.apache.maven.surefire.testng import java.util.HashMap; import java.util.List; import java.util.Map; + import org.apache.maven.surefire.group.match.AndGroupMatcher; import org.apache.maven.surefire.group.match.GroupMatcher; import org.apache.maven.surefire.group.match.InverseGroupMatcher; import org.apache.maven.surefire.group.parse.GroupMatcherParser; import org.apache.maven.surefire.group.parse.ParseException; - import org.testng.IMethodSelector; import org.testng.IMethodSelectorContext; import org.testng.ITestNGMethod; @@ -60,7 +60,7 @@ public class GroupMatcherMethodSelector { AndGroupMatcher matcher = new AndGroupMatcher(); GroupMatcher in = null; - if ( groups != null /* && groups.trim().length() > 0 */) + if ( groups != null && groups.trim().length() > 0 ) { in = new GroupMatcherParser( groups ).parse(); } @@ -71,7 +71,7 @@ public class GroupMatcherMethodSelector } GroupMatcher ex = null; - if ( excludedGroups != null/* && excludedGroups.trim().length() > 0 */) + if ( excludedGroups != null && excludedGroups.trim().length() > 0 ) { ex = new GroupMatcherParser( excludedGroups ).parse(); } @@ -89,9 +89,8 @@ public class GroupMatcherMethodSelector } catch ( ParseException e ) { - throw new IllegalArgumentException( - "Cannot parse group includes/excludes expression(s):\nIncludes: " + groups + "\nExcludes: " - + excludedGroups, e ); + throw new IllegalArgumentException( "Cannot parse group includes/excludes expression(s):\nIncludes: " + + groups + "\nExcludes: " + excludedGroups, e ); } }