Return-Path: X-Original-To: apmail-maven-surefire-commits-archive@www.apache.org Delivered-To: apmail-maven-surefire-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3E9BD290C for ; Wed, 27 Apr 2011 21:20:43 +0000 (UTC) Received: (qmail 98635 invoked by uid 500); 27 Apr 2011 21:20:43 -0000 Delivered-To: apmail-maven-surefire-commits-archive@maven.apache.org Received: (qmail 98613 invoked by uid 500); 27 Apr 2011 21:20:43 -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 98604 invoked by uid 99); 27 Apr 2011 21:20:43 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 27 Apr 2011 21:20:43 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.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; Wed, 27 Apr 2011 21:20:38 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 908802388B3A; Wed, 27 Apr 2011 21:20:18 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: svn commit: r1097246 [5/5] - in /maven/surefire/trunk: maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/ maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ maven-surefire-common/src/main/java/org/apache/maven/plug... Date: Wed, 27 Apr 2011 21:20:16 -0000 To: surefire-commits@maven.apache.org From: krosenvold@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110427212018.908802388B3A@eris.apache.org> Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/failsafe-buildfail/pom.xml URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/failsafe-buildfail/pom.xml?rev=1097246&view=auto ============================================================================== --- maven/surefire/trunk/surefire-integration-tests/src/test/resources/failsafe-buildfail/pom.xml (added) +++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/failsafe-buildfail/pom.xml Wed Apr 27 21:20:12 2011 @@ -0,0 +1,83 @@ + + + + + 4.0.0 + localhost + working-directory-test + 1.0 + Run tests multiple times + + + junit + junit + 3.8.2 + test + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + ${surefire.version} + + + integration-test + + integration-test + + + ${project.build.directory}/failsafe-reports/failsafe-summary-1.xml + + + + acceptance-test + + integration-test + + + + **/AT*.java + **/*AT.java + **/*ATCase.java + + ${project.build.directory}/failsafe-reports/failsafe-summary-2.xml + + + + verify + + verify + + + + ${project.build.directory}/failsafe-reports/failsafe-summary-1.xml + ${project.build.directory}/failsafe-reports/failsafe-summary-2.xml + + + + + + + + + Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/failsafe-buildfail/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Copied: maven/surefire/trunk/surefire-integration-tests/src/test/resources/failsafe-buildfail/src/test/java/MyAT.java (from r1097226, maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/Surefire.java) URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/failsafe-buildfail/src/test/java/MyAT.java?p2=maven/surefire/trunk/surefire-integration-tests/src/test/resources/failsafe-buildfail/src/test/java/MyAT.java&p1=maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/Surefire.java&r1=1097226&r2=1097246&rev=1097246&view=diff ============================================================================== --- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/Surefire.java (original) +++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/failsafe-buildfail/src/test/java/MyAT.java Wed Apr 27 21:20:12 2011 @@ -1,5 +1,3 @@ -package org.apache.maven.surefire; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ package org.apache.maven.surefire; * "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 + * 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 @@ -18,13 +16,10 @@ package org.apache.maven.surefire; * specific language governing permissions and limitations * under the License. */ +import junit.framework.TestCase; -/** - * @author Jason van Zyl - * @version $Id$ - */ -public class Surefire -{ - // todo: Move for 2.7.1 - public static final String SUREFIRE_BUNDLE_NAME = "org.apache.maven.surefire.surefire"; +public class MyAT extends TestCase { + public void testSomething() { + assertTrue(false); + } } Copied: maven/surefire/trunk/surefire-integration-tests/src/test/resources/failsafe-buildfail/src/test/java/MyIT.java (from r1097226, maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/Surefire.java) URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/failsafe-buildfail/src/test/java/MyIT.java?p2=maven/surefire/trunk/surefire-integration-tests/src/test/resources/failsafe-buildfail/src/test/java/MyIT.java&p1=maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/Surefire.java&r1=1097226&r2=1097246&rev=1097246&view=diff ============================================================================== --- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/Surefire.java (original) +++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/failsafe-buildfail/src/test/java/MyIT.java Wed Apr 27 21:20:12 2011 @@ -1,5 +1,3 @@ -package org.apache.maven.surefire; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ package org.apache.maven.surefire; * "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 + * 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 @@ -19,12 +17,10 @@ package org.apache.maven.surefire; * under the License. */ -/** - * @author Jason van Zyl - * @version $Id$ - */ -public class Surefire -{ - // todo: Move for 2.7.1 - public static final String SUREFIRE_BUNDLE_NAME = "org.apache.maven.surefire.surefire"; +import junit.framework.TestCase; + +public class MyIT extends TestCase { + public void testSomething() { + assertTrue(true); + } } Modified: maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutput/pom.xml URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutput/pom.xml?rev=1097246&r1=1097245&r2=1097246&view=diff ============================================================================== --- maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutput/pom.xml (original) +++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutput/pom.xml Wed Apr 27 21:20:12 2011 @@ -33,6 +33,7 @@ ${forkMode} ${printSummary} true + ${reportFormat} ${redirect.to.file} **/Test*.java @@ -48,6 +49,7 @@ true once true + brief Copied: maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutputWithErrors/pom.xml (from r1097226, maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutput/pom.xml) URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutputWithErrors/pom.xml?p2=maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutputWithErrors/pom.xml&p1=maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutput/pom.xml&r1=1097226&r2=1097246&rev=1097246&view=diff ============================================================================== --- maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutput/pom.xml (original) +++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutputWithErrors/pom.xml Wed Apr 27 21:20:12 2011 @@ -32,8 +32,9 @@ ${forkMode} ${printSummary} - true - ${redirect.to.file} + ${userFile} + ${reportFormat} + ${redirect.to.file} **/Test*.java @@ -48,6 +49,8 @@ true once true + true + brief Copied: maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutputWithErrors/src/test/java/forkConsoleOutput/Test1.java (from r1097226, maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/NullOutputConsumer.java) URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutputWithErrors/src/test/java/forkConsoleOutput/Test1.java?p2=maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutputWithErrors/src/test/java/forkConsoleOutput/Test1.java&p1=maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/NullOutputConsumer.java&r1=1097226&r2=1097246&rev=1097246&view=diff ============================================================================== --- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/NullOutputConsumer.java (original) +++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutputWithErrors/src/test/java/forkConsoleOutput/Test1.java Wed Apr 27 21:20:12 2011 @@ -1,4 +1,4 @@ -package org.apache.maven.plugin.surefire.booterclient.output; +package forkConsoleOutput; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -19,34 +19,25 @@ package org.apache.maven.plugin.surefire * under the License. */ -import org.apache.maven.surefire.report.ReportEntry; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; -/** - * @author Kristian Rosenvold - */ -public class NullOutputConsumer implements OutputConsumer +public class Test1 { - public void consumeHeaderLine( String line ) - { - } - - public void consumeMessageLine( String line ) - { - } - - public void consumeFooterLine( String line ) - { - } - - public void consumeOutputLine( String line ) - { + @Test + public void test6281() { + System.out.println( "Test1 on" + Thread.currentThread().getName()); } - public void testSetStarting( ReportEntry reportEntry ) - { + @BeforeClass + public static void testWithFailingAssumption2() { + System.out.println( "BeforeTest1 on" + Thread.currentThread().getName()); + } + + @AfterClass + public static void testWithFailingAssumption3() { + System.out.println( "AfterTest1 on" + Thread.currentThread().getName()); } - public void testSetCompleted() - { - } } Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutputWithErrors/src/test/java/forkConsoleOutput/Test1.java ------------------------------------------------------------------------------ svn:eol-style = native Copied: maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutputWithErrors/src/test/java/forkConsoleOutput/Test2.java (from r1097226, maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/Surefire.java) URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutputWithErrors/src/test/java/forkConsoleOutput/Test2.java?p2=maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutputWithErrors/src/test/java/forkConsoleOutput/Test2.java&p1=maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/Surefire.java&r1=1097226&r2=1097246&rev=1097246&view=diff ============================================================================== --- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/Surefire.java (original) +++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutputWithErrors/src/test/java/forkConsoleOutput/Test2.java Wed Apr 27 21:20:12 2011 @@ -1,4 +1,4 @@ -package org.apache.maven.surefire; +package forkConsoleOutput; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -19,12 +19,14 @@ package org.apache.maven.surefire; * under the License. */ -/** - * @author Jason van Zyl - * @version $Id$ - */ -public class Surefire +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +public class Test2 { - // todo: Move for 2.7.1 - public static final String SUREFIRE_BUNDLE_NAME = "org.apache.maven.surefire.surefire"; + @Test + public void test6281() { + throw new RuntimeException("FailHere"); + } } Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutputWithErrors/src/test/java/forkConsoleOutput/Test2.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutputWithErrors/src/test/java/forkConsoleOutput/Test2.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Modified: maven/surefire/trunk/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/junit4/MockReporter.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/junit4/MockReporter.java?rev=1097246&r1=1097245&r2=1097246&view=diff ============================================================================== --- maven/surefire/trunk/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/junit4/MockReporter.java (original) +++ maven/surefire/trunk/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/junit4/MockReporter.java Wed Apr 27 21:20:12 2011 @@ -24,19 +24,16 @@ import java.util.List; import java.util.concurrent.atomic.AtomicInteger; import org.apache.maven.surefire.report.ReportEntry; import org.apache.maven.surefire.report.ReporterConfiguration; -import org.apache.maven.surefire.report.ReporterException; import org.apache.maven.surefire.report.RunListener; -/** Internal use only */ +/** + * Internal use only + */ public class MockReporter implements RunListener { private final List events = new ArrayList(); - public static final String RUN_STARTED = "RUN_STARTED"; - - public static final String RUN_COMPLETED = "RUN_COMPLETED"; - public static final String SET_STARTED = "SET_STARTED"; public static final String SET_COMPLETED = "SET_COMPLETED"; @@ -68,24 +65,12 @@ public class MockReporter } - public void runStarting() - { - events.add( RUN_STARTED ); - } - - public void runCompleted() - { - events.add( RUN_COMPLETED ); - } - public void testSetStarting( ReportEntry report ) - throws ReporterException { events.add( SET_STARTED ); } public void testSetCompleted( ReportEntry report ) - throws ReporterException { events.add( SET_COMPLETED ); } @@ -153,4 +138,8 @@ public class MockReporter public void testAssumptionFailure( ReportEntry report ) { } + + public void writeTestOutput( String output, boolean stdout ) + { + } } Modified: maven/surefire/trunk/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java?rev=1097246&r1=1097245&r2=1097246&view=diff ============================================================================== --- maven/surefire/trunk/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java (original) +++ maven/surefire/trunk/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java Wed Apr 27 21:20:12 2011 @@ -19,25 +19,25 @@ package org.apache.maven.surefire.junit; * under the License. */ +import java.util.Iterator; import org.apache.maven.surefire.common.junit3.JUnit3Reflector; import org.apache.maven.surefire.common.junit3.JUnit3TestChecker; import org.apache.maven.surefire.providerapi.AbstractProvider; import org.apache.maven.surefire.providerapi.ProviderParameters; -import org.apache.maven.surefire.report.RunListener; +import org.apache.maven.surefire.report.ConsoleOutputCapture; +import org.apache.maven.surefire.report.ConsoleOutputReceiver; import org.apache.maven.surefire.report.ReportEntry; import org.apache.maven.surefire.report.ReporterException; import org.apache.maven.surefire.report.ReporterFactory; +import org.apache.maven.surefire.report.RunListener; import org.apache.maven.surefire.report.SimpleReportEntry; import org.apache.maven.surefire.suite.RunResult; import org.apache.maven.surefire.testset.TestSetFailedException; import org.apache.maven.surefire.util.DirectoryScanner; import org.apache.maven.surefire.util.TestsToRun; -import java.util.Iterator; - /** * @author Kristian Rosenvold - * @noinspection UnusedDeclaration */ public class JUnit3Provider extends AbstractProvider @@ -75,8 +75,8 @@ public class JUnit3Provider } ReporterFactory reporterFactory = providerParameters.getReporterFactory(); - - RunListener reporter = reporterFactory.createReporter(); + final RunListener reporter = reporterFactory.createReporter(); + ConsoleOutputCapture.startCapture( (ConsoleOutputReceiver) reporter ); for ( Iterator iter = testsToRun.iterator(); iter.hasNext(); ) { Modified: maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java?rev=1097246&r1=1097245&r2=1097246&view=diff ============================================================================== --- maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java (original) +++ maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java Wed Apr 27 21:20:12 2011 @@ -19,17 +19,20 @@ package org.apache.maven.surefire.junit4 * under the License. */ -import org.apache.maven.surefire.Surefire; +import java.util.Iterator; +import java.util.List; import org.apache.maven.surefire.common.junit4.JUnit4RunListener; import org.apache.maven.surefire.common.junit4.JUnit4RunListenerFactory; import org.apache.maven.surefire.common.junit4.JUnit4TestChecker; import org.apache.maven.surefire.providerapi.AbstractProvider; import org.apache.maven.surefire.providerapi.ProviderParameters; +import org.apache.maven.surefire.report.ConsoleOutputCapture; +import org.apache.maven.surefire.report.ConsoleOutputReceiver; import org.apache.maven.surefire.report.PojoStackTraceWriter; -import org.apache.maven.surefire.report.RunListener; import org.apache.maven.surefire.report.ReportEntry; import org.apache.maven.surefire.report.ReporterException; import org.apache.maven.surefire.report.ReporterFactory; +import org.apache.maven.surefire.report.RunListener; import org.apache.maven.surefire.report.SimpleReportEntry; import org.apache.maven.surefire.suite.RunResult; import org.apache.maven.surefire.testset.TestSetFailedException; @@ -39,20 +42,12 @@ import org.apache.maven.surefire.util.Te import org.junit.runner.notification.RunNotifier; -import java.util.Iterator; -import java.util.List; -import java.util.ResourceBundle; - - /** * @author Kristian Rosenvold */ -@SuppressWarnings( { "UnusedDeclaration" } ) -public class JUnit4Provider extends AbstractProvider +public class JUnit4Provider + extends AbstractProvider { - - private static ResourceBundle bundle = ResourceBundle.getBundle( Surefire.SUREFIRE_BUNDLE_NAME ); - private final ClassLoader testClassLoader; private final DirectoryScanner directoryScanner; @@ -60,7 +55,7 @@ public class JUnit4Provider extends Abst private final List customRunListeners; private final JUnit4TestChecker jUnit4TestChecker; - + private final String requestedTestMethod; private TestsToRun testsToRun; @@ -79,10 +74,10 @@ public class JUnit4Provider extends Abst } - @SuppressWarnings( { "UnnecessaryUnboxing" } ) public RunResult invoke( Object forkTestSet ) throws TestSetFailedException, ReporterException { + long start = System.currentTimeMillis(); if ( testsToRun == null ) { testsToRun = forkTestSet == null ? scanClassPath() : TestsToRun.fromClass( (Class) forkTestSet ); @@ -92,22 +87,32 @@ public class JUnit4Provider extends Abst final ReporterFactory reporterFactory = providerParameters.getReporterFactory(); - RunListener reporter = reporterFactory.createReporter(); - JUnit4RunListener jUnit4TestSetReporter = new JUnit4RunListener( reporter ); + final RunListener reporter = reporterFactory.createReporter(); + //final AsynchRunListener asynchRunListener = new AsynchRunListener( reporter , "JUnitProvider"); + final RunListener asynchRunListener = reporter; + + ConsoleOutputCapture.startCapture( (ConsoleOutputReceiver) asynchRunListener ); + + JUnit4RunListener jUnit4TestSetReporter = new JUnit4RunListener( asynchRunListener ); + RunNotifier runNotifer = getRunNotifer( jUnit4TestSetReporter, customRunListeners ); for ( Class clazz : testsToRun.getLocatedClasses() ) { - executeTestSet( clazz, reporter, testClassLoader, runNotifer ); + executeTestSet( clazz, reporter, runNotifer ); } closeRunNotifer( jUnit4TestSetReporter, customRunListeners ); - return reporterFactory.close(); + ConsoleOutputReceiver consoleOutputReceiver = (ConsoleOutputReceiver) reporter; + final String s = "Done after " + ( System.currentTimeMillis() - start ); + consoleOutputReceiver.writeTestOutput( s.getBytes(), 0, s.getBytes().length, true ); + //asynchRunListener.close(); + return reporterFactory.close(); } - private void executeTestSet( Class clazz, RunListener reporter, ClassLoader classLoader, RunNotifier listeners ) + private void executeTestSet( Class clazz, RunListener reporter, RunNotifier listeners ) throws ReporterException, TestSetFailedException { final ReportEntry report = new SimpleReportEntry( this.getClass().getName(), clazz.getName() ); @@ -134,7 +139,8 @@ public class JUnit4Provider extends Abst } } - private RunNotifier getRunNotifer( org.junit.runner.notification.RunListener main, List others ) + private RunNotifier getRunNotifer( org.junit.runner.notification.RunListener main, + List others ) { RunNotifier fNotifier = new RunNotifier(); fNotifier.addListener( main ); @@ -147,7 +153,8 @@ public class JUnit4Provider extends Abst // I am not entierly sure as to why we do this explicit freeing, it's one of those // pieces of code that just seem to linger on in here ;) - private void closeRunNotifer( org.junit.runner.notification.RunListener main, List others ) + private void closeRunNotifer( org.junit.runner.notification.RunListener main, + List others ) { RunNotifier fNotifier = new RunNotifier(); fNotifier.removeListener( main ); @@ -193,9 +200,4 @@ public class JUnit4Provider extends Abst final String property = System.getProperty( "surefire.junit4.upgradecheck" ); return property != null; } - - public Boolean isRunnable() - { - return Boolean.TRUE; - } } Copied: maven/surefire/trunk/surefire-providers/surefire-junit4/src/test/java/org/apache/maven/surefire/junit4/JUnit4ProviderTest.java (from r1097226, maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/SupressHeaderOutputConsumerProxy.java) URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit4/src/test/java/org/apache/maven/surefire/junit4/JUnit4ProviderTest.java?p2=maven/surefire/trunk/surefire-providers/surefire-junit4/src/test/java/org/apache/maven/surefire/junit4/JUnit4ProviderTest.java&p1=maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/SupressHeaderOutputConsumerProxy.java&r1=1097226&r2=1097246&rev=1097246&view=diff ============================================================================== --- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/SupressHeaderOutputConsumerProxy.java (original) +++ maven/surefire/trunk/surefire-providers/surefire-junit4/src/test/java/org/apache/maven/surefire/junit4/JUnit4ProviderTest.java Wed Apr 27 21:20:12 2011 @@ -1,4 +1,4 @@ -package org.apache.maven.plugin.surefire.booterclient.output; +package org.apache.maven.surefire.junit4; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -19,33 +19,23 @@ package org.apache.maven.plugin.surefire * under the License. */ +import java.util.Properties; +import org.apache.maven.surefire.booter.BaseProviderFactory; +import org.apache.maven.surefire.testset.TestRequest; + +import junit.framework.TestCase; + /** - * Surefire output consumer that will take out the surefire header - * - * @author Carlos Sanchez - * @version $Id$ - * @since 2.1 + * @author Kristian Rosenvold */ -public class SupressHeaderOutputConsumerProxy - extends OutputConsumerProxy +public class JUnit4ProviderTest + extends TestCase { - - /** - * Create a consumer that will delegate all calls to the next filter but {@link #consumeHeaderLine(String)} - * - * @param nextFilter filter to delegate to - */ - public SupressHeaderOutputConsumerProxy( OutputConsumer nextFilter ) - { - super( nextFilter ); + public void testCreateProvider(){ + BaseProviderFactory providerParameters = new BaseProviderFactory(null); + providerParameters.setProviderProperties( new Properties() ); + providerParameters.setClassLoaders( this.getClass().getClassLoader(), this.getClass().getClassLoader() ); + providerParameters.setTestRequest( new TestRequest( null, null, null ) ); + assertNotNull(new JUnit4Provider( providerParameters )); } - - /** - * Do nothing - */ - public void consumeHeaderLine( String line ) - { - /* do nothing */ - } - } Propchange: maven/surefire/trunk/surefire-providers/surefire-junit4/src/test/java/org/apache/maven/surefire/junit4/JUnit4ProviderTest.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/surefire/trunk/surefire-providers/surefire-junit4/src/test/java/org/apache/maven/surefire/junit4/JUnit4ProviderTest.java ------------------------------------------------------------------------------ svn:keywords = "Author Date Id Revision" Modified: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ClassesParallelRunListener.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ClassesParallelRunListener.java?rev=1097246&r1=1097245&r2=1097246&view=diff ============================================================================== --- maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ClassesParallelRunListener.java (original) +++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ClassesParallelRunListener.java Wed Apr 27 21:20:12 2011 @@ -19,12 +19,11 @@ package org.apache.maven.surefire.junitc * under the License. */ +import java.util.Map; import org.apache.maven.surefire.report.ReporterConfiguration; import org.apache.maven.surefire.report.ReporterFactory; import org.apache.maven.surefire.testset.TestSetFailedException; -import java.util.Map; - /** * @author Kristian Rosenvold */ @@ -35,7 +34,7 @@ public class ClassesParallelRunListener ReporterConfiguration reporterConfiguration ) throws TestSetFailedException { - super( reporterFactory, false, reporterConfiguration, classMethodCounts ); + super( reporterFactory, false, classMethodCounts ); } @Override Modified: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConcurrentReporterManager.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConcurrentReporterManager.java?rev=1097246&r1=1097245&r2=1097246&view=diff ============================================================================== --- maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConcurrentReporterManager.java (original) +++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConcurrentReporterManager.java Wed Apr 27 21:20:12 2011 @@ -19,53 +19,41 @@ package org.apache.maven.surefire.junitc * under the License. */ -import org.apache.maven.surefire.report.RunListener; +import java.util.Map; +import org.apache.maven.surefire.report.ConsoleOutputReceiver; import org.apache.maven.surefire.report.ReportEntry; import org.apache.maven.surefire.report.ReporterConfiguration; -import org.apache.maven.surefire.report.ReporterException; import org.apache.maven.surefire.report.ReporterFactory; +import org.apache.maven.surefire.report.RunListener; import org.apache.maven.surefire.testset.TestSetFailedException; -import java.io.IOException; -import java.util.Map; - /** * @author Kristian Rosenvold */ public abstract class ConcurrentReporterManager - implements RunListener + implements RunListener, ConsoleOutputReceiver { private final Map classMethodCounts; - - private final ReporterConfiguration reporterConfiguration; + // private final ReporterConfiguration reporterConfiguration; private final ThreadLocal reporterManagerThreadLocal = new ThreadLocal(); private final boolean reportImmediately; - private final ConcurrentPrintStream out = new ConcurrentPrintStream( true ); - - private final ConcurrentPrintStream err = new ConcurrentPrintStream( false ); - private final ReporterFactory reporterFactory; ConcurrentReporterManager( ReporterFactory reporterFactory, boolean reportImmediately, - ReporterConfiguration reporterConfiguration, Map classMethodCounts ) + Map classMethodCounts ) throws TestSetFailedException { this.reportImmediately = reportImmediately; this.reporterFactory = reporterFactory; - this.reporterConfiguration = reporterConfiguration; this.classMethodCounts = classMethodCounts; // We must create the first reporterManager here, even though we will never use it. // There is some room for improvement here + // todo: Find out if needed for 2.8.1 this.reporterFactory.createReporter(); - // Important: We must capture System.out/System.err AFTER the reportManager captures stdout/stderr - // because we know how to demultiplex correctly. The redirection in reporterManager is basically - // ignored/unused because we use ConcurrentPrintStream. - System.setOut( out ); - System.setErr( err ); } public void testSetStarting( ReportEntry description ) @@ -73,20 +61,11 @@ public abstract class ConcurrentReporter } public void testSetCompleted( ReportEntry result ) - throws ReporterException { + final RunListener reporterManager = getReporterManager(); for ( TestSet testSet : classMethodCounts.values() ) { - testSet.replay( getReporterManager() ); - } - try - { - out.writeTo( reporterConfiguration.getOriginalSystemOut() ); - err.writeTo( reporterConfiguration.getOriginalSystemErr() ); - } - catch ( IOException e ) - { - throw new ReporterException( "When writing reports", e ); + testSet.replay( reporterManager ); } } @@ -183,4 +162,20 @@ public abstract class ConcurrentReporter !parallelBoth ); } + + public void writeTestOutput( byte[] buf, int off, int len, boolean stdout ) + { + TestMethod threadTestMethod = TestMethod.getThreadTestMethod(); + if ( threadTestMethod != null ) + { + final LogicalStream logicalStream = threadTestMethod.getLogicalStream(); + logicalStream.write( stdout, buf, off, len ); + } + else + { + // No test running, just dump the message "somewhere" + reporterFactory.createConsoleReporter().writeMessage( new String( buf, off, len ) ); + } + } + } Modified: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java?rev=1097246&r1=1097245&r2=1097246&view=diff ============================================================================== --- maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java (original) +++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java Wed Apr 27 21:20:12 2011 @@ -19,25 +19,26 @@ package org.apache.maven.surefire.junitc * under the License. */ +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import org.apache.maven.surefire.common.junit4.JUnit4RunListenerFactory; import org.apache.maven.surefire.common.junit4.JUnit4TestChecker; import org.apache.maven.surefire.providerapi.AbstractProvider; import org.apache.maven.surefire.providerapi.ProviderParameters; -import org.apache.maven.surefire.report.RunListener; +import org.apache.maven.surefire.report.ConsoleOutputCapture; +import org.apache.maven.surefire.report.ConsoleOutputReceiver; import org.apache.maven.surefire.report.ReporterConfiguration; import org.apache.maven.surefire.report.ReporterException; import org.apache.maven.surefire.report.ReporterFactory; +import org.apache.maven.surefire.report.RunListener; import org.apache.maven.surefire.suite.RunResult; import org.apache.maven.surefire.testset.TestSetFailedException; import org.apache.maven.surefire.util.DirectoryScanner; import org.apache.maven.surefire.util.ScannerFilter; import org.apache.maven.surefire.util.TestsToRun; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - /** * @author Kristian Rosenvold */ @@ -88,7 +89,7 @@ public class JUnitCoreProvider public RunResult invoke( Object forkTestSet ) throws TestSetFailedException, ReporterException { - final String message = "Concurrency config is " + jUnitCoreParameters.toString(); + final String message = "Concurrency config is " + jUnitCoreParameters.toString() + "\n"; final ReporterFactory reporterFactory = providerParameters.getReporterFactory(); reporterFactory.createConsoleReporter().writeMessage( message ); @@ -103,6 +104,9 @@ public class JUnitCoreProvider ConcurrentReporterManager.createInstance( testSetMap, reporterFactory, this.reporterConfiguration, jUnitCoreParameters.isParallelClasses(), jUnitCoreParameters.isParallelBoth() ); + + ConsoleOutputCapture.startCapture((ConsoleOutputReceiver) listener); + org.junit.runner.notification.RunListener jUnit4RunListener = new JUnitCoreRunListener( listener, testSetMap ); customRunListeners.add( 0, jUnit4RunListener ); Modified: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreWrapper.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreWrapper.java?rev=1097246&r1=1097245&r2=1097246&view=diff ============================================================================== --- maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreWrapper.java (original) +++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreWrapper.java Wed Apr 27 21:20:12 2011 @@ -19,14 +19,14 @@ package org.apache.maven.surefire.junitc * under the License. */ -import org.apache.maven.surefire.testset.TestSetFailedException; -import org.apache.maven.surefire.util.TestsToRun; - import java.util.List; import java.util.concurrent.ExecutionException; +import org.apache.maven.surefire.testset.TestSetFailedException; +import org.apache.maven.surefire.util.TestsToRun; import org.junit.runner.Computer; import org.junit.runner.JUnitCore; +import org.junit.runner.Result; import org.junit.runner.notification.RunListener; /** @@ -49,7 +49,17 @@ class JUnitCoreWrapper } try { - junitCore.run( computer, testsToRun.getLocatedClasses() ); + final Result run = junitCore.run( computer, testsToRun.getLocatedClasses() ); + + if ( run.getFailureCount() > 0 ) + { + // There is something interesting going on here; + // the "run" result can contain other exceptions that did not occur as + // part of the test run, for instance if something bad happened in the + // RunListener. But it also contains regular problems from the test-run. + // I am not entirely sure of what to do with this; it might even be + // that these errors are the correct errors to report back to the client. + } } finally { Modified: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/LogicalStream.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/LogicalStream.java?rev=1097246&r1=1097245&r2=1097246&view=diff ============================================================================== --- maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/LogicalStream.java (original) +++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/LogicalStream.java Wed Apr 27 21:20:12 2011 @@ -35,14 +35,17 @@ public class LogicalStream class Entry { final boolean stdout; + final byte[] b; + final int off; + final int len; Entry( boolean stdout, byte[] b, int off, int len ) { this.stdout = stdout; - this.b = ByteBuffer.copy( b, off, len); + this.b = ByteBuffer.copy( b, off, len ); this.off = 0; this.len = len; } @@ -65,9 +68,9 @@ public class LogicalStream reporter.writeDetailMessage( str ); } - public void writeDetails( ConsoleOutputReceiver outputReceiver) + public void writeDetails( ConsoleOutputReceiver outputReceiver ) { - outputReceiver.writeTestOutput( b, off, len , stdout ); + outputReceiver.writeTestOutput( b, off, len, stdout ); } @Override Modified: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/MethodsParallelRunListener.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/MethodsParallelRunListener.java?rev=1097246&r1=1097245&r2=1097246&view=diff ============================================================================== --- maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/MethodsParallelRunListener.java (original) +++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/MethodsParallelRunListener.java Wed Apr 27 21:20:12 2011 @@ -19,12 +19,11 @@ package org.apache.maven.surefire.junitc * under the License. */ +import java.util.Map; import org.apache.maven.surefire.report.ReporterConfiguration; import org.apache.maven.surefire.report.ReporterFactory; import org.apache.maven.surefire.testset.TestSetFailedException; -import java.util.Map; - /** * @author Kristian Rosenvold */ @@ -39,7 +38,7 @@ public class MethodsParallelRunListener ReporterConfiguration reporterConfiguration, boolean reportImmediately ) throws TestSetFailedException { - super( reporterFactory, reportImmediately, reporterConfiguration, classMethodCounts ); + super( reporterFactory, reportImmediately, classMethodCounts ); } @Override Modified: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestMethod.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestMethod.java?rev=1097246&r1=1097245&r2=1097246&view=diff ============================================================================== --- maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestMethod.java (original) +++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestMethod.java Wed Apr 27 21:20:12 2011 @@ -22,7 +22,7 @@ package org.apache.maven.surefire.junitc import org.apache.maven.surefire.report.ConsoleOutputReceiver; import org.apache.maven.surefire.report.ConsoleOutputReceiverForCurrentThread; import org.apache.maven.surefire.report.ReportEntry; -import org.apache.maven.surefire.report.Reporter; +import org.apache.maven.surefire.report.RunListener; /** * Represents the test-state of a single test method that is run. @@ -88,7 +88,7 @@ class TestMethod } - public void replay( Reporter reporter ) + public void replay( RunListener reporter ) throws Exception { @@ -101,16 +101,16 @@ class TestMethod reporter.testStarting( createReportEntry() ); if ( output != null ) { - output.writeDetails( reporter ); + output.writeDetails( ( (ConsoleOutputReceiver) reporter ) ); } if ( testFailure != null ) { - reporter.testFailed( testFailure, getStdout(), getStdErr() ); + reporter.testFailed( testFailure ); } else if ( testError != null ) { - reporter.testError( testError, getStdout(), getStdErr() ); + reporter.testError( testError ); } else { Modified: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestSet.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestSet.java?rev=1097246&r1=1097245&r2=1097246&view=diff ============================================================================== --- maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestSet.java (original) +++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestSet.java Wed Apr 27 21:20:12 2011 @@ -19,18 +19,17 @@ package org.apache.maven.surefire.junitc * under the License. */ -import org.apache.maven.surefire.report.RunListener; -import org.apache.maven.surefire.report.ReportEntry; -import org.apache.maven.surefire.report.Reporter; -import org.apache.maven.surefire.report.SimpleReportEntry; - import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; - +import org.apache.maven.surefire.report.ConsoleOutputReceiver; +import org.apache.maven.surefire.report.ReportEntry; +import org.apache.maven.surefire.report.RunListener; +import org.apache.maven.surefire.report.SimpleReportEntry; import org.apache.maven.surefire.util.NestedRuntimeException; + import org.junit.runner.Description; /** @@ -81,8 +80,10 @@ public class TestSet for ( TestMethod testMethod : testMethods ) { - testMethod.replay( (Reporter) target ); + testMethod.replay( target ); + testMethod.getLogicalStream().writeDetails( (ConsoleOutputReceiver) target ); } + report = createReportEntry( elapsed ); target.testSetCompleted( report ); Modified: maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/ConcurrentReporterManagerTest.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/ConcurrentReporterManagerTest.java?rev=1097246&r1=1097245&r2=1097246&view=diff ============================================================================== --- maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/ConcurrentReporterManagerTest.java (original) +++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/ConcurrentReporterManagerTest.java Wed Apr 27 21:20:12 2011 @@ -20,37 +20,33 @@ package org.apache.maven.surefire.junitcore; -import junit.framework.Assert; -import junit.framework.TestCase; -import junit.framework.TestSuite; -import org.apache.maven.surefire.report.ConsoleReporter; -import org.apache.maven.surefire.report.RunListener; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.PrintStream; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import org.apache.maven.plugin.surefire.report.ReporterManagerFactory; import org.apache.maven.surefire.report.ReporterConfiguration; import org.apache.maven.surefire.report.ReporterFactory; -import org.apache.maven.surefire.report.ReporterManagerFactory; +import org.apache.maven.surefire.report.RunListener; import org.apache.maven.surefire.report.RunStatistics; import org.apache.maven.surefire.testset.TestSetFailedException; + +import junit.framework.Assert; +import junit.framework.TestCase; +import junit.framework.TestSuite; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.Computer; import org.junit.runner.JUnitCore; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.PrintStream; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; - -import static junit.framework.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - /* * @author Kristian Rosenvold */ -public class ConcurrentReporterManagerTest extends TestCase +public class ConcurrentReporterManagerTest + extends TestCase { // Tests are in order of increasing complexity public void testNoErrorsCounting() @@ -176,7 +172,8 @@ public class ConcurrentReporterManagerTe { HashMap classMethodCounts = new HashMap(); final ReporterFactory reporterManagerFactory = createReporterFactory(); - org.junit.runner.notification.RunListener demultiplexingRunListener = createRunListener( reporterManagerFactory, classMethodCounts ); + org.junit.runner.notification.RunListener demultiplexingRunListener = + createRunListener( reporterManagerFactory, classMethodCounts ); JUnitCore jUnitCore = new JUnitCore(); @@ -188,7 +185,8 @@ public class ConcurrentReporterManagerTe return reporterManagerFactory.getGlobalRunStatistics(); } - private RunStatistics runClasses( ReporterFactory reporterManagerFactory, org.junit.runner.notification.RunListener demultiplexingRunListener, + private RunStatistics runClasses( ReporterFactory reporterManagerFactory, + org.junit.runner.notification.RunListener demultiplexingRunListener, Class... classes ) throws TestSetFailedException { @@ -202,7 +200,8 @@ public class ConcurrentReporterManagerTe return reporterManagerFactory.getGlobalRunStatistics(); } - private org.junit.runner.notification.RunListener createRunListener( ReporterFactory reporterFactory, Map testSetMap ) + private org.junit.runner.notification.RunListener createRunListener( ReporterFactory reporterFactory, + Map testSetMap ) throws TestSetFailedException { return new JUnitCoreRunListener( @@ -211,7 +210,7 @@ public class ConcurrentReporterManagerTe public ReporterConfiguration getReporterConfiguration() { - return new ReporterConfiguration( new ArrayList(), new File( "." ), true, null ); + return new ReporterConfiguration( new File( "." ), true ); } @@ -403,13 +402,12 @@ public class ConcurrentReporterManagerTe private ReporterFactory createReporterFactory() { ReporterConfiguration reporterConfiguration = getTestReporterConfiguration(); - return new ReporterManagerFactory( this.getClass().getClassLoader(), reporterConfiguration ); + return new ReporterManagerFactory( this.getClass().getClassLoader(), reporterConfiguration, Arrays.asList() ); } public static ReporterConfiguration getTestReporterConfiguration() { - return new ReporterConfiguration( Arrays.asList( ConsoleReporter.class.getName() ), null, Boolean.TRUE, - null ); + return new ReporterConfiguration( null, Boolean.TRUE ); } Modified: maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MavenSurefireJUnit47RunnerTest.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MavenSurefireJUnit47RunnerTest.java?rev=1097246&r1=1097245&r2=1097246&view=diff ============================================================================== --- maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MavenSurefireJUnit47RunnerTest.java (original) +++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MavenSurefireJUnit47RunnerTest.java Wed Apr 27 21:20:12 2011 @@ -16,17 +16,16 @@ */ package org.apache.maven.surefire.junitcore; -import junit.framework.TestCase; -import org.apache.maven.surefire.report.RunListener; -import org.apache.maven.surefire.report.ReporterConfiguration; -import org.apache.maven.surefire.report.ReporterFactory; -import org.apache.maven.surefire.report.ReporterManagerFactory; - import java.io.File; -import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; +import org.apache.maven.plugin.surefire.report.ReporterManagerFactory; +import org.apache.maven.surefire.report.ReporterConfiguration; +import org.apache.maven.surefire.report.ReporterFactory; +import org.apache.maven.surefire.report.RunListener; import junit.framework.Assert; +import junit.framework.TestCase; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.Computer; @@ -87,7 +86,8 @@ import org.junit.runner.notification.Fai * @author Aslak Knutsen * @version $Revision: $ */ -public class MavenSurefireJUnit47RunnerTest extends TestCase +public class MavenSurefireJUnit47RunnerTest + extends TestCase { /* @@ -120,13 +120,14 @@ public class MavenSurefireJUnit47RunnerT ReporterConfiguration reporterConfiguration = ConcurrentReporterManagerTest.getTestReporterConfiguration(); ReporterFactory reporterManagerFactory = - new ReporterManagerFactory( this.getClass().getClassLoader(), reporterConfiguration ); + new ReporterManagerFactory( this.getClass().getClassLoader(), reporterConfiguration, Arrays.asList() ); final HashMap classMethodCounts = new HashMap(); RunListener reporter = ConcurrentReporterManager.createInstance( classMethodCounts, reporterManagerFactory, - getReporterConfiguration(), false, false ); + getReporterConfiguration(), false, false ); - org.junit.runner.notification.RunListener concurrentReportingRunListener = new JUnitCoreRunListener( reporter, classMethodCounts ); + org.junit.runner.notification.RunListener concurrentReportingRunListener = + new JUnitCoreRunListener( reporter, classMethodCounts ); Computer computer = new Computer(); JUnitCore junitCore = new JUnitCore(); @@ -156,7 +157,7 @@ public class MavenSurefireJUnit47RunnerT private ReporterConfiguration getReporterConfiguration() { - return new ReporterConfiguration( new ArrayList(), new File( "." ), true, null ); + return new ReporterConfiguration( new File( "." ), true ); } /** Modified: maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java?rev=1097246&r1=1097245&r2=1097246&view=diff ============================================================================== --- maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java (original) +++ maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java Wed Apr 27 21:20:12 2011 @@ -19,31 +19,31 @@ package org.apache.maven.surefire.testng * under the License. */ +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.SortedMap; +import java.util.TreeMap; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.surefire.NonAbstractClassFilter; -import org.apache.maven.surefire.report.RunListener; +import org.apache.maven.surefire.report.ConsoleOutputCapture; +import org.apache.maven.surefire.report.ConsoleOutputReceiver; import org.apache.maven.surefire.report.ReportEntry; import org.apache.maven.surefire.report.ReporterException; import org.apache.maven.surefire.report.ReporterFactory; -import org.apache.maven.surefire.report.ReporterManagerFactory; +import org.apache.maven.surefire.report.RunListener; import org.apache.maven.surefire.report.SimpleReportEntry; import org.apache.maven.surefire.testset.TestSetFailedException; import org.apache.maven.surefire.util.DefaultDirectoryScanner; import org.apache.maven.surefire.util.DirectoryScanner; import org.apache.maven.surefire.util.TestsToRun; -import java.io.File; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.SortedMap; -import java.util.TreeMap; - /** * Test suite for TestNG based on a directory of Java test classes. Can also execute JUnit tests. * @@ -64,11 +64,12 @@ public class TestNGDirectoryTestSuite private SortedMap testSets; private final DirectoryScanner surefireDirectoryScanner; - + private String testMethodPattern; public TestNGDirectoryTestSuite( File basedir, ArrayList includes, ArrayList excludes, String testSourceDirectory, - String artifactVersion, Properties confOptions, File reportsDirectory, String testMethodPattern ) + String artifactVersion, Properties confOptions, File reportsDirectory, + String testMethodPattern ) { this.surefireDirectoryScanner = new DefaultDirectoryScanner( basedir, includes, excludes, "filesystem" ); @@ -77,7 +78,7 @@ public class TestNGDirectoryTestSuite this.testSourceDirectory = testSourceDirectory; this.reportsDirectory = reportsDirectory; - this.version = new DefaultArtifactVersion( artifactVersion ); + this.version = new DefaultArtifactVersion( artifactVersion ); this.testMethodPattern = testMethodPattern; } @@ -97,6 +98,8 @@ public class TestNGDirectoryTestSuite } RunListener reporter = reporterManagerFactory.createReporter(); + ConsoleOutputCapture.startCapture( (ConsoleOutputReceiver) reporter ); + startTestSuite( reporter, this ); TestNGExecutor.run( new Class[]{ (Class) testsToRun.iterator().next() }, this.testSourceDirectory, this.options, @@ -141,7 +144,9 @@ public class TestNGDirectoryTestSuite junitReportsDirectory = new File( reportsDirectory, "testng-junit-results" ); } - RunListener reporterManager = new SynchronizedReporterManager( reporterFactory.createReporter() ); +// RunListener reporterManager = new SynchronizedReporterManager( reporterFactory.createReporter() ); + RunListener reporterManager = reporterFactory.createReporter(); + ConsoleOutputCapture.startCapture( (ConsoleOutputReceiver) reporterManager ); startTestSuite( reporterManager, this ); Class[] testClasses = (Class[]) testNgTestClasses.toArray( new Class[testNgTestClasses.size()] ); @@ -170,7 +175,7 @@ public class TestNGDirectoryTestSuite } // single class test - public void execute( String testSetName, ReporterManagerFactory reporterManagerFactory, ClassLoader classLoader ) + public void execute( String testSetName, ReporterFactory reporterManagerFactory, ClassLoader classLoader ) throws ReporterException, TestSetFailedException { if ( testSets == null ) @@ -185,6 +190,8 @@ public class TestNGDirectoryTestSuite } RunListener reporter = reporterManagerFactory.createReporter(); + ConsoleOutputCapture.startCapture( (ConsoleOutputReceiver) reporter ); + startTestSuite( reporter, this ); TestNGExecutor.run( new Class[]{ testSet.getTestClass() }, this.testSourceDirectory, this.options, this.version, Modified: maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java?rev=1097246&r1=1097245&r2=1097246&view=diff ============================================================================== --- maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java (original) +++ maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java Wed Apr 27 21:20:12 2011 @@ -19,12 +19,15 @@ package org.apache.maven.surefire.testng * under the License. */ +import java.io.File; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.Properties; import org.apache.maven.surefire.providerapi.AbstractProvider; import org.apache.maven.surefire.providerapi.ProviderParameters; import org.apache.maven.surefire.report.ReporterConfiguration; import org.apache.maven.surefire.report.ReporterException; import org.apache.maven.surefire.report.ReporterFactory; -import org.apache.maven.surefire.report.ReporterManagerFactory; import org.apache.maven.surefire.suite.RunResult; import org.apache.maven.surefire.testset.DirectoryScannerParameters; import org.apache.maven.surefire.testset.TestArtifactInfo; @@ -34,11 +37,6 @@ import org.apache.maven.surefire.util.Di import org.apache.maven.surefire.util.NestedRuntimeException; import org.apache.maven.surefire.util.TestsToRun; -import java.io.File; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.Properties; - /** * @author Kristian Rosenvold * @noinspection UnusedDeclaration @@ -96,12 +94,12 @@ public class TestNGProvider testNGXmlTestSuite.locateTestSets( testClassLoader ); if ( forkTestSet != null && testRequest == null ) { - testNGXmlTestSuite.execute( (String) forkTestSet, (ReporterManagerFactory) reporterFactory, + testNGXmlTestSuite.execute( (String) forkTestSet, reporterFactory, testClassLoader ); } else { - testNGXmlTestSuite.execute( (ReporterManagerFactory) reporterFactory ); + testNGXmlTestSuite.execute( reporterFactory ); } } else Modified: maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGXmlTestSuite.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGXmlTestSuite.java?rev=1097246&r1=1097245&r2=1097246&view=diff ============================================================================== --- maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGXmlTestSuite.java (original) +++ maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGXmlTestSuite.java Wed Apr 27 21:20:12 2011 @@ -19,13 +19,6 @@ package org.apache.maven.surefire.testng * under the License. */ -import org.apache.maven.artifact.versioning.ArtifactVersion; -import org.apache.maven.artifact.versioning.DefaultArtifactVersion; -import org.apache.maven.surefire.report.RunListener; -import org.apache.maven.surefire.report.ReporterException; -import org.apache.maven.surefire.report.ReporterManagerFactory; -import org.apache.maven.surefire.testset.TestSetFailedException; - import java.io.File; import java.util.ArrayList; import java.util.HashMap; @@ -33,6 +26,14 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Properties; +import org.apache.maven.artifact.versioning.ArtifactVersion; +import org.apache.maven.artifact.versioning.DefaultArtifactVersion; +import org.apache.maven.surefire.report.ConsoleOutputCapture; +import org.apache.maven.surefire.report.ConsoleOutputReceiver; +import org.apache.maven.surefire.report.ReporterException; +import org.apache.maven.surefire.report.ReporterFactory; +import org.apache.maven.surefire.report.RunListener; +import org.apache.maven.surefire.testset.TestSetFailedException; /** * Handles suite xml file definitions for TestNG. @@ -76,21 +77,24 @@ public class TestNGXmlTestSuite this.reportsDirectory = reportsDirectory; } - public void execute( ReporterManagerFactory reporterManagerFactory ) + public void execute( ReporterFactory reporterManagerFactory ) throws ReporterException, TestSetFailedException { if ( testSets == null ) { throw new IllegalStateException( "You must call locateTestSets before calling execute" ); } - RunListener reporter = new SynchronizedReporterManager( reporterManagerFactory.createReporter() ); +// RunListener reporter = new SynchronizedReporterManager( reporterManagerFactory.createReporter() ); + RunListener reporter = reporterManagerFactory.createReporter(); + ConsoleOutputCapture.startCapture( (ConsoleOutputReceiver) reporter ); + TestNGDirectoryTestSuite.startTestSuite( reporter, this ); - TestNGExecutor.run( this.suiteFilePaths, this.testSourceDirectory, this.options, this.version, reporter, - this, reportsDirectory ); + TestNGExecutor.run( this.suiteFilePaths, this.testSourceDirectory, this.options, this.version, reporter, this, + reportsDirectory ); TestNGDirectoryTestSuite.finishTestSuite( reporter, this ); } - public void execute( String testSetName, ReporterManagerFactory reporterManagerFactory, ClassLoader classLoader ) + public void execute( String testSetName, ReporterFactory reporterManagerFactory, ClassLoader classLoader ) throws TestSetFailedException { throw new TestSetFailedException( "Cannot run individual test when suite files are specified" ); Modified: maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNgTestSuite.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNgTestSuite.java?rev=1097246&r1=1097245&r2=1097246&view=diff ============================================================================== --- maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNgTestSuite.java (original) +++ maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNgTestSuite.java Wed Apr 27 21:20:12 2011 @@ -19,12 +19,11 @@ package org.apache.maven.surefire.testng * under the License. */ +import java.util.Map; import org.apache.maven.surefire.report.ReporterException; -import org.apache.maven.surefire.report.ReporterManagerFactory; +import org.apache.maven.surefire.report.ReporterFactory; import org.apache.maven.surefire.testset.TestSetFailedException; -import java.util.Map; - /** * A complete test suite that contains one or more test sets. * @@ -33,7 +32,7 @@ import java.util.Map; public interface TestNgTestSuite { - void execute( String testSetName, ReporterManagerFactory reporterManagerFactory, ClassLoader classLoader ) + void execute( String testSetName, ReporterFactory reporterManagerFactory, ClassLoader classLoader ) throws ReporterException, TestSetFailedException; Map locateTestSets( ClassLoader classLoader ) Modified: maven/surefire/trunk/surefire-setup-integration-tests/pom.xml URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-setup-integration-tests/pom.xml?rev=1097246&r1=1097245&r2=1097246&view=diff ============================================================================== --- maven/surefire/trunk/surefire-setup-integration-tests/pom.xml (original) +++ maven/surefire/trunk/surefire-setup-integration-tests/pom.xml Wed Apr 27 21:20:12 2011 @@ -170,9 +170,15 @@ ${project.build.directory}/it-repo - - + + + org.apache.maven.surefire + surefire-shadefire + ${project.version} + + + maven-enforcer-plugin