Return-Path: Delivered-To: apmail-maven-surefire-commits-archive@www.apache.org Received: (qmail 83482 invoked from network); 12 Jan 2010 07:40:13 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 12 Jan 2010 07:40:13 -0000 Received: (qmail 73016 invoked by uid 500); 12 Jan 2010 07:40:13 -0000 Delivered-To: apmail-maven-surefire-commits-archive@maven.apache.org Received: (qmail 72972 invoked by uid 500); 12 Jan 2010 07:40:12 -0000 Mailing-List: contact surefire-commits-help@maven.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: surefire-dev@maven.apache.org Delivered-To: mailing list surefire-commits@maven.apache.org Received: (qmail 72963 invoked by uid 99); 12 Jan 2010 07:40:12 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 Jan 2010 07:40:12 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 Jan 2010 07:40:11 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 0C2FF23888CF; Tue, 12 Jan 2010 07:39:51 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r898206 - in /maven/surefire/trunk: maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/ surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ surefire-integration-tests/src/test/resources/concurrentjunit4... Date: Tue, 12 Jan 2010 07:39:50 -0000 To: surefire-commits@maven.apache.org From: stephenc@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100112073951.0C2FF23888CF@eris.apache.org> Author: stephenc Date: Tue Jan 12 07:39:49 2010 New Revision: 898206 URL: http://svn.apache.org/viewvc?rev=898206&view=rev Log: [SUREFIRE-596] Applied patch version 2 unchanged Submitted by: Kristian Rosenvold o Files applied: junit2.diff, junit2.zip Added: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Junit47concurrencyIT.java (with props) maven/surefire/trunk/surefire-integration-tests/src/test/resources/concurrentjunit47/ maven/surefire/trunk/surefire-integration-tests/src/test/resources/concurrentjunit47/pom.xml (with props) maven/surefire/trunk/surefire-integration-tests/src/test/resources/concurrentjunit47/src/ maven/surefire/trunk/surefire-integration-tests/src/test/resources/concurrentjunit47/src/test/ maven/surefire/trunk/surefire-integration-tests/src/test/resources/concurrentjunit47/src/test/java/ maven/surefire/trunk/surefire-integration-tests/src/test/resources/concurrentjunit47/src/test/java/junit47/ maven/surefire/trunk/surefire-integration-tests/src/test/resources/concurrentjunit47/src/test/java/junit47/BasicTest.java (with props) Modified: maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Junit4VersionsIT.java maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreTestSet.java maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreTestSetReporter.java Modified: maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java?rev=898206&r1=898205&r2=898206&view=diff ============================================================================== --- maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java (original) +++ maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java Tue Jan 12 07:39:49 2010 @@ -445,7 +445,7 @@ * methods that depend on each other, which will be run in the same thread in order to respect their order of * execution. * - * In JUnit 4.6 the values are classes/methods/both to run in separate threads, as controlled by threadCount. + * In JUnit 4.7 the values are classes/methods/both to run in separate threads, as controlled by threadCount. * * @parameter expression="${parallel}" * @todo test how this works with forking, and console/file output parallelism @@ -681,6 +681,10 @@ } } + private boolean isAnyConcurrencySelected(){ + return this.parallel != null && this.parallel.trim().length() > 0; + } + /** * Converts old TestNG configuration parameters over to new properties based configuration * method. (if any are defined the old way) @@ -717,8 +721,8 @@ return isWithinVersionSpec(artifact, "[4.7,)"); } - private boolean isJunit40to46(Artifact artifact) throws MojoExecutionException { - return isWithinVersionSpec(artifact, "[4.0,4.7)"); + private boolean isAnyJunit4(Artifact artifact) throws MojoExecutionException { + return isWithinVersionSpec(artifact, "[4.0,)"); } private boolean isWithinVersionSpec(Artifact artifact, String versionSpec) throws MojoExecutionException { @@ -800,15 +804,13 @@ // The plugin uses a JDK based profile to select the right testng. We might be explicity using a // different one since its based on the source level, not the JVM. Prune using the filter. addProvider( surefireBooter, "surefire-testng", surefireArtifact.getBaseVersion(), testNgArtifact ); - } - else if ( junitArtifact != null && isJunit47Compatible( junitArtifact ) ) - { - convertJunitCoreParameters(); - addProvider( surefireBooter, "surefire-junit47", surefireArtifact.getBaseVersion(), null ); - } - else if ( junitArtifact != null && isJunit40to46( junitArtifact ) ) - { - addProvider( surefireBooter, "surefire-junit4", surefireArtifact.getBaseVersion(), null ); + } else if (junitArtifact != null && isAnyJunit4( junitArtifact)){ + if ( isAnyConcurrencySelected() && isJunit47Compatible( junitArtifact ) ){ + convertJunitCoreParameters(); + addProvider( surefireBooter, "surefire-junit47", surefireArtifact.getBaseVersion(), null ); + } else { + addProvider( surefireBooter, "surefire-junit4", surefireArtifact.getBaseVersion(), null ); + } } else { @@ -907,16 +909,16 @@ else { String junitDirectoryTestSuite; - if ( isJunit47Compatible( junitArtifact ) ) + if ( isAnyConcurrencySelected() && isJunit47Compatible( junitArtifact ) ) { junitDirectoryTestSuite = "org.apache.maven.surefire.junitcore.JUnitCoreDirectoryTestSuite"; - getLog().warn( "Props are" + properties.toString() ); + getLog().info( "Concurrency config is " + properties.toString() ); surefireBooter.addTestSuite( junitDirectoryTestSuite, new Object[]{testClassesDirectory, includes, excludes, properties} ); } else { - if ( isJunit40to46( junitArtifact ) ) + if ( isAnyJunit4( junitArtifact ) ) { junitDirectoryTestSuite = "org.apache.maven.surefire.junit4.JUnit4DirectoryTestSuite"; } Added: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Junit47concurrencyIT.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Junit47concurrencyIT.java?rev=898206&view=auto ============================================================================== --- maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Junit47concurrencyIT.java (added) +++ maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Junit47concurrencyIT.java Tue Jan 12 07:39:49 2010 @@ -0,0 +1,46 @@ +package org.apache.maven.surefire.its; + + +import org.apache.maven.it.Verifier; +import org.apache.maven.it.util.ResourceExtractor; + +import java.io.File; +import java.util.List; + +/** + * Basic suite test using all known versions of JUnit 4.x + * + * @author Kristian Rosenvold + * + */ +public class Junit47concurrencyIT + extends AbstractSurefireIntegrationTestClass +{ + + + public void test47 () throws Exception + { + runJUnitTest(); + } + + + public void runJUnitTest () + throws Exception + { + File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/concurrentjunit47" ); + + Verifier verifier = new Verifier( testDir.getAbsolutePath() ); + List arguments = this.getInitialGoals(); + arguments.add( "test" ); + // DGF we have to pass in the version as a command line argument + // and NOT as a system property; otherwise our setting will be ignored + arguments.add( "-DjunitVersion=4.7"); + verifier.executeGoals( arguments ); + + verifier.verifyErrorFreeLog(); + verifier.resetStreams(); + + IntegrationTestSuiteResults suite = HelperAssertions.parseTestResults( new File[] { testDir } ); + HelperAssertions.assertTestSuiteResults( 1, 0, 0, 0, suite ); + } +} \ No newline at end of file Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Junit47concurrencyIT.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Junit47concurrencyIT.java ------------------------------------------------------------------------------ svn:executable = * Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Junit47concurrencyIT.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Junit4VersionsIT.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Junit4VersionsIT.java?rev=898206&r1=898205&r2=898206&view=diff ============================================================================== --- maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Junit4VersionsIT.java (original) +++ maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Junit4VersionsIT.java Tue Jan 12 07:39:49 2010 @@ -46,6 +46,22 @@ { runJUnitTest( "4.4" ); } + + public void test45 () throws Exception + { + runJUnitTest( "4.5" ); + } + + public void test46 () throws Exception + { + runJUnitTest( "4.6" ); + } + + public void test47 () throws Exception + { + runJUnitTest( "4.7" ); + } + public void runJUnitTest (String version) throws Exception Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/concurrentjunit47/pom.xml URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/concurrentjunit47/pom.xml?rev=898206&view=auto ============================================================================== --- maven/surefire/trunk/surefire-integration-tests/src/test/resources/concurrentjunit47/pom.xml (added) +++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/concurrentjunit47/pom.xml Tue Jan 12 07:39:49 2010 @@ -0,0 +1,67 @@ + + + + + 4.0.0 + + org.apache.maven.plugins.surefire + junit47 + 1.0-SNAPSHOT + Test for JUnit 4.7 + + + + 4.7 + + + + + junit + junit + ${junitVersion} + test + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.5 + 1.5 + + + + org.apache.maven.plugins + maven-surefire-plugin + ${surefire.version} + + methods + 2 + + + + + + Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/concurrentjunit47/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/concurrentjunit47/pom.xml ------------------------------------------------------------------------------ svn:executable = * Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/concurrentjunit47/pom.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/concurrentjunit47/src/test/java/junit47/BasicTest.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/concurrentjunit47/src/test/java/junit47/BasicTest.java?rev=898206&view=auto ============================================================================== --- maven/surefire/trunk/surefire-integration-tests/src/test/resources/concurrentjunit47/src/test/java/junit47/BasicTest.java (added) +++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/concurrentjunit47/src/test/java/junit47/BasicTest.java Tue Jan 12 07:39:49 2010 @@ -0,0 +1,41 @@ +package concurrentjunit47.src.test.java.junit47; + +import org.junit.*; + + +public class BasicTest +{ + + private boolean setUpCalled = false; + + private static boolean tearDownCalled = false; + + @Before + public void setUp() + { + setUpCalled = true; + tearDownCalled = false; + System.out.println( "Called setUp" ); + } + + @After + public void tearDown() + { + setUpCalled = false; + tearDownCalled = true; + System.out.println( "Called tearDown" ); + } + + @Test + public void testSetUp() + { + Assert.assertTrue( "setUp was not called", setUpCalled ); + } + + @AfterClass + public static void oneTimeTearDown() + { + + } + +} \ No newline at end of file Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/concurrentjunit47/src/test/java/junit47/BasicTest.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/concurrentjunit47/src/test/java/junit47/BasicTest.java ------------------------------------------------------------------------------ svn:executable = * Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/concurrentjunit47/src/test/java/junit47/BasicTest.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreTestSet.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreTestSet.java?rev=898206&r1=898205&r2=898206&view=diff ============================================================================== --- maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreTestSet.java (original) +++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreTestSet.java Tue Jan 12 07:39:49 2010 @@ -79,10 +79,8 @@ public static void execute(Class[] classes, ReporterManager reportManager, JUnitCoreParameters jUnitCoreParameters) throws TestSetFailedException { - RunListener listener = new JUnitCoreTestSetReporter(reportManager); - if (jUnitCoreParameters.isAnyParallelitySelected()) { - listener = createRunListener(listener, jUnitCoreParameters.isConfigurableParallelComputerPresent()); - } + RunListener realTarget = new JUnitCoreTestSetReporter(reportManager); + RunListener listener = createRunListener(realTarget, jUnitCoreParameters.isConfigurableParallelComputerPresent()); Computer computer = getComputer(jUnitCoreParameters); try { runJunitCore(classes, computer, listener); @@ -94,7 +92,9 @@ private static RunListener createRunListener(RunListener realTarget, boolean configurableParallelComputerPresent) throws TestSetFailedException { - if (!configurableParallelComputerPresent) return new DemultiplexingRunListener(realTarget); + if (!configurableParallelComputerPresent) { + return new DemultiplexingRunListener(realTarget); + } try { Class cpcClass = Class.forName(demuxerClassName); Constructor constructor = cpcClass.getConstructor(RunListener.class); Modified: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreTestSetReporter.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreTestSetReporter.java?rev=898206&r1=898205&r2=898206&view=diff ============================================================================== --- maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreTestSetReporter.java (original) +++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreTestSetReporter.java Tue Jan 12 07:39:49 2010 @@ -21,6 +21,8 @@ import java.util.ResourceBundle; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.apache.maven.surefire.Surefire; import org.apache.maven.surefire.report.ReportEntry; @@ -33,10 +35,21 @@ class JUnitCoreTestSetReporter extends RunListener { + + private static final Pattern PARENS = Pattern.compile( + "^" + + "[^\\(\\)]+" + //non-parens + "\\((" + // then an open-paren (start matching a group) + "[^\\\\(\\\\)]+" + //non-parens + ")\\)" + + "$" ); // then a close-paren (end group match) + // Constants private static ResourceBundle bundle = ResourceBundle.getBundle( Surefire.SUREFIRE_BUNDLE_NAME ); + private Description currentRunStart; + private String currentClassName; private ReporterManager reportMgr; /** @@ -63,8 +76,10 @@ throws Exception { String rawString = bundle.getString( "testSetStarting" ); - ReportEntry report = new ReportEntry( description.getClassName(), description.getDisplayName(), rawString ); + currentClassName = extractClassName(description); + currentRunStart = description; + ReportEntry report = new ReportEntry( description.getClassName(), currentClassName, rawString ); this.reportMgr.testSetStarting( report ); } @@ -77,7 +92,7 @@ throws Exception { String rawString = bundle.getString( "testSetCompletedNormally" ); - ReportEntry report = new ReportEntry( result.getClass().getCanonicalName(), result.getClass().getName(), rawString ); + ReportEntry report = new ReportEntry( currentRunStart.getClassName(), currentClassName, rawString ); this.reportMgr.testSetCompleted( report ); this.reportMgr.reset(); } @@ -152,4 +167,13 @@ this.reportMgr.testSucceeded( report ); } } + + private String extractClassName( Description description ) + { + String displayName = description.getDisplayName(); + Matcher m = PARENS.matcher( displayName ); + if (!m.find()) return displayName; + return m.group( 1 ); + } + }