maven-surefire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r381916 - in /maven/surefire/branches/surefire-testng: surefire-booter/src/main/java/org/apache/maven/surefire/ surefire/src/main/java/org/apache/maven/surefire/ surefire/src/main/java/org/apache/maven/surefire/battery/ surefire/src/main/ja...
Date Wed, 01 Mar 2006 06:13:20 GMT
Author: brett
Date: Tue Feb 28 22:13:17 2006
New Revision: 381916

URL: http://svn.apache.org/viewcvs?rev=381916&view=rev
Log:
further removal of duplicate code

Added:
    maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/AbstractFileReporter.java   (with props)
Modified:
    maven/surefire/branches/surefire-testng/surefire-booter/src/main/java/org/apache/maven/surefire/SurefireBooter.java
    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/battery/AbstractBattery.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/TestNGBattery.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/report/AbstractConsoleReporter.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/ForkingSummaryConsoleReporter.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

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=381916&r1=381915&r2=381916&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 22:13:17 2006
@@ -763,41 +763,9 @@
 
             batteryParms[0] = new File( batteryParts[1] );
 
-            String stringList = batteryParts[2];
+            batteryParms[1] = processStringList( batteryParts[2] );
 
-            if ( stringList.startsWith( "[" ) && stringList.endsWith( "]" ) )
-            {
-                stringList = stringList.substring( 1, stringList.length() - 1 );
-            }
-
-            ArrayList includesList = new ArrayList();
-
-            String[] stringArray = stringList.split( "," );
-
-            for ( int i = 0; i < stringArray.length; i++ )
-            {
-                includesList.add( stringArray[i].trim() );
-            }
-
-            batteryParms[1] = includesList;
-
-            stringList = batteryParts[3];
-
-            ArrayList excludesList = new ArrayList();
-
-            if ( stringList.startsWith( "[" ) && stringList.endsWith( "]" ) )
-            {
-                stringList = stringList.substring( 1, stringList.length() - 1 );
-            }
-
-            stringArray = stringList.split( "," );
-
-            for ( int i = 0; i < stringArray.length; i++ )
-            {
-                excludesList.add( stringArray[i].trim() );
-            }
-
-            batteryParms[2] = excludesList;
+            batteryParms[2] = processStringList( batteryParts[3] );
         }
         else
         {
@@ -842,6 +810,25 @@
         System.exit( returnCode );
     }
 
+    private static List processStringList( String stringList )
+    {
+        String sl = stringList;
+
+        if ( sl.startsWith( "[" ) && sl.endsWith( "]" ) )
+        {
+            sl = sl.substring( 1, sl.length() - 1 );
+        }
+
+        List list = new ArrayList();
+
+        String[] stringArray = sl.split( "," );
+
+        for ( int i = 0; i < stringArray.length; i++ )
+        {
+            list.add( stringArray[i].trim() );
+        }
+        return list;
+    }
 
     private static void logClassLoader( ClassLoader classLoader )
     {

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=381916&r1=381915&r2=381916&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 22:13:17 2006
@@ -66,16 +66,6 @@
 
     private boolean parallel;
 
-    public Surefire()
-    {
-        super();
-    }
-
-    public static ResourceBundle getResources()
-    {
-        return resources;
-    }
-
     public boolean run( List reports, List batteryHolders, String reportsDirectory )
         throws Exception
     {
@@ -171,7 +161,7 @@
                         e.printStackTrace();
 
                         ReportEntry report = new ReportEntry( e, "org.apache.maven.surefire.Runner",
-                                                              getResources().getString( "bigProblems" ), e );
+                                                              getResourceString( "bigProblems" ), e );
 
                         reporterManager.batteryAborted( report );
                     }
@@ -277,7 +267,7 @@
                             e.printStackTrace();
 
                             ReportEntry report = new ReportEntry( e, "org.apache.maven.surefire.SurefireRunner",
-                                                                  getResources().getString( "bigProblems" ), e );
+                                                                  getResourceString( "bigProblems" ), e );
 
                             reporterManager.batteryAborted( report );
                         }
@@ -309,8 +299,8 @@
         {
             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", getResourceString( "bigProblems" ), ex );
 
             reporterManager.runAborted( report );
         }
@@ -355,7 +345,7 @@
     {
         try
         {
-            String rawString = getResources().getString( "suiteExecutionStarting" );
+            String rawString = getResourceString( "suiteExecutionStarting" );
 
             ReportEntry report = new ReportEntry( this, battery.getBatteryName(), battery.getBatteryName(), rawString );
 
@@ -365,7 +355,7 @@
             {
                 battery.execute( reportManager );
 
-                rawString = getResources().getString( "suiteCompletedNormally" );
+                rawString = getResourceString( "suiteCompletedNormally" );
 
                 report = new ReportEntry( this, battery.getBatteryName(), battery.getBatteryName(), rawString );
 
@@ -375,7 +365,7 @@
             {
                 e.printStackTrace();
 
-                rawString = getResources().getString( "executeException" );
+                rawString = getResourceString( "executeException" );
 
                 report = new ReportEntry( this, battery.getBatteryName(), battery.getBatteryName(), rawString, e );
 
@@ -386,11 +376,10 @@
 
             reportManager.dispose();
         }
-
         catch ( Throwable ex )
         {
-            ReportEntry report = new ReportEntry( ex, "org.apache.maven.surefire.Runner", getResources()
-                .getString( "bigProblems" ), ex );
+            ReportEntry report =
+                new ReportEntry( ex, "org.apache.maven.surefire.Runner", getResourceString( "bigProblems" ), ex );
 
             reportManager.runAborted( report );
         }
@@ -460,5 +449,10 @@
         }
 
         return reports;
+    }
+
+    public static String getResourceString( String key )
+    {
+        return resources.getString( key );
     }
 }

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=381916&r1=381915&r2=381916&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 22:13:17 2006
@@ -23,7 +23,6 @@
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
 import java.text.MessageFormat;
 import java.util.ArrayList;
 import java.util.List;
@@ -98,7 +97,7 @@
         catch ( Exception e )
         {
             // Treat any exception from setUpFixture as a failure of the test.
-            String rawString = Surefire.getResources().getString( "setupFixtureFailed" );
+            String rawString = Surefire.getResourceString( "setupFixtureFailed" );
 
             MessageFormat msgFmt = new MessageFormat( rawString );
 
@@ -168,7 +167,7 @@
         {
 
             // Treat any exception from tearDownFixture as a failure of the test.
-            String rawString = Surefire.getResources().getString( "cleanupFixtureFailed" );
+            String rawString = Surefire.getResourceString( "cleanupFixtureFailed" );
 
             MessageFormat msgFmt = new MessageFormat( rawString );
 
@@ -250,15 +249,7 @@
             {
                 Method m = methods[i];
 
-                Class[] paramTypes = m.getParameterTypes();
-
-                boolean isInstanceMethod = !Modifier.isStatic( m.getModifiers() );
-
-                boolean returnsVoid = m.getReturnType().equals( void.class );
-
-                boolean hasNoParams = paramTypes.length == 0;
-
-                if ( isInstanceMethod && returnsVoid && hasNoParams )
+                if ( isValidMethod( m ) )
                 {
                     String simpleName = m.getName();
 

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=381916&r1=381915&r2=381916&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 22:13:17 2006
@@ -80,31 +80,28 @@
 
         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" );
-
-            }
-
-            scanner.setIncludes( incs );
+            scanner.setIncludes( processIncludesExcludes( includes ) );
         }
 
         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" );
-            }
-
-            scanner.setExcludes( excls );
+            scanner.setExcludes( processIncludesExcludes( excludes ) );
         }
 
         scanner.scan();
 
         return scanner.getIncludedFiles();
+    }
+
+    private static String[] processIncludesExcludes( List list )
+    {
+        String[] incs = new String[list.size()];
+
+        for ( int i = 0; i < incs.length; i++ )
+        {
+            incs[i] = StringUtils.replace( (String) list.get( i ), "java", "class" );
+
+        }
+        return incs;
     }
 }

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=381916&r1=381915&r2=381916&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 22:13:17 2006
@@ -16,10 +16,10 @@
  * limitations under the License.
  */
 
+import org.apache.maven.surefire.battery.assertion.BatteryAssert;
 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;
 
@@ -32,7 +32,6 @@
 public class TestNGBattery
     implements Battery
 {
-
     protected List testMethods;
 
     protected List subBatteryClassNames;
@@ -90,15 +89,8 @@
             {
                 Method m = methods[i];
 
-                Class[] paramTypes = m.getParameterTypes();
-
-                boolean isInstanceMethod = !Modifier.isStatic( m.getModifiers() );
-
-                boolean returnsVoid = m.getReturnType().equals( void.class );
-
-                boolean hasNoParams = paramTypes.length == 0;
-
-                if ( isInstanceMethod && returnsVoid && hasNoParams )
+                // TODO: better location
+                if ( BatteryAssert.isValidMethod( m ) )
                 {
                     String simpleName = m.getName();
 

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=381916&r1=381915&r2=381916&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 22:13:17 2006
@@ -19,12 +19,17 @@
 import junit.framework.TestCase;
 import org.apache.maven.surefire.Surefire;
 
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+// TODO: get rid of TestCase?
+
 public class BatteryAssert
     extends TestCase
 {
     public static void verify( boolean condition )
     {
-        String detailMsg = Surefire.getResources().getString( "conditionFalse" );
+        String detailMsg = Surefire.getResourceString( "conditionFalse" );
 
         verify( condition, detailMsg );
     }
@@ -334,5 +339,16 @@
         }
 
         return formatted + "expected:<" + expected + "> but was:<" + actual + ">";
+    }
+
+    public static boolean isValidMethod( Method m )
+    {
+        boolean isInstanceMethod = !Modifier.isStatic( m.getModifiers() );
+
+        boolean returnsVoid = m.getReturnType().equals( void.class );
+
+        boolean hasNoParams = m.getParameterTypes().length == 0;
+
+        return isInstanceMethod && returnsVoid && hasNoParams;
     }
 }

Modified: maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/AbstractConsoleReporter.java
URL: http://svn.apache.org/viewcvs/maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/AbstractConsoleReporter.java?rev=381916&r1=381915&r2=381916&view=diff
==============================================================================
--- maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/AbstractConsoleReporter.java (original)
+++ maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/AbstractConsoleReporter.java Tue Feb 28 22:13:17 2006
@@ -17,11 +17,14 @@
  */
 
 import java.io.BufferedOutputStream;
+import java.io.IOException;
 import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
 
 /**
  * Base class for console reporters.
+ * <p/>
+ * // TODO: what about stream closing?
  *
  * @author <a href="mailto:brett@apache.org">Brett Porter</a>
  */
@@ -32,16 +35,22 @@
 
     protected PrintWriter writer;
 
-    protected long batteryStartTime;
-
     protected AbstractConsoleReporter()
     {
         writer = new PrintWriter( new OutputStreamWriter( new BufferedOutputStream( System.out, BUFFER_SIZE ) ) );
     }
 
+    public void batteryStarting( ReportEntry report )
+        throws IOException
+    {
+        super.batteryStarting( report );
+
+        writeMessage( "Running " + report.getName() );
+    }
+
     public void writeMessage( String message )
     {
-        writer.println( message );
+        writer.println( "[surefire] " + message );
         writer.flush();
     }
 
@@ -52,29 +61,5 @@
         writer.println( " T E S T S" );
         writer.println( "-------------------------------------------------------" );
         writer.flush();
-    }
-
-    public void batteryStarting( ReportEntry report )
-    {
-        batteryStartTime = System.currentTimeMillis();
-
-        writer.println( "[surefire] Running " + report.getName() );
-        writer.flush();
-    }
-
-    protected StringBuffer getBatterySummary()
-    {
-        StringBuffer batterySummary = new StringBuffer();
-
-        batterySummary.append( "[surefire] Tests run: " );
-        batterySummary.append( completedCount );
-        batterySummary.append( ", Failures: " );
-        batterySummary.append( failures );
-        batterySummary.append( ", Errors: " );
-        batterySummary.append( errors );
-        batterySummary.append( ", Time elapsed: " );
-        batterySummary.append( elapsedTimeAsString( System.currentTimeMillis() - batteryStartTime ) );
-        batterySummary.append( " sec" );
-        return batterySummary;
     }
 }

Added: maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/AbstractFileReporter.java
URL: http://svn.apache.org/viewcvs/maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/AbstractFileReporter.java?rev=381916&view=auto
==============================================================================
--- maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/AbstractFileReporter.java (added)
+++ maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/AbstractFileReporter.java Tue Feb 28 22:13:17 2006
@@ -0,0 +1,58 @@
+package org.apache.maven.surefire.report;
+
+/*
+ * 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 java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+/**
+ * Base class for file reporters.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ */
+public abstract class AbstractFileReporter
+    extends AbstractReporter
+{
+    protected StringBuffer reportContent;
+
+    protected PrintWriter writer;
+
+    public void batteryStarting( ReportEntry report )
+        throws IOException
+    {
+        super.batteryStarting( report );
+
+        reportContent = new StringBuffer();
+
+        File reportFile = new File( getReportsDirectory(), report.getName() + ".txt" );
+
+        File reportDir = reportFile.getParentFile();
+
+        reportDir.mkdirs();
+
+        writer = new PrintWriter( new FileWriter( reportFile ) );
+
+        writer.println( "-------------------------------------------------------------------------------" );
+
+        writer.println( "Battery: " + report.getName() );
+
+        writer.println( "-------------------------------------------------------------------------------" );
+    }
+
+}

Propchange: maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/AbstractFileReporter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/AbstractFileReporter.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

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=381916&r1=381915&r2=381916&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 22:13:17 2006
@@ -17,6 +17,8 @@
  */
 
 import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
 import java.text.NumberFormat;
 
 /**
@@ -44,6 +46,8 @@
 
     private static final int MS_PER_SEC = 1000;
 
+    private long batteryStartTime;
+
     public void setReportsDirectory( String reportsDirectory )
     {
         this.reportsDirectory = reportsDirectory;
@@ -81,6 +85,7 @@
     public void batteryStarting( ReportEntry report )
         throws IOException
     {
+        batteryStartTime = System.currentTimeMillis();
     }
 
     public void batteryCompleted( ReportEntry report )
@@ -102,26 +107,27 @@
 
     public void testSucceeded( ReportEntry report )
     {
-        ++completedCount;
-
-        endTime = System.currentTimeMillis();
+        endTest();
     }
 
     public void testError( ReportEntry report, String stdOut, String stdErr )
     {
-        ++completedCount;
-
         ++errors;
 
-        endTime = System.currentTimeMillis();
+        endTest();
     }
 
     public void testFailed( ReportEntry report, String stdOut, String stdErr )
     {
-        ++completedCount;
-
         ++failures;
 
+        endTest();
+    }
+
+    private void endTest()
+    {
+        ++completedCount;
+
         endTime = System.currentTimeMillis();
     }
 
@@ -150,6 +156,11 @@
 
     public void dispose()
     {
+        errors = 0;
+
+        failures = 0;
+
+        completedCount = 0;
     }
 
     // ----------------------------------------------------------------------
@@ -159,5 +170,63 @@
     protected String elapsedTimeAsString( long runTime )
     {
         return numberFormat.format( (double) runTime / MS_PER_SEC );
+    }
+
+    /**
+     * Returns stacktrace as String.
+     *
+     * @param report ReportEntry object.
+     * @return stacktrace as string.
+     */
+    protected static String getStackTrace( ReportEntry report )
+    {
+        StringWriter writer = new StringWriter();
+
+        report.getThrowable().printStackTrace( new PrintWriter( writer ) );
+
+        writer.flush();
+
+        return writer.toString();
+    }
+
+    protected StringBuffer getBatterySummary()
+    {
+        StringBuffer batterySummary = new StringBuffer();
+
+        batterySummary.append( "Tests run: " );
+        batterySummary.append( completedCount );
+        batterySummary.append( ", Failures: " );
+        batterySummary.append( failures );
+        batterySummary.append( ", Errors: " );
+        batterySummary.append( errors );
+        batterySummary.append( ", Time elapsed: " );
+        batterySummary.append( elapsedTimeAsString( System.currentTimeMillis() - batteryStartTime ) );
+        batterySummary.append( " sec" );
+        return batterySummary;
+    }
+
+    protected String getElapsedTimeSummary()
+    {
+        StringBuffer reportContent = new StringBuffer();
+        long runTime = this.endTime - this.startTime;
+
+        reportContent.append( "  Time elapsed: " ).append( elapsedTimeAsString( runTime ) ).append( " sec" );
+
+        return reportContent.toString();
+    }
+
+    protected String getOutput( ReportEntry report, String msg )
+    {
+        StringBuffer buf = new StringBuffer();
+
+        buf.append( report.getName() );
+
+        buf.append( getElapsedTimeSummary() );
+
+        buf.append( "  <<< " ).append( msg ).append( "!" ).append( NL );
+
+        buf.append( getStackTrace( report ) ).append( NL );
+
+        return buf.toString();
     }
 }

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=381916&r1=381915&r2=381916&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 22:13:17 2006
@@ -16,8 +16,7 @@
  * limitations under the License.
  */
 
-import java.io.PrintWriter;
-import java.io.StringWriter;
+import java.io.IOException;
 
 /**
  * Brief format console reporter.
@@ -29,9 +28,10 @@
 public class BriefConsoleReporter
     extends AbstractConsoleReporter
 {
-    private StringBuffer reportContent;
+    protected StringBuffer reportContent;
 
     public void batteryStarting( ReportEntry report )
+        throws IOException
     {
         super.batteryStarting( report );
 
@@ -43,67 +43,30 @@
         StringBuffer batterySummary = getBatterySummary();
 
         batterySummary.append( NL );
-        batterySummary.append( "[surefire] " ).append( NL );
-
-        reportContent = batterySummary.append( reportContent );
+        batterySummary.append( NL );
 
-        writer.println( batterySummary );
+        batterySummary.append( reportContent );
 
-        writer.flush();
+        writeMessage( batterySummary.toString() );
     }
 
     public void testError( ReportEntry report, String stdOut, String stdErr )
     {
         super.testError( report, stdOut, stdErr );
 
-        reportContent.append( "[surefire] " );
         appendOutput( report, "ERROR" );
     }
 
-    public void testFailed( ReportEntry report, String stdOut, String stdErr )
-    {
-        super.testFailed( report, stdOut, stdErr );
-
-        reportContent.append( "[surefire] " );
-        appendOutput( report, "FAILURE" );
-    }
-
     private void appendOutput( ReportEntry report, String msg )
     {
-        reportContent.append( report.getName() );
-
-        long runTime = this.endTime - this.startTime;
-
-        reportContent.append( "  Time elapsed: " ).append( elapsedTimeAsString( runTime ) ).append( " sec" );
-
-        reportContent.append( "  <<< " ).append( msg ).append( "!" ).append( NL );
-
-        reportContent.append( getStackTrace( report ) ).append( NL );
-    }
-
-    public void dispose()
-    {
-        errors = 0;
-
-        failures = 0;
-
-        completedCount = 0;
+        reportContent.append( "[surefire] " );
+        reportContent.append( getOutput( report, msg ) );
     }
 
-    /**
-     * Returns stacktrace as String.
-     *
-     * @param report ReportEntry object.
-     * @return stacktrace as string.
-     */
-    private String getStackTrace( ReportEntry report )
+    public void testFailed( ReportEntry report, String stdOut, String stdErr )
     {
-        StringWriter writer = new StringWriter();
-
-        report.getThrowable().printStackTrace( new PrintWriter( writer ) );
-
-        writer.flush();
+        super.testFailed( report, stdOut, stdErr );
 
-        return writer.toString();
+        appendOutput( report, "FAILURE" );
     }
 }

Modified: maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/BriefFileReporter.java
URL: http://svn.apache.org/viewcvs/maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/BriefFileReporter.java?rev=381916&r1=381915&r2=381916&view=diff
==============================================================================
--- maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/BriefFileReporter.java (original)
+++ maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/BriefFileReporter.java Tue Feb 28 22:13:17 2006
@@ -16,12 +16,6 @@
  * limitations under the License.
  */
 
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-
 /**
  * Brief format file reporter.
  *
@@ -29,53 +23,18 @@
  * @version $Id$
  */
 public class BriefFileReporter
-    extends AbstractReporter
+    extends AbstractFileReporter
 {
-    private PrintWriter writer;
-
-    protected StringBuffer reportContent;
-
-    private long batteryStartTime;
-
-    public void batteryStarting( ReportEntry report )
-        throws IOException
-    {
-        batteryStartTime = System.currentTimeMillis();
-
-        reportContent = new StringBuffer();
-
-        File reportFile = new File( getReportsDirectory(), report.getName() + ".txt" );
-
-        File reportDir = reportFile.getParentFile();
-
-        reportDir.mkdirs();
-
-        writer = new PrintWriter( new FileWriter( reportFile ) );
-
-        writer.println( "-------------------------------------------------------------------------------" );
-
-        writer.println( "Battery: " + report.getName() );
-
-        writer.println( "-------------------------------------------------------------------------------" );
-    }
-
     public void batteryCompleted( ReportEntry report )
     {
-        long runTime = System.currentTimeMillis() - this.batteryStartTime;
+        StringBuffer batterySummary = getBatterySummary();
 
-        StringBuffer batterySummary = new StringBuffer();
-
-        batterySummary.append( "Tests run: " ).append( String.valueOf( this.getNbTests() ) );
-        batterySummary.append( ", Failures: " ).append( String.valueOf( this.getNbFailures() ) );
-        batterySummary.append( ", Errors: " ).append( String.valueOf( this.getNbErrors() ) );
-        batterySummary.append( ", Time elapsed: " ).append( elapsedTimeAsString( runTime ) );
-        batterySummary.append( " sec" );
         batterySummary.append( NL );
         batterySummary.append( NL );
 
         reportContent = batterySummary.append( reportContent );
 
-        writer.println( reportContent.toString() );
+        writer.println( batterySummary );
 
         writer.flush();
 
@@ -86,82 +45,13 @@
     {
         super.testError( report, stdOut, stdErr );
 
-        appendOutput( report, "ERROR" );
+        reportContent.append( getOutput( report, "ERROR" ) );
     }
 
     public void testFailed( ReportEntry report, String stdOut, String stdErr )
     {
         super.testFailed( report, stdOut, stdErr );
 
-        appendOutput( report, "FAILURE" );
-    }
-
-    private void appendOutput( ReportEntry report, String msg )
-    {
-        reportContent.append( report.getName() );
-
-        long runTime = this.endTime - this.startTime;
-
-        reportContent.append( "  Time elapsed: " ).append( elapsedTimeAsString( runTime ) ).append( " sec" );
-
-        reportContent.append( "  <<< " ).append( msg ).append( "!" ).append( NL );
-
-        reportContent.append( getStackTrace( report ) ).append( NL );
-    }
-
-    public void dispose()
-    {
-        errors = 0;
-
-        failures = 0;
-
-        completedCount = 0;
-    }
-
-    protected void writeTimeElapsed( long sec )
-    {
-        reportContent.append( "  Time elapsed: " ).append( elapsedTimeAsString( sec ) ).append( " sec" );
-    }
-
-    protected void writeStdLogs( String stdOut, String stdErr )
-    {
-        reportContent.append( NL );
-
-        reportContent.append( "[ stdout ] ---------------------------------------------------------------" );
-
-        reportContent.append( NL );
-
-        reportContent.append( stdOut ).append( NL );
-
-        reportContent.append( NL );
-
-        reportContent.append( "[ stderr ] ---------------------------------------------------------------" );
-
-        reportContent.append( NL );
-
-        reportContent.append( stdErr ).append( NL );
-
-        reportContent.append( NL );
-
-        reportContent.append( "[ stacktrace ] -----------------------------------------------------------" );
-
-        reportContent.append( NL );
-    }
-
-    /**
-     * Returns stacktrace as String.
-     *
-     * @param report ReportEntry object.
-     * @return stacktrace as string.
-     */
-    protected String getStackTrace( ReportEntry report )
-    {
-        StringWriter writer = new StringWriter();
-
-        report.getThrowable().printStackTrace( new PrintWriter( writer ) );
-
-        writer.flush();
-
-        return writer.toString();
+        reportContent.append( getOutput( report, "FAILURE" ) );
     }
 }

Modified: maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/ConsoleReporter.java
URL: http://svn.apache.org/viewcvs/maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/ConsoleReporter.java?rev=381916&r1=381915&r2=381916&view=diff
==============================================================================
--- maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/ConsoleReporter.java (original)
+++ maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/ConsoleReporter.java Tue Feb 28 22:13:17 2006
@@ -34,15 +34,7 @@
             batterySummary.append( " <<< FAILURE! " );
         }
 
-        writer.println( batterySummary );
-
-        writer.flush();
-
-        completedCount = 0;
-
-        errors = 0;
-
-        failures = 0;
+        writeMessage( batterySummary.toString() );
     }
 
     public void runAborted( ReportEntry report )

Modified: maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/DetailedConsoleReporter.java
URL: http://svn.apache.org/viewcvs/maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/DetailedConsoleReporter.java?rev=381916&r1=381915&r2=381916&view=diff
==============================================================================
--- maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/DetailedConsoleReporter.java (original)
+++ maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/DetailedConsoleReporter.java Tue Feb 28 22:13:17 2006
@@ -16,9 +16,6 @@
  * limitations under the License.
  */
 
-import java.io.PrintWriter;
-import java.io.StringWriter;
-
 /**
  * Detailed console reporter.
  *
@@ -26,30 +23,8 @@
  * @version $Id$
  */
 public class DetailedConsoleReporter
-    extends AbstractConsoleReporter
+    extends BriefConsoleReporter
 {
-    private StringBuffer reportContent;
-
-    public void batteryStarting( ReportEntry report )
-    {
-        super.batteryStarting( report );
-
-        reportContent = new StringBuffer();
-    }
-
-    public void batteryCompleted( ReportEntry report )
-    {
-        StringBuffer batterySummary = getBatterySummary();
-        batterySummary.append( NL );
-        batterySummary.append( "[surefire] " ).append( NL );
-
-        reportContent = batterySummary.append( reportContent );
-
-        writer.println( batterySummary );
-
-        writer.flush();
-    }
-
     public void testStarting( ReportEntry report )
     {
         super.testStarting( report );
@@ -61,63 +36,7 @@
     {
         super.testSucceeded( report );
 
-        long runTime = this.endTime - this.startTime;
-
-        reportContent.append( "  Time elapsed: " ).append( elapsedTimeAsString( runTime ) ).append( " sec" );
-
+        reportContent.append( getElapsedTimeSummary() );
         reportContent.append( NL );
-    }
-
-    public void testError( ReportEntry report, String stdOut, String stdErr )
-    {
-        super.testError( report, stdOut, stdErr );
-
-        appendOutput( report, "ERROR" );
-    }
-
-    public void testFailed( ReportEntry report, String stdOut, String stdErr )
-    {
-        super.testFailed( report, stdOut, stdErr );
-
-        appendOutput( report, "FAILURE" );
-    }
-
-    private void appendOutput( ReportEntry report, String msg )
-    {
-        reportContent.append( report.getName() );
-
-        long runTime = this.endTime - this.startTime;
-
-        reportContent.append( "  Time elapsed: " ).append( elapsedTimeAsString( runTime ) ).append( " sec" );
-
-        reportContent.append( "  <<< " ).append( msg ).append( "!" ).append( NL );
-
-        reportContent.append( getStackTrace( report ) ).append( NL );
-    }
-
-    public void dispose()
-    {
-        errors = 0;
-
-        failures = 0;
-
-        completedCount = 0;
-    }
-
-    /**
-     * Returns stacktrace as String.
-     *
-     * @param report ReportEntry object.
-     * @return stacktrace as string.
-     */
-    private String getStackTrace( ReportEntry report )
-    {
-        StringWriter writer = new StringWriter();
-
-        report.getThrowable().printStackTrace( new PrintWriter( writer ) );
-
-        writer.flush();
-
-        return writer.toString();
     }
 }

Modified: maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/FileReporter.java
URL: http://svn.apache.org/viewcvs/maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/FileReporter.java?rev=381916&r1=381915&r2=381916&view=diff
==============================================================================
--- maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/FileReporter.java (original)
+++ maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/FileReporter.java Tue Feb 28 22:13:17 2006
@@ -36,10 +36,7 @@
     {
         super.testSucceeded( report );
 
-        long runTime = this.endTime - this.startTime;
-
-        writeTimeElapsed( runTime );
-
+        reportContent.append( getElapsedTimeSummary() );
         reportContent.append( NL );
     }
 }

Modified: maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/ForkingConsoleReporter.java
URL: http://svn.apache.org/viewcvs/maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/ForkingConsoleReporter.java?rev=381916&r1=381915&r2=381916&view=diff
==============================================================================
--- maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/ForkingConsoleReporter.java (original)
+++ maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/ForkingConsoleReporter.java Tue Feb 28 22:13:17 2006
@@ -19,42 +19,20 @@
 public class ForkingConsoleReporter
     extends ConsoleReporter
 {
-    public void println( String message )
-    {
-        writer.print( ForkingReport.FORKING_PREFIX_STANDARD );
-
-        writer.println( message );
-
-        writer.flush();
-    }
-
-    public void print( String message )
+    public void runStarting( int testCount )
     {
-        writer.write( ForkingReport.FORKING_PREFIX_STANDARD );
-
-        writer.print( message );
+        heading( "" );
+        heading( "-------------------------------------------------------" );
+        heading( " T E S T S" );
+        heading( "-------------------------------------------------------" );
 
         writer.flush();
     }
 
-    public void runStarting( int testCount )
+    private void heading( String line )
     {
         writer.print( ForkingReport.FORKING_PREFIX_HEADING );
 
-        writer.println( "" );
-
-        writer.print( ForkingReport.FORKING_PREFIX_HEADING );
-
-        writer.println( "-------------------------------------------------------" );
-
-        writer.print( ForkingReport.FORKING_PREFIX_HEADING );
-
-        writer.println( " T E S T S" );
-
-        writer.print( ForkingReport.FORKING_PREFIX_HEADING );
-
-        writer.println( "-------------------------------------------------------" );
-
-        writer.flush();
+        writer.println( line );
     }
 }

Modified: maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/ForkingSummaryConsoleReporter.java
URL: http://svn.apache.org/viewcvs/maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/ForkingSummaryConsoleReporter.java?rev=381916&r1=381915&r2=381916&view=diff
==============================================================================
--- maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/ForkingSummaryConsoleReporter.java (original)
+++ maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/ForkingSummaryConsoleReporter.java Tue Feb 28 22:13:17 2006
@@ -27,19 +27,15 @@
 {
     public void batteryStarting( ReportEntry report )
     {
+        // TODO: why empty? Summary?
     }
 
     public void batteryCompleted( ReportEntry report )
     {
         if ( failures > 0 || errors > 0 )
         {
-            println( "[surefire] " + report.getName() + " <<< FAILURE! " );
+            // TODO: fix this use of writeMessage, it won't prefix
+            writeMessage( ForkingReport.FORKING_PREFIX_STANDARD + report.getName() + " <<< FAILURE! " );
         }
-
-        completedCount = 0;
-
-        errors = 0;
-
-        failures = 0;
     }
 }

Modified: maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/ReporterManager.java
URL: http://svn.apache.org/viewcvs/maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/ReporterManager.java?rev=381916&r1=381915&r2=381916&view=diff
==============================================================================
--- maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/ReporterManager.java (original)
+++ maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/ReporterManager.java Tue Feb 28 22:13:17 2006
@@ -103,7 +103,7 @@
     {
         writeMessage( "" );
         writeMessage( "Results :" );
-        writeMessage( "[surefire] Tests run: " + completedCount + ", Failures: " + failures + ", Errors: " + errors );
+        writeMessage( "Tests run: " + completedCount + ", Failures: " + failures + ", Errors: " + errors );
         writeMessage( "" );
     }
 
@@ -414,7 +414,7 @@
 
     private void handleReporterException( String reporterMethod, Exception e )
     {
-        String reporterThrewException = Surefire.getResources().getString( "reporterThrew" );
+        String reporterThrewException = Surefire.getResourceString( "reporterThrew" );
 
         MessageFormat msgFmt = new MessageFormat( reporterThrewException );
 
@@ -426,5 +426,4 @@
 
         e.printStackTrace( System.err );
     }
-
 }

Modified: maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/SummaryConsoleReporter.java
URL: http://svn.apache.org/viewcvs/maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/SummaryConsoleReporter.java?rev=381916&r1=381915&r2=381916&view=diff
==============================================================================
--- maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/SummaryConsoleReporter.java (original)
+++ maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/SummaryConsoleReporter.java Tue Feb 28 22:13:17 2006
@@ -27,19 +27,14 @@
 {
     public void batteryStarting( ReportEntry report )
     {
+        // TODO: why empty? Summary?
     }
 
     public void batteryCompleted( ReportEntry report )
     {
         if ( failures > 0 || errors > 0 )
         {
-            writeMessage( "[surefire] " + report.getName() + " <<< FAILURE! " );
+            writeMessage( report.getName() + " <<< FAILURE! " );
         }
-
-        completedCount = 0;
-
-        errors = 0;
-
-        failures = 0;
     }
 }

Modified: maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/TestNGReporter.java
URL: http://svn.apache.org/viewcvs/maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/TestNGReporter.java?rev=381916&r1=381915&r2=381916&view=diff
==============================================================================
--- maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/TestNGReporter.java (original)
+++ maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/TestNGReporter.java Tue Feb 28 22:13:17 2006
@@ -79,7 +79,7 @@
     */
     public void onTestStart( ITestResult result )
     {
-        String rawString = Surefire.getResources().getString( "testStarting" );
+        String rawString = Surefire.getResourceString( "testStarting" );
         String group = groupString( result.getMethod().getGroups(), result.getTestClass().getName() );
         ReportEntry report = new ReportEntry( surefire, result.getTestClass().getName() + "#" +
             result.getMethod().getMethodName(), group, rawString );
@@ -102,7 +102,7 @@
      */
     public void onTestFailure( ITestResult result )
     {
-        String rawString = Surefire.getResources().getString( "executeException" );
+        String rawString = Surefire.getResourceString( "executeException" );
 
         // TODO: almost certainly not correct: result.getMethod().getExtraOutput().getParameterOutput()
         ReportEntry report = new ReportEntry( surefire, result.getName(),
@@ -123,7 +123,7 @@
 
     private ReportEntry createReport( ITestResult result, String key )
     {
-        return new ReportEntry( surefire, result.getName(), Surefire.getResources().getString( key ) );
+        return new ReportEntry( surefire, result.getName(), Surefire.getResourceString( key ) );
     }
 
     /* (non-Javadoc)
@@ -131,7 +131,7 @@
      */
     public void onTestFailedButWithinSuccessPercentage( ITestResult result )
     {
-        String rawString = Surefire.getResources().getString( "executeException" );
+        String rawString = Surefire.getResourceString( "executeException" );
 
         // TODO: almost certainly not correct: result.getMethod().getExtraOutput().getParameterOutput()
         ReportEntry report = new ReportEntry( surefire, result.getName(),
@@ -145,7 +145,7 @@
      */
     public void onStart( ITestContext context )
     {
-        String rawString = Surefire.getResources().getString( "suiteExecutionStarting" );
+        String rawString = Surefire.getResourceString( "suiteExecutionStarting" );
 
         String group = groupString( context.getIncludedGroups(), context.getName() );
 
@@ -159,7 +159,7 @@
     */
     public void onFinish( ITestContext context )
     {
-        String rawString = Surefire.getResources().getString( "suiteCompletedNormally" );
+        String rawString = Surefire.getResourceString( "suiteCompletedNormally" );
 
         ReportEntry report =
             new ReportEntry( surefire, context.getName(), groupString( context.getIncludedGroups(), null ), rawString );

Modified: maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/XMLReporter.java
URL: http://svn.apache.org/viewcvs/maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/XMLReporter.java?rev=381916&r1=381915&r2=381916&view=diff
==============================================================================
--- maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/XMLReporter.java (original)
+++ maven/surefire/branches/surefire-testng/surefire/src/main/java/org/apache/maven/surefire/report/XMLReporter.java Tue Feb 28 22:13:17 2006
@@ -26,7 +26,6 @@
 import java.io.FileOutputStream;
 import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
-import java.io.StringWriter;
 import java.io.UnsupportedEncodingException;
 import java.util.Enumeration;
 import java.util.Properties;
@@ -76,13 +75,7 @@
 
         writer.write( "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" );
 
-        testSuite = new Xpp3Dom( "testsuite" );
-
-        testSuite.setAttribute( "name", report.getName() );
-        if ( report.getGroup() != null )
-        {
-            testSuite.setAttribute( "group", report.getGroup() );
-        }
+        testSuite = createTestElement( new Xpp3Dom( "testsuite" ), report.getName(), report );
         showProperties();
     }
 
@@ -123,13 +116,17 @@
             reportName = report.getName();
         }
 
-        testCase = createElement( testSuite, "testcase" );
+        this.testCase = createTestElement( createElement( testSuite, "testcase" ), reportName, report );
+    }
 
-        testCase.setAttribute( "name", reportName );
+    private Xpp3Dom createTestElement( Xpp3Dom element, String reportName, ReportEntry report )
+    {
+        element.setAttribute( "name", reportName );
         if ( report.getGroup() != null )
         {
-            testCase.setAttribute( "group", report.getGroup() );
+            element.setAttribute( "group", report.getGroup() );
         }
+        return element;
     }
 
     public void testSucceeded( ReportEntry report )
@@ -145,22 +142,19 @@
     {
         super.testError( report, stdOut, stdErr );
 
-        Xpp3Dom element = createElement( testCase, "error" );
-
-        writeTestProblems( report, stdOut, stdErr, element );
+        writeTestProblems( report, stdOut, stdErr, "error" );
     }
 
     public void testFailed( ReportEntry report, String stdOut, String stdErr )
     {
         super.testFailed( report, stdOut, stdErr );
 
-        Xpp3Dom element = createElement( testCase, "failure" );
-
-        writeTestProblems( report, stdOut, stdErr, element );
+        writeTestProblems( report, stdOut, stdErr, "failure" );
     }
 
-    private void writeTestProblems( ReportEntry report, String stdOut, String stdErr, Xpp3Dom element )
+    private void writeTestProblems( ReportEntry report, String stdOut, String stdErr, String name )
     {
+        Xpp3Dom element = createElement( testCase, name );
 
         String stackTrace = getStackTrace( report );
 
@@ -202,15 +196,6 @@
         }
     }
 
-    public void dispose()
-    {
-        errors = 0;
-
-        failures = 0;
-
-        completedCount = 0;
-    }
-
     private Xpp3Dom createElement( Xpp3Dom element, String name )
     {
         Xpp3Dom component = new Xpp3Dom( name );
@@ -218,23 +203,6 @@
         element.addChild( component );
 
         return component;
-    }
-
-    /**
-     * Returns stacktrace as String.
-     *
-     * @param report ReportEntry object.
-     * @return stacktrace as string.
-     */
-    private String getStackTrace( ReportEntry report )
-    {
-        StringWriter writer = new StringWriter();
-
-        report.getThrowable().printStackTrace( new PrintWriter( writer ) );
-
-        writer.flush();
-
-        return writer.toString();
     }
 
     /**



Mime
View raw message