From surefire-commits-returnzcarey@example.org Wed Mar 02 20:31:53 2011 Return-Path: <surefire-commits-returnzcarey@example.org> Delivered-To: zcarey@example.org Received: (qmail 82589 invoked from network); 2 Mar 2011 20:31:53 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 2 Mar 2011 20:31:53 -0000 Received: (qmail 29577 invoked by uid 500); 2 Mar 2011 20:31:53 -0000 Delivered-To: zcarey@example.org Received: (qmail 29535 invoked by uid 500); 2 Mar 2011 20:31:52 -0000 Mailing-List: contact zcarey@example.org; run by ezmlm Precedence: bulk List-Help: <mailto:zcarey@example.org> List-Unsubscribe: <mailto:zcarey@example.org> List-Post: <mailto:zcarey@example.org> List-Id: <surefire-commits.maven.apache.org> Reply-To: zcarey@example.org Delivered-To: mailing list zcarey@example.org Received: (qmail 29526 invoked by uid 99); 2 Mar 2011 20:31:52 -0000 Received: from athena.apache.org (HELO athena.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Mar 2011 20:31:52 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [83.161.120.155] (HELO eris.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Mar 2011 20:31:49 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 42F02238890D; Wed, 2 Mar 2011 20:30:51 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1076367 - in /maven/surefire/trunk: maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ surefire-api/src/main/java/org/apache/maven/surefire/booter/ surefire-api/src/main/java/org/apache/maven/surefire/provid... Date: Wed, 02 Mar 2011 20:30:50 -0000 To: zcarey@example.org From: zcarey@example.org X-Mailer: svnmailer-1.0.8 Message-Id: <zcarey@example.org> Author: krosenvold Date: Wed Mar 2 20:30:49 2011 New Revision: 1076367 URL: http://svn.apache.org/viewvc?rev=1076367&view=rev Log: [SUREFIRE-705] Fixed problem with timeout in parallel Analysis also revealed that SUREFIRE-468 needs to be reopened. Added: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkTimeoutException.java - copied, changed from r1075071, maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooterForkException.java maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/AbstractProvider.java - copied, changed from r1075071, maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooterForkException.java maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkTimeout.java (with props) maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/ForkTimeoutTest.java - copied, changed from r1075071, maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test-provider/src/main/java/org/apache/maven/surefire/testprovider/TestProvider.java maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire705ParallelForkTimeoutIT.java - copied, changed from r1075071, maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TimeoutForkedTestIT.java maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-timeout/ maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-timeout/pom.xml (with props) maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-timeout/src/ maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-timeout/src/test/ maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-timeout/src/test/java/ maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-timeout/src/test/java/forktimeout/ maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-timeout/src/test/java/forktimeout/BaseForkTimeout.java - copied, changed from r1075071, maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TimeoutForkedTestIT.java maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-timeout/src/test/java/forktimeout/Test1.java - copied, changed from r1075071, maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooterForkException.java maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-timeout/src/test/java/forktimeout/Test2.java - copied, changed from r1075071, maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooterForkException.java maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-timeout/src/test/java/forktimeout/Test3.java - copied, changed from r1075071, maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooterForkException.java maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-timeout/src/test/java/forktimeout/Test4.java - copied, changed from r1075071, maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooterForkException.java maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-timeout/src/test/java/forktimeout/Test5.java - copied, changed from r1075071, maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooterForkException.java Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/SurefireProvider.java maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterManagerFactory.java maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderConfiguration.java maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooterForkException.java maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireStarter.java maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TimeoutForkedTestIT.java maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test-provider/src/main/java/org/apache/maven/surefire/testprovider/TestProvider.java maven/surefire/trunk/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java?rev=1076367&r1=1076366&r2=1076367&view=diff ============================================================================== --- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java (original) +++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java Wed Mar 2 20:30:49 2011 @@ -36,6 +36,12 @@ import org.apache.maven.surefire.booter. import org.apache.maven.surefire.booter.SystemPropertyManager; import org.apache.maven.surefire.providerapi.SurefireProvider; import org.apache.maven.surefire.suite.RunResult; +import org.codehaus.plexus.util.IOUtil; +import org.codehaus.plexus.util.cli.CommandLineException; +import org.codehaus.plexus.util.cli.CommandLineTimeOutException; +import org.codehaus.plexus.util.cli.CommandLineUtils; +import org.codehaus.plexus.util.cli.Commandline; +import org.codehaus.plexus.util.cli.StreamConsumer; import java.io.File; import java.io.FileInputStream; @@ -44,13 +50,6 @@ import java.io.IOException; import java.util.Iterator; import java.util.Properties; -import org.codehaus.plexus.util.IOUtil; -import org.codehaus.plexus.util.cli.CommandLineException; -import org.codehaus.plexus.util.cli.CommandLineTimeOutException; -import org.codehaus.plexus.util.cli.CommandLineUtils; -import org.codehaus.plexus.util.cli.Commandline; -import org.codehaus.plexus.util.cli.StreamConsumer; - /** * Starts the fork or runs in-process. @@ -191,7 +190,7 @@ public class ForkStarter throw new SurefireBooterForkException( "Error creating properties files for forking", e ); } - final Classpath bootClasspathConfiguration = forkConfiguration.getBootClasspath(); + final Classpath bootClasspathConfiguration = forkConfiguration.getBootClasspath(); final Classpath additionlClassPathUrls = startupConfiguration.useSystemClassLoader() ? startupConfiguration.getClasspathConfiguration().getTestClasspath() : null; @@ -229,7 +228,8 @@ public class ForkStarter try { - returnCode = CommandLineUtils.executeCommandLine( cli, out, err, forkedProcessTimeoutInSeconds > 0 ? forkedProcessTimeoutInSeconds + 1 : 0 ); + returnCode = CommandLineUtils.executeCommandLine( cli, out, err, forkedProcessTimeoutInSeconds > 0 ? + forkedProcessTimeoutInSeconds: 0 ); } catch ( CommandLineTimeOutException e ) { @@ -240,6 +240,13 @@ public class ForkStarter throw new SurefireBooterForkException( "Error while executing forked tests.", e.getCause() ); } + /*if ( !providerConfiguration.isSurefireForkReturnCode( returnCode ) ) + { + throw new SurefireBooterForkException( "Uncontrolled error while forking surefire." + + "You need to inspect log files (with reportFormat=plain and redirectTestOutputToFile=true )" + + " to see stacktrace" ); + } */ + if ( startupConfiguration.isRedirectTestOutputToFile() ) { // ensure the FileOutputConsumerProxy flushes/closes the output file @@ -279,6 +286,7 @@ public class ForkStarter return returnCode; } + private ForkingStreamConsumer getForkingStreamConsumer( boolean showHeading, boolean showFooter, boolean redirectTestOutputToFile, boolean mustBeThreadSafe, boolean printSummary ) Copied: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkTimeoutException.java (from r1075071, maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooterForkException.java) URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkTimeoutException.java?p2=maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkTimeoutException.java&p1=maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooterForkException.java&r1=1075071&r2=1076367&rev=1076367&view=diff ============================================================================== --- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooterForkException.java (original) +++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkTimeoutException.java Wed Mar 2 20:30:49 2011 @@ -22,16 +22,8 @@ package org.apache.maven.surefire.booter import org.apache.maven.surefire.util.NestedCheckedException; /** - * Encapsulates exceptions thrown during Surefire forking. - * - * @version $Id$ + * @author Kristian Rosenvold */ -public class SurefireBooterForkException - extends NestedCheckedException +public class ForkTimeoutException extends NestedCheckedException { - - public SurefireBooterForkException( String message, Throwable cause ) - { - super( message, cause ); - } } Copied: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/AbstractProvider.java (from r1075071, maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooterForkException.java) URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/AbstractProvider.java?p2=maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/AbstractProvider.java&p1=maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooterForkException.java&r1=1075071&r2=1076367&rev=1076367&view=diff ============================================================================== --- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooterForkException.java (original) +++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/AbstractProvider.java Wed Mar 2 20:30:49 2011 @@ -1,4 +1,4 @@ -package org.apache.maven.surefire.booter; +package org.apache.maven.surefire.providerapi; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -19,19 +19,24 @@ package org.apache.maven.surefire.booter * under the License. */ -import org.apache.maven.surefire.util.NestedCheckedException; - /** - * Encapsulates exceptions thrown during Surefire forking. + * A provider base class that all providers should extend to shield themselves from interface changes * - * @version $Id$ + * @author Kristian Rosenvold */ -public class SurefireBooterForkException - extends NestedCheckedException +public abstract class AbstractProvider + implements SurefireProvider { + private final Thread creatingThread = Thread.currentThread(); - public SurefireBooterForkException( String message, Throwable cause ) + public void cancel() { - super( message, cause ); + synchronized ( creatingThread ) + { + if ( creatingThread.isAlive() ) + { + creatingThread.interrupt(); + } + } } } Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/SurefireProvider.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/SurefireProvider.java?rev=1076367&r1=1076366&r2=1076367&view=diff ============================================================================== --- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/SurefireProvider.java (original) +++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/SurefireProvider.java Wed Mar 2 20:30:49 2011 @@ -66,4 +66,22 @@ public interface SurefireProvider RunResult invoke( Object forkTestSet ) throws TestSetFailedException, ReporterException; + + /** + * Makes an attempt at cancelling the current run, giving the provider a chance to notify + * reporting that the remaining tests have been cancelled due to timeout. + * + * If the provider thinks it can terminate properly it is the responsibility of + * the invoke method to return a RunResult with a booter code of failure. + * + * It is up to the provider to find out how to implement this method properly. + * A provider may also choose to not do anything at all in this method, + * which means surefire will kill the forked process soon afterwards anyway. + * + * Will be called on a different thread than the one calling invoke. + */ + // Todo: Need to think a lot closer about how/if this works and if there is a use case for it. + // Killing a process is slightly non-deterministic + // And it + void cancel(); } Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterManagerFactory.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterManagerFactory.java?rev=1076367&r1=1076366&r2=1076367&view=diff ============================================================================== --- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterManagerFactory.java (original) +++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterManagerFactory.java Wed Mar 2 20:30:49 2011 @@ -27,7 +27,6 @@ import java.lang.reflect.Constructor; import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import java.util.Timer; /** * Creates ReporterManager instances for the providers. @@ -64,27 +63,12 @@ public class ReporterManagerFactory private final SystemStreamCapturer systemStreamCapturer = new SystemStreamCapturer(); - private final SurefireTimeoutMonitor timeoutTask; - - private final Timer timer; - public ReporterManagerFactory( ClassLoader surefireClassLoader, ReporterConfiguration reporterConfiguration ) { this.reportDefinitions = reporterConfiguration.getReports(); this.surefireClassLoader = surefireClassLoader; this.reporterConfiguration = reporterConfiguration; this.reports = instantiateReportsNewStyle( reportDefinitions, reporterConfiguration, surefireClassLoader ); - if ( reporterConfiguration.getForkTimeout() != null ) - { - timeoutTask = new SurefireTimeoutMonitor( reporterConfiguration ); - timer = new Timer( "Surefire fork timeout timer" ); - } - else - { - timeoutTask = null; - timer = null; - } - } public RunStatistics getGlobalRunStatistics() @@ -94,7 +78,6 @@ public class ReporterManagerFactory public Reporter createReporter() { - startTimer(); reports = instantiateReportsNewStyle( reportDefinitions, reporterConfiguration, surefireClassLoader ); return setupReporter( reports ); } @@ -124,7 +107,6 @@ public class ReporterManagerFactory public RunResult close() { warnIfNoTests(); - cancelTimerIfActive(); synchronized ( lock ) { if ( first != null ) @@ -190,21 +172,4 @@ public class ReporterManagerFactory new MulticastingReporter( reports ).writeMessage( "There are no tests to run." ); } } - - private void startTimer() - { - if ( timer != null ) - { - timer.schedule( timeoutTask, reporterConfiguration.getForkTimeout().intValue() * 1000 ); - } - } - - private void cancelTimerIfActive() - { - if ( timer != null ) - { - timer.cancel(); - } - } - } Added: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkTimeout.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkTimeout.java?rev=1076367&view=auto ============================================================================== --- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkTimeout.java (added) +++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkTimeout.java Wed Mar 2 20:30:49 2011 @@ -0,0 +1,72 @@ +package org.apache.maven.surefire.booter; + +/* + * 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.apache.maven.surefire.providerapi.SurefireProvider; +import org.apache.maven.surefire.report.ReporterConfiguration; + +import java.util.Timer; +import java.util.TimerTask; + +/** + * Handles timeout of the forked process. Basically disables reporting + * when the timeout has expired, to avoid leaving incorrect files on disk. + * + * @author Kristian Rosenvold + */ +class ForkTimeout +{ + + private final Timer timer; + + + ForkTimeout( int timeOutInMs, ReporterConfiguration reporterConfiguration, SurefireProvider surefireProvider ) + { + SurefireTimeoutMonitor timeoutTask = new SurefireTimeoutMonitor( reporterConfiguration, surefireProvider ); + timer = new Timer( "Surefire fork timeout timer" ); + timer.schedule( timeoutTask, timeOutInMs ); + } + + public void close() + { + timer.cancel(); + } + + private static class SurefireTimeoutMonitor + extends TimerTask + { + private final ReporterConfiguration reporterConfiguration; + private final SurefireProvider surefireProvider; + + + public SurefireTimeoutMonitor( ReporterConfiguration reporterConfiguration, SurefireProvider surefireProvider ) + { + this.reporterConfiguration = reporterConfiguration; + this.surefireProvider = surefireProvider; + } + + public void run() + { + reporterConfiguration.setTimedOut( true ); + surefireProvider.cancel(); + } + } + +} Propchange: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkTimeout.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderConfiguration.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderConfiguration.java?rev=1076367&r1=1076366&r2=1076367&view=diff ============================================================================== --- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderConfiguration.java (original) +++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderConfiguration.java Wed Mar 2 20:30:49 2011 @@ -148,5 +148,13 @@ public class ProviderConfiguration return (String) forkTestSet; } + public boolean isSurefireForkReturnCode( int returnCode ) + { + return TESTS_SUCCEEDED_EXIT_CODE == returnCode || + NO_TESTS_EXIT_CODE == returnCode || + TESTS_FAILED_EXIT_CODE == returnCode; + + } + } Modified: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooterForkException.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooterForkException.java?rev=1076367&r1=1076366&r2=1076367&view=diff ============================================================================== --- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooterForkException.java (original) +++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooterForkException.java Wed Mar 2 20:30:49 2011 @@ -34,4 +34,9 @@ public class SurefireBooterForkException { super( message, cause ); } + + public SurefireBooterForkException( String msg ) + { + super( msg ); + } } Modified: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireStarter.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireStarter.java?rev=1076367&r1=1076366&r2=1076367&view=diff ============================================================================== --- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireStarter.java (original) +++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireStarter.java Wed Mar 2 20:30:49 2011 @@ -20,6 +20,7 @@ package org.apache.maven.surefire.booter */ import org.apache.maven.surefire.providerapi.SurefireProvider; +import org.apache.maven.surefire.report.ReporterConfiguration; import org.apache.maven.surefire.report.ReporterException; import org.apache.maven.surefire.suite.RunResult; import org.apache.maven.surefire.testset.TestSetFailedException; Copied: maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/ForkTimeoutTest.java (from r1075071, maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test-provider/src/main/java/org/apache/maven/surefire/testprovider/TestProvider.java) URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/ForkTimeoutTest.java?p2=maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/ForkTimeoutTest.java&p1=maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test-provider/src/main/java/org/apache/maven/surefire/testprovider/TestProvider.java&r1=1075071&r2=1076367&rev=1076367&view=diff ============================================================================== --- maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test-provider/src/main/java/org/apache/maven/surefire/testprovider/TestProvider.java (original) +++ maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/ForkTimeoutTest.java Wed Mar 2 20:30:49 2011 @@ -1,4 +1,4 @@ -package org.apache.maven.surefire.testprovider; +package org.apache.maven.surefire.booter; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -19,45 +19,58 @@ package org.apache.maven.surefire.testpr * under the License. */ -import org.apache.maven.surefire.providerapi.ProviderParameters; +import org.apache.maven.surefire.providerapi.AbstractProvider; import org.apache.maven.surefire.providerapi.SurefireProvider; +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.TestSetFailedException; import java.util.Iterator; +import junit.framework.TestCase; + /** * @author Kristian Rosenvold */ -public class TestProvider - implements SurefireProvider +public class ForkTimeoutTest + extends TestCase { - private final ReporterFactory reporterManagerFactory; - private final ClassLoader testClassLoader; - - public TestProvider( ProviderParameters booterParameters ) + public void testClose() + throws Exception { - this.reporterManagerFactory = booterParameters.getReporterFactory(); - this.testClassLoader = booterParameters.getTestClassLoader(); - } - + final Integer forkTimeout1 = new Integer( 100 ); + SurefireProvider surefireProvider = new TestProvider(); + ReporterConfiguration reporterConfiguration = new ReporterConfiguration( null, null, null, forkTimeout1 ); + new ForkTimeout( 100, reporterConfiguration, surefireProvider ); + try + { + Thread.sleep( 1500 ); + } + catch ( InterruptedException ignore ) + { - public Boolean isRunnable() - { - return Boolean.TRUE; + } } - public Iterator getSuites() + public class TestProvider + extends AbstractProvider { - return null; - } - public RunResult invoke( Object forkTestSet ) - throws TestSetFailedException, ReporterException - { - return new RunResult( 1,0,0,2 ); + public TestProvider() + { + } + + public Iterator getSuites() + { + return null; + } + + public RunResult invoke( Object forkTestSet ) + throws TestSetFailedException, ReporterException + { + return new RunResult( 1, 0, 0, 2 ); + } } + } Copied: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire705ParallelForkTimeoutIT.java (from r1075071, maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TimeoutForkedTestIT.java) URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire705ParallelForkTimeoutIT.java?p2=maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire705ParallelForkTimeoutIT.java&p1=maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TimeoutForkedTestIT.java&r1=1075071&r2=1076367&rev=1076367&view=diff ============================================================================== --- maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TimeoutForkedTestIT.java (original) +++ maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire705ParallelForkTimeoutIT.java Wed Mar 2 20:30:49 2011 @@ -23,15 +23,15 @@ import org.apache.maven.it.VerificationE /** * Test * - * @author <a href="mailto:zcarey@example.org">Dan Fabulich</a> + * @author Kristian Rosenvold */ -public class TimeoutForkedTestIT +public class Surefire705ParallelForkTimeoutIT extends SurefireVerifierTestClass { - public TimeoutForkedTestIT() + public Surefire705ParallelForkTimeoutIT() { - super( "/timeout-forked" ); + super( "/fork-timeout" ); } public void testTimeoutForked() @@ -39,8 +39,9 @@ public class TimeoutForkedTestIT { try { - addGoal( "-DsleepLength=10000" ); - addGoal( "-DforkTimeout=1" ); + addGoal( "-Djunit.version=4.8.1" ); + addGoal( "-Djunit.parallel=classes" ); + addGoal( "-DtimeOut=1" ); executeTest(); verifyErrorFreeLog(); fail( "Build didn't fail, but it should have" ); @@ -48,7 +49,7 @@ public class TimeoutForkedTestIT catch ( VerificationException ignore ) { } - assertFalse( getSurefireReportsFile( "TEST-timeoutForked.BasicTest.xml" ).exists() ); - assertFalse( getSurefireReportsFile( "timeoutForked.BasicTest.txt" ).exists() ); + // assertFalse( getSurefireReportsFile( "TEST-timeoutForked.BasicTest.xml" ).exists() ); + // assertFalse( getSurefireReportsFile( "timeoutForked.BasicTest.txt" ).exists() ); } } Modified: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TimeoutForkedTestIT.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TimeoutForkedTestIT.java?rev=1076367&r1=1076366&r2=1076367&view=diff ============================================================================== --- maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TimeoutForkedTestIT.java (original) +++ maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TimeoutForkedTestIT.java Wed Mar 2 20:30:49 2011 @@ -48,7 +48,8 @@ public class TimeoutForkedTestIT catch ( VerificationException ignore ) { } - assertFalse( getSurefireReportsFile( "TEST-timeoutForked.BasicTest.xml" ).exists() ); - assertFalse( getSurefireReportsFile( "timeoutForked.BasicTest.txt" ).exists() ); + // SUREFIRE-468 test that had to be reverted due to SUREFIRE-705 + //assertFalse( getSurefireReportsFile( "TEST-timeoutForked.BasicTest.xml" ).exists() ); + // assertFalse( getSurefireReportsFile( "timeoutForked.BasicTest.txt" ).exists() ); } } Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-timeout/pom.xml URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-timeout/pom.xml?rev=1076367&view=auto ============================================================================== --- maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-timeout/pom.xml (added) +++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-timeout/pom.xml Wed Mar 2 20:30:49 2011 @@ -0,0 +1,49 @@ +<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>fork-timeout-test</artifactId> + <packaging>jar</packaging> + <version>1.0-SNAPSHOT</version> + <name>fork-timeout</name> + <url>http://maven.apache.org</url> + <properties> + <junit.version>4.8.1</junit.version> + <junit.parallel>classes</junit.parallel> + <forkMode>once</forkMode> + <timeOut>1</timeOut> + </properties> + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>${junit.version}</version> + </dependency> + </dependencies> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>2.3.2</version> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>${surefire.version}</version> + <configuration> + <forkMode>${forkMode}</forkMode> + <parallel>${junit.parallel}</parallel> + <threadCount>5</threadCount> + <redirectTestOutputToFile>true</redirectTestOutputToFile> + <forkedProcessTimeoutInSeconds>${timeOut}</forkedProcessTimeoutInSeconds> + <reportFormat>plain</reportFormat> + <useFile>true</useFile> + <includes> + <include>**/Test*.java</include> + </includes> + </configuration> + </plugin> + </plugins> + </build> +</project> Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-timeout/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Copied: maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-timeout/src/test/java/forktimeout/BaseForkTimeout.java (from r1075071, maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TimeoutForkedTestIT.java) URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-timeout/src/test/java/forktimeout/BaseForkTimeout.java?p2=maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-timeout/src/test/java/forktimeout/BaseForkTimeout.java&p1=maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TimeoutForkedTestIT.java&r1=1075071&r2=1076367&rev=1076367&view=diff ============================================================================== --- maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TimeoutForkedTestIT.java (original) +++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-timeout/src/test/java/forktimeout/BaseForkTimeout.java Wed Mar 2 20:30:49 2011 @@ -1,4 +1,5 @@ -package org.apache.maven.surefire.its; +package forktimeout; + /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,37 +19,35 @@ package org.apache.maven.surefire.its; * under the License. */ -import org.apache.maven.it.VerificationException; - -/** - * Test - * - * @author <a href="mailto:zcarey@example.org">Dan Fabulich</a> - */ -public class TimeoutForkedTestIT - extends SurefireVerifierTestClass +public abstract class BaseForkTimeout { - - public TimeoutForkedTestIT() + protected void dumpStuff( String prefix ) { - super( "/timeout-forked" ); + reallySleep( 990 ); + for ( int i = 0; i < 200; i++ ) + { + System.out.println( prefix + " with lots of output " + i ); + System.err.println( prefix + "e with lots of output " + i ); + } + System.out.println( prefix + "last line" ); + System.err.println( prefix + "e last line" ); } - public void testTimeoutForked() - throws Exception + private void reallySleep( long timeout ) { + long endAt = System.currentTimeMillis() + timeout; try { - addGoal( "-DsleepLength=10000" ); - addGoal( "-DforkTimeout=1" ); - executeTest(); - verifyErrorFreeLog(); - fail( "Build didn't fail, but it should have" ); + Thread.sleep( timeout ); + while ( System.currentTimeMillis() < endAt ) + { + Thread.yield(); + Thread.sleep( 5 ); + } } - catch ( VerificationException ignore ) + catch ( InterruptedException e ) { + throw new RuntimeException( e ); } - assertFalse( getSurefireReportsFile( "TEST-timeoutForked.BasicTest.xml" ).exists() ); - assertFalse( getSurefireReportsFile( "timeoutForked.BasicTest.txt" ).exists() ); } } Copied: maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-timeout/src/test/java/forktimeout/Test1.java (from r1075071, maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooterForkException.java) URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-timeout/src/test/java/forktimeout/Test1.java?p2=maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-timeout/src/test/java/forktimeout/Test1.java&p1=maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooterForkException.java&r1=1075071&r2=1076367&rev=1076367&view=diff ============================================================================== --- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooterForkException.java (original) +++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-timeout/src/test/java/forktimeout/Test1.java Wed Mar 2 20:30:49 2011 @@ -1,4 +1,4 @@ -package org.apache.maven.surefire.booter; +package forktimeout; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -19,19 +19,15 @@ package org.apache.maven.surefire.booter * under the License. */ -import org.apache.maven.surefire.util.NestedCheckedException; -/** - * Encapsulates exceptions thrown during Surefire forking. - * - * @version $Id$ - */ -public class SurefireBooterForkException - extends NestedCheckedException -{ +import org.junit.Test; - public SurefireBooterForkException( String message, Throwable cause ) - { - super( message, cause ); +public class Test1 extends BaseForkTimeout +{ + @Test + public void test690() { + dumpStuff( "test690" ); + System.out.println(" with lots of output "); + System.err.println( "e with lots of output "); } -} +} \ No newline at end of file Copied: maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-timeout/src/test/java/forktimeout/Test2.java (from r1075071, maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooterForkException.java) URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-timeout/src/test/java/forktimeout/Test2.java?p2=maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-timeout/src/test/java/forktimeout/Test2.java&p1=maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooterForkException.java&r1=1075071&r2=1076367&rev=1076367&view=diff ============================================================================== --- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooterForkException.java (original) +++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-timeout/src/test/java/forktimeout/Test2.java Wed Mar 2 20:30:49 2011 @@ -1,5 +1,4 @@ -package org.apache.maven.surefire.booter; - +package forktimeout; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -19,19 +18,13 @@ package org.apache.maven.surefire.booter * under the License. */ -import org.apache.maven.surefire.util.NestedCheckedException; -/** - * Encapsulates exceptions thrown during Surefire forking. - * - * @version $Id$ - */ -public class SurefireBooterForkException - extends NestedCheckedException -{ +import org.junit.Test; - public SurefireBooterForkException( String message, Throwable cause ) - { - super( message, cause ); +public class Test2 extends BaseForkTimeout +{ + @Test + public void test690_2() { + dumpStuff( "test690_2" ); } -} +} \ No newline at end of file Copied: maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-timeout/src/test/java/forktimeout/Test3.java (from r1075071, maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooterForkException.java) URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-timeout/src/test/java/forktimeout/Test3.java?p2=maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-timeout/src/test/java/forktimeout/Test3.java&p1=maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooterForkException.java&r1=1075071&r2=1076367&rev=1076367&view=diff ============================================================================== --- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooterForkException.java (original) +++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-timeout/src/test/java/forktimeout/Test3.java Wed Mar 2 20:30:49 2011 @@ -1,5 +1,4 @@ -package org.apache.maven.surefire.booter; - +package forktimeout; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -19,19 +18,15 @@ package org.apache.maven.surefire.booter * under the License. */ -import org.apache.maven.surefire.util.NestedCheckedException; -/** - * Encapsulates exceptions thrown during Surefire forking. - * - * @version $Id$ - */ -public class SurefireBooterForkException - extends NestedCheckedException +import org.junit.Test; + +public class Test3 extends BaseForkTimeout { - public SurefireBooterForkException( String message, Throwable cause ) - { - super( message, cause ); + @Test + public void test690_3() { + dumpStuff( "test690_3" ); } -} + +} \ No newline at end of file Copied: maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-timeout/src/test/java/forktimeout/Test4.java (from r1075071, maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooterForkException.java) URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-timeout/src/test/java/forktimeout/Test4.java?p2=maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-timeout/src/test/java/forktimeout/Test4.java&p1=maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooterForkException.java&r1=1075071&r2=1076367&rev=1076367&view=diff ============================================================================== --- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooterForkException.java (original) +++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-timeout/src/test/java/forktimeout/Test4.java Wed Mar 2 20:30:49 2011 @@ -1,5 +1,4 @@ -package org.apache.maven.surefire.booter; - +package forktimeout; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -19,19 +18,15 @@ package org.apache.maven.surefire.booter * under the License. */ -import org.apache.maven.surefire.util.NestedCheckedException; -/** - * Encapsulates exceptions thrown during Surefire forking. - * - * @version $Id$ - */ -public class SurefireBooterForkException - extends NestedCheckedException -{ +import org.junit.Test; - public SurefireBooterForkException( String message, Throwable cause ) - { - super( message, cause ); +public class Test4 + extends BaseForkTimeout +{ + @Test + public void test690_4() { + dumpStuff( "test690_4" ); } -} + +} \ No newline at end of file Copied: maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-timeout/src/test/java/forktimeout/Test5.java (from r1075071, maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooterForkException.java) URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-timeout/src/test/java/forktimeout/Test5.java?p2=maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-timeout/src/test/java/forktimeout/Test5.java&p1=maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooterForkException.java&r1=1075071&r2=1076367&rev=1076367&view=diff ============================================================================== --- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooterForkException.java (original) +++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-timeout/src/test/java/forktimeout/Test5.java Wed Mar 2 20:30:49 2011 @@ -1,5 +1,4 @@ -package org.apache.maven.surefire.booter; - +package forktimeout; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -19,19 +18,15 @@ package org.apache.maven.surefire.booter * under the License. */ -import org.apache.maven.surefire.util.NestedCheckedException; -/** - * Encapsulates exceptions thrown during Surefire forking. - * - * @version $Id$ - */ -public class SurefireBooterForkException - extends NestedCheckedException -{ +import org.junit.Test; - public SurefireBooterForkException( String message, Throwable cause ) - { - super( message, cause ); +public class Test5 + extends BaseForkTimeout +{ + @Test + public void test690_5() { + dumpStuff( "test690_5" ); } -} + +} \ No newline at end of file Modified: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test-provider/src/main/java/org/apache/maven/surefire/testprovider/TestProvider.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test-provider/src/main/java/org/apache/maven/surefire/testprovider/TestProvider.java?rev=1076367&r1=1076366&r2=1076367&view=diff ============================================================================== --- maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test-provider/src/main/java/org/apache/maven/surefire/testprovider/TestProvider.java (original) +++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test-provider/src/main/java/org/apache/maven/surefire/testprovider/TestProvider.java Wed Mar 2 20:30:49 2011 @@ -19,11 +19,10 @@ package org.apache.maven.surefire.testpr * under the License. */ +import org.apache.maven.surefire.providerapi.AbstractProvider; import org.apache.maven.surefire.providerapi.ProviderParameters; -import org.apache.maven.surefire.providerapi.SurefireProvider; 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.TestSetFailedException; @@ -32,8 +31,7 @@ import java.util.Iterator; /** * @author Kristian Rosenvold */ -public class TestProvider - implements SurefireProvider +public class TestProvider extends AbstractProvider { private final ReporterFactory reporterManagerFactory; private final ClassLoader testClassLoader; 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=1076367&r1=1076366&r2=1076367&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 Mar 2 20:30:49 2011 @@ -21,8 +21,8 @@ package org.apache.maven.surefire.junit; 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.providerapi.SurefireProvider; import org.apache.maven.surefire.report.ReportEntry; import org.apache.maven.surefire.report.Reporter; import org.apache.maven.surefire.report.ReporterException; @@ -39,8 +39,7 @@ import java.util.Iterator; * @author Kristian Rosenvold * @noinspection UnusedDeclaration */ -public class JUnit3Provider - implements SurefireProvider +public class JUnit3Provider extends AbstractProvider { private final ReporterFactory reporterFactory; 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=1076367&r1=1076366&r2=1076367&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 Mar 2 20:30:49 2011 @@ -23,8 +23,8 @@ import org.apache.maven.surefire.Surefir 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.providerapi.SurefireProvider; import org.apache.maven.surefire.report.PojoStackTraceWriter; import org.apache.maven.surefire.report.ReportEntry; import org.apache.maven.surefire.report.Reporter; @@ -36,20 +36,20 @@ import org.apache.maven.surefire.testset import org.apache.maven.surefire.util.DefaultDirectoryScanner; import org.apache.maven.surefire.util.DirectoryScanner; import org.apache.maven.surefire.util.TestsToRun; -import org.junit.runner.notification.RunListener; -import org.junit.runner.notification.RunNotifier; import java.util.Iterator; import java.util.List; import java.util.ResourceBundle; +import org.junit.runner.notification.RunListener; +import org.junit.runner.notification.RunNotifier; + /** * @author Kristian Rosenvold */ @SuppressWarnings( { "UnusedDeclaration" } ) -public class JUnit4Provider - implements SurefireProvider +public class JUnit4Provider extends AbstractProvider { private static ResourceBundle bundle = ResourceBundle.getBundle( Surefire.SUREFIRE_BUNDLE_NAME ); 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=1076367&r1=1076366&r2=1076367&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 Mar 2 20:30:49 2011 @@ -21,6 +21,7 @@ package org.apache.maven.surefire.junitc 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.providerapi.SurefireProvider; import org.apache.maven.surefire.report.Reporter; @@ -32,19 +33,19 @@ import org.apache.maven.surefire.testset import org.apache.maven.surefire.util.DirectoryScanner; import org.apache.maven.surefire.util.ScannerFilter; import org.apache.maven.surefire.util.TestsToRun; -import org.junit.runner.notification.RunListener; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import org.junit.runner.notification.RunListener; + /** * @author Kristian Rosenvold */ @SuppressWarnings( { "UnusedDeclaration" } ) -public class JUnitCoreProvider - implements SurefireProvider +public class JUnitCoreProvider extends AbstractProvider { private final ReporterFactory reporterFactory; 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=1076367&r1=1076366&r2=1076367&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 Mar 2 20:30:49 2011 @@ -19,8 +19,8 @@ package org.apache.maven.surefire.testng * under the License. */ +import org.apache.maven.surefire.providerapi.AbstractProvider; import org.apache.maven.surefire.providerapi.ProviderParameters; -import org.apache.maven.surefire.providerapi.SurefireProvider; import org.apache.maven.surefire.report.ReporterConfiguration; import org.apache.maven.surefire.report.ReporterException; import org.apache.maven.surefire.report.ReporterFactory; @@ -43,8 +43,7 @@ import java.util.Properties; * @author Kristian Rosenvold * @noinspection UnusedDeclaration */ -public class TestNGProvider - implements SurefireProvider +public class TestNGProvider extends AbstractProvider { private final Properties providerProperties; From surefire-commits-returnzcarey@example.org Thu Mar 03 11:37:11 2011 Return-Path: <surefire-commits-returnzcarey@example.org> Delivered-To: zcarey@example.org Received: (qmail 43678 invoked from network); 3 Mar 2011 11:37:11 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 3 Mar 2011 11:37:11 -0000 Received: (qmail 90619 invoked by uid 500); 3 Mar 2011 11:37:08 -0000 Delivered-To: zcarey@example.org Received: (qmail 90576 invoked by uid 500); 3 Mar 2011 11:37:08 -0000 Mailing-List: contact zcarey@example.org; run by ezmlm Precedence: bulk List-Help: <mailto:zcarey@example.org> List-Unsubscribe: <mailto:zcarey@example.org> List-Post: <mailto:zcarey@example.org> List-Id: <surefire-commits.maven.apache.org> Reply-To: zcarey@example.org Delivered-To: mailing list zcarey@example.org Received: (qmail 90567 invoked by uid 99); 3 Mar 2011 11:37:08 -0000 Received: from nike.apache.org (HELO nike.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Mar 2011 11:37:08 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [83.161.120.155] (HELO eris.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Mar 2011 11:37:07 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id E72892388A41; Thu, 3 Mar 2011 11:36:07 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1076592 - in /maven/surefire/trunk/maven-surefire-report-plugin: pom.xml src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportGenerator.java Date: Thu, 03 Mar 2011 11:36:07 -0000 To: zcarey@example.org From: zcarey@example.org X-Mailer: svnmailer-1.0.8 Message-Id: <zcarey@example.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: ltheussl Date: Thu Mar 3 11:36:07 2011 New Revision: 1076592 URL: http://svn.apache.org/viewvc?rev=1076592&view=rev Log: [SUREFIRE-566] upgrade to doxia 1.1 Modified: maven/surefire/trunk/maven-surefire-report-plugin/pom.xml maven/surefire/trunk/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportGenerator.java Modified: maven/surefire/trunk/maven-surefire-report-plugin/pom.xml URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-report-plugin/pom.xml?rev=1076592&r1=1076591&r2=1076592&view=diff ============================================================================== --- maven/surefire/trunk/maven-surefire-report-plugin/pom.xml (original) +++ maven/surefire/trunk/maven-surefire-report-plugin/pom.xml Thu Mar 3 11:36:07 2011 @@ -54,7 +54,7 @@ </distributionManagement> <properties> - <doxiaVersion>1.0</doxiaVersion> + <doxiaVersion>1.1.4</doxiaVersion> </properties> <dependencies> @@ -81,7 +81,7 @@ <dependency> <groupId>org.apache.maven.reporting</groupId> <artifactId>maven-reporting-impl</artifactId> - <version>2.0.5</version> + <version>2.1</version> </dependency> <!-- doxia --> @@ -92,6 +92,11 @@ </dependency> <dependency> <groupId>org.apache.maven.doxia</groupId> + <artifactId>doxia-core</artifactId> + <version>${doxiaVersion}</version> + </dependency> + <dependency> + <groupId>org.apache.maven.doxia</groupId> <artifactId>doxia-decoration-model</artifactId> <version>${doxiaVersion}</version> </dependency> Modified: maven/surefire/trunk/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportGenerator.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportGenerator.java?rev=1076592&r1=1076591&r2=1076592&view=diff ============================================================================== --- maven/surefire/trunk/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportGenerator.java (original) +++ maven/surefire/trunk/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportGenerator.java Thu Mar 3 11:36:07 2011 @@ -19,7 +19,10 @@ package org.apache.maven.plugins.surefir * under the License. */ +import org.apache.maven.doxia.markup.HtmlMarkup; import org.apache.maven.doxia.sink.Sink; +import org.apache.maven.doxia.sink.SinkEventAttributeSet; +import org.apache.maven.doxia.sink.SinkEventAttributes; import org.apache.maven.reporting.MavenReportException; import java.text.NumberFormat; @@ -64,30 +67,16 @@ public class SurefireReportGenerator sink.text( bundle.getString( "report.surefire.header" ) ); sink.title_(); - StringBuffer str = new StringBuffer(); - str.append( "<script type=\"text/javascript\">\n" ); - str.append( "function toggleDisplay(elementId) {\n" ); - str.append( " var elm = document.getElementById(elementId + 'error');\n" ); - str.append( " if (elm && typeof elm.style != \"undefined\") {\n" ); - str.append( " if (elm.style.display == \"none\") {\n" ); - str.append( " elm.style.display = \"\";\n" ); - str.append( " document.getElementById(elementId + 'off').style.display = \"none\";\n" ); - str.append( " document.getElementById(elementId + 'on').style.display = \"inline\";\n" ); - str.append( " }" ); - str.append( " else if (elm.style.display == \"\") {" ); - str.append( " elm.style.display = \"none\";\n" ); - str.append( " document.getElementById(elementId + 'off').style.display = \"inline\";\n" ); - str.append( " document.getElementById(elementId + 'on').style.display = \"none\";\n" ); - str.append( " } \n" ); - str.append( " } \n" ); - str.append( " }\n" ); - str.append( "</script>" ); - sink.rawText( str.toString() ); - sink.head_(); sink.body(); + SinkEventAttributeSet atts = new SinkEventAttributeSet(); + atts.addAttribute( SinkEventAttributes.TYPE, "text/javascript" ); + sink.unknown( "script", new Object[]{new Integer( HtmlMarkup.TAG_TYPE_START )}, atts ); + sink.unknown( "cdata", new Object[]{new Integer( HtmlMarkup.CDATA_TYPE ), javascriptToggleDisplayCode() }, null ); + sink.unknown( "script", new Object[]{new Integer( HtmlMarkup.TAG_TYPE_END )}, null ); + sink.section1(); sink.sectionTitle1(); sink.text( bundle.getString( "report.surefire.header" ) ); @@ -174,7 +163,7 @@ public class SurefireReportGenerator sink.lineBreak(); sink.paragraph(); - sink.rawText( bundle.getString( "report.surefire.text.note1" ) ); + sink.text( bundle.getString( "report.surefire.text.note1" ) ); sink.paragraph_(); sinkLineBreak( sink ); @@ -251,7 +240,7 @@ public class SurefireReportGenerator sink.lineBreak(); sink.paragraph(); - sink.rawText( bundle.getString( "report.surefire.text.note2" ) ); + sink.text( bundle.getString( "report.surefire.text.note2" ) ); sink.paragraph_(); packIter = suitePackages.keySet().iterator(); @@ -425,17 +414,31 @@ public class SurefireReportGenerator sinkLink( sink, testCase.getName(), "#" + testCase.getFullName() ); - sink.rawText( " <div class=\"detailToggle\" style=\"display:inline\">" ); + SinkEventAttributeSet atts = new SinkEventAttributeSet(); + atts.addAttribute( SinkEventAttributes.CLASS, "detailToggle" ); + atts.addAttribute( SinkEventAttributes.STYLE, "display:inline" ); + sink.unknown( "div", new Object[]{new Integer( HtmlMarkup.TAG_TYPE_START )}, atts ); sink.link( "javascript:toggleDisplay('" + toHtmlId( testCase.getFullName() ) + "');" ); - sink.rawText( "<span style=\"display: inline;\" " + "id=\"" + toHtmlId( testCase.getFullName() ) - + "off\">+</span><span id=\"" + toHtmlId( testCase.getFullName() ) + "on\" " - + "style=\"display: none;\">-</span> " ); + atts = new SinkEventAttributeSet(); + atts.addAttribute( SinkEventAttributes.STYLE, "display:inline;" ); + atts.addAttribute( SinkEventAttributes.ID, toHtmlId( testCase.getFullName() ) + "off" ); + sink.unknown( "span", new Object[]{new Integer( HtmlMarkup.TAG_TYPE_START )}, atts ); + sink.text( " + " ); + sink.unknown( "span", new Object[]{new Integer( HtmlMarkup.TAG_TYPE_END )}, null ); + + atts = new SinkEventAttributeSet(); + atts.addAttribute( SinkEventAttributes.STYLE, "display:none;" ); + atts.addAttribute( SinkEventAttributes.ID, toHtmlId( testCase.getFullName() ) + "on" ); + sink.unknown( "span", new Object[]{new Integer( HtmlMarkup.TAG_TYPE_START )}, atts ); + sink.text( " - " ); + sink.unknown( "span", new Object[]{new Integer( HtmlMarkup.TAG_TYPE_END )}, null ); + sink.text( "[ Detail ]" ); sink.link_(); - sink.rawText( "</div>" ); + sink.unknown( "div", new Object[]{new Integer( HtmlMarkup.TAG_TYPE_END )}, null ); sink.tableCell_(); } @@ -465,12 +468,14 @@ public class SurefireReportGenerator sinkCell( sink, "" ); sink.tableCell(); - sink.rawText( - " <div id=\"" + toHtmlId( testCase.getFullName() ) + "error\" style=\"display:none;\">" ); + SinkEventAttributeSet atts = new SinkEventAttributeSet(); + atts.addAttribute( SinkEventAttributes.ID, toHtmlId( testCase.getFullName() ) + "error" ); + atts.addAttribute( SinkEventAttributes.STYLE, "display:none;" ); + sink.unknown( "div", new Object[]{new Integer( HtmlMarkup.TAG_TYPE_START )}, atts ); Iterator it = detail.iterator(); - sink.verbatim( true ); + sink.verbatim( null ); while ( it.hasNext() ) { sink.text( it.next().toString() ); @@ -478,7 +483,7 @@ public class SurefireReportGenerator } sink.verbatim_(); - sink.rawText( "</div>" ); + sink.unknown( "div", new Object[]{new Integer( HtmlMarkup.TAG_TYPE_END )}, null ); sink.tableCell_(); sinkCell( sink, "" ); @@ -587,7 +592,9 @@ public class SurefireReportGenerator sinkCell( sink, "" ); sink.tableCell(); - sink.rawText( " <div id=\"" + tCase.getName() + "error\" >" ); + SinkEventAttributeSet atts = new SinkEventAttributeSet(); + atts.addAttribute( SinkEventAttributes.ID, tCase.getName() + "error" ); + sink.unknown( "div", new Object[]{new Integer( HtmlMarkup.TAG_TYPE_START )}, atts ); if ( xrefLocation != null ) { @@ -603,7 +610,7 @@ public class SurefireReportGenerator { sink.link_(); } - sink.rawText( "</div>" ); + sink.unknown( "div", new Object[]{new Integer( HtmlMarkup.TAG_TYPE_END )}, null ); sink.tableCell_(); @@ -726,4 +733,31 @@ public class SurefireReportGenerator sink.anchor( anchor ); sink.anchor_(); } + + private static String javascriptToggleDisplayCode() + { + final StringBuffer str = new StringBuffer( 64 ); + + // the javascript code is emitted within a commented CDATA section + // so we have to start with a newline and comment the CDATA closing in the end + str.append( "\n" ); + str.append( "function toggleDisplay(elementId) {\n" ); + str.append( " var elm = document.getElementById(elementId + 'error');\n" ); + str.append( " if (elm && typeof elm.style != \"undefined\") {\n" ); + str.append( " if (elm.style.display == \"none\") {\n" ); + str.append( " elm.style.display = \"\";\n" ); + str.append( " document.getElementById(elementId + 'off').style.display = \"none\";\n" ); + str.append( " document.getElementById(elementId + 'on').style.display = \"inline\";\n" ); + str.append( " }" ); + str.append( " else if (elm.style.display == \"\") {" ); + str.append( " elm.style.display = \"none\";\n" ); + str.append( " document.getElementById(elementId + 'off').style.display = \"inline\";\n" ); + str.append( " document.getElementById(elementId + 'on').style.display = \"none\";\n" ); + str.append( " } \n" ); + str.append( " } \n" ); + str.append( " }\n" ); + str.append( "//" ); + + return str.toString(); + } } From surefire-commits-returnzcarey@example.org Thu Mar 03 16:35:37 2011 Return-Path: <surefire-commits-returnzcarey@example.org> Delivered-To: zcarey@example.org Received: (qmail 31477 invoked from network); 3 Mar 2011 16:35:37 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 3 Mar 2011 16:35:37 -0000 Received: (qmail 28589 invoked by uid 500); 3 Mar 2011 16:35:37 -0000 Delivered-To: zcarey@example.org Received: (qmail 28566 invoked by uid 500); 3 Mar 2011 16:35:37 -0000 Mailing-List: contact zcarey@example.org; run by ezmlm Precedence: bulk List-Help: <mailto:zcarey@example.org> List-Unsubscribe: <mailto:zcarey@example.org> List-Post: <mailto:zcarey@example.org> List-Id: <surefire-commits.maven.apache.org> Reply-To: zcarey@example.org Delivered-To: mailing list zcarey@example.org Received: (qmail 28558 invoked by uid 99); 3 Mar 2011 16:35:37 -0000 Received: from athena.apache.org (HELO athena.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Mar 2011 16:35:37 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [83.161.120.155] (HELO eris.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Mar 2011 16:35:36 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 939142388A36; Thu, 3 Mar 2011 16:35:16 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1076671 - /maven/surefire/trunk/maven-failsafe-plugin/src/site/site.xml Date: Thu, 03 Mar 2011 16:35:16 -0000 To: zcarey@example.org From: zcarey@example.org X-Mailer: svnmailer-1.0.8 Message-Id: <zcarey@example.org> Author: krosenvold Date: Thu Mar 3 16:35:16 2011 New Revision: 1076671 URL: http://svn.apache.org/viewvc?rev=1076671&view=rev Log: [SUREFIRE-692] Wrong link to API Patch by Stehpan Birkner Modified: maven/surefire/trunk/maven-failsafe-plugin/src/site/site.xml Modified: maven/surefire/trunk/maven-failsafe-plugin/src/site/site.xml URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-failsafe-plugin/src/site/site.xml?rev=1076671&r1=1076670&r2=1076671&view=diff ============================================================================== --- maven/surefire/trunk/maven-failsafe-plugin/src/site/site.xml (original) +++ maven/surefire/trunk/maven-failsafe-plugin/src/site/site.xml Thu Mar 3 16:35:16 2011 @@ -25,7 +25,6 @@ <item name="Introduction" href="index.html"/> <item name="Goals" href="plugin-info.html"/> <item name="Usage" href="usage.html"/> - <item name="API" href="api.html"/> <item name="FAQ" href="faq.html"/> </menu> <menu name="Examples"> From surefire-commits-returnzcarey@example.org Thu Mar 03 16:36:59 2011 Return-Path: <surefire-commits-returnzcarey@example.org> Delivered-To: zcarey@example.org Received: (qmail 41250 invoked from network); 3 Mar 2011 16:36:59 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 3 Mar 2011 16:36:59 -0000 Received: (qmail 31718 invoked by uid 500); 3 Mar 2011 16:36:59 -0000 Delivered-To: zcarey@example.org Received: (qmail 31690 invoked by uid 500); 3 Mar 2011 16:36:59 -0000 Mailing-List: contact zcarey@example.org; run by ezmlm Precedence: bulk List-Help: <mailto:zcarey@example.org> List-Unsubscribe: <mailto:zcarey@example.org> List-Post: <mailto:zcarey@example.org> List-Id: <surefire-commits.maven.apache.org> Reply-To: zcarey@example.org Delivered-To: mailing list zcarey@example.org Received: (qmail 31683 invoked by uid 99); 3 Mar 2011 16:36:59 -0000 Received: from nike.apache.org (HELO nike.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Mar 2011 16:36:59 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [83.161.120.155] (HELO eris.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Mar 2011 16:36:54 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id B33A52388A02; Thu, 3 Mar 2011 16:36:32 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1076672 - in /maven/surefire/trunk: maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ surefire-booter/src/main/java/org/apa... Date: Thu, 03 Mar 2011 16:36:32 -0000 To: zcarey@example.org From: zcarey@example.org X-Mailer: svnmailer-1.0.8 Message-Id: <zcarey@example.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: krosenvold Date: Thu Mar 3 16:36:32 2011 New Revision: 1076672 URL: http://svn.apache.org/viewvc?rev=1076672&view=rev Log: [SUREFIRE-702] Improve transformation from properties->classpath Based on patch by Stephan Birkner, modified by me. Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterConstants.java maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/Classpath.java maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ClasspathConfiguration.java maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PropertiesWrapper.java maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/ClasspathTest.java maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/PropertiesWrapperTest.java Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java?rev=1076672&r1=1076671&r2=1076672&view=diff ============================================================================== --- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java (original) +++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java Thu Mar 3 16:36:32 2011 @@ -77,7 +77,7 @@ public class BooterSerializer new Object[]{ BooterConstants.DIRSCANNER_OPTIONS, booterConfiguration.getDirScannerParamsArray() } ); addPropertiesForTypeHolder( params, properties.getProperties(), BooterConstants.DIRSCANNER_PROPERTY_PREFIX ); - providerConfiguration.getClasspathConfiguration().setForkProperties( properties.getProperties() ); + providerConfiguration.getClasspathConfiguration().setForkProperties( properties); TestArtifactInfo testNg = booterConfiguration.getTestArtifact(); if ( testNg != null ) Modified: maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java?rev=1076672&r1=1076671&r2=1076672&view=diff ============================================================================== --- maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java (original) +++ maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java Thu Mar 3 16:36:32 2011 @@ -24,15 +24,14 @@ import java.io.FileInputStream; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; -import java.util.List; import java.util.Properties; import junit.framework.TestCase; -import org.apache.maven.surefire.booter.BooterConstants; import org.apache.maven.surefire.booter.BooterDeserializer; import org.apache.maven.surefire.booter.ClassLoaderConfiguration; import org.apache.maven.surefire.booter.ClasspathConfiguration; +import org.apache.maven.surefire.booter.PropertiesWrapper; import org.apache.maven.surefire.booter.ProviderConfiguration; import org.apache.maven.surefire.booter.StartupConfiguration; import org.apache.maven.surefire.booter.SystemPropertyManager; @@ -49,13 +48,10 @@ import org.apache.maven.surefire.testset public class BooterDeserializerStartupConfigurationTest extends TestCase { + private final ClasspathConfiguration classpathConfiguration = createClasspathConfiguration(); private final String aTest = "aTest"; - private final String aUserRequestedTest = "aUserRequestedTest"; - - private final String aUserRequestedTestMethod = "aUserRequestedTestMethod"; - public void testProvider() throws IOException { @@ -65,18 +61,25 @@ public class BooterDeserializerStartupCo public void testClassPathConfiguration() throws IOException { - final ClasspathConfiguration classpathConfiguration = + ClasspathConfiguration reloadedClasspathConfiguration = getReloadedStartupConfiguration().getClasspathConfiguration(); - Properties props = new Properties(); - classpathConfiguration.setForkProperties( props ); - List testClassPathUrls = classpathConfiguration.getTestClasspath().getClassPath(); - assertEquals( "true", props.get( BooterConstants.ENABLE_ASSERTIONS ) ); - assertEquals( "true", props.get( BooterConstants.CHILD_DELEGATION ) ); - assertEquals( 2, testClassPathUrls.size() ); - assertEquals( "CP1", testClassPathUrls.get( 0 ) ); - assertEquals( "CP2", testClassPathUrls.get( 1 ) ); - assertEquals( "SP1", props.get( BooterConstants.SUREFIRE_CLASSPATHURL + "0" ) ); - assertEquals( "SP2", props.get( BooterConstants.SUREFIRE_CLASSPATHURL + "1" ) ); + assertEquals( classpathConfiguration, reloadedClasspathConfiguration ); + } + + private void assertEquals( ClasspathConfiguration expectedConfiguration, ClasspathConfiguration actualConfiguration ) + { + assertEquals( expectedConfiguration.getTestClasspath().getClassPath(), + actualConfiguration.getTestClasspath().getClassPath() ); + Properties propertiesForExpectedConfiguration = getPropertiesForClasspathConfiguration( expectedConfiguration ); + Properties propertiesForActualConfiguration = getPropertiesForClasspathConfiguration( actualConfiguration ); + assertEquals( propertiesForExpectedConfiguration, propertiesForActualConfiguration ); + } + + private Properties getPropertiesForClasspathConfiguration( ClasspathConfiguration configuration ) + { + Properties properties = new Properties(); + configuration.setForkProperties( new PropertiesWrapper( properties )); + return properties; } public void testClassLoaderConfiguration() @@ -94,6 +97,15 @@ public class BooterDeserializerStartupCo assertEquals( current, saveAndReload( testStartupConfiguration ).isManifestOnlyJarRequestedAndUsable() ); } + private ClasspathConfiguration createClasspathConfiguration() + { + ClasspathConfiguration classpathConfiguration = new ClasspathConfiguration( true, true ); + classpathConfiguration.addClasspathUrl( "CP1" ); + classpathConfiguration.addClasspathUrl( "CP2" ); + classpathConfiguration.addSurefireClasspathUrl( "SP1" ); + classpathConfiguration.addSurefireClasspathUrl( "SP2" ); + return classpathConfiguration; + } public static ClassLoaderConfiguration getSystemClassLoaderConfiguration() throws IOException @@ -137,8 +149,11 @@ public class BooterDeserializerStartupCo new DirectoryScannerParameters( cwd, new ArrayList(), new ArrayList(), Boolean.TRUE, "hourly" ); ReporterConfiguration reporterConfiguration = new ReporterConfiguration( new ArrayList(), cwd, Boolean.TRUE, null ); + String aUserRequestedTest = "aUserRequestedTest"; + String aUserRequestedTestMethod = "aUserRequestedTestMethod"; TestRequest testSuiteDefinition = - new TestRequest( Arrays.asList( getSuiteXmlFileStrings() ), getTestSourceDirectory(), aUserRequestedTest, aUserRequestedTestMethod ); + new TestRequest( Arrays.asList( getSuiteXmlFileStrings() ), getTestSourceDirectory(), aUserRequestedTest, + aUserRequestedTestMethod ); return new ProviderConfiguration( directoryScannerParameters, true, reporterConfiguration, new TestArtifactInfo( "5.0", "ABC" ), testSuiteDefinition, new Properties(), aTest ); @@ -146,11 +161,6 @@ public class BooterDeserializerStartupCo private StartupConfiguration getTestStartupConfiguration( ClassLoaderConfiguration classLoaderConfiguration ) { - ClasspathConfiguration classpathConfiguration = new ClasspathConfiguration( true, true ); - classpathConfiguration.addClasspathUrl( "CP1" ); - classpathConfiguration.addClasspathUrl( "CP2" ); - classpathConfiguration.addSurefireClasspathUrl( "SP1" ); - classpathConfiguration.addSurefireClasspathUrl( "SP2" ); return new StartupConfiguration( "com.provider", classpathConfiguration, classLoaderConfiguration, false, false, false ); } Modified: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterConstants.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterConstants.java?rev=1076672&r1=1076671&r2=1076672&view=diff ============================================================================== --- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterConstants.java (original) +++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterConstants.java Thu Mar 3 16:36:32 2011 @@ -34,10 +34,6 @@ public interface BooterConstants String REPORT_PROPERTY_PREFIX = "report."; String PARAMS_SUFIX = ".params"; String TYPES_SUFIX = ".types"; - String CLASSPATH_URL = "classPathUrl."; - String SUREFIRE_CLASSPATHURL = "surefireClassPathUrl."; - String CHILD_DELEGATION = "childDelegation"; - String ENABLE_ASSERTIONS = "enableAssertions"; String USESYSTEMCLASSLOADER = "useSystemClassLoader"; String USEMANIFESTONLYJAR = "useManifestOnlyJar"; String FAILIFNOTESTS = "failIfNoTests"; Modified: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java?rev=1076672&r1=1076671&r2=1076672&view=diff ============================================================================== --- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java (original) +++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java Thu Mar 3 16:36:32 2011 @@ -96,20 +96,14 @@ public class BooterDeserializer public StartupConfiguration getProviderConfiguration() throws IOException { - boolean enableAssertions = properties.getBooleanProperty( ENABLE_ASSERTIONS ); - boolean childDelegation = properties.getBooleanProperty( CHILD_DELEGATION ); boolean useSystemClassLoader = properties.getBooleanProperty( USESYSTEMCLASSLOADER ); boolean useManifestOnlyJar = properties.getBooleanProperty( USEMANIFESTONLYJAR ); String providerConfiguration = properties.getProperty( PROVIDER_CONFIGURATION ); - Classpath classpath = Classpath.readFromForkProperties( properties, CLASSPATH_URL ); - Classpath sureFireClasspath = Classpath.readFromForkProperties( properties, SUREFIRE_CLASSPATHURL ); - ClassLoaderConfiguration classLoaderConfiguration = new ClassLoaderConfiguration( useSystemClassLoader, useManifestOnlyJar ); - ClasspathConfiguration classpathConfiguration = - new ClasspathConfiguration( classpath, sureFireClasspath, enableAssertions, childDelegation ); + ClasspathConfiguration classpathConfiguration = new ClasspathConfiguration( properties ); return StartupConfiguration.inForkedVm( providerConfiguration, classpathConfiguration, classLoaderConfiguration ); Modified: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/Classpath.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/Classpath.java?rev=1076672&r1=1076671&r2=1076672&view=diff ============================================================================== --- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/Classpath.java (original) +++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/Classpath.java Thu Mar 3 16:36:32 2011 @@ -24,10 +24,8 @@ import org.apache.maven.surefire.util.Ur import java.io.File; import java.net.MalformedURLException; import java.util.ArrayList; -import java.util.Collection; import java.util.Iterator; import java.util.List; -import java.util.Properties; /** * An ordered set of classpath elements @@ -36,12 +34,6 @@ import java.util.Properties; */ public class Classpath { - static Classpath readFromForkProperties( PropertiesWrapper properties, String prefix ) - { - List elements = properties.getStringList( prefix ); - return new Classpath( elements ); - } - public static Classpath join( Classpath firstClasspath, Classpath secondClasspath ) { Classpath joinedClasspath = new Classpath(); @@ -74,7 +66,7 @@ public class Classpath } } - private void addElements( Collection additionalElements ) + private void addElements( List additionalElements ) { for ( Iterator it = additionalElements.iterator(); it.hasNext(); ) { @@ -109,15 +101,6 @@ public class Classpath return urls; } - void writeToForkProperties( Properties properties, String prefix ) - { - for ( int i = 0; i < elements.size(); ++i ) - { - String element = (String) elements.get( i ); - properties.setProperty( prefix + i, element ); - } - } - public void writeToSystemProperty( String propertyName ) { StringBuffer sb = new StringBuffer(); @@ -127,4 +110,26 @@ public class Classpath } System.setProperty( propertyName, sb.toString() ); } + + public boolean equals( Object o ) + { + if ( this == o ) + { + return true; + } + if ( o == null || getClass() != o.getClass() ) + { + return false; + } + + Classpath classpath = (Classpath) o; + + return !( elements != null ? !elements.equals( classpath.elements ) : classpath.elements != null ); + + } + + public int hashCode() + { + return elements != null ? elements.hashCode() : 0; + } } Modified: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ClasspathConfiguration.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ClasspathConfiguration.java?rev=1076672&r1=1076671&r2=1076672&view=diff ============================================================================== --- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ClasspathConfiguration.java (original) +++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ClasspathConfiguration.java Thu Mar 3 16:36:32 2011 @@ -27,7 +27,6 @@ import java.net.MalformedURLException; import java.net.URL; import java.util.Iterator; import java.util.List; -import java.util.Properties; /** * Represents the classpaths for the BooterConfiguration. @@ -40,6 +39,13 @@ import java.util.Properties; */ public class ClasspathConfiguration { + private static final String CHILD_DELEGATION = "childDelegation"; + + private static final String ENABLE_ASSERTIONS = "enableAssertions"; + + private static final String CLASSPATH = "classPathUrl."; + + private static final String SUREFIRE_CLASSPATH = "surefireClassPathUrl."; private final Classpath classpathUrls; @@ -59,11 +65,15 @@ public class ClasspathConfiguration this( new Classpath(), new Classpath(), enableAssertions, childDelegation ); } - /* - * Reads the config from the supplied stream. Closes the stream. - */ - public ClasspathConfiguration( Classpath classPathUrls, Classpath surefireClassPathUrls, boolean enableAssertions, - boolean childDelegation ) + ClasspathConfiguration( PropertiesWrapper properties ) + { + this( properties.getClasspath( CLASSPATH ), + properties.getClasspath( SUREFIRE_CLASSPATH ), + properties.getBooleanProperty( ENABLE_ASSERTIONS ), properties.getBooleanProperty( CHILD_DELEGATION ) ); + } + + private ClasspathConfiguration( Classpath classPathUrls, Classpath surefireClassPathUrls, boolean enableAssertions, + boolean childDelegation ) { this.enableAssertions = enableAssertions; this.childDelegation = childDelegation; @@ -71,12 +81,12 @@ public class ClasspathConfiguration this.surefireClasspathUrls = surefireClassPathUrls; } - public void setForkProperties( Properties properties ) + public void setForkProperties( PropertiesWrapper properties ) { - classpathUrls.writeToForkProperties( properties, BooterConstants.CLASSPATH_URL ); - surefireClasspathUrls.writeToForkProperties( properties, BooterConstants.SUREFIRE_CLASSPATHURL ); - properties.setProperty( BooterConstants.ENABLE_ASSERTIONS, String.valueOf( enableAssertions ) ); - properties.setProperty( BooterConstants.CHILD_DELEGATION, String.valueOf( childDelegation ) ); + properties.setClasspath( CLASSPATH, classpathUrls ); + properties.setClasspath( SUREFIRE_CLASSPATH, classpathUrls ); + properties.setProperty( ENABLE_ASSERTIONS, String.valueOf( enableAssertions ) ); + properties.setProperty( CHILD_DELEGATION, String.valueOf( childDelegation ) ); } private static Method assertionStatusMethod; Modified: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PropertiesWrapper.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PropertiesWrapper.java?rev=1076672&r1=1076671&r2=1076672&view=diff ============================================================================== --- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PropertiesWrapper.java (original) +++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PropertiesWrapper.java Thu Mar 3 16:36:32 2011 @@ -234,6 +234,22 @@ public class PropertiesWrapper } } + Classpath getClasspath( String prefix ) + { + List elements = getStringList( prefix ); + return new Classpath( elements ); + } + + public void setClasspath( String prefix, Classpath classpath ) + { + List classpathElements = classpath.getClassPath(); + for ( int i = 0; i < classpathElements.size(); ++i ) + { + String element = (String) classpathElements.get( i ); + setProperty( prefix + i, element ); + } + } + public void setProperty( String key, Integer integer ) { if ( integer != null ) Modified: maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/ClasspathTest.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/ClasspathTest.java?rev=1076672&r1=1076671&r2=1076672&view=diff ============================================================================== --- maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/ClasspathTest.java (original) +++ maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/ClasspathTest.java Thu Mar 3 16:36:32 2011 @@ -21,7 +21,6 @@ package org.apache.maven.surefire.booter import java.io.File; import java.util.List; -import java.util.Properties; import junit.framework.TestCase; @@ -73,17 +72,6 @@ public class ClasspathTest assertTrue( asUrlList.get( 1 ).toString().endsWith( DUMMY_URL_2 ) ); } - public void testSetForkProperties() - throws Exception - { - Properties properties = new Properties(); - createClasspathWithTwoElements().writeToForkProperties( properties, "test" ); - assertEquals( DUMMY_URL_1, properties.get( "test0" ) ); - assertEquals( DUMMY_URL_2, properties.get( "test1" ) ); - } - - - public void testShouldJoinTwoNullClasspaths() { Classpath joinedClasspath = Classpath.join( null, null ); @@ -111,21 +99,7 @@ public class ClasspathTest Classpath joinedClasspath = Classpath.join( firstClasspath, secondClasspath ); assertClasspathConsistsOfElements( joinedClasspath, new String[] { DUMMY_URL_1 } ); } - - public void testShouldReadEmptyClasspathFromForkProperties() { - PropertiesWrapper properties = new PropertiesWrapper( new Properties() ); - Classpath classpath = Classpath.readFromForkProperties( properties, "test" ); - assertEmptyClasspath(classpath); - } - - public void testShouldReadClasspathWithToElementsFromForkProperties() { - PropertiesWrapper properties = new PropertiesWrapper( new Properties() ); - properties.setProperty( "test0", DUMMY_URL_1 ); - properties.setProperty( "test1", DUMMY_URL_2 ); - Classpath classpath = Classpath.readFromForkProperties( properties, "test" ); - assertClasspathConsistsOfElements( classpath, new String[] { DUMMY_URL_1, DUMMY_URL_2 } ); - } - + public void testShouldNotBeAbleToRemoveElement() throws Exception { Modified: maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/PropertiesWrapperTest.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/PropertiesWrapperTest.java?rev=1076672&r1=1076671&r2=1076672&view=diff ============================================================================== --- maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/PropertiesWrapperTest.java (original) +++ maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/PropertiesWrapperTest.java Thu Mar 3 16:36:32 2011 @@ -51,4 +51,61 @@ public class PropertiesWrapperTest assertEquals( "String2", test.get( 1 ) ); } + + private static final String DUMMY_PREFIX = "dummyPrefix"; + + private static final String FIRST_ELEMENT = "foo0"; + + private static final String SECOND_ELEMENT = "foo1"; + + private final Properties properties = new Properties(); + + + private final PropertiesWrapper mapper = new PropertiesWrapper( properties ); + private final Classpath classpathWithTwoElements = createClasspathWithTwoElements(); + + public void testReadFromProperties() + throws Exception + { + properties.put( DUMMY_PREFIX + "0", FIRST_ELEMENT ); + properties.put( DUMMY_PREFIX + "1", SECOND_ELEMENT ); + Classpath recreatedClasspath = readClasspathFromProperties(); + assertEquals( classpathWithTwoElements, recreatedClasspath ); + } + + public void testReadFromPropertiesWithEmptyProperties() + throws Exception + { + Classpath recreatedClasspath = readClasspathFromProperties(); + assertTrue( recreatedClasspath.getClassPath().isEmpty() ); + } + + public void testWriteToProperties() + throws Exception + { + mapper.setClasspath( DUMMY_PREFIX, classpathWithTwoElements); + assertEquals( FIRST_ELEMENT, mapper.getProperty( DUMMY_PREFIX + "0" ) ); + assertEquals( SECOND_ELEMENT, mapper.getProperty( DUMMY_PREFIX + "1" ) ); + } + + public void testRoundtrip() + throws Exception + { + mapper.setClasspath( DUMMY_PREFIX, classpathWithTwoElements); + Classpath recreatedClasspath = readClasspathFromProperties(); + assertEquals( classpathWithTwoElements, recreatedClasspath ); + } + + private Classpath createClasspathWithTwoElements() + { + Classpath classpath = new Classpath(); + classpath.addClassPathElementUrl( FIRST_ELEMENT ); + classpath.addClassPathElementUrl( SECOND_ELEMENT ); + return classpath; + } + + private Classpath readClasspathFromProperties() + { + return mapper.getClasspath( DUMMY_PREFIX); + } } From surefire-commits-returnzcarey@example.org Thu Mar 03 16:39:47 2011 Return-Path: <surefire-commits-returnzcarey@example.org> Delivered-To: zcarey@example.org Received: (qmail 42792 invoked from network); 3 Mar 2011 16:39:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 3 Mar 2011 16:39:47 -0000 Received: (qmail 37595 invoked by uid 500); 3 Mar 2011 16:39:47 -0000 Delivered-To: zcarey@example.org Received: (qmail 37573 invoked by uid 500); 3 Mar 2011 16:39:47 -0000 Mailing-List: contact zcarey@example.org; run by ezmlm Precedence: bulk List-Help: <mailto:zcarey@example.org> List-Unsubscribe: <mailto:zcarey@example.org> List-Post: <mailto:zcarey@example.org> List-Id: <surefire-commits.maven.apache.org> Reply-To: zcarey@example.org Delivered-To: mailing list zcarey@example.org Received: (qmail 37566 invoked by uid 99); 3 Mar 2011 16:39:47 -0000 Received: from nike.apache.org (HELO nike.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Mar 2011 16:39:47 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [83.161.120.155] (HELO eris.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Mar 2011 16:39:41 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 7247E238899C; Thu, 3 Mar 2011 16:39:20 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1076673 - in /maven/surefire/trunk: maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ surefire-booter/src/main/java/org/apache/maven/sur... Date: Thu, 03 Mar 2011 16:39:20 -0000 To: zcarey@example.org From: zcarey@example.org X-Mailer: svnmailer-1.0.8 Message-Id: <zcarey@example.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: krosenvold Date: Thu Mar 3 16:39:19 2011 New Revision: 1076673 URL: http://svn.apache.org/viewvc?rev=1076673&view=rev Log: o Minor cleanups around classpath construction Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ProviderInfo.java maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireDependencyResolver.java maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/Classpath.java maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ClasspathConfiguration.java maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/ClasspathTest.java 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=1076673&r1=1076672&r2=1076673&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 Thu Mar 3 16:39:19 2011 @@ -357,58 +357,45 @@ public abstract class AbstractSurefireMo ClassLoaderConfiguration classLoaderConfiguration ) throws MojoExecutionException, MojoFailureException { - final ClasspathConfiguration classpathConfiguration = - new ClasspathConfiguration( isEnableAssertions(), isChildDelegation() ); - String providerName; try { provider.addProviderProperties(); - provider.addProviderArtifactToSurefireClasspath( classpathConfiguration ); - providerName = provider.getProviderName(); - } - catch ( ArtifactNotFoundException e ) - { - throw new MojoExecutionException( - "Unable to locate required surefire provider dependency: " + e.getMessage(), e ); - } - catch ( ArtifactResolutionException e ) - { - throw new MojoExecutionException( "Error to resolving surefire provider dependency: " + e.getMessage(), e ); - } + String providerName = provider.getProviderName(); + final Classpath providerClasspath = provider.getProviderClasspath(); + final Classpath testClasspath = generateTestClasspath(); + + logClasspath( testClasspath, "test classpath" ); + logClasspath( testClasspath, "provider classpath" ); + final ClasspathConfiguration classpathConfiguration =new ClasspathConfiguration( testClasspath, providerClasspath, + isEnableAssertions(), isChildDelegation() ); - List classpathElements; - try - { - classpathElements = generateTestClasspath(); + return new StartupConfiguration( providerName, classpathConfiguration, classLoaderConfiguration, + forkConfiguration.isForking(), false, isRedirectTestOutputToFile() ); } catch ( DependencyResolutionRequiredException e ) { - throw new MojoExecutionException( "Unable to generate test classpath: " + e, e ); + throw new MojoExecutionException( "Unable to generate classpath: " + e, e ); } catch ( ArtifactResolutionException e ) { - throw new MojoExecutionException( "Unable to generate test classpath: " + e, e ); + throw new MojoExecutionException( "Unable to generate classpath: " + e, e ); } catch ( ArtifactNotFoundException e ) { - throw new MojoExecutionException( "Unable to generate test classpath: " + e, e ); + throw new MojoExecutionException( "Unable to generate classpath: " + e, e ); } catch ( InvalidVersionSpecificationException e ) { - throw new MojoExecutionException( "Unable to generate test classpath: " + e, e ); + throw new MojoExecutionException( "Unable to generate classpath: " + e, e ); } - addClasspathElementsToClasspathConfiguration( classpathElements, classpathConfiguration ); - return new StartupConfiguration( providerName, classpathConfiguration, classLoaderConfiguration, - forkConfiguration.isForking(), false, isRedirectTestOutputToFile() ); } - private void addClasspathElementsToClasspathConfiguration( List classpathElements, - ClasspathConfiguration classpathConfiguration ) + public void logClasspath( Classpath classpath, String descriptor ) { - getLog().debug( "Test classpath:" ); - for ( Iterator i = classpathElements.iterator(); i.hasNext(); ) + getLog().debug( descriptor + " classpath:" ); + for ( Iterator i = classpath.getClassPath().iterator(); i.hasNext(); ) { String classpathElement = (String) i.next(); if ( classpathElement == null ) @@ -418,11 +405,11 @@ public abstract class AbstractSurefireMo else { getLog().debug( " " + classpathElement ); - classpathConfiguration.addClasspathUrl( classpathElement ); } } } + private boolean isSpecificTestSpecified() { return getTest() != null; @@ -727,13 +714,14 @@ public abstract class AbstractSurefireMo * when dependency resolution fails * @throws org.apache.maven.plugin.MojoExecutionException * upon other problems - * @throws InvalidVersionSpecificationException - * @throws MojoFailureException - * @throws ArtifactNotFoundException - * @throws ArtifactResolutionException + * @throws InvalidVersionSpecificationException when it happens + * @throws MojoFailureException when it happens + * @throws ArtifactNotFoundException when it happens + * @throws ArtifactResolutionException when it happens */ - public List generateTestClasspath() - throws DependencyResolutionRequiredException, MojoExecutionException, MojoFailureException, InvalidVersionSpecificationException, ArtifactResolutionException, ArtifactNotFoundException + public Classpath generateTestClasspath() + throws DependencyResolutionRequiredException, MojoExecutionException, InvalidVersionSpecificationException, + MojoFailureException, ArtifactResolutionException, ArtifactNotFoundException { List classpath = new ArrayList( 2 + getProject().getArtifacts().size() ); @@ -774,11 +762,14 @@ public abstract class AbstractSurefireMo for ( Iterator iter = getAdditionalClasspathElements().iterator(); iter.hasNext(); ) { String classpathElement = (String) iter.next(); - classpath.add( classpathElement ); + if (classpathElement != null){ + classpath.add( classpathElement ); + } } } // adding TestNG MethodSelector to the classpath + // Todo: move if ( getTestNgArtifact() != null ) { Artifact testNgUtils = getTestNgUtilsArtifact(); @@ -787,7 +778,7 @@ public abstract class AbstractSurefireMo } - return classpath; + return new Classpath(classpath); } protected Artifact getTestNgUtilsArtifact() @@ -1099,13 +1090,13 @@ public abstract class AbstractSurefireMo convertTestNGParameters(); } - public void addProviderArtifactToSurefireClasspath( ClasspathConfiguration bootclasspath ) + public Classpath getProviderClasspath() throws ArtifactResolutionException, ArtifactNotFoundException { Artifact surefireArtifact = (Artifact) getPluginArtifactMap().get( "org.apache.maven.surefire:surefire-booter" ); - dependencyResolver.addProviderToClasspath( bootclasspath, "surefire-testng", - surefireArtifact.getBaseVersion(), testNgArtifact ); + return dependencyResolver.getProviderClasspath( "surefire-testng", surefireArtifact.getBaseVersion(), + testNgArtifact ); } } @@ -1126,13 +1117,13 @@ public abstract class AbstractSurefireMo { } - public void addProviderArtifactToSurefireClasspath( ClasspathConfiguration classpathConfiguration ) + public Classpath getProviderClasspath() throws ArtifactResolutionException, ArtifactNotFoundException { // add the JUnit provider as default - it doesn't require JUnit to be present, // since it supports POJO tests. - dependencyResolver.addProviderToClasspath( classpathConfiguration, "surefire-junit3", - surefireArtifact.getBaseVersion(), null ); + return dependencyResolver.getProviderClasspath( "surefire-junit3", surefireArtifact.getBaseVersion(), + null ); } @@ -1165,11 +1156,11 @@ public abstract class AbstractSurefireMo { } - public void addProviderArtifactToSurefireClasspath( ClasspathConfiguration classpathConfiguration ) + public Classpath getProviderClasspath() throws ArtifactResolutionException, ArtifactNotFoundException { - dependencyResolver.addProviderToClasspath( classpathConfiguration, "surefire-junit4", - surefireArtifact.getBaseVersion(), null ); + return dependencyResolver.getProviderClasspath( "surefire-junit4", surefireArtifact.getBaseVersion(), + null ); } @@ -1209,11 +1200,11 @@ public abstract class AbstractSurefireMo convertJunitCoreParameters(); } - public void addProviderArtifactToSurefireClasspath( ClasspathConfiguration classpathConfiguration ) + public Classpath getProviderClasspath() throws ArtifactResolutionException, ArtifactNotFoundException { - dependencyResolver.addProviderToClasspath( classpathConfiguration, "surefire-junit47", - surefireArtifact.getBaseVersion(), null ); + return dependencyResolver.getProviderClasspath( "surefire-junit47", surefireArtifact.getBaseVersion(), + null ); } } @@ -1250,12 +1241,13 @@ public abstract class AbstractSurefireMo convertTestNGParameters(); } - public void addProviderArtifactToSurefireClasspath( ClasspathConfiguration classpathConfiguration ) + + public Classpath getProviderClasspath() throws ArtifactResolutionException, ArtifactNotFoundException { final Map pluginArtifactMap = getPluginArtifactMap(); Artifact plugin = (Artifact) pluginArtifactMap.get( "org.apache.maven.plugins:maven-surefire-plugin" ); - dependencyResolver.addProviderToClasspath( classpathConfiguration, pluginArtifactMap, plugin ); + return dependencyResolver.addProviderToClasspath( pluginArtifactMap, plugin ); } } Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ProviderInfo.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ProviderInfo.java?rev=1076673&r1=1076672&r2=1076673&view=diff ============================================================================== --- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ProviderInfo.java (original) +++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ProviderInfo.java Thu Mar 3 16:39:19 2011 @@ -21,7 +21,7 @@ package org.apache.maven.plugin.surefire import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; -import org.apache.maven.surefire.booter.ClasspathConfiguration; +import org.apache.maven.surefire.booter.Classpath; /** * @author Kristian Rosenvold @@ -32,7 +32,7 @@ public interface ProviderInfo boolean isApplicable(); - void addProviderArtifactToSurefireClasspath( ClasspathConfiguration bootclasspath ) + Classpath getProviderClasspath() throws ArtifactResolutionException, ArtifactNotFoundException; void addProviderProperties(); Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireDependencyResolver.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireDependencyResolver.java?rev=1076673&r1=1076672&r2=1076673&view=diff ============================================================================== --- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireDependencyResolver.java (original) +++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireDependencyResolver.java Thu Mar 3 16:39:19 2011 @@
{'source': 'Apache Software Foundation Public Mail Archives'}