Author: krosenvold
Date: Sun May 1 10:19:40 2011
New Revision: 1098246
URL: http://svn.apache.org/viewvc?rev=1098246&view=rev
Log:
o Moved reporter construction logic further into ReporterManagerFactory
Added:
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/StartupReportConfiguration.java
(with props)
Removed:
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/SurefireTimeoutMonitor.java
maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkTimeout.java
maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/ForkTimeoutTest.java
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/booterclient/ForkStarter.java
maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/TestSetMockReporterFactory.java
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/plugin/surefire/report/ReporterManagerFactory.java
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractConsoleReporter.java
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractFileReporter.java
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractReporter.java
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractTextReporter.java
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterConfiguration.java
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/XMLReporter.java
maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/TestConsoleOutputRunListenerTest.java
maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireStarter.java
maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/ConcurrentReporterManagerTest.java
maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MavenSurefireJUnit47RunnerTest.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=1098246&r1=1098245&r2=1098246&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
Sun May 1 10:19:40 2011
@@ -53,6 +53,7 @@ import org.apache.maven.surefire.booter.
import org.apache.maven.surefire.booter.ClasspathConfiguration;
import org.apache.maven.surefire.booter.ProviderConfiguration;
import org.apache.maven.surefire.booter.StartupConfiguration;
+import org.apache.maven.surefire.booter.StartupReportConfiguration;
import org.apache.maven.surefire.report.BriefConsoleReporter;
import org.apache.maven.surefire.report.BriefFileReporter;
import org.apache.maven.surefire.report.ConsoleOutputDirectReporter;
@@ -80,9 +81,9 @@ public abstract class AbstractSurefireMo
implements SurefireExecutionParameters
{
- private static final String BRIEF_REPORT_FORMAT = "brief";
+ private static final String BRIEF_REPORT_FORMAT =
StartupReportConfiguration.BRIEF_REPORT_FORMAT;
- private static final String PLAIN_REPORT_FORMAT = "plain";
+ private static final String PLAIN_REPORT_FORMAT =
StartupReportConfiguration.PLAIN_REPORT_FORMAT;
// common field getters/setters
@@ -372,7 +373,8 @@ public abstract class AbstractSurefireMo
isChildDelegation() );
return new StartupConfiguration( providerName,
classpathConfiguration, classLoaderConfiguration,
- forkConfiguration.getForkMode(),
false, isRedirectTestOutputToFile() );
+ forkConfiguration.getForkMode(),
false, isRedirectTestOutputToFile()
+ );
}
catch ( DependencyResolutionRequiredException e )
{
@@ -393,6 +395,13 @@ public abstract class AbstractSurefireMo
}
+ private StartupReportConfiguration getStartupReportConfiguration()
+ {
+ return new StartupReportConfiguration( isUseFile(), isPrintSummary(),
getReportFormat(),
+ isRedirectTestOutputToFile(),
isDisableXmlReport(),
+ getReportsDirectory() );
+ }
+
public void logClasspath( Classpath classpath, String descriptor )
{
getLog().debug( descriptor + " classpath:" );
@@ -523,9 +532,10 @@ public abstract class AbstractSurefireMo
{
StartupConfiguration startupConfiguration =
createStartupConfiguration( forkConfiguration, provider,
classLoaderConfiguration );
+ StartupReportConfiguration startupReportConfiguration =
getStartupReportConfiguration();
ProviderConfiguration providerConfiguration =
createProviderConfiguration( forkConfiguration );
return new ForkStarter( providerConfiguration, startupConfiguration,
forkConfiguration,
- getForkedProcessTimeoutInSeconds() );
+ getForkedProcessTimeoutInSeconds(),
startupReportConfiguration );
}
protected ForkConfiguration getForkConfiguration()
@@ -1020,7 +1030,7 @@ public abstract class AbstractSurefireMo
{
return isPrintSummary() ? ConsoleReporter.class.getName() : null;
}
- else if ( BRIEF_REPORT_FORMAT.equals( getReportFormat() ) )
+ else if ( isRedirectTestOutputToFile() || BRIEF_REPORT_FORMAT.equals(
getReportFormat() ) )
{
return BriefConsoleReporter.class.getName();
}
@@ -1028,6 +1038,10 @@ public abstract class AbstractSurefireMo
{
return DetailedConsoleReporter.class.getName();
}
+/* if (isRedirectTestOutputToFile())
+ {
+ return null;
+ }*/
return null;
}
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=1098246&r1=1098245&r2=1098246&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
Sun May 1 10:19:40 2011
@@ -30,6 +30,7 @@ import org.apache.maven.surefire.booter.
import org.apache.maven.surefire.booter.ProviderConfiguration;
import org.apache.maven.surefire.booter.ProviderFactory;
import org.apache.maven.surefire.booter.StartupConfiguration;
+import org.apache.maven.surefire.booter.StartupReportConfiguration;
import org.apache.maven.surefire.booter.SurefireBooterForkException;
import org.apache.maven.surefire.booter.SurefireExecutionException;
import org.apache.maven.surefire.booter.SurefireReflector;
@@ -70,13 +71,17 @@ public class ForkStarter
private final ForkConfiguration forkConfiguration;
+ private final StartupReportConfiguration startupReportConfiguration;
+
public ForkStarter( ProviderConfiguration providerConfiguration,
StartupConfiguration startupConfiguration,
- ForkConfiguration forkConfiguration, int
forkedProcessTimeoutInSeconds )
+ ForkConfiguration forkConfiguration, int
forkedProcessTimeoutInSeconds,
+ StartupReportConfiguration startupReportConfiguration )
{
this.forkConfiguration = forkConfiguration;
this.providerConfiguration = providerConfiguration;
this.forkedProcessTimeoutInSeconds = forkedProcessTimeoutInSeconds;
this.startupConfiguration = startupConfiguration;
+ this.startupReportConfiguration = startupReportConfiguration;
}
public RunResult run()
@@ -87,7 +92,7 @@ public class ForkStarter
final String requestedForkMode = forkConfiguration.getForkMode();
if ( ForkConfiguration.FORK_NEVER.equals( requestedForkMode ) )
{
- SurefireStarter surefireStarter = new SurefireStarter(
startupConfiguration, providerConfiguration, false );
+ SurefireStarter surefireStarter = new SurefireStarter(
startupConfiguration, providerConfiguration, false,
this.startupReportConfiguration );
result = surefireStarter.runSuitesInProcess();
}
else if ( ForkConfiguration.FORK_ONCE.equals( requestedForkMode ) )
@@ -111,7 +116,8 @@ public class ForkStarter
final ReporterManagerFactory testSetReporterFactory =
new ReporterManagerFactory(
Thread.currentThread().getContextClassLoader(),
providerConfiguration.getReporterConfiguration(),
-
providerConfiguration.getReporterConfiguration().getReports() );
+
providerConfiguration.getReporterConfiguration().getReports(),
+ startupReportConfiguration );
try
{
return fork( null, providerConfiguration.getProviderProperties(),
testSetReporterFactory );
@@ -148,7 +154,8 @@ public class ForkStarter
final ReporterManagerFactory testSetReporterFactory =
new ReporterManagerFactory(
Thread.currentThread().getContextClassLoader(),
providerConfiguration.getReporterConfiguration(),
-
providerConfiguration.getReporterConfiguration().getReports() );
+
providerConfiguration.getReporterConfiguration().getReports(),
+ startupReportConfiguration );
try
{
while ( suites.hasNext() )
@@ -171,7 +178,7 @@ public class ForkStarter
{
SurefireReflector surefireReflector = new SurefireReflector(
surefireClassLoader );
Object reporterFactory =
- surefireReflector.createReportingReporterFactory(
this.providerConfiguration.getReporterConfiguration() );
+ surefireReflector.createReportingReporterFactory(
this.providerConfiguration.getReporterConfiguration(),
startupReportConfiguration );
final ProviderFactory providerFactory =
new ProviderFactory( startupConfiguration, providerConfiguration,
surefireClassLoader, testsClassLoader,
Modified:
maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/TestSetMockReporterFactory.java
URL:
http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/TestSetMockReporterFactory.java?rev=1098246&r1=1098245&r2=1098246&view=diff
==============================================================================
---
maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/TestSetMockReporterFactory.java
(original)
+++
maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/TestSetMockReporterFactory.java
Sun May 1 10:19:40 2011
@@ -22,6 +22,7 @@ package org.apache.maven.plugin.surefire
import java.io.File;
import java.util.ArrayList;
import org.apache.maven.plugin.surefire.report.ReporterManagerFactory;
+import org.apache.maven.surefire.booter.StartupReportConfiguration;
import org.apache.maven.surefire.report.DefaultConsoleReporter;
import org.apache.maven.surefire.report.DirectConsoleReporter;
import org.apache.maven.surefire.report.ReporterConfiguration;
@@ -30,18 +31,23 @@ import org.apache.maven.surefire.report.
/**
* @author Kristian Rosenvold
*/
-public class TestSetMockReporterFactory extends ReporterManagerFactory
+public class TestSetMockReporterFactory
+ extends ReporterManagerFactory
{
- public TestSetMockReporterFactory( )
+ public TestSetMockReporterFactory()
{
- super( Thread.currentThread().getContextClassLoader(), new
ReporterConfiguration(new File("."), Boolean.TRUE), new ArrayList( ) );
+ super( Thread.currentThread().getContextClassLoader(),
+ new ReporterConfiguration( new File( "." ), Boolean.TRUE ), new
ArrayList(),
+ StartupReportConfiguration.defaultValue() );
}
- public DirectConsoleReporter createConsoleReporter() {
- return new DefaultConsoleReporter(System.out);
+ public DirectConsoleReporter createConsoleReporter()
+ {
+ return new DefaultConsoleReporter( System.out );
}
- public RunListener createReporter(){
+ public RunListener createReporter()
+ {
return new MockReporter();
}
}
Modified:
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/plugin/surefire/report/ReporterManagerFactory.java
URL:
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/plugin/surefire/report/ReporterManagerFactory.java?rev=1098246&r1=1098245&r2=1098246&view=diff
==============================================================================
---
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/plugin/surefire/report/ReporterManagerFactory.java
(original)
+++
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/plugin/surefire/report/ReporterManagerFactory.java
Sun May 1 10:19:40 2011
@@ -23,6 +23,7 @@ import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import org.apache.maven.surefire.booter.StartupReportConfiguration;
import org.apache.maven.surefire.report.AbstractConsoleReporter;
import org.apache.maven.surefire.report.AbstractFileReporter;
import org.apache.maven.surefire.report.DefaultDirectConsoleReporter;
@@ -44,12 +45,13 @@ import org.apache.maven.surefire.util.Su
* <p/>
* Keeps a centralized count of test run results.
*
+ * TODO: Move out of API module
+ *
* @author Kristian Rosenvold
*/
public class ReporterManagerFactory
implements ReporterFactory
{
- private List reportDefinitions;
private ClassLoader surefireClassLoader;
@@ -59,12 +61,14 @@ public class ReporterManagerFactory
private final MulticastingReporter multicastingReporter;
+ private final StartupReportConfiguration reportConfiguration;
+
public ReporterManagerFactory( ClassLoader surefireClassLoader,
ReporterConfiguration reporterConfiguration,
- List reportDefinitions )
+ List reportDefinitions,
StartupReportConfiguration reportConfiguration )
{
this.reporterConfiguration = reporterConfiguration;
- this.reportDefinitions = reportDefinitions;
this.surefireClassLoader = surefireClassLoader;
+ this.reportConfiguration = reportConfiguration;
multicastingReporter = new MulticastingReporter( instantiateReports()
);
runStarting();
}
@@ -77,27 +81,27 @@ public class ReporterManagerFactory
private AbstractConsoleReporter instantiateConsoleReporter()
{
- return (AbstractConsoleReporter) instantiateReport(
reporterConfiguration.getConsoleReporter() );
+ return (AbstractConsoleReporter) instantiateReport(
reportConfiguration.getConsoleReporter() );
}
private AbstractFileReporter instantiateFileReporter()
{
- return (AbstractFileReporter) instantiateReport(
reporterConfiguration.getFileReporter() );
+ return (AbstractFileReporter) instantiateReport(
reportConfiguration.getFileReporter() );
}
private XMLReporter instantiateXmlReporter()
{
- return (XMLReporter) instantiateReport(
reporterConfiguration.getXmlReporter() );
+ return (XMLReporter) instantiateReport(
reportConfiguration.getXmlReporterName() );
}
private Reporter instantiateConsoleOutputFileReporter()
{
- return instantiateReport(
reporterConfiguration.getConsoleOutputFileReporterName() );
+ return instantiateReport(
reportConfiguration.getConsoleOutputFileReporterName() );
}
private List instantiateReports()
{
- return instantiateReportsNewStyle( reportDefinitions,
reporterConfiguration, surefireClassLoader );
+ return instantiateReportsNewStyle( reportConfiguration.getReports(),
reporterConfiguration, surefireClassLoader );
}
public RunResult close()
Added:
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/StartupReportConfiguration.java
URL:
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/StartupReportConfiguration.java?rev=1098246&view=auto
==============================================================================
---
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/StartupReportConfiguration.java
(added)
+++
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/StartupReportConfiguration.java
Sun May 1 10:19:40 2011
@@ -0,0 +1,203 @@
+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 java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.maven.surefire.report.BriefConsoleReporter;
+import org.apache.maven.surefire.report.BriefFileReporter;
+import org.apache.maven.surefire.report.ConsoleOutputDirectReporter;
+import org.apache.maven.surefire.report.ConsoleOutputFileReporter;
+import org.apache.maven.surefire.report.ConsoleReporter;
+import org.apache.maven.surefire.report.DetailedConsoleReporter;
+import org.apache.maven.surefire.report.FileReporter;
+import org.apache.maven.surefire.report.XMLReporter;
+
+/**
+ * All the parameters used to construct reporters
+ * <p/>
+ * TODO: Move out of API module
+ *
+ * @author Kristian Rosenvold
+ */
+public class StartupReportConfiguration
+{
+ private final boolean useFile;
+
+ private final boolean printSummary;
+
+ private final String reportFormat;
+
+ private final boolean redirectTestOutputToFile;
+
+ private final boolean disableXmlReport;
+
+ private final File reportsDirectory;
+
+
+ public static final String BRIEF_REPORT_FORMAT = "brief";
+
+ public static final String PLAIN_REPORT_FORMAT = "plain";
+
+ public StartupReportConfiguration( boolean useFile, boolean printSummary,
String reportFormat,
+ boolean redirectTestOutputToFile,
boolean disableXmlReport,
+ File reportsDirectory )
+ {
+ this.useFile = useFile;
+ this.printSummary = printSummary;
+ this.reportFormat = reportFormat;
+ this.redirectTestOutputToFile = redirectTestOutputToFile;
+ this.disableXmlReport = disableXmlReport;
+ this.reportsDirectory = reportsDirectory;
+ }
+
+ public static StartupReportConfiguration defaultValue()
+ {
+ File target = new File( "./target" );
+ return new StartupReportConfiguration( true, true, "PLAIN", false,
false, target );
+ }
+
+ public static StartupReportConfiguration defaultNoXml()
+ {
+ File target = new File( "./target" );
+ return new StartupReportConfiguration( true, true, "PLAIN", false,
true, target );
+ }
+
+ public boolean isUseFile()
+ {
+ return useFile;
+ }
+
+ public boolean isPrintSummary()
+ {
+ return printSummary;
+ }
+
+ public String getReportFormat()
+ {
+ return reportFormat;
+ }
+
+ public boolean isRedirectTestOutputToFile()
+ {
+ return redirectTestOutputToFile;
+ }
+
+ public boolean isDisableXmlReport()
+ {
+ return disableXmlReport;
+ }
+
+ public File getReportsDirectory()
+ {
+ return reportsDirectory;
+ }
+
+ public String getXmlReporterName()
+ {
+ if ( !isDisableXmlReport() )
+ {
+ return XMLReporter.class.getName();
+ }
+ return null;
+ }
+
+ public String getFileReporter()
+ {
+ if ( isUseFile() )
+ {
+ if ( BRIEF_REPORT_FORMAT.equals( getReportFormat() ) )
+ {
+ return BriefFileReporter.class.getName();
+ }
+ else if ( PLAIN_REPORT_FORMAT.equals( getReportFormat() ) )
+ {
+ return FileReporter.class.getName();
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the reporter that will write to the console
+ *
+ * @return a console reporter of null if no console reporting
+ */
+ public String getConsoleReporter()
+ {
+ if ( isUseFile() )
+ {
+ return isPrintSummary() ? ConsoleReporter.class.getName() : null;
+ }
+ else if ( isRedirectTestOutputToFile() || BRIEF_REPORT_FORMAT.equals(
getReportFormat() ) )
+ {
+ return BriefConsoleReporter.class.getName();
+ }
+ else if ( PLAIN_REPORT_FORMAT.equals( getReportFormat() ) )
+ {
+ return DetailedConsoleReporter.class.getName();
+ }
+/* if (isRedirectTestOutputToFile())
+ {
+ return null;
+ }*/
+ return null;
+ }
+
+ public String getConsoleOutputFileReporterName()
+ {
+ if ( isRedirectTestOutputToFile() )
+ {
+ return ConsoleOutputFileReporter.class.getName();
+ }
+ else
+ {
+ return ConsoleOutputDirectReporter.class.getName();
+ }
+ }
+
+
+ /**
+ * A list of classnames representing runnable reports for this test-run.
+ *
+ * @return A list of strings, each string is a classname of a class
+ * implementing the org.apache.maven.surefire.report.Reporter
interface
+ */
+ public List getReports()
+ {
+ ArrayList reports = new ArrayList();
+ addIfNotNull( reports, getConsoleReporter() );
+ addIfNotNull( reports, getFileReporter() );
+ addIfNotNull( reports, getXmlReporterName() );
+ addIfNotNull( reports, getConsoleOutputFileReporterName() );
+ return reports;
+ }
+
+ private void addIfNotNull( ArrayList reports, String reporter )
+ {
+ if ( reporter != null )
+ {
+ reports.add( reporter );
+ }
+ }
+
+
+}
Propchange:
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/StartupReportConfiguration.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java
URL:
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java?rev=1098246&r1=1098245&r2=1098246&view=diff
==============================================================================
---
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java
(original)
+++
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java
Sun May 1 10:19:40 2011
@@ -77,12 +77,15 @@ public class SurefireReflector
private final Class forkConfigurationInfo;
+ private final Class startupReportConfiguration;
+
public SurefireReflector( ClassLoader surefireClassLoader )
{
this.surefireClassLoader = surefireClassLoader;
try
{
reporterConfiguration = surefireClassLoader.loadClass(
ReporterConfiguration.class.getName() );
+ startupReportConfiguration = surefireClassLoader.loadClass(
StartupReportConfiguration.class.getName() );
testRequest = surefireClassLoader.loadClass(
TestRequest.class.getName() );
testArtifactInfo = surefireClassLoader.loadClass(
TestArtifactInfo.class.getName() );
testArtifactInfoAware = surefireClassLoader.loadClass(
TestArtifactInfoAware.class.getName() );
@@ -208,9 +211,23 @@ public class SurefireReflector
new Class[]{
File.class, Boolean.class, String.class,
String.class, String.class, String.class } );
return ReflectionUtils.newInstance( constructor, new Object[]{
reporterConfiguration.getReportsDirectory(),
- reporterConfiguration.isTrimStackTrace(),
reporterConfiguration.getConsoleReporter(),
- reporterConfiguration.getFileReporter(),
reporterConfiguration.getXmlReporter(),
- reporterConfiguration.getConsoleOutputFileReporterName() } );
+ reporterConfiguration.isTrimStackTrace(), null, null, null, null }
);
+ }
+
+ Object createStartupReportConfiguration( StartupReportConfiguration
reporterConfiguration )
+ {
+ Constructor constructor = ReflectionUtils.getConstructor(
this.startupReportConfiguration,
+ new Class[]{
boolean.class, boolean.class,
+
String.class, boolean.class, boolean.class,
+
File.class } );
+ //noinspection BooleanConstructorCall
+ final Object[] params =
+ { new Boolean( reporterConfiguration.isUseFile() ), new Boolean(
reporterConfiguration.isPrintSummary() ),
+ reporterConfiguration.getReportFormat(),
+ new Boolean(
reporterConfiguration.isRedirectTestOutputToFile() ),
+ new Boolean( reporterConfiguration.isDisableXmlReport() ),
+ reporterConfiguration.getReportsDirectory() };
+ return ReflectionUtils.newInstance( constructor, params );
}
public Object createForkingReporterFactory( Boolean trimStackTrace,
PrintStream originalSystemOut )
@@ -221,11 +238,14 @@ public class SurefireReflector
surefireClassLoader );
}
- public Object createReportingReporterFactory( ReporterConfiguration
reporterConfiguration )
+ public Object createReportingReporterFactory( ReporterConfiguration
reporterConfiguration,
+ StartupReportConfiguration
startupReportConfiguration )
{
- Class[] args = new Class[]{ ClassLoader.class,
this.reporterConfiguration, List.class };
+ Class[] args =
+ new Class[]{ ClassLoader.class, this.reporterConfiguration,
List.class, this.startupReportConfiguration };
Object report = createReporterConfiguration( reporterConfiguration );
- Object[] params = new Object[]{ this.surefireClassLoader, report,
reporterConfiguration.getReports() };
+ Object src = createStartupReportConfiguration(
startupReportConfiguration );
+ Object[] params = new Object[]{ this.surefireClassLoader, report,
reporterConfiguration.getReports(), src };
return ReflectionUtils.instantiateObject(
ReporterManagerFactory.class.getName(), args, params,
surefireClassLoader );
Modified:
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractConsoleReporter.java
URL:
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractConsoleReporter.java?rev=1098246&r1=1098245&r2=1098246&view=diff
==============================================================================
---
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractConsoleReporter.java
(original)
+++
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractConsoleReporter.java
Sun May 1 10:19:40 2011
@@ -42,11 +42,19 @@ public abstract class AbstractConsoleRep
private static final PrintStream ORIGINAL_SYSTEM_OUT = System.out;
+ public AbstractConsoleReporter( boolean trimStackTrace, String format )
+ {
+ super( getPrintWriter(), trimStackTrace, format);
+ }
+
AbstractConsoleReporter( String format, ReporterConfiguration
reporterConfiguration )
{
- super(
- new PrintWriter( new OutputStreamWriter( new BufferedOutputStream(
ORIGINAL_SYSTEM_OUT, BUFFER_SIZE ) ) ),
- format, reporterConfiguration );
+ super( getPrintWriter(),
reporterConfiguration.isTrimStackTrace().booleanValue(), format);
+ }
+
+ private static PrintWriter getPrintWriter()
+ {
+ return new PrintWriter( new OutputStreamWriter( new
BufferedOutputStream( ORIGINAL_SYSTEM_OUT, BUFFER_SIZE ) ) );
}
public void testSetStarting( ReportEntry report )
Modified:
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractFileReporter.java
URL:
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractFileReporter.java?rev=1098246&r1=1098245&r2=1098246&view=diff
==============================================================================
---
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractFileReporter.java
(original)
+++
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractFileReporter.java
Sun May 1 10:19:40 2011
@@ -36,15 +36,17 @@ public abstract class AbstractFileReport
private final boolean deleteOnStarting;
- AbstractFileReporter( ReporterConfiguration reporterConfiguration, String
format )
+ protected AbstractFileReporter( boolean trimStackTrace, String format,
File reportsDirectory )
{
- super( reporterConfiguration, format );
-
- this.reportsDirectory = reporterConfiguration.getReportsDirectory();
-
+ super( trimStackTrace, format );
+ this.reportsDirectory = reportsDirectory;
this.deleteOnStarting = false;
}
+ AbstractFileReporter( ReporterConfiguration reporterConfiguration, String
format )
+ {
+ this( reporterConfiguration.isTrimStackTrace().booleanValue(), format,
reporterConfiguration.getReportsDirectory());
+ }
public void testSetStarting( ReportEntry report )
throws ReporterException
@@ -97,10 +99,5 @@ public abstract class AbstractFileReport
writer.close();
writer = null;
-
- if ( isTimedOut() )
- {
- deleteIfExisting( getReportFile( report ) );
- }
}
}
Modified:
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractReporter.java
URL:
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractReporter.java?rev=1098246&r1=1098245&r2=1098246&view=diff
==============================================================================
---
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractReporter.java
(original)
+++
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractReporter.java
Sun May 1 10:19:40 2011
@@ -52,22 +52,19 @@ public abstract class AbstractReporter
private final boolean trimStackTrace;
- private final ReporterConfiguration reporterConfiguration;
-
// ----------------------------------------------------------------------
// Report interface
// ----------------------------------------------------------------------
- AbstractReporter( ReporterConfiguration reporterConfiguration )
+ protected AbstractReporter( boolean trimStackTrace )
{
- this.reporterConfiguration = reporterConfiguration;
- this.trimStackTrace =
reporterConfiguration.isTrimStackTrace().booleanValue();
+ this.trimStackTrace = trimStackTrace;
}
- boolean isTimedOut()
+ AbstractReporter( ReporterConfiguration reporterConfiguration )
{
- return reporterConfiguration.isTimedOut();
+ this(reporterConfiguration.isTrimStackTrace().booleanValue());
}
public void writeFooter( String footer )
Modified:
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractTextReporter.java
URL:
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractTextReporter.java?rev=1098246&r1=1098245&r2=1098246&view=diff
==============================================================================
---
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractTextReporter.java
(original)
+++
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractTextReporter.java
Sun May 1 10:19:40 2011
@@ -46,13 +46,24 @@ public abstract class AbstractTextReport
private List testResults;
- protected AbstractTextReporter( ReporterConfiguration
reporterConfiguration, String format )
- {
- super( reporterConfiguration );
+ protected AbstractTextReporter( boolean trimStackTrace, String format )
+ {
+ super( trimStackTrace );
this.format = format;
}
+ protected AbstractTextReporter( PrintWriter writer, boolean
trimStackTrace, String format )
+ {
+ this( trimStackTrace, format);
+ this.writer = writer;
+ }
+
+ protected AbstractTextReporter( ReporterConfiguration
reporterConfiguration, String format )
+ {
+ this( reporterConfiguration.isTrimStackTrace().booleanValue(), format);
+ }
+
protected AbstractTextReporter( PrintWriter writer, String format,
ReporterConfiguration reporterConfiguration )
{
Modified:
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterConfiguration.java
URL:
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterConfiguration.java?rev=1098246&r1=1098245&r2=1098246&view=diff
==============================================================================
---
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterConfiguration.java
(original)
+++
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterConfiguration.java
Sun May 1 10:19:40 2011
@@ -40,8 +40,6 @@ public class ReporterConfiguration
private final PrintStream originalSystemOut;
- private final PrintStream originalSystemErr;
-
private final Properties testVmSystemProperties;
private final String consoleReporter;
@@ -57,8 +55,6 @@ public class ReporterConfiguration
*/
private final Boolean trimStackTrace;
- private volatile boolean timedOut = false;
-
public ReporterConfiguration( File reportsDirectory, Boolean
trimStackTrace, String consoleReporter,
String fileReporter, String xmlReporter,
String consoleOutputFileReporterName )
{
@@ -76,7 +72,6 @@ public class ReporterConfiguration
* As soon as we start loading user code, all h*ll breaks loose in this
respect.
*/
this.originalSystemOut = System.out;
- this.originalSystemErr = System.err;
}
public ReporterConfiguration( File reportsDirectory, Boolean
trimStackTrace )
@@ -147,34 +142,4 @@ public class ReporterConfiguration
{
return testVmSystemProperties;
}
-
- public void setTimedOut( boolean timedOut )
- {
- this.timedOut = timedOut;
- }
-
- public boolean isTimedOut()
- {
- return this.timedOut;
- }
-
- public String getConsoleReporter()
- {
- return consoleReporter;
- }
-
- public String getFileReporter()
- {
- return fileReporter;
- }
-
- public String getXmlReporter()
- {
- return xmlReporter;
- }
-
- public String getConsoleOutputFileReporterName()
- {
- return consoleOutputFileReporterName;
- }
}
Modified:
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/XMLReporter.java
URL:
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/XMLReporter.java?rev=1098246&r1=1098245&r2=1098246&view=diff
==============================================================================
---
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/XMLReporter.java
(original)
+++
maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/XMLReporter.java
Sun May 1 10:19:40 2011
@@ -54,15 +54,19 @@ public class XMLReporter
private final List results = Collections.synchronizedList( new ArrayList()
);
- public XMLReporter( ReporterConfiguration reporterConfiguration )
- {
- super( reporterConfiguration );
-
- this.reportsDirectory = reporterConfiguration.getReportsDirectory();
+ public XMLReporter( boolean trimStackTrace, File reportsDirectory )
+ {
+ super( trimStackTrace );
+ this.reportsDirectory = reportsDirectory;
this.deleteOnStarting = false;
}
+ public XMLReporter( ReporterConfiguration reporterConfiguration )
+ {
+ this( reporterConfiguration.isTrimStackTrace().booleanValue(),
reporterConfiguration.getReportsDirectory() );
+ }
+
public void writeMessage( String message )
{
@@ -94,10 +98,6 @@ public class XMLReporter
{
super.testSetCompleted( report );
- if ( isTimedOut() )
- {
- return;
- }
long runTime = System.currentTimeMillis() - testSetStartTime;
Xpp3Dom testSuite = createTestSuiteElement( report, runTime );
@@ -122,6 +122,7 @@ public class XMLReporter
File reportDir = reportFile.getParentFile();
+ //noinspection ResultOfMethodCallIgnored
reportDir.mkdirs();
PrintWriter writer = null;
@@ -242,6 +243,7 @@ public class XMLReporter
Throwable t = null;
if ( report.getStackTraceWriter() != null )
{
+ //noinspection ThrowableResultOfMethodCallIgnored
t = report.getStackTraceWriter().getThrowable();
}
@@ -296,7 +298,7 @@ public class XMLReporter
/**
* Adds system properties to the XML report.
*
- * @param testSuite
+ * @param testSuite The test suite to report to
*/
private void showProperties( Xpp3Dom testSuite )
{
Modified:
maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/TestConsoleOutputRunListenerTest.java
URL:
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/TestConsoleOutputRunListenerTest.java?rev=1098246&r1=1098245&r2=1098246&view=diff
==============================================================================
---
maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/TestConsoleOutputRunListenerTest.java
(original)
+++
maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/TestConsoleOutputRunListenerTest.java
Sun May 1 10:19:40 2011
@@ -19,8 +19,10 @@ package org.apache.maven.surefire.report
* under the License.
*/
+import java.io.File;
import java.util.ArrayList;
import org.apache.maven.plugin.surefire.report.ReporterManagerFactory;
+import org.apache.maven.surefire.booter.StartupReportConfiguration;
import junit.framework.TestCase;
@@ -50,12 +52,13 @@ public class TestConsoleOutputRunListene
private ReporterFactory createReporterFactory()
{
ReporterConfiguration reporterConfiguration =
getTestReporterConfiguration();
- return new ReporterManagerFactory( this.getClass().getClassLoader(),
reporterConfiguration, new ArrayList() );
+ return new ReporterManagerFactory( this.getClass().getClassLoader(),
reporterConfiguration, new ArrayList(),
+
StartupReportConfiguration.defaultValue() );
}
public static ReporterConfiguration getTestReporterConfiguration()
{
- return new ReporterConfiguration( null, Boolean.TRUE,
ConsoleReporter.class.getName(), null, null, null );
+ return new ReporterConfiguration( new File( "." ), Boolean.TRUE,
ConsoleReporter.class.getName(), null, null, null );
}
}
Modified:
maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
URL:
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java?rev=1098246&r1=1098245&r2=1098246&view=diff
==============================================================================
---
maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
(original)
+++
maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
Sun May 1 10:19:40 2011
@@ -22,7 +22,6 @@ package org.apache.maven.surefire.booter
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
-import java.util.Properties;
import org.apache.maven.surefire.suite.RunResult;
/**
@@ -65,7 +64,7 @@ public class ForkedBooter
final StartupConfiguration providerConfiguration =
booterDeserializer.getProviderConfiguration();
- SurefireStarter starter = new SurefireStarter(
providerConfiguration, booterConfiguration, true );
+ SurefireStarter starter = new SurefireStarter(
providerConfiguration, booterConfiguration, true, null );
Object forkedTestSet = booterConfiguration.getTestForFork();
final RunResult result = forkedTestSet != null
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=1098246&r1=1098245&r2=1098246&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
Sun May 1 10:19:40 2011
@@ -50,12 +50,15 @@ public class SurefireStarter
private final boolean inFork;
+ private final StartupReportConfiguration startupReportConfiguration;
+
public SurefireStarter( StartupConfiguration startupConfiguration,
ProviderConfiguration providerConfiguration,
- boolean inFork )
+ boolean inFork, StartupReportConfiguration
startupReportConfiguration )
{
this.providerConfiguration = providerConfiguration;
this.startupConfiguration = startupConfiguration;
this.inFork = inFork;
+ this.startupReportConfiguration = startupReportConfiguration;
}
public RunResult runSuitesInProcessWhenForked( Object testSet )
@@ -116,7 +119,7 @@ public class SurefireStarter
SurefireReflector surefireReflector = new SurefireReflector(
surefireClassLoader );
final Object factory =
- surefireReflector.createReportingReporterFactory(
this.providerConfiguration.getReporterConfiguration() );
+ surefireReflector.createReportingReporterFactory(
this.providerConfiguration.getReporterConfiguration(),
startupReportConfiguration );
return invokeProvider( null, testsClassLoader, surefireClassLoader,
factory );
}
Modified:
maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/ConcurrentReporterManagerTest.java
URL:
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/ConcurrentReporterManagerTest.java?rev=1098246&r1=1098245&r2=1098246&view=diff
==============================================================================
---
maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/ConcurrentReporterManagerTest.java
(original)
+++
maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/ConcurrentReporterManagerTest.java
Sun May 1 10:19:40 2011
@@ -27,6 +27,7 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.apache.maven.plugin.surefire.report.ReporterManagerFactory;
+import org.apache.maven.surefire.booter.StartupReportConfiguration;
import org.apache.maven.surefire.report.ReporterConfiguration;
import org.apache.maven.surefire.report.ReporterFactory;
import org.apache.maven.surefire.report.RunListener;
@@ -402,12 +403,13 @@ public class ConcurrentReporterManagerTe
private ReporterFactory createReporterFactory()
{
ReporterConfiguration reporterConfiguration =
getTestReporterConfiguration();
- return new ReporterManagerFactory( this.getClass().getClassLoader(),
reporterConfiguration, Arrays.asList() );
+ return new ReporterManagerFactory( this.getClass().getClassLoader(),
reporterConfiguration, Arrays.asList(),
+
StartupReportConfiguration.defaultNoXml() );
}
public static ReporterConfiguration getTestReporterConfiguration()
{
- return new ReporterConfiguration( null, Boolean.TRUE );
+ return new ReporterConfiguration( new File( "." ), Boolean.TRUE );
}
Modified:
maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MavenSurefireJUnit47RunnerTest.java
URL:
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MavenSurefireJUnit47RunnerTest.java?rev=1098246&r1=1098245&r2=1098246&view=diff
==============================================================================
---
maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MavenSurefireJUnit47RunnerTest.java
(original)
+++
maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MavenSurefireJUnit47RunnerTest.java
Sun May 1 10:19:40 2011
@@ -20,6 +20,7 @@ import java.io.File;
import java.util.Arrays;
import java.util.HashMap;
import org.apache.maven.plugin.surefire.report.ReporterManagerFactory;
+import org.apache.maven.surefire.booter.StartupReportConfiguration;
import org.apache.maven.surefire.report.ReporterConfiguration;
import org.apache.maven.surefire.report.ReporterFactory;
import org.apache.maven.surefire.report.RunListener;
@@ -120,7 +121,8 @@ public class MavenSurefireJUnit47RunnerT
ReporterConfiguration reporterConfiguration =
ConcurrentReporterManagerTest.getTestReporterConfiguration();
ReporterFactory reporterManagerFactory =
- new ReporterManagerFactory( this.getClass().getClassLoader(),
reporterConfiguration, Arrays.asList() );
+ new ReporterManagerFactory( this.getClass().getClassLoader(),
reporterConfiguration, Arrays.asList(),
+
StartupReportConfiguration.defaultNoXml() );
final HashMap<String, TestSet> classMethodCounts = new HashMap<String,
TestSet>();
RunListener reporter = ConcurrentReporterManager.createInstance(
classMethodCounts, reporterManagerFactory,