You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jd...@apache.org on 2012/01/25 17:12:16 UTC
svn commit: r1235805 [1/2] - in /maven/surefire/trunk: ./
maven-surefire-common/
maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/
maven-surefire-common/src/main/java/org/apache/maven/surefire/group/match/
maven-surefire-common/src/...
Author: jdcasey
Date: Wed Jan 25 16:12:14 2012
New Revision: 1235805
URL: http://svn.apache.org/viewvc?rev=1235805&view=rev
Log:
[SUREFIRE-809] Moved group-expression parser and matcher classes to separate module, so it can be included alongside testng-utils in the testng test classpath, which enables the GroupMatchingMethodSelector to function properly. Also, added unit tests for grouping expressions in junit and testng.
Added:
maven/surefire/trunk/surefire-grouper/
maven/surefire/trunk/surefire-grouper/pom.xml (with props)
maven/surefire/trunk/surefire-grouper/src/
maven/surefire/trunk/surefire-grouper/src/main/
maven/surefire/trunk/surefire-grouper/src/main/java/
maven/surefire/trunk/surefire-grouper/src/main/java/org/
maven/surefire/trunk/surefire-grouper/src/main/java/org/apache/
maven/surefire/trunk/surefire-grouper/src/main/java/org/apache/maven/
maven/surefire/trunk/surefire-grouper/src/main/java/org/apache/maven/surefire/
maven/surefire/trunk/surefire-grouper/src/main/java/org/apache/maven/surefire/group/
maven/surefire/trunk/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/
maven/surefire/trunk/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/AndGroupMatcher.java (with props)
maven/surefire/trunk/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/GroupMatcher.java (with props)
maven/surefire/trunk/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/InverseGroupMatcher.java (with props)
maven/surefire/trunk/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/JoinGroupMatcher.java (with props)
maven/surefire/trunk/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/OrGroupMatcher.java (with props)
maven/surefire/trunk/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/SingleGroupMatcher.java (with props)
maven/surefire/trunk/surefire-grouper/src/main/javacc/
maven/surefire/trunk/surefire-grouper/src/main/javacc/category-expression.jj
maven/surefire/trunk/surefire-grouper/src/test/
maven/surefire/trunk/surefire-grouper/src/test/java/
maven/surefire/trunk/surefire-grouper/src/test/java/org/
maven/surefire/trunk/surefire-grouper/src/test/java/org/apache/
maven/surefire/trunk/surefire-grouper/src/test/java/org/apache/maven/
maven/surefire/trunk/surefire-grouper/src/test/java/org/apache/maven/surefire/
maven/surefire/trunk/surefire-grouper/src/test/java/org/apache/maven/surefire/group/
maven/surefire/trunk/surefire-grouper/src/test/java/org/apache/maven/surefire/group/match/
maven/surefire/trunk/surefire-grouper/src/test/java/org/apache/maven/surefire/group/match/AndGroupMatcherTest.java (with props)
maven/surefire/trunk/surefire-grouper/src/test/java/org/apache/maven/surefire/group/match/InverseGroupMatcherTest.java (with props)
maven/surefire/trunk/surefire-grouper/src/test/java/org/apache/maven/surefire/group/match/OrGroupMatcherTest.java (with props)
maven/surefire/trunk/surefire-grouper/src/test/java/org/apache/maven/surefire/group/match/SingleGroupMatcherTest.java (with props)
maven/surefire/trunk/surefire-grouper/src/test/java/org/apache/maven/surefire/group/parse/
maven/surefire/trunk/surefire-grouper/src/test/java/org/apache/maven/surefire/group/parse/GroupMatcherParserTest.java (with props)
maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire809GroupExpressionsIT.java (with props)
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-junit48/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-junit48/pom.xml (with props)
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-junit48/src/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-junit48/src/test/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/BasicTest.java (with props)
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/CategoryA.java (with props)
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/CategoryB.java (with props)
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/CategoryC.java (with props)
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/CategoryCTest.java (with props)
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/NoCategoryTest.java (with props)
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-testng/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-testng/pom.xml (with props)
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-testng/src/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-testng/src/test/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-testng/src/test/java/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-testng/src/test/java/testng/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-testng/src/test/java/testng/BasicTest.java (with props)
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-testng/src/test/java/testng/CategoryCTest.java (with props)
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-testng/src/test/java/testng/NoCategoryTest.java (with props)
maven/surefire/trunk/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/GroupMatcherMethodSelector.java (with props)
Removed:
maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/group/match/AndGroupMatcher.java
maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/group/match/GroupMatcher.java
maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/group/match/InverseGroupMatcher.java
maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/group/match/JoinGroupMatcher.java
maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/group/match/OrGroupMatcher.java
maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/group/match/SingleGroupMatcher.java
maven/surefire/trunk/maven-surefire-common/src/main/javacc/category-expression.jj
maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/surefire/group/match/AndGroupMatcherTest.java
maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/surefire/group/match/InverseGroupMatcherTest.java
maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/surefire/group/match/OrGroupMatcherTest.java
maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/surefire/group/match/SingleGroupMatcherTest.java
maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/surefire/group/parse/GroupMatcherParserTest.java
maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/group/GroupMatcherMethodSelector.java
Modified:
maven/surefire/trunk/maven-surefire-common/pom.xml
maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
maven/surefire/trunk/pom.xml
maven/surefire/trunk/surefire-providers/common-junit48/pom.xml
maven/surefire/trunk/surefire-providers/surefire-testng-utils/pom.xml
maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java
maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/AbstractDirectConfigurator.java
maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNGMapConfigurator.java
Modified: maven/surefire/trunk/maven-surefire-common/pom.xml
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/pom.xml?rev=1235805&r1=1235804&r2=1235805&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/pom.xml (original)
+++ maven/surefire/trunk/maven-surefire-common/pom.xml Wed Jan 25 16:12:14 2012
@@ -85,19 +85,6 @@
<build>
<plugins>
<plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>javacc-maven-plugin</artifactId>
- <version>2.6</version>
- <executions>
- <execution>
- <id>javacc</id>
- <goals>
- <goal>javacc</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
<artifactId>maven-surefire-plugin</artifactId>
<dependencies>
<dependency>
@@ -107,16 +94,6 @@
</dependency>
</dependencies>
</plugin>
- <plugin>
- <artifactId>maven-jar-plugin</artifactId>
- <configuration>
- <archive>
- <manifest>
- <mainClass>org.apache.maven.surefire.group.parse.GroupMatcherParser</mainClass>
- </manifest>
- </archive>
- </configuration>
- </plugin>
</plugins>
</build>
</project>
Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java?rev=1235805&r1=1235804&r2=1235805&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java Wed Jan 25 16:12:14 2012
@@ -958,26 +958,32 @@ public abstract class AbstractSurefireMo
// Todo: move
if ( getTestNgArtifact() != null )
{
- Artifact testNgUtils = getTestNgUtilsArtifact();
- String path = testNgUtils.getFile().getPath();
- classpath.add( path );
-
+ addTestNgUtilsArtifacts( classpath );
}
return new Classpath( classpath );
}
- Artifact getTestNgUtilsArtifact()
+ void addTestNgUtilsArtifacts( List<String> classpath )
throws ArtifactResolutionException, ArtifactNotFoundException
{
Artifact surefireArtifact = getPluginArtifactMap().get( "org.apache.maven.surefire:surefire-booter" );
String surefireVersion = surefireArtifact.getBaseVersion();
- Artifact testNgUtils =
- getArtifactFactory().createArtifact( "org.apache.maven.surefire", "surefire-testng-utils", surefireVersion,
- "runtime", "jar" );
- getArtifactResolver().resolve( testNgUtils, getRemoteRepositories(), getLocalRepository() );
- return testNgUtils;
+ Artifact[] extraTestNgArtifacts =
+ {
+ getArtifactFactory().createArtifact( "org.apache.maven.surefire", "surefire-testng-utils",
+ surefireVersion, "runtime", "jar" ),
+ getArtifactFactory().createArtifact( "org.apache.maven.surefire", "surefire-grouper", surefireVersion,
+ "runtime", "jar" ) };
+
+ for ( Artifact artifact : extraTestNgArtifacts )
+ {
+ getArtifactResolver().resolve( artifact, getRemoteRepositories(), getLocalRepository() );
+
+ String path = artifact.getFile().getPath();
+ classpath.add( path );
+ }
}
/**
Modified: maven/surefire/trunk/pom.xml
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/pom.xml?rev=1235805&r1=1235804&r2=1235805&view=diff
==============================================================================
--- maven/surefire/trunk/pom.xml (original)
+++ maven/surefire/trunk/pom.xml Wed Jan 25 16:12:14 2012
@@ -90,6 +90,7 @@
<module>surefire-shadefire</module>
<module>surefire-api</module>
<module>surefire-booter</module>
+ <module>surefire-grouper</module>
<module>surefire-providers</module>
<module>maven-surefire-common</module>
<module>maven-surefire-plugin</module>
@@ -132,6 +133,11 @@
</dependency>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
+ <artifactId>surefire-grouper</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.surefire</groupId>
<artifactId>maven-surefire-common</artifactId>
<version>${project.version}</version>
</dependency>
Added: maven/surefire/trunk/surefire-grouper/pom.xml
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-grouper/pom.xml?rev=1235805&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-grouper/pom.xml (added)
+++ maven/surefire/trunk/surefire-grouper/pom.xml Wed Jan 25 16:12:14 2012
@@ -0,0 +1,76 @@
+<?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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.maven.surefire</groupId>
+ <artifactId>surefire</artifactId>
+ <version>2.12-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>surefire-grouper</artifactId>
+
+ <name>Maven Surefire Test-Grouping Support</name>
+
+ <prerequisites>
+ <maven>2.0.9</maven>
+ </prerequisites>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>javacc-maven-plugin</artifactId>
+ <version>2.6</version>
+ <executions>
+ <execution>
+ <id>javacc</id>
+ <goals>
+ <goal>javacc</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.surefire</groupId>
+ <artifactId>surefire-shadefire</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <mainClass>org.apache.maven.surefire.group.parse.GroupMatcherParser</mainClass>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Propchange: maven/surefire/trunk/surefire-grouper/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/surefire/trunk/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/AndGroupMatcher.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/AndGroupMatcher.java?rev=1235805&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/AndGroupMatcher.java (added)
+++ maven/surefire/trunk/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/AndGroupMatcher.java Wed Jan 25 16:12:14 2012
@@ -0,0 +1,97 @@
+package org.apache.maven.surefire.group.match;
+
+import java.util.Collection;
+
+public class AndGroupMatcher
+ extends JoinGroupMatcher
+{
+
+ public AndGroupMatcher( GroupMatcher... matchers )
+ {
+ for ( GroupMatcher matcher : matchers )
+ {
+ addMatcher( matcher );
+ }
+ }
+
+ public AndGroupMatcher( Collection<GroupMatcher> matchers )
+ {
+ for ( GroupMatcher matcher : matchers )
+ {
+ addMatcher( matcher );
+ }
+ }
+
+ public boolean enabled( Class<?>... cats )
+ {
+ for ( GroupMatcher matcher : getMatchers() )
+ {
+ boolean result = matcher.enabled( cats );
+ if ( !result )
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ public boolean enabled( String... cats )
+ {
+ for ( GroupMatcher matcher : getMatchers() )
+ {
+ boolean result = matcher.enabled( cats );
+ if ( !result )
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+ for ( GroupMatcher matcher : getMatchers() )
+ {
+ if ( sb.length() > 0 )
+ {
+ sb.append( " AND " );
+ }
+ sb.append( matcher );
+ }
+
+ return sb.toString();
+ }
+
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result;
+ for ( GroupMatcher matcher : getMatchers() )
+ {
+ result += matcher.hashCode();
+ }
+ return result;
+ }
+
+ @Override
+ public boolean equals( Object obj )
+ {
+ if ( this == obj )
+ return true;
+ if ( obj == null )
+ return false;
+ if ( getClass() != obj.getClass() )
+ return false;
+ AndGroupMatcher other = (AndGroupMatcher) obj;
+ if ( !getMatchers().equals( other.getMatchers() ) )
+ return false;
+ return true;
+ }
+
+}
Propchange: maven/surefire/trunk/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/AndGroupMatcher.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/surefire/trunk/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/GroupMatcher.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/GroupMatcher.java?rev=1235805&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/GroupMatcher.java (added)
+++ maven/surefire/trunk/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/GroupMatcher.java Wed Jan 25 16:12:14 2012
@@ -0,0 +1,13 @@
+package org.apache.maven.surefire.group.match;
+
+
+public interface GroupMatcher
+{
+
+ void loadGroupClasses( ClassLoader cloader );
+
+ boolean enabled( Class<?>... cats );
+
+ boolean enabled( String... cats );
+
+}
Propchange: maven/surefire/trunk/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/GroupMatcher.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/surefire/trunk/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/InverseGroupMatcher.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/InverseGroupMatcher.java?rev=1235805&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/InverseGroupMatcher.java (added)
+++ maven/surefire/trunk/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/InverseGroupMatcher.java Wed Jan 25 16:12:14 2012
@@ -0,0 +1,65 @@
+package org.apache.maven.surefire.group.match;
+
+
+public class InverseGroupMatcher
+ implements GroupMatcher
+{
+
+ private final GroupMatcher matcher;
+
+ public InverseGroupMatcher( GroupMatcher matcher )
+ {
+ this.matcher = matcher;
+ }
+
+ public boolean enabled( Class<?>... cats )
+ {
+ return cats == null ? true : !matcher.enabled( cats );
+ }
+
+ public boolean enabled( String... cats )
+ {
+ return cats == null ? true : !matcher.enabled( cats );
+ }
+
+ @Override
+ public String toString()
+ {
+ return "NOT " + matcher;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ( ( matcher == null ) ? 0 : matcher.hashCode() );
+ return result;
+ }
+
+ @Override
+ public boolean equals( Object obj )
+ {
+ if ( this == obj )
+ return true;
+ if ( obj == null )
+ return false;
+ if ( getClass() != obj.getClass() )
+ return false;
+ InverseGroupMatcher other = (InverseGroupMatcher) obj;
+ if ( matcher == null )
+ {
+ if ( other.matcher != null )
+ return false;
+ }
+ else if ( !matcher.equals( other.matcher ) )
+ return false;
+ return true;
+ }
+
+ public void loadGroupClasses( ClassLoader cloader )
+ {
+ matcher.loadGroupClasses( cloader );
+ }
+
+}
Propchange: maven/surefire/trunk/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/InverseGroupMatcher.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/surefire/trunk/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/JoinGroupMatcher.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/JoinGroupMatcher.java?rev=1235805&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/JoinGroupMatcher.java (added)
+++ maven/surefire/trunk/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/JoinGroupMatcher.java Wed Jan 25 16:12:14 2012
@@ -0,0 +1,30 @@
+package org.apache.maven.surefire.group.match;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public abstract class JoinGroupMatcher
+ implements GroupMatcher
+{
+
+ Set<GroupMatcher> matchers = new HashSet<GroupMatcher>();
+
+ public final boolean addMatcher( GroupMatcher matcher )
+ {
+ return matchers.add( matcher );
+ }
+
+ protected final Set<GroupMatcher> getMatchers()
+ {
+ return matchers;
+ }
+
+ public void loadGroupClasses( ClassLoader cloader )
+ {
+ for ( GroupMatcher matcher : matchers )
+ {
+ matcher.loadGroupClasses( cloader );
+ }
+ }
+
+}
Propchange: maven/surefire/trunk/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/JoinGroupMatcher.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/surefire/trunk/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/OrGroupMatcher.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/OrGroupMatcher.java?rev=1235805&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/OrGroupMatcher.java (added)
+++ maven/surefire/trunk/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/OrGroupMatcher.java Wed Jan 25 16:12:14 2012
@@ -0,0 +1,96 @@
+package org.apache.maven.surefire.group.match;
+
+import java.util.Collection;
+
+public class OrGroupMatcher
+ extends JoinGroupMatcher
+{
+
+ public OrGroupMatcher( GroupMatcher... matchers )
+ {
+ for ( GroupMatcher matcher : matchers )
+ {
+ addMatcher( matcher );
+ }
+ }
+
+ public OrGroupMatcher( Collection<GroupMatcher> matchers )
+ {
+ for ( GroupMatcher matcher : matchers )
+ {
+ addMatcher( matcher );
+ }
+ }
+
+ public boolean enabled( Class<?>... cats )
+ {
+ for ( GroupMatcher matcher : getMatchers() )
+ {
+ boolean result = matcher.enabled( cats );
+ if ( result )
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public boolean enabled( String... cats )
+ {
+ for ( GroupMatcher matcher : getMatchers() )
+ {
+ boolean result = matcher.enabled( cats );
+ if ( result )
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+ for ( GroupMatcher matcher : getMatchers() )
+ {
+ if ( sb.length() > 0 )
+ {
+ sb.append( " OR " );
+ }
+ sb.append( matcher );
+ }
+
+ return sb.toString();
+ }
+
+ @Override
+ public int hashCode()
+ {
+ final int prime = 37;
+ int result = 1;
+ result = prime * result;
+ for ( GroupMatcher matcher : getMatchers() )
+ {
+ result += matcher.hashCode();
+ }
+ return result;
+ }
+
+ @Override
+ public boolean equals( Object obj )
+ {
+ if ( this == obj )
+ return true;
+ if ( obj == null )
+ return false;
+ if ( getClass() != obj.getClass() )
+ return false;
+ AndGroupMatcher other = (AndGroupMatcher) obj;
+ if ( !getMatchers().equals( other.getMatchers() ) )
+ return false;
+ return true;
+ }
+}
Propchange: maven/surefire/trunk/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/OrGroupMatcher.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/surefire/trunk/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/SingleGroupMatcher.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/SingleGroupMatcher.java?rev=1235805&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/SingleGroupMatcher.java (added)
+++ maven/surefire/trunk/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/SingleGroupMatcher.java Wed Jan 25 16:12:14 2012
@@ -0,0 +1,110 @@
+package org.apache.maven.surefire.group.match;
+
+
+public class SingleGroupMatcher
+ implements GroupMatcher
+{
+
+ private String enabled;
+
+ private Class<?> enabledClass;
+
+ public SingleGroupMatcher( String enabled )
+ {
+ this.enabled = enabled.endsWith( ".class" ) ? enabled.substring( 0, enabled.length() - 6 ) : enabled;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ( ( enabled == null ) ? 0 : enabled.hashCode() );
+ return result;
+ }
+
+ @Override
+ public boolean equals( Object obj )
+ {
+ if ( this == obj )
+ return true;
+ if ( obj == null )
+ return false;
+ if ( getClass() != obj.getClass() )
+ return false;
+ SingleGroupMatcher other = (SingleGroupMatcher) obj;
+ if ( enabled == null )
+ {
+ if ( other.enabled != null )
+ return false;
+ }
+ else if ( !enabled.equals( other.enabled ) )
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "*" + enabled;
+ }
+
+ public boolean enabled( Class<?>... cats )
+ {
+ if ( cats != null )
+ {
+ for ( Class<?> cls : cats )
+ {
+ String name = cls.getName();
+ if ( enabledClass != null && enabledClass.getName().equals( name ) )
+ {
+ return true;
+ }
+
+ if ( name.endsWith( enabled ) )
+ {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ public boolean enabled( String... cats )
+ {
+ if ( enabled == null )
+ {
+ return true;
+ }
+
+ for ( String cat : cats )
+ {
+ if ( cat == null || cat.trim().length() < 1 )
+ {
+ continue;
+ }
+
+ // System.out.println( cat + ".endsWith(" + enabled + ")? " + ( cat.endsWith( enabled ) ) );
+ if ( cat.endsWith( enabled ) )
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public void loadGroupClasses( ClassLoader cloader )
+ {
+ try
+ {
+ enabledClass = cloader.loadClass( enabled );
+ }
+ catch ( ClassNotFoundException e )
+ {
+ throw new RuntimeException( "Unable to load category: " + enabled, e );
+ }
+ }
+
+}
Propchange: maven/surefire/trunk/surefire-grouper/src/main/java/org/apache/maven/surefire/group/match/SingleGroupMatcher.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/surefire/trunk/surefire-grouper/src/main/javacc/category-expression.jj
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-grouper/src/main/javacc/category-expression.jj?rev=1235805&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-grouper/src/main/javacc/category-expression.jj (added)
+++ maven/surefire/trunk/surefire-grouper/src/main/javacc/category-expression.jj Wed Jan 25 16:12:14 2012
@@ -0,0 +1,199 @@
+options {
+ DEBUG_PARSER = false;
+ DEBUG_LOOKAHEAD = false;
+ DEBUG_TOKEN_MANAGER = false;
+ LOOKAHEAD=3;
+ FORCE_LA_CHECK=true;
+ STATIC = false;
+}
+
+PARSER_BEGIN(GroupMatcherParser)
+package org.apache.maven.surefire.group.parse;
+
+import org.apache.maven.surefire.group.match.*;
+import java.io.*;
+
+public class GroupMatcherParser
+{
+ public static void main( String[] args )
+ throws Exception
+ {
+ BufferedReader reader = new BufferedReader( new InputStreamReader( System.in ) );
+ while( true )
+ {
+ try
+ {
+ System.out.print( "Enter expression: " );
+ String expr = reader.readLine();
+ GroupMatcherParser parser = new GroupMatcherParser( expr );
+ GroupMatcher matcher = parser.parse();
+ System.out.println( matcher );
+ }
+ catch ( ParseException e )
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public GroupMatcherParser( String expression )
+ {
+ this( (Reader)(new StringReader( expression ) ) );
+ }
+
+ private GroupMatcher getMatcher( Op op, GroupMatcher...matchers )
+ {
+ GroupMatcher matcher = null;
+ if ( Op.AND == op )
+ {
+ matcher = new AndGroupMatcher( matchers );
+ }
+ else
+ {
+ matcher = new OrGroupMatcher( matchers );
+ }
+
+ return matcher;
+ }
+
+ public enum Op
+ {
+ AND, OR;
+ }
+}
+
+PARSER_END(GroupMatcherParser)
+
+SKIP :
+{
+ " "
+| "\t"
+| "\r"
+| "\n"
+}
+
+TOKEN:
+{
+ <AND: (["A", "a"] ["N", "n"] ["D", "d"]) >
+| <OR: (["O","o"] ["R", "r"]) >
+| <AMP2: "&&">
+| <PIPE2: "||">
+| <COMMA: ",">
+| <NOT: "NOT">
+| <BANG: "!">
+| <LPAREN: "(">
+| <RPAREN: ")">
+| <STRING: (["A"-"Z", "a"-"z", "0"-"9", "_", "$", "#", "."])+ >
+| <CLS: ".class">
+}
+
+GroupMatcher parse() :
+{GroupMatcher matcher = null;}
+{
+ matcher=expr()
+ {
+ return matcher;
+ }
+}
+
+GroupMatcher expr() :
+{
+GroupMatcher matcher=null;
+}
+{
+(
+ matcher=igroup()
+| matcher=group()
+)
+ {return matcher;}
+}
+
+GroupMatcher igroup() :
+{
+GroupMatcher lhs=null;
+GroupMatcher rhs=null;
+Op op=null;
+}
+{
+ (lhs=value() (op=op() rhs=expr())?)
+ {
+ GroupMatcher matcher = lhs;
+ if ( op != null )
+ {
+ matcher = getMatcher( op, lhs, rhs );
+ }
+
+ return matcher;
+ }
+}
+
+GroupMatcher group() :
+{
+boolean inverted=false;
+GroupMatcher lhs=null;
+GroupMatcher rhs=null;
+Op op=null;
+}
+{
+ (not()
+ {
+ inverted=true;
+ }
+ )?
+ <LPAREN>
+ lhs=expr()
+ (
+ op=op()
+ rhs=expr()
+ )?
+ <RPAREN>
+ {
+ GroupMatcher matcher = lhs;
+ if ( op != null )
+ {
+ matcher = getMatcher( op, lhs, rhs );
+ }
+
+ return inverted ? new InverseGroupMatcher( matcher ) : matcher;
+ }
+}
+
+GroupMatcher value() :
+{
+boolean inverted=false;
+Token val=null;
+}
+{
+( not()
+ {inverted=true;}
+)?
+ val=<STRING>
+ {
+ GroupMatcher m = new SingleGroupMatcher( val.image );
+ return inverted ? new InverseGroupMatcher( m ) : m;
+ }
+}
+
+Op op() :
+{Op o=null;}
+{
+(
+ <AND>
+ {o=Op.AND;}
+| <OR>
+ {o=Op.OR;}
+| <AMP2>
+ {o=Op.AND;}
+| <PIPE2>
+ {o=Op.OR;}
+| <COMMA>
+ {o=Op.OR;}
+)
+ {return o;}
+}
+
+void not() :
+{}
+{
+ <NOT> | <BANG>
+}
Added: maven/surefire/trunk/surefire-grouper/src/test/java/org/apache/maven/surefire/group/match/AndGroupMatcherTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-grouper/src/test/java/org/apache/maven/surefire/group/match/AndGroupMatcherTest.java?rev=1235805&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-grouper/src/test/java/org/apache/maven/surefire/group/match/AndGroupMatcherTest.java (added)
+++ maven/surefire/trunk/surefire-grouper/src/test/java/org/apache/maven/surefire/group/match/AndGroupMatcherTest.java Wed Jan 25 16:12:14 2012
@@ -0,0 +1,36 @@
+package org.apache.maven.surefire.group.match;
+
+import junit.framework.TestCase;
+
+public class AndGroupMatcherTest
+ extends TestCase
+{
+
+ public void testDontMatchOneInGroup()
+ {
+ AndGroupMatcher matcher =
+ new AndGroupMatcher( new SingleGroupMatcher( SingleGroupMatcher.class.getName() ),
+ new SingleGroupMatcher( InverseGroupMatcher.class.getName() ) );
+
+ assertFalse( matcher.enabled( InverseGroupMatcher.class, AndGroupMatcher.class ) );
+ }
+
+ public void testMatchBothInGroup()
+ {
+ AndGroupMatcher matcher =
+ new AndGroupMatcher( new SingleGroupMatcher( SingleGroupMatcher.class.getName() ),
+ new SingleGroupMatcher( InverseGroupMatcher.class.getName() ) );
+
+ assertTrue( matcher.enabled( InverseGroupMatcher.class, SingleGroupMatcher.class ) );
+ }
+
+ public void testDontMatchAnyInGroup()
+ {
+ AndGroupMatcher matcher =
+ new AndGroupMatcher( new SingleGroupMatcher( SingleGroupMatcher.class.getName() ),
+ new SingleGroupMatcher( InverseGroupMatcher.class.getName() ) );
+
+ assertFalse( matcher.enabled( OrGroupMatcher.class, AndGroupMatcher.class ) );
+ }
+
+}
Propchange: maven/surefire/trunk/surefire-grouper/src/test/java/org/apache/maven/surefire/group/match/AndGroupMatcherTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/surefire/trunk/surefire-grouper/src/test/java/org/apache/maven/surefire/group/match/InverseGroupMatcherTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-grouper/src/test/java/org/apache/maven/surefire/group/match/InverseGroupMatcherTest.java?rev=1235805&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-grouper/src/test/java/org/apache/maven/surefire/group/match/InverseGroupMatcherTest.java (added)
+++ maven/surefire/trunk/surefire-grouper/src/test/java/org/apache/maven/surefire/group/match/InverseGroupMatcherTest.java Wed Jan 25 16:12:14 2012
@@ -0,0 +1,16 @@
+package org.apache.maven.surefire.group.match;
+
+import junit.framework.TestCase;
+
+public class InverseGroupMatcherTest
+ extends TestCase
+{
+
+ public void testInvertSingleMatcher()
+ {
+ InverseGroupMatcher matcher =
+ new InverseGroupMatcher( new SingleGroupMatcher( InverseGroupMatcher.class.getName() ) );
+ assertFalse( matcher.enabled( InverseGroupMatcher.class ) );
+ }
+
+}
Propchange: maven/surefire/trunk/surefire-grouper/src/test/java/org/apache/maven/surefire/group/match/InverseGroupMatcherTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/surefire/trunk/surefire-grouper/src/test/java/org/apache/maven/surefire/group/match/OrGroupMatcherTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-grouper/src/test/java/org/apache/maven/surefire/group/match/OrGroupMatcherTest.java?rev=1235805&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-grouper/src/test/java/org/apache/maven/surefire/group/match/OrGroupMatcherTest.java (added)
+++ maven/surefire/trunk/surefire-grouper/src/test/java/org/apache/maven/surefire/group/match/OrGroupMatcherTest.java Wed Jan 25 16:12:14 2012
@@ -0,0 +1,36 @@
+package org.apache.maven.surefire.group.match;
+
+import junit.framework.TestCase;
+
+public class OrGroupMatcherTest
+ extends TestCase
+{
+
+ public void testMatchOneInOredGroup()
+ {
+ OrGroupMatcher matcher =
+ new OrGroupMatcher( new SingleGroupMatcher( SingleGroupMatcher.class.getName() ),
+ new SingleGroupMatcher( InverseGroupMatcher.class.getName() ) );
+
+ assertTrue( matcher.enabled( InverseGroupMatcher.class, AndGroupMatcher.class ) );
+ }
+
+ public void testMatchBothInOredGroup()
+ {
+ OrGroupMatcher matcher =
+ new OrGroupMatcher( new SingleGroupMatcher( SingleGroupMatcher.class.getName() ),
+ new SingleGroupMatcher( InverseGroupMatcher.class.getName() ) );
+
+ assertTrue( matcher.enabled( InverseGroupMatcher.class, SingleGroupMatcher.class ) );
+ }
+
+ public void testMatchNoneInOredGroup()
+ {
+ OrGroupMatcher matcher =
+ new OrGroupMatcher( new SingleGroupMatcher( SingleGroupMatcher.class.getName() ),
+ new SingleGroupMatcher( InverseGroupMatcher.class.getName() ) );
+
+ assertFalse( matcher.enabled( OrGroupMatcher.class, AndGroupMatcher.class ) );
+ }
+
+}
Propchange: maven/surefire/trunk/surefire-grouper/src/test/java/org/apache/maven/surefire/group/match/OrGroupMatcherTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/surefire/trunk/surefire-grouper/src/test/java/org/apache/maven/surefire/group/match/SingleGroupMatcherTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-grouper/src/test/java/org/apache/maven/surefire/group/match/SingleGroupMatcherTest.java?rev=1235805&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-grouper/src/test/java/org/apache/maven/surefire/group/match/SingleGroupMatcherTest.java (added)
+++ maven/surefire/trunk/surefire-grouper/src/test/java/org/apache/maven/surefire/group/match/SingleGroupMatcherTest.java Wed Jan 25 16:12:14 2012
@@ -0,0 +1,28 @@
+package org.apache.maven.surefire.group.match;
+
+import junit.framework.TestCase;
+
+public class SingleGroupMatcherTest
+ extends TestCase
+{
+
+ public void testMatchExactClassName()
+ {
+ SingleGroupMatcher matcher = new SingleGroupMatcher( SingleGroupMatcher.class.getName() );
+ assertTrue( matcher.enabled( SingleGroupMatcher.class ) );
+ }
+
+ public void testMatchLoadedClass()
+ {
+ SingleGroupMatcher matcher = new SingleGroupMatcher( SingleGroupMatcher.class.getName() );
+ matcher.loadGroupClasses( Thread.currentThread().getContextClassLoader() );
+ assertTrue( matcher.enabled( SingleGroupMatcher.class ) );
+ }
+
+ public void testMatchClassNameWithoutPackage()
+ {
+ SingleGroupMatcher matcher = new SingleGroupMatcher( SingleGroupMatcher.class.getSimpleName() );
+ assertTrue( matcher.enabled( SingleGroupMatcher.class ) );
+ }
+
+}
Propchange: maven/surefire/trunk/surefire-grouper/src/test/java/org/apache/maven/surefire/group/match/SingleGroupMatcherTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/surefire/trunk/surefire-grouper/src/test/java/org/apache/maven/surefire/group/parse/GroupMatcherParserTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-grouper/src/test/java/org/apache/maven/surefire/group/parse/GroupMatcherParserTest.java?rev=1235805&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-grouper/src/test/java/org/apache/maven/surefire/group/parse/GroupMatcherParserTest.java (added)
+++ maven/surefire/trunk/surefire-grouper/src/test/java/org/apache/maven/surefire/group/parse/GroupMatcherParserTest.java Wed Jan 25 16:12:14 2012
@@ -0,0 +1,128 @@
+package org.apache.maven.surefire.group.parse;
+
+import junit.framework.TestCase;
+
+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.match.OrGroupMatcher;
+import org.apache.maven.surefire.group.match.SingleGroupMatcher;
+
+public class GroupMatcherParserTest
+ extends TestCase
+{
+
+ public void testParseSingleClass()
+ throws ParseException
+ {
+ GroupMatcher matcher = new GroupMatcherParser( GroupMatcherParser.class.getName() ).parse();
+ assertTrue( "Wrong matcher type: " + matcher.getClass().getName(), matcher instanceof SingleGroupMatcher );
+ assertTrue( matcher.enabled( GroupMatcherParser.class ) );
+ }
+
+ public void testParseInvertedSingleClass()
+ throws ParseException
+ {
+ GroupMatcher matcher = new GroupMatcherParser( "NOT " + GroupMatcherParser.class.getName() ).parse();
+ assertTrue( "Wrong matcher type: " + matcher.getClass().getName(), matcher instanceof InverseGroupMatcher );
+ assertFalse( matcher.enabled( GroupMatcherParser.class ) );
+ }
+
+ public void testParseBareANDedPair()
+ throws ParseException
+ {
+ GroupMatcher matcher =
+ new GroupMatcherParser( GroupMatcherParser.class.getName() + " AND " + SingleGroupMatcher.class.getName() ).parse();
+
+ assertTrue( "Wrong matcher type: " + matcher.getClass().getName(), matcher instanceof AndGroupMatcher );
+ assertFalse( matcher.enabled( GroupMatcherParser.class ) );
+ assertTrue( matcher.enabled( GroupMatcherParser.class, SingleGroupMatcher.class ) );
+ }
+
+ public void testParseBareORedPair()
+ throws ParseException
+ {
+ GroupMatcher matcher =
+ new GroupMatcherParser( GroupMatcherParser.class.getName() + " OR " + SingleGroupMatcher.class.getName() ).parse();
+
+ assertTrue( "Wrong matcher type: " + matcher.getClass().getName(), matcher instanceof OrGroupMatcher );
+ assertTrue( matcher.enabled( GroupMatcherParser.class ) );
+ assertTrue( matcher.enabled( GroupMatcherParser.class, SingleGroupMatcher.class ) );
+ }
+
+ public void testBareCommaSeparatedORedPair()
+ throws ParseException
+ {
+ GroupMatcher matcher =
+ new GroupMatcherParser( GroupMatcherParser.class.getName() + ", " + SingleGroupMatcher.class.getName() ).parse();
+
+ assertTrue( "Wrong matcher type: " + matcher.getClass().getName(), matcher instanceof OrGroupMatcher );
+ assertTrue( matcher.enabled( GroupMatcherParser.class ) );
+ assertTrue( matcher.enabled( GroupMatcherParser.class, SingleGroupMatcher.class ) );
+ }
+
+ public void testParseGroupedANDedPair()
+ throws ParseException
+ {
+ GroupMatcher matcher =
+ new GroupMatcherParser( "(" + GroupMatcherParser.class.getName() + " AND "
+ + SingleGroupMatcher.class.getName() + ")" ).parse();
+
+ assertTrue( "Wrong matcher type: " + matcher.getClass().getName(), matcher instanceof AndGroupMatcher );
+ assertFalse( matcher.enabled( GroupMatcherParser.class ) );
+ assertTrue( matcher.enabled( GroupMatcherParser.class, SingleGroupMatcher.class ) );
+ }
+
+ public void testParseGroupedORedPair()
+ throws ParseException
+ {
+ GroupMatcher matcher =
+ new GroupMatcherParser( "(" + GroupMatcherParser.class.getName() + " OR "
+ + SingleGroupMatcher.class.getName() + ")" ).parse();
+
+ assertTrue( "Wrong matcher type: " + matcher.getClass().getName(), matcher instanceof OrGroupMatcher );
+ assertTrue( matcher.enabled( GroupMatcherParser.class ) );
+ assertTrue( matcher.enabled( GroupMatcherParser.class, SingleGroupMatcher.class ) );
+ }
+
+ public void testParseInvertedGroupedANDedPair()
+ throws ParseException
+ {
+ GroupMatcher matcher =
+ new GroupMatcherParser( "NOT (" + GroupMatcherParser.class.getName() + " AND "
+ + SingleGroupMatcher.class.getName() + ")" ).parse();
+
+ assertTrue( "Wrong matcher type: " + matcher.getClass().getName(), matcher instanceof InverseGroupMatcher );
+ assertTrue( matcher.enabled( GroupMatcherParser.class ) );
+ assertFalse( matcher.enabled( GroupMatcherParser.class, SingleGroupMatcher.class ) );
+ }
+
+ public void testParseInvertedGroupedORedPair()
+ throws ParseException
+ {
+ GroupMatcher matcher =
+ new GroupMatcherParser( "NOT (" + GroupMatcherParser.class.getName() + " OR "
+ + SingleGroupMatcher.class.getName() + ")" ).parse();
+
+ assertTrue( "Wrong matcher type: " + matcher.getClass().getName(), matcher instanceof InverseGroupMatcher );
+ assertFalse( matcher.enabled( GroupMatcherParser.class ) );
+ assertFalse( matcher.enabled( GroupMatcherParser.class, SingleGroupMatcher.class ) );
+ }
+
+ public void testSingleMatchWhenDotClassAppended()
+ throws ParseException
+ {
+ GroupMatcher matcher = new GroupMatcherParser( SingleGroupMatcher.class.getName() + ".class" ).parse();
+ assertTrue( "Wrong matcher type: " + matcher.getClass().getName(), matcher instanceof SingleGroupMatcher );
+ assertTrue( matcher.enabled( SingleGroupMatcher.class ) );
+ }
+
+ public void testSingleMatchWithOnlyClassSimpleName()
+ throws ParseException
+ {
+ GroupMatcher matcher = new GroupMatcherParser( SingleGroupMatcher.class.getSimpleName() ).parse();
+ assertTrue( "Wrong matcher type: " + matcher.getClass().getName(), matcher instanceof SingleGroupMatcher );
+ assertTrue( matcher.enabled( SingleGroupMatcher.class ) );
+ }
+
+}
Propchange: maven/surefire/trunk/surefire-grouper/src/test/java/org/apache/maven/surefire/group/parse/GroupMatcherParserTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire809GroupExpressionsIT.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire809GroupExpressionsIT.java?rev=1235805&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire809GroupExpressionsIT.java (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire809GroupExpressionsIT.java Wed Jan 25 16:12:14 2012
@@ -0,0 +1,70 @@
+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 Surefire809GroupExpressionsIT
+ extends SurefireIntegrationTestCase
+{
+ public void testJUnitRunCategoryAB()
+ {
+ OutputValidator validator = unpackJUnit().groups( "junit4.CategoryA&&junit4.CategoryB" ).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" );
+ }
+
+ public void testJUnitRunCategoryNotC()
+ {
+ OutputValidator validator = unpackJUnit().groups( "!junit4.CategoryC" ).executeTest();
+ validator.verifyErrorFreeLog();
+ validator.assertTestSuiteResults( 5, 0, 0, 0 );
+ validator.verifyTextInLog( "catA: 2" );
+ validator.verifyTextInLog( "catB: 2" );
+ validator.verifyTextInLog( "catC: 0" );
+ validator.verifyTextInLog( "catNone: 1" );
+ validator.verifyTextInLog( "NoCategoryTest.CatNone: 1" );
+ }
+
+ public void testTestNGRunCategoryAB()
+ {
+ OutputValidator validator = unpackTestNG().groups( "CategoryA&&CategoryB" ).executeTest();
+ validator.verifyErrorFreeLog();
+ validator.assertTestSuiteResults( 2, 0, 0, 0 );
+ validator.verifyTextInLog( "BasicTest.testInCategoriesAB()" );
+ validator.verifyTextInLog( "CategoryCTest.testInCategoriesAB()" );
+ }
+
+ public void testTestNGRunCategoryNotC()
+ {
+ OutputValidator validator = unpackTestNG().groups( "!CategoryC" ).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-809-groupExpr-junit48" );
+ }
+
+ private SurefireLauncher unpackTestNG()
+ {
+ return unpack( "surefire-809-groupExpr-testng" );
+ }
+
+}
Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire809GroupExpressionsIT.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-junit48/pom.xml
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-junit48/pom.xml?rev=1235805&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-junit48/pom.xml (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-junit48/pom.xml Wed Jan 25 16:12:14 2012
@@ -0,0 +1,74 @@
+<?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>
+ </configuration>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.surefire</groupId>
+ <artifactId>surefire-junit47</artifactId>
+ <version>${surefire.version}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-junit48/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/BasicTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/BasicTest.java?rev=1235805&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/BasicTest.java (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/BasicTest.java Wed Jan 25 16:12:14 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-809-groupExpr-junit48/src/test/java/junit4/BasicTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/CategoryA.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/CategoryA.java?rev=1235805&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/CategoryA.java (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/CategoryA.java Wed Jan 25 16:12:14 2012
@@ -0,0 +1,3 @@
+package junit4;
+
+interface CategoryA {}
Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/CategoryA.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/CategoryB.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/CategoryB.java?rev=1235805&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/CategoryB.java (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/CategoryB.java Wed Jan 25 16:12:14 2012
@@ -0,0 +1,3 @@
+package junit4;
+
+interface CategoryB {}
Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/CategoryB.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/CategoryC.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/CategoryC.java?rev=1235805&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/CategoryC.java (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/CategoryC.java Wed Jan 25 16:12:14 2012
@@ -0,0 +1,3 @@
+package junit4;
+
+interface CategoryC {}
Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/CategoryC.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/CategoryCTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/CategoryCTest.java?rev=1235805&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/CategoryCTest.java (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/CategoryCTest.java Wed Jan 25 16:12:14 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-809-groupExpr-junit48/src/test/java/junit4/CategoryCTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/NoCategoryTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/NoCategoryTest.java?rev=1235805&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/NoCategoryTest.java (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-junit48/src/test/java/junit4/NoCategoryTest.java Wed Jan 25 16:12:14 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-809-groupExpr-junit48/src/test/java/junit4/NoCategoryTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-testng/pom.xml
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-testng/pom.xml?rev=1235805&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-testng/pom.xml (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-testng/pom.xml Wed Jan 25 16:12:14 2012
@@ -0,0 +1,51 @@
+<?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>
+
+ <properties>
+ <groups>!CategoryC</groups>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>${surefire.version}</version>
+ </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>
+</project>
Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-testng/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-testng/src/test/java/testng/BasicTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-testng/src/test/java/testng/BasicTest.java?rev=1235805&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-testng/src/test/java/testng/BasicTest.java (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-testng/src/test/java/testng/BasicTest.java Wed Jan 25 16:12:14 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-809-groupExpr-testng/src/test/java/testng/BasicTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-testng/src/test/java/testng/CategoryCTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-testng/src/test/java/testng/CategoryCTest.java?rev=1235805&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-testng/src/test/java/testng/CategoryCTest.java (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-testng/src/test/java/testng/CategoryCTest.java Wed Jan 25 16:12:14 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-809-groupExpr-testng/src/test/java/testng/CategoryCTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-testng/src/test/java/testng/NoCategoryTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-testng/src/test/java/testng/NoCategoryTest.java?rev=1235805&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-testng/src/test/java/testng/NoCategoryTest.java (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-809-groupExpr-testng/src/test/java/testng/NoCategoryTest.java Wed Jan 25 16:12:14 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-809-groupExpr-testng/src/test/java/testng/NoCategoryTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: maven/surefire/trunk/surefire-providers/common-junit48/pom.xml
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/common-junit48/pom.xml?rev=1235805&r1=1235804&r2=1235805&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/common-junit48/pom.xml (original)
+++ maven/surefire/trunk/surefire-providers/common-junit48/pom.xml Wed Jan 25 16:12:14 2012
@@ -49,7 +49,7 @@
</dependency>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
- <artifactId>maven-surefire-common</artifactId>
+ <artifactId>surefire-grouper</artifactId>
</dependency>
</dependencies>
Modified: maven/surefire/trunk/surefire-providers/surefire-testng-utils/pom.xml
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-testng-utils/pom.xml?rev=1235805&r1=1235804&r2=1235805&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-testng-utils/pom.xml (original)
+++ maven/surefire/trunk/surefire-providers/surefire-testng-utils/pom.xml Wed Jan 25 16:12:14 2012
@@ -24,6 +24,10 @@
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.maven.surefire</groupId>
+ <artifactId>surefire-grouper</artifactId>
+ </dependency>
</dependencies>
<build>
Added: 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=1235805&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/GroupMatcherMethodSelector.java (added)
+++ maven/surefire/trunk/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/GroupMatcherMethodSelector.java Wed Jan 25 16:12:14 2012
@@ -0,0 +1,92 @@
+package org.apache.maven.surefire.testng.utils;
+
+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;
+
+public class GroupMatcherMethodSelector
+ implements IMethodSelector
+{
+
+ private static final long serialVersionUID = 1L;
+
+ private static GroupMatcher matcher;
+
+ private Map<ITestNGMethod, Boolean> answers = new HashMap<ITestNGMethod, Boolean>();
+
+ public boolean includeMethod( IMethodSelectorContext context, ITestNGMethod method, boolean isTestMethod )
+ {
+ // System.out.println( "Checking: " + method + " vs. matcher: " + matcher );
+ Boolean result = (Boolean) answers.get( method );
+ if ( result != null )
+ {
+ // System.out.println( "Enabled? " + result );
+ return result;
+ }
+
+ if ( matcher == null )
+ {
+ // System.out.println( "No matcher, enable by default" );
+ return true;
+ }
+
+ String[] groups = method.getGroups();
+ result = Boolean.valueOf( matcher.enabled( groups ) );
+
+ answers.put( method, result );
+
+ // System.out.println( "Enabled? " + result );
+ return result;
+ }
+
+ public void setTestMethods( List<ITestNGMethod> testMethods )
+ {
+ }
+
+ public static void setGroups( String groups, String excludedGroups )
+ {
+ // System.out.println( "Processing group includes: '" + groups + "'\nExcludes: '" + excludedGroups + "'" );
+
+ try
+ {
+ AndGroupMatcher matcher = new AndGroupMatcher();
+ GroupMatcher in = groups == null ? null : new GroupMatcherParser( groups ).parse();
+ if ( in != null )
+ {
+ matcher.addMatcher( in );
+ }
+
+ GroupMatcher ex = excludedGroups == null ? null : new GroupMatcherParser( excludedGroups ).parse();
+ if ( ex != null )
+ {
+ matcher.addMatcher( new InverseGroupMatcher( ex ) );
+ }
+
+ if ( in != null || ex != null )
+ {
+ // System.out.println( "Group matcher: " + matcher );
+ GroupMatcherMethodSelector.matcher = matcher;
+ }
+ }
+ catch ( ParseException e )
+ {
+ throw new IllegalArgumentException( "Cannot parse group includes/excludes expression(s):\nIncludes: "
+ + groups + "\nExcludes: " + excludedGroups, e );
+ }
+ }
+
+ public static void setGroupMatcher( GroupMatcher matcher )
+ {
+ GroupMatcherMethodSelector.matcher = matcher;
+ }
+
+}
Propchange: maven/surefire/trunk/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/GroupMatcherMethodSelector.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java?rev=1235805&r1=1235804&r2=1235805&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java (original)
+++ maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java Wed Jan 25 16:12:14 2012
@@ -29,6 +29,7 @@ import java.util.Map;
import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.artifact.versioning.VersionRange;
+import org.apache.maven.surefire.booter.ProviderParameterNames;
import org.apache.maven.surefire.report.RunListener;
import org.apache.maven.surefire.testng.conf.Configurator;
import org.apache.maven.surefire.testng.conf.TestNG4751Configurator;
@@ -59,11 +60,15 @@ public class TestNGExecutor
throws TestSetFailedException
{
TestNG testng = new TestNG( true );
+
+ applyGroupMatching( testng, options );
if (!StringUtils.isBlank( methodNamePattern ))
{
applyMethodNameFiltering( testng, methodNamePattern );
- }
+ }
+
Configurator configurator = getConfigurator( version );
+ System.out.println( "Configuring TestNG with: " + configurator );
configurator.configure( testng, options );
postConfigure( testng, testSourceDirectory, reportManager, suite, reportsDirectory );
testng.setTestClasses( testClasses );
@@ -110,6 +115,55 @@ public class TestNGExecutor
}
}
+ private static void applyGroupMatching( TestNG testng, Map options )
+ throws TestSetFailedException
+ {
+ String groups = (String) options.get( ProviderParameterNames.TESTNG_GROUPS_PROP );
+ String excludedGroups = (String) options.get( ProviderParameterNames.TESTNG_EXCLUDEDGROUPS_PROP );
+
+ if ( groups == null && excludedGroups == null )
+ {
+ return;
+ }
+
+ // the class is available in the testClassPath
+ String clazzName = "org.apache.maven.surefire.testng.utils.GroupMatcherMethodSelector";
+ // looks to need a high value
+ testng.addMethodSelector( clazzName, 9999 );
+ try
+ {
+ Class clazz = Class.forName( clazzName );
+
+ // HORRIBLE hack, but TNG doesn't allow us to setup a method selector instance directly.
+ Method method = clazz.getMethod( "setGroups", new Class[] { String.class, String.class } );
+ method.invoke( null, new Object[] { groups, excludedGroups } );
+ }
+ catch ( ClassNotFoundException e )
+ {
+ throw new TestSetFailedException( e.getMessage(), e );
+ }
+ catch ( SecurityException e )
+ {
+ throw new TestSetFailedException( e.getMessage(), e );
+ }
+ catch ( NoSuchMethodException e )
+ {
+ throw new TestSetFailedException( e.getMessage(), e );
+ }
+ catch ( IllegalArgumentException e )
+ {
+ throw new TestSetFailedException( e.getMessage(), e );
+ }
+ catch ( IllegalAccessException e )
+ {
+ throw new TestSetFailedException( e.getMessage(), e );
+ }
+ catch ( InvocationTargetException e )
+ {
+ throw new TestSetFailedException( e.getMessage(), e );
+ }
+ }
+
public static void run( List suiteFiles, String testSourceDirectory, Map options, ArtifactVersion version,
RunListener reportManager, TestNgTestSuite suite, File reportsDirectory )
throws TestSetFailedException