You are viewing a plain text version of this content. The canonical link for it is here.
Posted to surefire-commits@maven.apache.org by br...@apache.org on 2006/03/01 03:42:25 UTC
svn commit: r381878 [1/2] - in /maven/surefire/branches/surefire-testng:
surefire-booter/ surefire-booter/src/main/java/org/apache/maven/surefire/
surefire/ surefire/src/main/java/org/apache/maven/surefire/
surefire/src/main/java/org/apache/maven/suref...
Author: brett
Date: Tue Feb 28 18:42:20 2006
New Revision: 381878
URL: http://svn.apache.org/viewcvs?rev=381878&view=rev
Log:
reformat and update license of all code
Modified:
maven/surefire/branches/surefire-testng/surefire-booter/pom.xml
maven/surefire/branches/surefire-testng/surefire-booter/src/main/java/org/apache/maven/surefire/ForkingWriterStreamConsumer.java
maven/surefire/branches/surefire-testng/surefire-booter/src/main/java/org/apache/maven/surefire/IsolatedClassLoader.java
maven/surefire/branches/surefire-testng/surefire-booter/src/main/java/org/apache/maven/surefire/SurefireBooter.java
maven/surefire/branches/surefire-testng/surefire-booter/src/main/java/org/apache/maven/surefire/SurefireBooterForkException.java
maven/surefire/branches/surefire-testng/surefire/pom.xml
maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/Surefire.java
maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/SurefireUtils.java
maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/AbstractBattery.java
maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/Battery.java
maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/DirectoryBattery.java
maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/JUnitBattery.java
maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/SingleTestBattery.java
maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/TestListenerInvocationHandler.java
maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/TestNGBattery.java
maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/TestNGXMLBattery.java
maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/assertion/BatteryAssert.java
maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/assertion/BatteryAssertionFailedError.java
maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/assertion/BatteryComparisonFailure.java
maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/assertion/BatteryTestFailedException.java
maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/AbstractReporter.java
maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/BriefConsoleReporter.java
maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/BriefFileReporter.java
maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/ConsoleReporter.java
maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/DetailedConsoleReporter.java
maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/FileReporter.java
maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/ForkingConsoleReporter.java
maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/ForkingReport.java
maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/ForkingSummaryConsoleReporter.java
maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/ReportEntry.java
maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/Reporter.java
maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/ReporterManager.java
maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/SummaryConsoleReporter.java
maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/TestNGReporter.java
maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/XMLReporter.java
maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/util/TeeStream.java
maven/surefire/branches/surefire-testng/surefire/src/main/resources/org/apache/maven/surefire/surefire.properties
maven/surefire/branches/surefire-testng/surefire/src/test/java/org/apache/maven/surefire/DummySuite.java
maven/surefire/branches/surefire-testng/surefire/src/test/java/org/apache/maven/surefire/JUnitTestSuite.java
maven/surefire/branches/surefire-testng/surefire/src/test/java/org/apache/maven/surefire/POJOTest.java
maven/surefire/branches/surefire-testng/surefire/src/test/java/org/apache/maven/surefire/ReportEntryTest.java
maven/surefire/branches/surefire-testng/surefire/src/test/java/org/apache/maven/surefire/SimpleBatteryTest.java
maven/surefire/branches/surefire-testng/surefire/src/test/java/org/apache/maven/surefire/SimpleJUnitTest.java
maven/surefire/branches/surefire-testng/surefire/src/test/java/org/apache/maven/surefire/SysUnitTest.java
maven/surefire/branches/surefire-testng/surefire/src/test/java/org/apache/maven/surefire/TestReport.java
maven/surefire/branches/surefire-testng/surefire/src/test/java/org/apache/maven/surefire/User.java
maven/surefire/branches/surefire-testng/surefire/src/test/java/org/apache/maven/surefire/report/XMLReporterTest.java
maven/surefire/branches/surefire-testng/surefire/src/test/java/org/apache/maven/surefire/suite/directory/a/DirectoryJUnitTestSuite.java
maven/surefire/branches/surefire-testng/surefire/src/test/java/org/apache/maven/surefire/suite/directory/a/JUnitTestSuite.java
maven/surefire/branches/surefire-testng/surefire/src/test/java/org/apache/maven/surefire/suite/directory/b/DirectoryJUnitTestSuite.java
maven/surefire/branches/surefire-testng/surefire/src/test/java/org/apache/maven/surefire/suite/directory/b/JUnitTestSuite.java
Modified: maven/surefire/branches/surefire-testng/surefire-booter/pom.xml
URL: http://svn.apache.org/viewcvs/maven/surefire/branches/surefire-testng/surefire-booter/pom.xml?rev=381878&r1=381877&r2=381878&view=diff
==============================================================================
--- maven/surefire/branches/surefire-testng/surefire-booter/pom.xml (original)
+++ maven/surefire/branches/surefire-testng/surefire-booter/pom.xml Tue Feb 28 18:42:20 2006
@@ -1,4 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2001-2006 The Apache Software Foundation.
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
<project>
<parent>
<artifactId>surefire-root</artifactId>
Modified: maven/surefire/branches/surefire-testng/surefire-booter/src/main/java/org/apache/maven/surefire/ForkingWriterStreamConsumer.java
URL: http://svn.apache.org/viewcvs/maven/surefire/branches/surefire-testng/surefire-booter/src/main/java/org/apache/maven/surefire/ForkingWriterStreamConsumer.java?rev=381878&r1=381877&r2=381878&view=diff
==============================================================================
--- maven/surefire/branches/surefire-testng/surefire-booter/src/main/java/org/apache/maven/surefire/ForkingWriterStreamConsumer.java (original)
+++ maven/surefire/branches/surefire-testng/surefire-booter/src/main/java/org/apache/maven/surefire/ForkingWriterStreamConsumer.java Tue Feb 28 18:42:20 2006
@@ -1,5 +1,21 @@
package org.apache.maven.surefire;
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.report.ForkingReport;
import org.codehaus.plexus.util.cli.StreamConsumer;
Modified: maven/surefire/branches/surefire-testng/surefire-booter/src/main/java/org/apache/maven/surefire/IsolatedClassLoader.java
URL: http://svn.apache.org/viewcvs/maven/surefire/branches/surefire-testng/surefire-booter/src/main/java/org/apache/maven/surefire/IsolatedClassLoader.java?rev=381878&r1=381877&r2=381878&view=diff
==============================================================================
--- maven/surefire/branches/surefire-testng/surefire-booter/src/main/java/org/apache/maven/surefire/IsolatedClassLoader.java (original)
+++ maven/surefire/branches/surefire-testng/surefire-booter/src/main/java/org/apache/maven/surefire/IsolatedClassLoader.java Tue Feb 28 18:42:20 2006
@@ -1,13 +1,13 @@
package org.apache.maven.surefire;
/*
- * Copyright 2001-2005 The Codehaus.
+ * Copyright 2001-2006 The Apache Software Foundation.
*
* Licensed 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
+ * 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,
@@ -64,7 +64,7 @@
{
Class c;
- if( childDelegation )
+ if ( childDelegation )
{
c = findLoadedClass( className );
Modified: maven/surefire/branches/surefire-testng/surefire-booter/src/main/java/org/apache/maven/surefire/SurefireBooter.java
URL: http://svn.apache.org/viewcvs/maven/surefire/branches/surefire-testng/surefire-booter/src/main/java/org/apache/maven/surefire/SurefireBooter.java?rev=381878&r1=381877&r2=381878&view=diff
==============================================================================
--- maven/surefire/branches/surefire-testng/surefire-booter/src/main/java/org/apache/maven/surefire/SurefireBooter.java (original)
+++ maven/surefire/branches/surefire-testng/surefire-booter/src/main/java/org/apache/maven/surefire/SurefireBooter.java Tue Feb 28 18:42:20 2006
@@ -1,7 +1,7 @@
package org.apache.maven.surefire;
/*
- * Copyright 2001-2005 The Codehaus.
+ * Copyright 2001-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -61,7 +61,7 @@
private List classpathUrls = new ArrayList();
private String testSourceDirectory;
-
+
private String reportsDirectory;
private String forkMode;
@@ -83,15 +83,15 @@
private boolean debug;
private boolean forceTestNG;
-
+
private String groups;
-
+
private String excludedGroups;
-
+
private int threadCount;
-
+
private boolean parallel;
-
+
private String surefireBooterJar;
private String plexusUtilsJar;
@@ -156,17 +156,17 @@
classpathUrls.add( path );
}
}
-
+
public void setClassPathUrls( List classpathUrls )
{
this.classpathUrls = classpathUrls;
}
- public void setTestSourceDirectory(String dirPath)
+ public void setTestSourceDirectory( String dirPath )
{
this.testSourceDirectory = dirPath;
}
-
+
// ----------------------------------------------------------------------
// Forking options
// ----------------------------------------------------------------------
@@ -192,27 +192,27 @@
{
this.forceTestNG = forceTestNG;
}
-
- public void setGroups(String groups)
+
+ public void setGroups( String groups )
{
this.groups = groups;
}
-
- public void setExcludedGroups(String excludedGroups)
+
+ public void setExcludedGroups( String excludedGroups )
{
this.excludedGroups = excludedGroups;
}
-
- public void setThreadCount(int threadCount)
+
+ public void setThreadCount( int threadCount )
{
this.threadCount = threadCount;
}
-
- public void setParallel(boolean parallel)
+
+ public void setParallel( boolean parallel )
{
this.parallel = parallel;
}
-
+
public void setSystemProperties( Properties systemProperties )
{
this.systemProperties = systemProperties;
@@ -273,12 +273,14 @@
return result;
}
- private ClassLoader createClassLoader() throws Exception
+ private ClassLoader createClassLoader()
+ throws Exception
{
return createClassLoader( classpathUrls, childDelegation );
}
- static private ClassLoader createClassLoader( List classpathUrls, boolean childDelegation ) throws Exception
+ static private ClassLoader createClassLoader( List classpathUrls, boolean childDelegation )
+ throws Exception
{
ArrayList urls = new ArrayList();
@@ -297,7 +299,8 @@
if ( childDelegation )
{
- IsolatedClassLoader surefireClassLoader = new IsolatedClassLoader( ClassLoader.getSystemClassLoader(), true );
+ IsolatedClassLoader surefireClassLoader =
+ new IsolatedClassLoader( ClassLoader.getSystemClassLoader(), true );
for ( Iterator iter = urls.iterator(); iter.hasNext(); )
{
URL url = (URL) iter.next();
@@ -336,23 +339,20 @@
Class batteryExecutorClass = surefireClassLoader.loadClass( BATTERY_EXECUTOR );
Object batteryExecutor = batteryExecutorClass.newInstance();
-
- Method run = batteryExecutorClass.getMethod( "run", new Class[]{List.class,
- List.class, ClassLoader.class, String.class,
- Boolean.class, String.class, String.class,
- Integer.class, Boolean.class, String.class} );
-
+
+ Method run = batteryExecutorClass.getMethod( "run", new Class[]{List.class, List.class, ClassLoader.class,
+ String.class, Boolean.class, String.class, String.class, Integer.class, Boolean.class, String.class} );
+
ClassLoader oldContextClassLoader = Thread.currentThread() .getContextClassLoader();
-
+
Thread.currentThread().setContextClassLoader( surefireClassLoader );
-
- Boolean result = (Boolean) run.invoke( batteryExecutor,
- new Object[]{reports, batteries, surefireClassLoader,
- reportsDirectory, new Boolean(forceTestNG), groups, excludedGroups,
- new Integer(threadCount), new Boolean(parallel), testSourceDirectory} );
-
+
+ Boolean result = (Boolean) run.invoke( batteryExecutor, new Object[]{reports, batteries, surefireClassLoader,
+ reportsDirectory, new Boolean( forceTestNG ), groups, excludedGroups, new Integer( threadCount ),
+ new Boolean( parallel ), testSourceDirectory} );
+
Thread.currentThread().setContextClassLoader( oldContextClassLoader );
-
+
return result.booleanValue();
}
@@ -717,7 +717,6 @@
}
ClassLoader classLoader = createForkingClassLoader( basedir );
-
Thread.currentThread().setContextClassLoader( classLoader );
Modified: maven/surefire/branches/surefire-testng/surefire-booter/src/main/java/org/apache/maven/surefire/SurefireBooterForkException.java
URL: http://svn.apache.org/viewcvs/maven/surefire/branches/surefire-testng/surefire-booter/src/main/java/org/apache/maven/surefire/SurefireBooterForkException.java?rev=381878&r1=381877&r2=381878&view=diff
==============================================================================
--- maven/surefire/branches/surefire-testng/surefire-booter/src/main/java/org/apache/maven/surefire/SurefireBooterForkException.java (original)
+++ maven/surefire/branches/surefire-testng/surefire-booter/src/main/java/org/apache/maven/surefire/SurefireBooterForkException.java Tue Feb 28 18:42:20 2006
@@ -1,7 +1,7 @@
package org.apache.maven.surefire;
/*
- * Copyright 2001-2005 The Codehaus.
+ * Copyright 2001-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,20 +16,21 @@
* limitations under the License.
*/
-public class SurefireBooterForkException extends Exception
+public class SurefireBooterForkException
+ extends Exception
{
- public SurefireBooterForkException(String message)
- {
- super(message);
- }
+ public SurefireBooterForkException( String message )
+ {
+ super( message );
+ }
- public SurefireBooterForkException(Throwable cause)
- {
- super(cause);
- }
+ public SurefireBooterForkException( Throwable cause )
+ {
+ super( cause );
+ }
- public SurefireBooterForkException(String message, Throwable cause)
- {
- super(message, cause);
- }
+ public SurefireBooterForkException( String message, Throwable cause )
+ {
+ super( message, cause );
+ }
}
Modified: maven/surefire/branches/surefire-testng/surefire/pom.xml
URL: http://svn.apache.org/viewcvs/maven/surefire/branches/surefire-testng/surefire/pom.xml?rev=381878&r1=381877&r2=381878&view=diff
==============================================================================
--- maven/surefire/branches/surefire-testng/surefire/pom.xml (original)
+++ maven/surefire/branches/surefire-testng/surefire/pom.xml Tue Feb 28 18:42:20 2006
@@ -1,4 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2001-2006 The Apache Software Foundation.
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
<project>
<parent>
<artifactId>surefire-root</artifactId>
Modified: maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/Surefire.java
URL: http://svn.apache.org/viewcvs/maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/Surefire.java?rev=381878&r1=381877&r2=381878&view=diff
==============================================================================
--- maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/Surefire.java (original)
+++ maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/Surefire.java Tue Feb 28 18:42:20 2006
@@ -1,7 +1,7 @@
package org.apache.maven.surefire;
/*
- * Copyright 2001-2005 The Codehaus.
+ * Copyright 2001-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,8 +37,8 @@
import java.util.ResourceBundle;
/**
- * @version $Id$
* @author Jason van Zyl
+ * @version $Id$
*/
public class Surefire
{
@@ -76,32 +76,35 @@
return resources;
}
- public boolean run(List reports, List batteryHolders,
- String reportsDirectory)
+ public boolean run( List reports, List batteryHolders, String reportsDirectory )
throws Exception
{
ClassLoader classLoader = this.getClass().getClassLoader();
- return run(reports, batteryHolders, classLoader, reportsDirectory);
+ return run( reports, batteryHolders, classLoader, reportsDirectory );
}
- public boolean run(List reports, List batteryHolders,
- ClassLoader classLoader, String reportsDirectory)
+ public boolean run( List reports, List batteryHolders, ClassLoader classLoader, String reportsDirectory )
throws Exception
{
- return run(reports, batteryHolders, classLoader, reportsDirectory,
- Boolean.FALSE, null, null, new Integer(0), Boolean.FALSE, null);
+ return run( reports, batteryHolders, classLoader, reportsDirectory, Boolean.FALSE, null, null, new Integer( 0 ),
+ Boolean.FALSE, null );
}
- public boolean run(List reports, List batteryHolders,
- ClassLoader classLoader, String reportsDirectory,
- Boolean forceTestNG, String groups, String excludedGroups,
- Integer threadCount, Boolean parallel, String testSourceDirectory)
+ public boolean run( List reports, List batteryHolders, ClassLoader classLoader, String reportsDirectory,
+ Boolean forceTestNG, String groups, String excludedGroups, Integer threadCount,
+ Boolean parallel, String testSourceDirectory )
throws Exception
{
- if (reports == null || batteryHolders == null || classLoader == null) { throw new NullPointerException(); }
+ if ( reports == null || batteryHolders == null || classLoader == null )
+ {
+ throw new NullPointerException();
+ }
- if (batteryHolders.size() == 0) { throw new IllegalArgumentException(); }
+ if ( batteryHolders.size() == 0 )
+ {
+ throw new IllegalArgumentException();
+ }
this.batteryHolders = batteryHolders;
@@ -130,106 +133,128 @@
throws Exception
{
//required for jdk14 javadoc annotations
- if (testSourceDirectory != null) {
- SurefireUtils.setTestSourceDirectory(testSourceDirectory);
+ if ( testSourceDirectory != null )
+ {
+ SurefireUtils.setTestSourceDirectory( testSourceDirectory );
}
- List batts = instantiateBatteries(batteryHolders, classLoader);
+ List batts = instantiateBatteries( batteryHolders, classLoader );
- reporterManager = new ReporterManager(instantiateReports(reports,
- classLoader), reportsDirectory);
+ reporterManager = new ReporterManager( instantiateReports( reports, classLoader ), reportsDirectory );
boolean jvm15 = false;
- if (System.getProperty("java.version").indexOf("1.5") > -1) jvm15 = true;
+ if ( System.getProperty( "java.version" ).indexOf( "1.5" ) > -1 )
+ {
+ jvm15 = true;
+ }
- try {
- reporterManager.runStarting(100);
+ try
+ {
+ reporterManager.runStarting( 100 );
- if (batts.size() > 0) {
+ if ( batts.size() > 0 )
+ {
int nbTests = 0;
- for(Iterator i = batts.iterator(); i.hasNext();) {
- Battery battery = (Battery)i.next();
+ for ( Iterator i = batts.iterator(); i.hasNext(); )
+ {
+ Battery battery = (Battery) i.next();
int testCount = 0;
- try {
+ try
+ {
testCount = battery.getTestCount();
- } catch (BatteryTestFailedException e) {
+ }
+ catch ( BatteryTestFailedException e )
+ {
e.printStackTrace();
- ReportEntry report = new ReportEntry(e,
- "org.apache.maven.surefire.Runner",
- getResources().getString("bigProblems"), e);
+ ReportEntry report = new ReportEntry( e, "org.apache.maven.surefire.Runner",
+ getResources().getString( "bigProblems" ), e );
- reporterManager.batteryAborted(report);
+ reporterManager.batteryAborted( report );
}
//TestNG needs a little config love
- if (battery instanceof TestNGXMLBattery) {
- TestNGXMLBattery xbat = (TestNGXMLBattery)battery;
- xbat.setOutputDirectory(reportsDirectory);
- xbat.setReporter(new TestNGReporter(reporterManager, this));
- xbat.execute(reporterManager);
+ if ( battery instanceof TestNGXMLBattery )
+ {
+ TestNGXMLBattery xbat = (TestNGXMLBattery) battery;
+ xbat.setOutputDirectory( reportsDirectory );
+ xbat.setReporter( new TestNGReporter( reporterManager, this ) );
+ xbat.execute( reporterManager );
nbTests += xbat.getTestCount();
- } else if (testCount > 0) {
- executeBattery(battery, reporterManager);
+ }
+ else if ( testCount > 0 )
+ {
+ executeBattery( battery, reporterManager );
nbTests += testCount;
}
List list = new ArrayList();
- for(Iterator j = battery.getSubBatteryClassNames()
- .iterator(); j.hasNext();) {
- String s = (String)j.next();
+ for ( Iterator j = battery.getSubBatteryClassNames()
+ .iterator(); j.hasNext(); )
+ {
+ String s = (String) j.next();
- list.add(new Object[] { s, null });
+ list.add( new Object[]{s, null} );
}
- List subBatteries = instantiateBatteries(list, classLoader);
+ List subBatteries = instantiateBatteries( list, classLoader );
//Handle testng tests
- if (forceTestNG || isTestNG(subBatteries)) {
+ if ( forceTestNG || isTestNG( subBatteries ) )
+ {
TestNG testNG = new TestNG();
List classes = new ArrayList();
- for (Iterator j = subBatteries.iterator(); j.hasNext();) {
- Battery b = (Battery)j.next();
- if (b instanceof TestNGBattery) {
- TestNGBattery tb = (TestNGBattery)b;
- classes.add(tb.getTestClass());
+ for ( Iterator j = subBatteries.iterator(); j.hasNext(); )
+ {
+ Battery b = (Battery) j.next();
+ if ( b instanceof TestNGBattery )
+ {
+ TestNGBattery tb = (TestNGBattery) b;
+ classes.add( tb.getTestClass() );
j.remove();
- } else if (forceTestNG && b instanceof JUnitBattery) {
- JUnitBattery jb = (JUnitBattery)b;
- classes.add(jb.getTestClass());
+ }
+ else if ( forceTestNG && b instanceof JUnitBattery )
+ {
+ JUnitBattery jb = (JUnitBattery) b;
+ classes.add( jb.getTestClass() );
j.remove();
}
}
//configure testng parameters
- ClassSuite classSuite =
- new ClassSuite(groups != null ? groups : "TestNG Suite",
- Utils.classesToXmlClasses(
- (Class[])classes.toArray(new Class[classes.size()])));
- testNG.setCommandLineSuite(classSuite);
- testNG.setOutputDirectory(reportsDirectory);
- TestNGReporter testngReporter = new TestNGReporter(reporterManager, this);
- testNG.addListener((ITestListener)testngReporter);
- testNG.addListener((ISuiteListener)testngReporter);
+ ClassSuite classSuite = new ClassSuite( groups != null ? groups : "TestNG Suite",
+ Utils.classesToXmlClasses( (Class[]) classes.toArray(
+ new Class[classes.size()] ) ) );
+ testNG.setCommandLineSuite( classSuite );
+ testNG.setOutputDirectory( reportsDirectory );
+ TestNGReporter testngReporter = new TestNGReporter( reporterManager, this );
+ testNG.addListener( (ITestListener) testngReporter );
+ testNG.addListener( (ISuiteListener) testngReporter );
// TODO: bring back when TestNG returns the method
// testNG.setReportResults(false);
- testNG.setThreadCount(threadCount);
- testNG.setParallel(parallel);
+ testNG.setThreadCount( threadCount );
+ testNG.setParallel( parallel );
- if (groups != null)
- testNG.setGroups(groups);
- if (excludedGroups != null)
- testNG.setExcludedGroups(excludedGroups);
+ if ( groups != null )
+ {
+ testNG.setGroups( groups );
+ }
+ if ( excludedGroups != null )
+ {
+ testNG.setExcludedGroups( excludedGroups );
+ }
//set source path so testng can find javadoc
//annotations if not in 1.5 jvm
- if (!jvm15 && testSourceDirectory != null)
- testNG.setSourcePath(testSourceDirectory);
+ if ( !jvm15 && testSourceDirectory != null )
+ {
+ testNG.setSourcePath( testSourceDirectory );
+ }
//actually runs all the tests
List result = testNG.runSuitesLocally();
@@ -237,28 +262,30 @@
}
//continue normal mode
- for(Iterator j = subBatteries.iterator(); j.hasNext();) {
- Battery b = (Battery)j.next();
+ for ( Iterator j = subBatteries.iterator(); j.hasNext(); )
+ {
+ Battery b = (Battery) j.next();
testCount = 0;
- try {
+ try
+ {
testCount = b.getTestCount();
- } catch (BatteryTestFailedException e) {
+ }
+ catch ( BatteryTestFailedException e )
+ {
e.printStackTrace();
- ReportEntry report = new ReportEntry(
- e,
- "org.apache.maven.surefire.SurefireRunner",
- getResources().getString("bigProblems"),
- e);
+ ReportEntry report = new ReportEntry( e, "org.apache.maven.surefire.SurefireRunner",
+ getResources().getString( "bigProblems" ), e );
- reporterManager.batteryAborted(report);
+ reporterManager.batteryAborted( report );
}
- if (testCount > 0) {
+ if ( testCount > 0 )
+ {
- executeBattery(b, reporterManager);
+ executeBattery( b, reporterManager );
nbTests += testCount;
}
@@ -266,43 +293,52 @@
}
- if (nbTests == 0) {
- reporterManager.writeMessage("There are no tests to run.");
+ if ( nbTests == 0 )
+ {
+ reporterManager.writeMessage( "There are no tests to run." );
}
- } else {
- reporterManager.writeMessage("There are no batteries to run.");
+ }
+ else
+ {
+ reporterManager.writeMessage( "There are no batteries to run." );
}
reporterManager.runCompleted();
- } catch (Throwable ex) {
+ }
+ catch ( Throwable ex )
+ {
ex.printStackTrace();
- ReportEntry report = new ReportEntry(ex,
- "org.apache.maven.surefire.Runner", getResources()
- .getString("bigProblems"), ex);
+ ReportEntry report = new ReportEntry( ex, "org.apache.maven.surefire.Runner", getResources()
+ .getString( "bigProblems" ), ex );
- reporterManager.runAborted(report);
+ reporterManager.runAborted( report );
}
reporterManager.resume();
- return !(reporterManager.getNbErrors() > 0 || reporterManager
- .getNbFailures() > 0);
+ return !( reporterManager.getNbErrors() > 0 || reporterManager
+ .getNbFailures() > 0 );
}
/**
* Determines if <i>any</i> of the batteries specified
* is an instance of {@link TestNGBattery}.
+ *
* @param batteries The batteries to check
* @return True, if any of the objects are an instanceof {@link TestNGBattery}
*/
- public boolean isTestNG(List batteries)
+ public boolean isTestNG( List batteries )
{
- if (batteries.size() > 0) {
- for (int i = 0; i < batteries.size(); i++) {
- Object obj = batteries.get(i);
- if (obj instanceof TestNGBattery)
+ if ( batteries.size() > 0 )
+ {
+ for ( int i = 0; i < batteries.size(); i++ )
+ {
+ Object obj = batteries.get( i );
+ if ( obj instanceof TestNGBattery )
+ {
return true;
+ }
}
}
@@ -314,38 +350,36 @@
* @param reportManager
* @throws Exception
*/
- public void executeBattery(Battery battery, ReporterManager reportManager)
+ public void executeBattery( Battery battery, ReporterManager reportManager )
throws Exception
{
- try {
- String rawString = getResources().getString(
- "suiteExecutionStarting");
+ try
+ {
+ String rawString = getResources().getString( "suiteExecutionStarting" );
- ReportEntry report = new ReportEntry(this,
- battery.getBatteryName(), battery.getBatteryName(), rawString);
+ ReportEntry report = new ReportEntry( this, battery.getBatteryName(), battery.getBatteryName(), rawString );
- reportManager.batteryStarting(report);
+ reportManager.batteryStarting( report );
- try {
- battery.execute(reportManager);
+ try
+ {
+ battery.execute( reportManager );
- rawString = getResources().getString("suiteCompletedNormally");
+ rawString = getResources().getString( "suiteCompletedNormally" );
- report = new ReportEntry(this, battery.getBatteryName(),
- battery.getBatteryName(),
- rawString);
+ report = new ReportEntry( this, battery.getBatteryName(), battery.getBatteryName(), rawString );
- reportManager.batteryCompleted(report);
- } catch (RuntimeException e) {
+ reportManager.batteryCompleted( report );
+ }
+ catch ( RuntimeException e )
+ {
e.printStackTrace();
- rawString = getResources().getString("executeException");
+ rawString = getResources().getString( "executeException" );
- report = new ReportEntry(this, battery.getBatteryName(),
- battery.getBatteryName(),
- rawString, e);
+ report = new ReportEntry( this, battery.getBatteryName(), battery.getBatteryName(), rawString, e );
- reportManager.batteryAborted(report);
+ reportManager.batteryAborted( report );
}
reportManager.runCompleted();
@@ -353,12 +387,12 @@
reportManager.dispose();
}
- catch (Throwable ex) {
- ReportEntry report = new ReportEntry(ex,
- "org.apache.maven.surefire.Runner", getResources()
- .getString("bigProblems"), ex);
+ catch ( Throwable ex )
+ {
+ ReportEntry report = new ReportEntry( ex, "org.apache.maven.surefire.Runner", getResources()
+ .getString( "bigProblems" ), ex );
- reportManager.runAborted(report);
+ reportManager.runAborted( report );
}
}
@@ -368,27 +402,27 @@
* @return
* @throws Exception
*/
- public static List instantiateBatteries(List batteryHolders,
- ClassLoader loader)
+ public static List instantiateBatteries( List batteryHolders, ClassLoader loader )
throws Exception
{
List batteries = new ArrayList();
- for(int i = 0; i < batteryHolders.size(); i++) {
- Object[] holder = (Object[])batteryHolders.get(i);
-
- Object battery = SurefireUtils.instantiateBattery(holder, loader);
-
- if (battery != null) {
- batteries.add(battery);
+ for ( int i = 0; i < batteryHolders.size(); i++ )
+ {
+ Object[] holder = (Object[]) batteryHolders.get( i );
+
+ Object battery = SurefireUtils.instantiateBattery( holder, loader );
+
+ if ( battery != null )
+ {
+ batteries.add( battery );
}
}
return batteries;
}
- protected List instantiateReports(List reportClassNames,
- ClassLoader classLoader)
+ protected List instantiateReports( List reportClassNames, ClassLoader classLoader )
throws Exception
{
List reports = new ArrayList();
@@ -397,27 +431,33 @@
ClassLoader reporterClassLoader = Reporter.class.getClassLoader();
- for(Iterator i = reportClassNames.iterator(); i.hasNext();) {
- String reportClassName = (String)i.next();
+ for ( Iterator i = reportClassNames.iterator(); i.hasNext(); )
+ {
+ String reportClassName = (String) i.next();
- try {
+ try
+ {
Class reportClass = reporterClassLoader
- .loadClass(reportClassName);
+ .loadClass( reportClassName );
// assert Reporter.class.isAssignableFrom(reportClass);
- Reporter report = (Reporter)reportClass.newInstance();
+ Reporter report = (Reporter) reportClass.newInstance();
- report.setReportsDirectory(reportsDirectory);
+ report.setReportsDirectory( reportsDirectory );
- reports.add(report);
- } catch (Exception e) {
+ reports.add( report );
+ }
+ catch ( Exception e )
+ {
e.printStackTrace();
}
}
- if (fail) { throw new RuntimeException(
- "couldn't assign reports as expected"); }
+ if ( fail )
+ {
+ throw new RuntimeException( "couldn't assign reports as expected" );
+ }
return reports;
}
Modified: maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/SurefireUtils.java
URL: http://svn.apache.org/viewcvs/maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/SurefireUtils.java?rev=381878&r1=381877&r2=381878&view=diff
==============================================================================
--- maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/SurefireUtils.java (original)
+++ maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/SurefireUtils.java Tue Feb 28 18:42:20 2006
@@ -1,9 +1,25 @@
package org.apache.maven.surefire;
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.battery.JUnitBattery;
import org.apache.maven.surefire.battery.TestNGBattery;
-import org.testng.internal.annotations.IAnnotationFinder;
import org.testng.internal.TestNGClassFinder;
+import org.testng.internal.annotations.IAnnotationFinder;
import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier;
@@ -14,7 +30,7 @@
*/
public class SurefireUtils
{
- private static final IAnnotationFinder annotationFinder;
+ private static final IAnnotationFinder annotationFinder;
static
{
@@ -37,7 +53,7 @@
public static void setTestSourceDirectory( String testSourceDirectory )
{
annotationFinder.addSourceDirs( new String[]{testSourceDirectory} );
-}
+ }
public static Object instantiateBattery( Object[] holder, ClassLoader loader )
throws Exception
@@ -61,9 +77,9 @@
{
return null;
}
-
+
Object battery = null;
-
+
if ( batteryClass.isAssignableFrom( testClass ) )
{
if ( holder[1] != null )
Modified: maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/AbstractBattery.java
URL: http://svn.apache.org/viewcvs/maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/AbstractBattery.java?rev=381878&r1=381877&r2=381878&view=diff
==============================================================================
--- maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/AbstractBattery.java (original)
+++ maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/AbstractBattery.java Tue Feb 28 18:42:20 2006
@@ -1,7 +1,7 @@
package org.apache.maven.surefire.battery;
/*
- * Copyright 2001-2005 The Codehaus.
+ * Copyright 2001-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Modified: maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/Battery.java
URL: http://svn.apache.org/viewcvs/maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/Battery.java?rev=381878&r1=381877&r2=381878&view=diff
==============================================================================
--- maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/Battery.java (original)
+++ maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/Battery.java Tue Feb 28 18:42:20 2006
@@ -1,7 +1,7 @@
package org.apache.maven.surefire.battery;
/*
- * Copyright 2001-2005 The Codehaus.
+ * Copyright 2001-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,7 +30,7 @@
String getBatteryName();
void discoverBatteryClassNames()
- throws Exception;
+ throws Exception;
List getSubBatteryClassNames();
}
Modified: maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/DirectoryBattery.java
URL: http://svn.apache.org/viewcvs/maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/DirectoryBattery.java?rev=381878&r1=381877&r2=381878&view=diff
==============================================================================
--- maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/DirectoryBattery.java (original)
+++ maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/DirectoryBattery.java Tue Feb 28 18:42:20 2006
@@ -1,7 +1,7 @@
package org.apache.maven.surefire.battery;
/*
- * Copyright 2001-2005 The Codehaus.
+ * Copyright 2001-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,9 +23,11 @@
import java.util.ArrayList;
import java.util.List;
-public class DirectoryBattery extends AbstractBattery {
+public class DirectoryBattery
+ extends AbstractBattery
+{
- private static final String FS = System.getProperty("file.separator");
+ private static final String FS = System.getProperty( "file.separator" );
private File basedir;
@@ -33,7 +35,7 @@
private List excludes;
- public DirectoryBattery(File basedir, ArrayList includes, ArrayList excludes)
+ public DirectoryBattery( File basedir, ArrayList includes, ArrayList excludes )
throws Exception
{
this.basedir = basedir;
@@ -44,55 +46,64 @@
discoverBatteryClassNames();
}
-
+
public void discoverBatteryClassNames()
throws Exception
{
- String[] tests = collectTests(basedir, includes, excludes);
+ String[] tests = collectTests( basedir, includes, excludes );
- if (tests == null) { return; }
+ if ( tests == null )
+ {
+ return;
+ }
- for(int i = 0; i < tests.length; i++) {
+ for ( int i = 0; i < tests.length; i++ )
+ {
String s = tests[i];
- s = s.substring(0, s.indexOf("."));
+ s = s.substring( 0, s.indexOf( "." ) );
- s = s.replace(FS.charAt(0), ".".charAt(0));
+ s = s.replace( FS.charAt( 0 ), ".".charAt( 0 ) );
- addSubBatteryClassName(s);
+ addSubBatteryClassName( s );
}
}
- public String[] collectTests(File basedir, List includes, List excludes)
+ public String[] collectTests( File basedir, List includes, List excludes )
throws Exception
{
- if (!basedir.exists()) { return null; }
+ if ( !basedir.exists() )
+ {
+ return null;
+ }
DirectoryScanner scanner = new DirectoryScanner();
- scanner.setBasedir(basedir);
+ scanner.setBasedir( basedir );
- if (includes != null) {
+ if ( includes != null )
+ {
String[] incs = new String[includes.size()];
- for(int i = 0; i < incs.length; i++) {
- incs[i] = StringUtils.replace((String)includes.get(i), "java",
- "class");
+ for ( int i = 0; i < incs.length; i++ )
+ {
+ incs[i] = StringUtils.replace( (String) includes.get( i ), "java", "class" );
}
- scanner.setIncludes(incs);
+ scanner.setIncludes( incs );
}
- if (excludes != null) {
+ if ( excludes != null )
+ {
String[] excls = new String[excludes.size()];
- for(int i = 0; i < excls.length; i++) {
- excls[i] = StringUtils.replace((String)excludes.get(i), "java",
- "class");
+ for ( int i = 0; i < excls.length; i++ )
+ {
+ excls[i] = StringUtils.replace( (String) excludes.get( i ), "java", "class" );
}
- scanner.setExcludes(excls);
+ scanner.setExcludes( excls );
}
scanner.scan();
Modified: maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/JUnitBattery.java
URL: http://svn.apache.org/viewcvs/maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/JUnitBattery.java?rev=381878&r1=381877&r2=381878&view=diff
==============================================================================
--- maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/JUnitBattery.java (original)
+++ maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/JUnitBattery.java Tue Feb 28 18:42:20 2006
@@ -1,7 +1,7 @@
package org.apache.maven.surefire.battery;
/*
- * Copyright 2001-2005 The Codehaus.
+ * Copyright 2001-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -147,7 +147,7 @@
if ( testObject == null )
{
- Constructor testConstructor = getTestConstructor( testClass );
+ Constructor testConstructor = getTestConstructor( testClass );
if ( testConstructor.getParameterTypes().length == 0 )
{
@@ -155,7 +155,7 @@
}
else
{
- testObject = testConstructor.newInstance( new Object[]{ testClass.getName() } );
+ testObject = testConstructor.newInstance( new Object[]{testClass.getName()} );
}
}
@@ -173,7 +173,7 @@
{
countTestCasesMethod = testInterface.getMethod( COUNT_TEST_CASES_METHOD, new Class[0] );
- runMethod = testInterface.getMethod( RUN_METHOD, new Class[] { testResultClass } );
+ runMethod = testInterface.getMethod( RUN_METHOD, new Class[]{testResultClass} );
}
else
@@ -181,19 +181,19 @@
try
{
countTestCasesMethod = testClass.getMethod( COUNT_TEST_CASES_METHOD, new Class[0] );
- }
- catch (Exception e)
- {
- countTestCasesMethod = null; // for clarity
- }
-
- try
- {
- runMethod = testClass.getMethod( RUN_METHOD, new Class[] { testResultClass } );
}
- catch (Exception e)
+ catch ( Exception e )
{
- runMethod = null; // for clarity
+ countTestCasesMethod = null; // for clarity
+ }
+
+ try
+ {
+ runMethod = testClass.getMethod( RUN_METHOD, new Class[]{testResultClass} );
+ }
+ catch ( Exception e )
+ {
+ runMethod = null; // for clarity
}
}
}
@@ -203,23 +203,23 @@
return testClass;
}
- protected Object getTestClassInstance()
- {
- return testObject;
- }
-
- public void execute( ReporterManager reportManager )
- throws Exception
- {
- if ( runMethod != null )
- {
- executeJUnit( reportManager );
- }
- else
- {
- super.execute( reportManager );
- }
- }
+ protected Object getTestClassInstance()
+ {
+ return testObject;
+ }
+
+ public void execute( ReporterManager reportManager )
+ throws Exception
+ {
+ if ( runMethod != null )
+ {
+ executeJUnit( reportManager );
+ }
+ else
+ {
+ super.execute( reportManager );
+ }
+ }
protected void executeJUnit( ReporterManager reportManager )
{
@@ -243,19 +243,23 @@
}
catch ( IllegalArgumentException e )
{
- throw new org.apache.maven.surefire.battery.assertion.BatteryTestFailedException( testObject.getClass().getName(), e );
+ throw new org.apache.maven.surefire.battery.assertion.BatteryTestFailedException(
+ testObject.getClass().getName(), e );
}
catch ( InstantiationException e )
{
- throw new org.apache.maven.surefire.battery.assertion.BatteryTestFailedException( testObject.getClass().getName(), e );
+ throw new org.apache.maven.surefire.battery.assertion.BatteryTestFailedException(
+ testObject.getClass().getName(), e );
}
catch ( IllegalAccessException e )
{
- throw new org.apache.maven.surefire.battery.assertion.BatteryTestFailedException( testObject.getClass().getName(), e );
+ throw new org.apache.maven.surefire.battery.assertion.BatteryTestFailedException(
+ testObject.getClass().getName(), e );
}
catch ( InvocationTargetException e )
{
- throw new org.apache.maven.surefire.battery.assertion.BatteryTestFailedException( testObject.getClass().getName(), e );
+ throw new org.apache.maven.surefire.battery.assertion.BatteryTestFailedException(
+ testObject.getClass().getName(), e );
}
}
@@ -263,7 +267,7 @@
{
try
{
- if ( countTestCasesMethod != null)
+ if ( countTestCasesMethod != null )
{
Integer integer = (Integer) countTestCasesMethod.invoke( testObject, new Class[0] );
@@ -276,15 +280,18 @@
}
catch ( IllegalAccessException e )
{
- throw new org.apache.maven.surefire.battery.assertion.BatteryTestFailedException( testObject.getClass().getName(), e );
+ throw new org.apache.maven.surefire.battery.assertion.BatteryTestFailedException(
+ testObject.getClass().getName(), e );
}
catch ( IllegalArgumentException e )
{
- throw new org.apache.maven.surefire.battery.assertion.BatteryTestFailedException( testObject.getClass().getName(), e );
+ throw new org.apache.maven.surefire.battery.assertion.BatteryTestFailedException(
+ testObject.getClass().getName(), e );
}
catch ( InvocationTargetException e )
{
- throw new org.apache.maven.surefire.battery.assertion.BatteryTestFailedException( testObject.getClass().getName(), e );
+ throw new org.apache.maven.surefire.battery.assertion.BatteryTestFailedException(
+ testObject.getClass().getName(), e );
}
}
@@ -293,11 +300,11 @@
return testClass.getName();
//return testClass.getPackage().getName();
}
-
+
protected Constructor getTestConstructor( Class testClass )
throws NoSuchMethodException
{
- Class[] params = { String.class };
+ Class[] params = {String.class};
try
{
Modified: maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/SingleTestBattery.java
URL: http://svn.apache.org/viewcvs/maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/SingleTestBattery.java?rev=381878&r1=381877&r2=381878&view=diff
==============================================================================
--- maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/SingleTestBattery.java (original)
+++ maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/SingleTestBattery.java Tue Feb 28 18:42:20 2006
@@ -1,7 +1,7 @@
package org.apache.maven.surefire.battery;
/*
- * Copyright 2001-2005 The Codehaus.
+ * Copyright 2001-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Modified: maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/TestListenerInvocationHandler.java
URL: http://svn.apache.org/viewcvs/maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/TestListenerInvocationHandler.java?rev=381878&r1=381877&r2=381878&view=diff
==============================================================================
--- maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/TestListenerInvocationHandler.java (original)
+++ maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/TestListenerInvocationHandler.java Tue Feb 28 18:42:20 2006
@@ -1,7 +1,7 @@
package org.apache.maven.surefire.battery;
/*
- * Copyright 2001-2005 The Codehaus.
+ * Copyright 2001-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,8 +28,11 @@
{
// The String names of the four methods in interface junit.framework.TestListener
private static final String START_TEST = "startTest";
+
private static final String ADD_FAILURE = "addFailure";
+
private static final String ADD_ERROR = "addError";
+
private static final String END_TEST = "endTest";
private HashSet failedTestsSet = new HashSet();
@@ -88,8 +91,7 @@
}
}
- public TestListenerInvocationHandler( ReporterManager reportManager,
- Object instanceOfTestResult,
+ public TestListenerInvocationHandler( ReporterManager reportManager, Object instanceOfTestResult,
ClassLoader loader )
{
if ( reportManager == null )
Modified: maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/TestNGBattery.java
URL: http://svn.apache.org/viewcvs/maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/TestNGBattery.java?rev=381878&r1=381877&r2=381878&view=diff
==============================================================================
--- maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/TestNGBattery.java (original)
+++ maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/TestNGBattery.java Tue Feb 28 18:42:20 2006
@@ -1,80 +1,104 @@
package org.apache.maven.surefire.battery;
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.report.ReporterManager;
+
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.List;
-import org.apache.maven.surefire.report.ReporterManager;
-
/**
* Main plugin point for running testng tests within the Surefire runtime
* infrastructure.
- *
+ *
* @author jkuhnert
*/
-public class TestNGBattery implements Battery {
-
+public class TestNGBattery
+ implements Battery
+{
+
protected List testMethods;
-
+
protected List subBatteryClassNames;
-
+
private Class testClass;
-
+
/**
* Creates a new test battery that will process the class being
* passed in to determine the testing configuration.
+ *
* @param testClass
* @param loader
* @throws Exception
*/
- public TestNGBattery(final Class testClass, ClassLoader loader)
- throws Exception {
- processTestClass(testClass, loader);
- }
-
- /**
- * Parses and configures this battery based on the test class
- * being passed in.
- * @param testClass
- * @param loader
- * @throws Exception
- */
- public void processTestClass(final Class testClass, ClassLoader loader)
- throws Exception {
- if (testClass == null) {
- throw new NullPointerException("testClass is null");
- }
-
- if (loader == null) {
- throw new NullPointerException("classLoader is null");
- }
-
- this.testClass = testClass;
- }
-
- public Class getTestClass()
+ public TestNGBattery( final Class testClass, ClassLoader loader )
+ throws Exception
+ {
+ processTestClass( testClass, loader );
+ }
+
+ /**
+ * Parses and configures this battery based on the test class
+ * being passed in.
+ *
+ * @param testClass
+ * @param loader
+ * @throws Exception
+ */
+ public void processTestClass( final Class testClass, ClassLoader loader )
+ throws Exception
+ {
+ if ( testClass == null )
+ {
+ throw new NullPointerException( "testClass is null" );
+ }
+
+ if ( loader == null )
+ {
+ throw new NullPointerException( "classLoader is null" );
+ }
+
+ this.testClass = testClass;
+ }
+
+ public Class getTestClass()
{
return testClass;
}
-
- protected void discoverTestMethods()
+
+ protected void discoverTestMethods()
{
if ( testMethods != null )
{
return;
}
-
+
testMethods = new ArrayList();
-
+
Method[] methods = testClass.getMethods();
-
+
for ( int i = 0; i < methods.length; ++i )
{
Method m = methods[i];
-
+
Class[] paramTypes = m.getParameterTypes();
-
+
boolean isInstanceMethod = !Modifier.isStatic( m.getModifiers() );
boolean returnsVoid = m.getReturnType() == void.class;
@@ -90,28 +114,33 @@
// name must have 5 or more chars
continue;
}
-
+
testMethods.add( m );
}
}
}
-
- public void discoverBatteryClassNames() throws Exception {
- }
-
- public void execute(ReporterManager reportManager) throws Exception {
- // TODO Auto-generated method stub
- }
-
- public String getBatteryName() {
- return testClass.getName();
- }
-
- public void addSubBatteryClassName( String batteryClassName )
+
+ public void discoverBatteryClassNames()
+ throws Exception
+ {
+ }
+
+ public void execute( ReporterManager reportManager )
+ throws Exception
+ {
+ // TODO Auto-generated method stub
+ }
+
+ public String getBatteryName()
+ {
+ return testClass.getName();
+ }
+
+ public void addSubBatteryClassName( String batteryClassName )
{
getSubBatteryClassNames().add( batteryClassName );
}
-
+
public List getSubBatteryClassNames()
{
if ( subBatteryClassNames == null )
@@ -121,10 +150,11 @@
return subBatteryClassNames;
}
-
- public int getTestCount() {
- discoverTestMethods();
-
+
+ public int getTestCount()
+ {
+ discoverTestMethods();
+
return testMethods.size();
- }
+ }
}
Modified: maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/TestNGXMLBattery.java
URL: http://svn.apache.org/viewcvs/maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/TestNGXMLBattery.java?rev=381878&r1=381877&r2=381878&view=diff
==============================================================================
--- maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/TestNGXMLBattery.java (original)
+++ maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/TestNGXMLBattery.java Tue Feb 28 18:42:20 2006
@@ -3,14 +3,21 @@
*/
package org.apache.maven.surefire.battery;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import javax.xml.parsers.ParserConfigurationException;
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.report.ReporterManager;
import org.apache.maven.surefire.report.TestNGReporter;
@@ -21,60 +28,79 @@
import org.testng.xml.XmlSuite;
import org.xml.sax.SAXException;
+import javax.xml.parsers.ParserConfigurationException;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
/**
* Handles suite xml file definitions for TestNG.
- *
+ *
* @author jkuhnert
*/
-public class TestNGXMLBattery implements Battery {
-
+public class TestNGXMLBattery
+ implements Battery
+{
+
protected File suiteFile;
+
protected TestNG testRunner;
+
protected int m_testCount = 0;
+
protected String m_suiteName = "TestNG XML Suite";
-
+
/**
* Creates a testng battery to be configured by the specified
* xml file.
*/
- public TestNGXMLBattery(File suiteFile)
+ public TestNGXMLBattery( File suiteFile )
{
this.suiteFile = suiteFile;
parseSuite();
}
-
- public void discoverBatteryClassNames() throws Exception {
+
+ public void discoverBatteryClassNames()
+ throws Exception
+ {
}
-
- public void execute(ReporterManager reportManager) throws Exception {
+
+ public void execute( ReporterManager reportManager )
+ throws Exception
+ {
testRunner.runSuitesLocally();
}
-
- public String getBatteryName() {
+
+ public String getBatteryName()
+ {
return m_suiteName;
}
-
+
public List getSubBatteryClassNames()
{
return Collections.EMPTY_LIST;
}
-
- public int getTestCount() {
+
+ public int getTestCount()
+ {
return m_testCount;
}
-
- public void setOutputDirectory(String reportsDirectory)
+
+ public void setOutputDirectory( String reportsDirectory )
{
- testRunner.setOutputDirectory(reportsDirectory);
+ testRunner.setOutputDirectory( reportsDirectory );
}
-
- public void setReporter(TestNGReporter reporter)
+
+ public void setReporter( TestNGReporter reporter )
{
- testRunner.addListener((ITestListener)reporter);
- testRunner.addListener((ISuiteListener)reporter);
+ testRunner.addListener( (ITestListener) reporter );
+ testRunner.addListener( (ISuiteListener) reporter );
}
-
+
/**
* Instantiates and partially configures testng suite
*/
@@ -82,27 +108,32 @@
{
testRunner = new TestNG();
List suites = new ArrayList();
-
- try {
- XmlSuite s = new Parser(suiteFile.getAbsolutePath()).parse();
+
+ try
+ {
+ XmlSuite s = new Parser( suiteFile.getAbsolutePath() ).parse();
m_suiteName = s.getName();
m_testCount += s.getTests().size();
- suites.add(s);
+ suites.add( s );
}
- catch(FileNotFoundException fne) {
- System.err.println("File not found: " + suiteFile.getAbsolutePath() + " Ignoring.");
+ catch ( FileNotFoundException fne )
+ {
+ System.err.println( "File not found: " + suiteFile.getAbsolutePath() + " Ignoring." );
}
- catch(IOException e) {
+ catch ( IOException e )
+ {
e.printStackTrace();
}
- catch(ParserConfigurationException e) {
+ catch ( ParserConfigurationException e )
+ {
e.printStackTrace();
}
- catch(SAXException e) {
+ catch ( SAXException e )
+ {
e.printStackTrace();
}
-
- testRunner.setXmlSuites(suites);
+
+ testRunner.setXmlSuites( suites );
// TODO: return when TestNG brings it back
// testRunner.setReportResults(false);
}
Modified: maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/assertion/BatteryAssert.java
URL: http://svn.apache.org/viewcvs/maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/assertion/BatteryAssert.java?rev=381878&r1=381877&r2=381878&view=diff
==============================================================================
--- maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/assertion/BatteryAssert.java (original)
+++ maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/assertion/BatteryAssert.java Tue Feb 28 18:42:20 2006
@@ -1,7 +1,7 @@
package org.apache.maven.surefire.battery.assertion;
/*
- * Copyright 2001-2005 The Codehaus.
+ * Copyright 2001-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,7 +19,8 @@
import junit.framework.TestCase;
import org.apache.maven.surefire.Surefire;
-public class BatteryAssert extends TestCase
+public class BatteryAssert
+ extends TestCase
{
public static void verify( boolean condition )
{
@@ -178,7 +179,8 @@
{
if ( !( expected == actual ) )
{
- failNotEquals( message, new Float( expected ), new Float( actual ) );}
+ failNotEquals( message, new Float( expected ), new Float( actual ) );
+ }
}
else if ( !( Math.abs( expected - actual ) <= delta ) )
Modified: maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/assertion/BatteryAssertionFailedError.java
URL: http://svn.apache.org/viewcvs/maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/assertion/BatteryAssertionFailedError.java?rev=381878&r1=381877&r2=381878&view=diff
==============================================================================
--- maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/assertion/BatteryAssertionFailedError.java (original)
+++ maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/assertion/BatteryAssertionFailedError.java Tue Feb 28 18:42:20 2006
@@ -1,7 +1,7 @@
package org.apache.maven.surefire.battery.assertion;
/*
- * Copyright 2001-2005 The Codehaus.
+ * Copyright 2001-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Modified: maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/assertion/BatteryComparisonFailure.java
URL: http://svn.apache.org/viewcvs/maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/assertion/BatteryComparisonFailure.java?rev=381878&r1=381877&r2=381878&view=diff
==============================================================================
--- maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/assertion/BatteryComparisonFailure.java (original)
+++ maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/assertion/BatteryComparisonFailure.java Tue Feb 28 18:42:20 2006
@@ -1,7 +1,7 @@
package org.apache.maven.surefire.battery.assertion;
/*
- * Copyright 2001-2005 The Codehaus.
+ * Copyright 2001-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,19 +18,22 @@
/**
* Thrown when an assertion equals for Strings failed.
- *
+ * <p/>
* Inspired by a patch from Alex Chaffee mailto:alex@purpletech.com
*/
-public class BatteryComparisonFailure extends BatteryAssertionFailedError
+public class BatteryComparisonFailure
+ extends BatteryAssertionFailedError
{
private String fExpected;
+
private String fActual;
/**
* Constructs a comparison failure.
- * @param message the identifying message or null
+ *
+ * @param message the identifying message or null
* @param expected the expected string value
- * @param actual the actual string value
+ * @param actual the actual string value
*/
public BatteryComparisonFailure( String message, String expected, String actual )
{
@@ -48,7 +51,9 @@
public String getMessage()
{
if ( fExpected == null || fActual == null )
+ {
return BatteryAssert.formatMismatch( super.getMessage(), fExpected, fActual );
+ }
int end = Math.min( fExpected.length(), fActual.length() );
@@ -56,14 +61,18 @@
for ( ; i < end; i++ )
{
if ( fExpected.charAt( i ) != fActual.charAt( i ) )
+ {
break;
+ }
}
int j = fExpected.length() - 1;
int k = fActual.length() - 1;
for ( ; k >= i && j >= i; k--, j-- )
{
if ( fExpected.charAt( j ) != fActual.charAt( k ) )
+ {
break;
+ }
}
String actual, expected;
@@ -84,9 +93,13 @@
}
if ( j < fExpected.length() - 1 )
+ {
expected = expected + "...";
+ }
if ( k < fActual.length() - 1 )
+ {
actual = actual + "...";
+ }
}
return BatteryAssert.formatMismatch( super.getMessage(), expected, actual );
}
Modified: maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/assertion/BatteryTestFailedException.java
URL: http://svn.apache.org/viewcvs/maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/assertion/BatteryTestFailedException.java?rev=381878&r1=381877&r2=381878&view=diff
==============================================================================
--- maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/assertion/BatteryTestFailedException.java (original)
+++ maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/battery/assertion/BatteryTestFailedException.java Tue Feb 28 18:42:20 2006
@@ -1,7 +1,7 @@
package org.apache.maven.surefire.battery.assertion;
/*
- * Copyright 2001-2005 The Codehaus.
+ * Copyright 2001-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,10 +21,12 @@
*
* @author Bill Venners
*/
- public class BatteryTestFailedException extends RuntimeException
+public class BatteryTestFailedException
+ extends RuntimeException
{
private boolean causeInitialized;
+
private Throwable cause;
/**
@@ -40,8 +42,8 @@
* Create a <code>TestFailedException</code> with a detail message.
*
* @param message A detail message for this <code>TestFailedException</code>, or
- * <code>null</code>. If <code>null</code> is passed, the <code>getMessage</code>
- * method will return an empty <code>String</code>.
+ * <code>null</code>. If <code>null</code> is passed, the <code>getMessage</code>
+ * method will return an empty <code>String</code>.
*/
public BatteryTestFailedException( String message )
{
@@ -52,14 +54,14 @@
/**
* Create a <code>TestFailedException</code> with the specified detail
* message and cause.
- *
+ * <p/>
* <p>Note that the detail message associated with cause is
* <em>not</em> automatically incorporated in this throwable's detail
* message.
*
* @param message A detail message for this <code>TestFailedException</code>, or <code>null</code>.
- * @param cause the cause, which is saved for later retrieval by the <code>getCause</code> method.
- * (A null value is permitted, and indicates that the cause is nonexistent or unknown.)
+ * @param cause the cause, which is saved for later retrieval by the <code>getCause</code> method.
+ * (A null value is permitted, and indicates that the cause is nonexistent or unknown.)
*/
public BatteryTestFailedException( String message, Throwable cause )
{
@@ -98,21 +100,21 @@
* Initializes the cause of this <code>TestFailedException</code> to the specified value.
* (The cause is the <code>Throwable</code> that caused this <code>TestFailedException</code>
* to get thrown.)
- *
+ * <p/>
* This method can be called at most once. It is generally called immediately after creating
* the <code>TestFailedException</code>. If this <code>TestFailedException</code> was created
* with <code>TestFailedException(Throwable)</code> or
* <code>TestFailedException(String, Throwable)</code>, this method cannot be called even once.
*
* @param cause the cause (which is saved for later retrieval by the <code>getCause()</code>
- * method). A <code>null</code> value is permitted, and indicates that the cause is
- * nonexistent or unknown.)
- * @throws java.lang.IllegalArgumentException - if cause is this <code>TestFailedException</code>. (A
- * <code>TestFailedException</code> cannot be its own cause.)
- * @throws java.lang.IllegalStateException if this <code>TestFailedException</code> was created
- * with <code>TestFailedException(Throwable)</code> or
- * <code>TestFailedException(String, Throwable)</code>, or this method has already been
- * called on this <code>TestFailedException</code>.
+ * method). A <code>null</code> value is permitted, and indicates that the cause is
+ * nonexistent or unknown.)
+ * @throws IllegalArgumentException - if cause is this <code>TestFailedException</code>. (A
+ * <code>TestFailedException</code> cannot be its own cause.)
+ * @throws IllegalStateException if this <code>TestFailedException</code> was created
+ * with <code>TestFailedException(Throwable)</code> or
+ * <code>TestFailedException(String, Throwable)</code>, or this method has already been
+ * called on this <code>TestFailedException</code>.
*/
public synchronized Throwable initCause( Throwable cause )
{
Modified: maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/AbstractReporter.java
URL: http://svn.apache.org/viewcvs/maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/AbstractReporter.java?rev=381878&r1=381877&r2=381878&view=diff
==============================================================================
--- maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/AbstractReporter.java (original)
+++ maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/AbstractReporter.java Tue Feb 28 18:42:20 2006
@@ -1,7 +1,7 @@
package org.apache.maven.surefire.report;
/*
- * Copyright 2001-2005 The Codehaus.
+ * Copyright 2001-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,7 +36,7 @@
protected long startTime;
protected long endTime;
-
+
private NumberFormat numberFormat = NumberFormat.getInstance();
public void setReportsDirectory( String reportsDirectory )
Modified: maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/BriefConsoleReporter.java
URL: http://svn.apache.org/viewcvs/maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/BriefConsoleReporter.java?rev=381878&r1=381877&r2=381878&view=diff
==============================================================================
--- maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/BriefConsoleReporter.java (original)
+++ maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/BriefConsoleReporter.java Tue Feb 28 18:42:20 2006
@@ -1,7 +1,7 @@
package org.apache.maven.surefire.report;
/*
- * Copyright 2001-2005 The Codehaus.
+ * Copyright 2001-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,35 +22,36 @@
import java.io.StringWriter;
/**
- * Brief format console reporter.
- * @author <a href="mailto:jruiz@exist.com">Johnny R. Ruiz III</a>
- * @version $Id$
+ * Brief format console reporter.
+ *
+ * @author <a href="mailto:jruiz@exist.com">Johnny R. Ruiz III</a>
+ * @version $Id$
*/
public class BriefConsoleReporter
extends AbstractReporter
{
private static final int BUFFER_SIZE = 4096;
-
+
private PrintWriter writer;
-
+
private StringBuffer reportContent;
-
+
private long batteryStartTime;
-
- String newLine = System.getProperty("line.separator");
-
+
+ String newLine = System.getProperty( "line.separator" );
+
public BriefConsoleReporter()
{
writer = new PrintWriter( new OutputStreamWriter( new BufferedOutputStream( System.out, BUFFER_SIZE ) ) );
}
-
+
public void writeMessage( String message )
{
writer.println( message );
writer.flush();
}
-
+
public void runStarting( int testCount )
{
writer.println();
@@ -58,72 +59,72 @@
writer.println( " T E S T S" );
writer.println( "-------------------------------------------------------" );
writer.flush();
-
+
}
public void batteryStarting( ReportEntry report )
throws Exception
{
batteryStartTime = System.currentTimeMillis();
-
+
reportContent = new StringBuffer();
-
+
writer.println( "[surefire] Running " + report.getName() );
}
public void batteryCompleted( ReportEntry report )
{
long runTime = System.currentTimeMillis() - this.batteryStartTime;
-
+
StringBuffer batterySummary = new StringBuffer();
batterySummary.append( "[surefire] Tests run: " + String.valueOf( this.getNbTests() ) )
- .append( ", Failures: " + String.valueOf( this.getNbFailures() ) )
- .append( ", Errors: " + String.valueOf( this.getNbErrors() ))
- .append( ", Time elapsed: " + elapsedTimeAsString( runTime ))
- .append(" sec")
- .append(newLine)
- .append("[surefire] " + newLine);
-
- reportContent = batterySummary.append(reportContent);
-
+ .append( ", Failures: " + String.valueOf( this.getNbFailures() ) )
+ .append( ", Errors: " + String.valueOf( this.getNbErrors() ) )
+ .append( ", Time elapsed: " + elapsedTimeAsString( runTime ) )
+ .append( " sec" )
+ .append( newLine )
+ .append( "[surefire] " + newLine );
+
+ reportContent = batterySummary.append( reportContent );
+
writer.println( reportContent.toString() );
-
+
writer.flush();
}
public void testStarting( ReportEntry report )
- {
- super.testStarting(report);
+ {
+ super.testStarting( report );
}
public void testError( ReportEntry report, String stdOut, String stdErr )
{
- super.testError(report, stdOut, stdErr);
+ super.testError( report, stdOut, stdErr );
+
+ reportContent.append( "[surefire] " + report.getName() );
- reportContent.append("[surefire] " + report.getName() );
-
long runTime = this.endTime - this.startTime;
-
- writeTimeElapsed(runTime);
-
- reportContent.append(" <<< ERROR!" + newLine);
-
+
+ writeTimeElapsed( runTime );
+
+ reportContent.append( " <<< ERROR!" + newLine );
+
reportContent.append( getStackTrace( report ) + newLine );
}
public void testFailed( ReportEntry report, String stdOut, String stdErr )
{
- super.testFailed(report, stdOut, stdErr);
-
- reportContent.append("[surefire] " + report.getName() );
-
+ super.testFailed( report, stdOut, stdErr );
+
+ reportContent.append( "[surefire] " + report.getName() );
+
long runTime = this.endTime - this.startTime;
-
- writeTimeElapsed(runTime);
-
- reportContent.append(" <<< FAILURE!" + newLine);
+
+ writeTimeElapsed( runTime );
+
+ reportContent.append( " <<< FAILURE!" + newLine );
reportContent.append( getStackTrace( report ) + newLine );
}
@@ -131,30 +132,31 @@
public void dispose()
{
errors = 0;
-
+
failures = 0;
-
- completedCount = 0;
+
+ completedCount = 0;
}
- private void writeTimeElapsed(long sec)
+ private void writeTimeElapsed( long sec )
{
reportContent.append( " Time elapsed: " + elapsedTimeAsString( sec ) + " sec" );
}
-
+
/**
* Returns stacktrace as String.
- * @param report ReportEntry object.
- * @return stacktrace as string.
+ *
+ * @param report ReportEntry object.
+ * @return stacktrace as string.
*/
- private String getStackTrace(ReportEntry report)
- {
+ private String getStackTrace( ReportEntry report )
+ {
StringWriter writer = new StringWriter();
-
- report.getThrowable().printStackTrace(new PrintWriter(writer));
-
+
+ report.getThrowable().printStackTrace( new PrintWriter( writer ) );
+
writer.flush();
-
+
return writer.toString();
}
}