ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit CompoundIterator.java NodeListImpl.java AggregateTransformer.java BaseTest.java BatchTest.java DOMUtil.java JUnitTask.java JUnitTest.java JUnitTestRunner.java XMLJUnitResultFormatter.java XMLResultAggregator.java Xalan1Executor.java Xalan2Executor.java XalanExecutor.java Enumerations.java
Date Sun, 06 Jan 2002 02:28:03 GMT
donaldp     02/01/05 18:28:03

  Modified:    proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit
                        AggregateTransformer.java BaseTest.java
                        BatchTest.java DOMUtil.java JUnitTask.java
                        JUnitTest.java JUnitTestRunner.java
                        XMLJUnitResultFormatter.java
                        XMLResultAggregator.java Xalan1Executor.java
                        Xalan2Executor.java XalanExecutor.java
  Added:       proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit
                        CompoundIterator.java NodeListImpl.java
  Removed:     proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit
                        Enumerations.java
  Log:
  Made sure junit compiled and started to bring it into line with recent changes
  
  Revision  Changes    Path
  1.9       +37 -34    jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java
  
  Index: AggregateTransformer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- AggregateTransformer.java	23 Dec 2001 14:22:46 -0000	1.8
  +++ AggregateTransformer.java	6 Jan 2002 02:28:02 -0000	1.9
  @@ -16,6 +16,7 @@
   import javax.xml.parsers.DocumentBuilder;
   import javax.xml.parsers.DocumentBuilderFactory;
   import org.apache.avalon.excalibur.io.FileUtil;
  +import org.apache.avalon.framework.logger.AbstractLogEnabled;
   import org.apache.myrmidon.api.TaskException;
   import org.apache.tools.ant.Task;
   import org.apache.tools.ant.types.EnumeratedAttribute;
  @@ -32,8 +33,8 @@
    * @author <a href="mailto:sbailliez@apache.org">Stephane Bailliez</a>
    */
   public class AggregateTransformer
  +    extends AbstractLogEnabled
   {
  -
       public final static String FRAMES = "frames";
   
       public final static String NOFRAMES = "noframes";
  @@ -41,53 +42,40 @@
       /**
        * XML Parser factory
        */
  -    protected final static DocumentBuilderFactory dbfactory = DocumentBuilderFactory.newInstance();
  +    private final static DocumentBuilderFactory c_dbfactory = DocumentBuilderFactory.newInstance();
   
       /**
        * the xml document to process
        */
  -    protected Document document;
  +    private Document m_document;
   
       /**
        * the format to use for the report. Must be <tt>FRAMES</tt> or <tt>NOFRAMES
        * </tt>
        */
  -    protected String format;
  +    private String m_format;
   
       /**
        * the style directory. XSLs should be read from here if necessary
        */
  -    protected File styleDir;
  +    private File m_styleDir;
   
  -    /**
  -     * Task
  -     */
  -    protected Task task;
  +    private Task m_task;
   
       /**
        * the destination directory, this is the root from where html should be
        * generated
        */
  -    protected File toDir;
  +    private File m_toDir;
   
       public AggregateTransformer( Task task )
       {
  -        this.task = task;
  -    }
  -
  -    /**
  -     * set the extension of the output files
  -     *
  -     * @param ext The new Extension value
  -     */
  -    public void setExtension( String ext )
  -    {
  -        task.getLogger().warn( "extension is not used anymore" );
  +        m_task = task;
       }
   
       public void setFormat( Format format )
       {
  -        this.format = format.getValue();
  +        m_format = format.getValue();
       }
   
       /**
  @@ -99,7 +87,7 @@
        */
       public void setStyledir( File styledir )
       {
  -        this.styleDir = styledir;
  +        m_styleDir = styledir;
       }
   
       /**
  @@ -109,12 +97,12 @@
        */
       public void setTodir( File todir )
       {
  -        this.toDir = todir;
  +        m_toDir = todir;
       }
   
       public void setXmlDocument( Document doc )
       {
  -        this.document = doc;
  +        m_document = doc;
       }
   
       public void transform()
  @@ -124,7 +112,7 @@
           final long t0 = System.currentTimeMillis();
           try
           {
  -            Element root = document.getDocumentElement();
  +            Element root = m_document.getDocumentElement();
               XalanExecutor executor = XalanExecutor.newInstance( this );
               executor.execute();
           }
  @@ -148,7 +136,7 @@
       {
           try
           {
  -            DocumentBuilder builder = dbfactory.newDocumentBuilder();
  +            DocumentBuilder builder = c_dbfactory.newDocumentBuilder();
               InputStream in = new FileInputStream( xmlfile );
               try
               {
  @@ -178,12 +166,12 @@
           throws IOException
       {
           String xslname = "junit-frames.xsl";
  -        if( NOFRAMES.equals( format ) )
  +        if( NOFRAMES.equals( m_format ) )
           {
               xslname = "junit-noframes.xsl";
           }
           URL url = null;
  -        if( styleDir == null )
  +        if( m_styleDir == null )
           {
               url = getClass().getResource( "xsl/" + xslname );
               if( url == null )
  @@ -193,7 +181,7 @@
           }
           else
           {
  -            File file = new File( styleDir, xslname );
  +            File file = new File( m_styleDir, xslname );
               if( !file.exists() )
               {
                   throw new FileNotFoundException( "Could not find file '" + file + "'" );
  @@ -212,14 +200,29 @@
           throws TaskException
       {
           // set the destination directory relative from the project if needed.
  -        if( toDir == null )
  +        if( m_toDir == null )
           {
  -            toDir = FileUtil.resolveFile( task.getBaseDirectory(), "." );
  +            m_toDir = FileUtil.resolveFile( m_task.getBaseDirectory(), "." );
           }
  -        else if( !toDir.isAbsolute() )
  +        else if( !m_toDir.isAbsolute() )
           {
  -            toDir = FileUtil.resolveFile( task.getBaseDirectory(), toDir.getPath() );
  +            m_toDir = FileUtil.resolveFile( m_task.getBaseDirectory(), m_toDir.getPath() );
           }
  +    }
  +
  +    protected Document getDocument()
  +    {
  +        return m_document;
  +    }
  +
  +    protected String getFormat()
  +    {
  +        return m_format;
  +    }
  +
  +    protected File getToDir()
  +    {
  +        return m_toDir;
       }
   
       public static class Format extends EnumeratedAttribute
  
  
  
  1.5       +9 -9      jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/BaseTest.java
  
  Index: BaseTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/BaseTest.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- BaseTest.java	23 Dec 2001 06:31:58 -0000	1.4
  +++ BaseTest.java	6 Jan 2002 02:28:02 -0000	1.5
  @@ -18,9 +18,9 @@
    */
   public abstract class BaseTest
   {
  -    protected boolean haltOnError = false;
  -    protected boolean haltOnFail = false;
  -    protected boolean filtertrace = true;
  +    protected boolean m_haltOnError = false;
  +    protected boolean m_haltOnFail = false;
  +    protected boolean m_filtertrace = true;
       protected boolean fork = false;
       protected String ifProperty = null;
       protected String unlessProperty = null;
  @@ -45,7 +45,7 @@
   
       public void setFiltertrace( boolean value )
       {
  -        filtertrace = value;
  +        m_filtertrace = value;
       }
   
       public void setFork( boolean value )
  @@ -55,12 +55,12 @@
   
       public void setHaltonerror( boolean value )
       {
  -        haltOnError = value;
  +        m_haltOnError = value;
       }
   
       public void setHaltonfailure( boolean value )
       {
  -        haltOnFail = value;
  +        m_haltOnFail = value;
       }
   
       public void setIf( String propertyName )
  @@ -95,7 +95,7 @@
   
       public boolean getFiltertrace()
       {
  -        return filtertrace;
  +        return m_filtertrace;
       }
   
       public boolean getFork()
  @@ -105,12 +105,12 @@
   
       public boolean getHaltonerror()
       {
  -        return haltOnError;
  +        return m_haltOnError;
       }
   
       public boolean getHaltonfailure()
       {
  -        return haltOnFail;
  +        return m_haltOnFail;
       }
   
       /**
  
  
  
  1.7       +13 -10    jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/BatchTest.java
  
  Index: BatchTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/BatchTest.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- BatchTest.java	1 Jan 2002 09:13:46 -0000	1.6
  +++ BatchTest.java	6 Jan 2002 02:28:02 -0000	1.7
  @@ -9,7 +9,9 @@
   
   import java.io.File;
   import java.util.ArrayList;
  +import java.util.Arrays;
   import java.util.Iterator;
  +import org.apache.myrmidon.api.TaskException;
   import org.apache.tools.ant.DirectoryScanner;
   import org.apache.tools.ant.Project;
   import org.apache.tools.ant.types.FileSet;
  @@ -32,7 +34,6 @@
    */
   public final class BatchTest extends BaseTest
   {
  -
       /**
        * the list of filesets containing the testcase filename rules
        */
  @@ -74,9 +75,10 @@
        *      JUnitTest</tt> instance.
        */
       public final Iterator iterator()
  +        throws TaskException
       {
  -        JUnitTest[] tests = createAllJUnitTest();
  -        return Iterators.fromArray( tests );
  +        final JUnitTest[] tests = createAllJUnitTest();
  +        return Arrays.asList( tests ).iterator();
       }
   
       /**
  @@ -99,8 +101,9 @@
        *      batch test.
        */
       final void addTestsTo( ArrayList v )
  +        throws TaskException
       {
  -        JUnitTest[] tests = createAllJUnitTest();
  +        final JUnitTest[] tests = createAllJUnitTest();
           v.ensureCapacity( v.size() + tests.length );
           for( int i = 0; i < tests.length; i++ )
           {
  @@ -121,6 +124,7 @@
        *      it will return <tt>org/apache/Whatever</tt> .
        */
       private String[] getFilenames()
  +        throws TaskException
       {
           ArrayList v = new ArrayList();
           final int size = this.filesets.size();
  @@ -144,9 +148,7 @@
               }
           }
   
  -        String[] files = new String[ v.size() ];
  -        v.copyInto( files );
  -        return files;
  +        return (String[])v.toArray( new String[ v.size() ] );
       }
   
       /**
  @@ -156,6 +158,7 @@
        * @return the array of all <tt>JUnitTest</tt> s that belongs to this batch.
        */
       private JUnitTest[] createAllJUnitTest()
  +        throws TaskException
       {
           String[] filenames = getFilenames();
           JUnitTest[] tests = new JUnitTest[ filenames.length ];
  @@ -179,9 +182,9 @@
       {
           JUnitTest test = new JUnitTest();
           test.setName( classname );
  -        test.setHaltonerror( this.haltOnError );
  -        test.setHaltonfailure( this.haltOnFail );
  -        test.setFiltertrace( this.filtertrace );
  +        test.setHaltonerror( this.m_haltOnError );
  +        test.setHaltonfailure( this.m_haltOnFail );
  +        test.setFiltertrace( this.m_filtertrace );
           test.setFork( this.fork );
           test.setIf( this.ifProperty );
           test.setUnless( this.unlessProperty );
  
  
  
  1.5       +0 -25     jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/DOMUtil.java
  
  Index: DOMUtil.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/DOMUtil.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DOMUtil.java	23 Dec 2001 06:31:58 -0000	1.4
  +++ DOMUtil.java	6 Jan 2002 02:28:02 -0000	1.5
  @@ -7,7 +7,6 @@
    */
   package org.apache.tools.ant.taskdefs.optional.junit;
   
  -import java.util.ArrayList;
   import org.w3c.dom.Attr;
   import org.w3c.dom.CDATASection;
   import org.w3c.dom.Comment;
  @@ -224,28 +223,4 @@
           boolean accept( Node node );
       }
   
  -    /**
  -     * custom implementation of a nodelist
  -     *
  -     * @author RT
  -     */
  -    public static class NodeListImpl extends ArrayList implements NodeList
  -    {
  -        public int getLength()
  -        {
  -            return size();
  -        }
  -
  -        public Node item( int i )
  -        {
  -            try
  -            {
  -                return (Node)get( i );
  -            }
  -            catch( ArrayIndexOutOfBoundsException e )
  -            {
  -                return null;// conforming to NodeList interface
  -            }
  -        }
  -    }
   }
  
  
  
  1.22      +10 -19    jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
  
  Index: JUnitTask.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- JUnitTask.java	30 Dec 2001 06:46:37 -0000	1.21
  +++ JUnitTask.java	6 Jan 2002 02:28:02 -0000	1.22
  @@ -21,7 +21,7 @@
   import java.util.Random;
   import org.apache.myrmidon.api.TaskException;
   import org.apache.tools.ant.Task;
  -import org.apache.tools.ant.taskdefs.exec.Execute;
  +import org.apache.tools.ant.taskdefs.exec.Execute2;
   import org.apache.tools.ant.taskdefs.exec.LogOutputStream;
   import org.apache.tools.ant.types.Argument;
   import org.apache.tools.ant.types.CommandlineJava;
  @@ -348,7 +348,7 @@
        */
       public Path createClasspath()
       {
  -        return commandline.createClasspath( getProject() ).createPath();
  +        return commandline.createClasspath().createPath();
       }
   
       /**
  @@ -408,6 +408,7 @@
        * @return The IndividualTests value
        */
       protected Iterator getIndividualTests()
  +        throws TaskException
       {
           Iterator[] enums = new Iterator[ batchTests.size() + 1 ];
           for( int i = 0; i < batchTests.size(); i++ )
  @@ -416,7 +417,7 @@
               enums[ i ] = batchtest.iterator();
           }
           enums[ enums.length - 1 ] = tests.iterator();
  -        return Iterators.fromCompound( enums );
  +        return new CompoundIterator( enums );
       }
   
       /**
  @@ -482,7 +483,7 @@
       protected Iterator allTests()
       {
           Iterator[] enums = {tests.iterator(), batchTests.iterator()};
  -        return Iterator.fromCompound( enums );
  +        return new CompoundIterator( enums );
       }
   
       /**
  @@ -585,13 +586,11 @@
        * @param watchdog the watchdog in charge of cancelling the test if it
        *      exceeds a certain amount of time. Can be <tt>null</tt> , in this
        *      case the test could probably hang forever.
  -     * @return Description of the Returned Value
  -     * @exception TaskException Description of Exception
        */
       private int executeAsForked( JUnitTest test )
           throws TaskException
       {
  -        CommandlineJava cmd = (CommandlineJava)commandline.clone();
  +        CommandlineJava cmd = commandline;//(CommandlineJava)commandline.clone();
   
           cmd.setClassname( "org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner" );
           cmd.createArgument().setValue( test.getName() );
  @@ -642,10 +641,8 @@
               throw new TaskException( "Error creating temporary properties file.", ioe );
           }
   
  -        final Execute exe = new Execute();
  -        exe.setOutput( new LogOutputStream( getLogger(), false ) );
  -        exe.setError( new LogOutputStream( getLogger(), true ) );
  -
  +        final Execute2 exe = new Execute2();
  +        setupLogger( exe );
           exe.setCommandline( cmd.getCommandline() );
           if( dir != null )
           {
  @@ -673,10 +670,6 @@
   
       /**
        * Execute inside VM.
  -     *
  -     * @param test Description of Parameter
  -     * @return Description of the Returned Value
  -     * @exception TaskException Description of Exception
        */
       private int executeInVM( JUnitTest test )
           throws TaskException
  @@ -748,11 +741,9 @@
   
       private FormatterElement[] mergeFormatters( JUnitTest test )
       {
  -        ArrayList feArrayList = (ArrayList)formatters.clone();
  +        final ArrayList feArrayList = (ArrayList)formatters.clone();
           test.addFormattersTo( feArrayList );
  -        FormatterElement[] feArray = new FormatterElement[ feArrayList.size() ];
  -        feArrayList.copyInto( feArray );
  -        return feArray;
  +        return (FormatterElement[])feArrayList.toArray( new FormatterElement[ feArrayList.size() ] );
       }
   
       /**
  
  
  
  1.6       +43 -48    jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTest.java
  
  Index: JUnitTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTest.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- JUnitTest.java	23 Dec 2001 06:31:58 -0000	1.5
  +++ JUnitTest.java	6 Jan 2002 02:28:02 -0000	1.6
  @@ -29,25 +29,27 @@
    */
   public class JUnitTest extends BaseTest
   {
  -
       /**
        * the name of the test case
        */
  -    private String name = null;
  +    private String m_name;
   
       /**
        * the name of the result file
        */
  -    private String outfile = null;
  +    private String m_outfile;
   
       // Snapshot of the system properties
  -    private Properties props = null;
  -    private long runTime;
  +    private Properties m_props;
  +
  +    private long m_runTime;
   
       // @todo this is duplicating TestResult information. Only the time is not
       // part of the result. So we'd better derive a new class from TestResult
       // and deal with it. (SB)
  -    private long runs, failures, errors;
  +    private long m_runs;
  +    private long m_failures;
  +    private long m_errors;
   
       public JUnitTest()
       {
  @@ -55,64 +57,63 @@
   
       public JUnitTest( String name )
       {
  -        this.name = name;
  +        m_name = name;
       }
   
  -    public JUnitTest( String name, boolean haltOnError, boolean haltOnFailure, boolean filtertrace )
  -    {
  -        this.name = name;
  -        this.haltOnError = haltOnError;
  -        this.haltOnFail = haltOnFailure;
  -        this.filtertrace = filtertrace;
  +    public JUnitTest( final String name,
  +                      final boolean haltOnError,
  +                      final boolean haltOnFailure,
  +                      final boolean filtertrace )
  +    {
  +        m_name = name;
  +        m_haltOnError = haltOnError;
  +        m_haltOnFail = haltOnFailure;
  +        m_filtertrace = filtertrace;
       }
   
       public void setCounts( long runs, long failures, long errors )
       {
  -        this.runs = runs;
  -        this.failures = failures;
  -        this.errors = errors;
  +        m_runs = runs;
  +        m_failures = failures;
  +        m_errors = errors;
       }
   
       /**
        * Set the name of the test class.
  -     *
  -     * @param value The new Name value
        */
  -    public void setName( String value )
  +    public void setName( final String value )
       {
  -        name = value;
  +        m_name = value;
       }
   
       /**
        * Set the name of the output file.
  -     *
  -     * @param value The new Outfile value
        */
  -    public void setOutfile( String value )
  +    public void setOutfile( final String value )
       {
  -        outfile = value;
  +        m_outfile = value;
       }
   
  -    public void setProperties( Hashtable p )
  +    public void setProperties( final Hashtable properties )
       {
  -        props = new Properties();
  -        for( Iterator enum = p.keys(); enum.hasNext(); )
  +        m_props = new Properties();
  +        final Iterator enum = properties.keySet().iterator();
  +        while( enum.hasNext() )
           {
  -            Object key = enum.next();
  -            props.put( key, p.get( key ) );
  +            final Object key = enum.next();
  +            final Object value = properties.get( key );
  +            m_props.put( key, value );
           }
       }
   
  -    public void setRunTime( long runTime )
  +    public void setRunTime( final long runTime )
       {
  -        this.runTime = runTime;
  +        m_runTime = runTime;
       }
   
       public FormatterElement[] getFormatters()
       {
  -        FormatterElement[] fes = new FormatterElement[ formatters.size() ];
  -        formatters.copyInto( fes );
  -        return fes;
  +        return (FormatterElement[])formatters.toArray( new FormatterElement[ formatters.size() ] );
       }
   
       /**
  @@ -122,7 +123,7 @@
        */
       public String getName()
       {
  -        return name;
  +        return m_name;
       }
   
       /**
  @@ -132,32 +133,32 @@
        */
       public String getOutfile()
       {
  -        return outfile;
  +        return m_outfile;
       }
   
       public Properties getProperties()
       {
  -        return props;
  +        return m_props;
       }
   
       public long getRunTime()
       {
  -        return runTime;
  +        return m_runTime;
       }
   
       public long errorCount()
       {
  -        return errors;
  +        return m_errors;
       }
   
       public long failureCount()
       {
  -        return failures;
  +        return m_failures;
       }
   
       public long runCount()
       {
  -        return runs;
  +        return m_runs;
       }
   
       public boolean shouldRun( Project p )
  @@ -177,15 +178,9 @@
   
       /**
        * Convenient method to add formatters to a vector
  -     *
  -     * @param v The feature to be added to the FormattersTo attribute
        */
       void addFormattersTo( ArrayList v )
       {
  -        final int count = formatters.size();
  -        for( int i = 0; i < count; i++ )
  -        {
  -            v.add( formatters.get( i ) );
  -        }
  +        v.addAll( formatters );
       }
   }
  
  
  
  1.9       +83 -79    jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java
  
  Index: JUnitTestRunner.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- JUnitTestRunner.java	30 Dec 2001 03:33:58 -0000	1.8
  +++ JUnitTestRunner.java	6 Jan 2002 02:28:02 -0000	1.9
  @@ -19,7 +19,6 @@
   import java.lang.reflect.Method;
   import java.util.ArrayList;
   import java.util.Hashtable;
  -import java.util.Iterator;
   import java.util.Properties;
   import junit.framework.AssertionFailedError;
   import junit.framework.Test;
  @@ -46,10 +45,9 @@
    * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
    * @author <a href="mailto:erik@hatcher.net">Erik Hatcher</a>
    */
  -
  -public class JUnitTestRunner implements TestListener
  +public class JUnitTestRunner
  +    implements TestListener
   {
  -
       /**
        * No problems with this test.
        */
  @@ -70,7 +68,8 @@
        */
       private static boolean filtertrace = true;
   
  -    private final static String[] DEFAULT_TRACE_FILTERS = new String[]{
  +    private final static String[] DEFAULT_TRACE_FILTERS = new String[]
  +    {
           "junit.framework.TestCase",
           "junit.framework.TestResult",
           "junit.framework.TestSuite",
  @@ -82,57 +81,57 @@
           "org.apache.tools.ant."
       };
   
  -    private static ArrayList fromCmdLine = new ArrayList();
  +    private static ArrayList m_fromCmdLine = new ArrayList();
   
       /**
        * Holds the registered formatters.
        */
  -    private ArrayList formatters = new ArrayList();
  +    private ArrayList m_formatters = new ArrayList();
   
       /**
        * Do we stop on errors.
        */
  -    private boolean haltOnError = false;
  +    private boolean m_haltOnError;
   
       /**
        * Do we stop on test failures.
        */
  -    private boolean haltOnFailure = false;
  +    private boolean m_haltOnFailure;
   
       /**
        * The corresponding testsuite.
        */
  -    private Test suite = null;
  +    private Test m_suite;
   
       /**
        * Returncode
        */
  -    private int retCode = SUCCESS;
  +    private int m_retCode = SUCCESS;
   
       /**
        * Exception caught in constructor.
        */
  -    private Exception exception;
  +    private Exception m_exception;
   
       /**
        * The TestSuite we are currently running.
        */
  -    private JUnitTest junitTest;
  +    private JUnitTest m_junitTest;
   
       /**
        * Collects TestResults.
        */
  -    private TestResult res;
  +    private TestResult m_res;
   
       /**
        * output written during the test
        */
  -    private PrintStream systemError;
  +    private PrintStream m_systemError;
   
       /**
        * Error output during the test
        */
  -    private PrintStream systemOut;
  +    private PrintStream m_systemOut;
   
       /**
        * Constructor for fork=true or when the user hasn't specified a classpath.
  @@ -142,8 +141,10 @@
        * @param filtertrace Description of Parameter
        * @param haltOnFailure Description of Parameter
        */
  -    public JUnitTestRunner( JUnitTest test, boolean haltOnError, boolean filtertrace,
  -                            boolean haltOnFailure )
  +    public JUnitTestRunner( final JUnitTest test,
  +                            final boolean haltOnError,
  +                            final boolean filtertrace,
  +                            final boolean haltOnFailure )
       {
           this( test, haltOnError, filtertrace, haltOnFailure, null );
       }
  @@ -162,9 +163,9 @@
       {
           //JUnitTestRunner.filtertrace = filtertrace;
           this.filtertrace = filtertrace;
  -        this.junitTest = test;
  -        this.haltOnError = haltOnError;
  -        this.haltOnFailure = haltOnFailure;
  +        this.m_junitTest = test;
  +        this.m_haltOnError = haltOnError;
  +        this.m_haltOnFailure = haltOnFailure;
   
           try
           {
  @@ -196,20 +197,20 @@
                   // if there is a suite method available, then try
                   // to extract the suite from it. If there is an error
                   // here it will be caught below and reported.
  -                suite = (Test)suiteMethod.invoke( null, new Class[ 0 ] );
  +                m_suite = (Test)suiteMethod.invoke( null, new Class[ 0 ] );
               }
               else
               {
                   // try to extract a test suite automatically
                   // this will generate warnings if the class is no suitable Test
  -                suite = new TestSuite( testClass );
  +                m_suite = new TestSuite( testClass );
               }
   
           }
           catch( Exception e )
           {
  -            retCode = ERRORS;
  -            exception = e;
  +            m_retCode = ERRORS;
  +            m_exception = e;
           }
       }
   
  @@ -339,7 +340,7 @@
        * @exception IOException Description of Exception
        */
       public static void main( String[] args )
  -        throws IOException
  +        throws IOException, TaskException
       {
           boolean exitAtEnd = true;
           boolean haltError = false;
  @@ -391,11 +392,7 @@
   
           // Add/overlay system properties on the properties from the Ant project
           Hashtable p = System.getProperties();
  -        for( Iterator enum = p.keys(); enum.hasNext(); )
  -        {
  -            Object key = enum.next();
  -            props.put( key, p.get( key ) );
  -        }
  +        props.putAll( p );
           t.setProperties( props );
   
           JUnitTestRunner runner = new JUnitTestRunner( t, haltError, stackfilter, haltFail );
  @@ -426,7 +423,7 @@
               fe.setClassname( line.substring( 0, pos ) );
               fe.setOutfile( new File( line.substring( pos + 1 ) ) );
           }
  -        fromCmdLine.add( fe.createFormatter() );
  +        m_fromCmdLine.add( fe.createFormatter() );
       }
   
       private static boolean filterLine( String line )
  @@ -443,9 +440,9 @@
   
       private static void transferFormatters( JUnitTestRunner runner )
       {
  -        for( int i = 0; i < fromCmdLine.size(); i++ )
  +        for( int i = 0; i < m_fromCmdLine.size(); i++ )
           {
  -            runner.addFormatter( (JUnitResultFormatter)fromCmdLine.get( i ) );
  +            runner.addFormatter( (JUnitResultFormatter)m_fromCmdLine.get( i ) );
           }
       }
   
  @@ -456,7 +453,7 @@
        */
       public int getRetCode()
       {
  -        return retCode;
  +        return m_retCode;
       }
   
       /**
  @@ -469,9 +466,9 @@
        */
       public void addError( Test test, Throwable t )
       {
  -        if( haltOnError )
  +        if( m_haltOnError )
           {
  -            res.stop();
  +            m_res.stop();
           }
       }
   
  @@ -485,9 +482,9 @@
        */
       public void addFailure( Test test, Throwable t )
       {
  -        if( haltOnFailure )
  +        if( m_haltOnFailure )
           {
  -            res.stop();
  +            m_res.stop();
           }
       }
   
  @@ -506,7 +503,7 @@
   
       public void addFormatter( JUnitResultFormatter f )
       {
  -        formatters.add( f );
  +        m_formatters.add( f );
       }
   
       /**
  @@ -521,63 +518,65 @@
       }
   
       public void run()
  +        throws TaskException
       {
  -        res = new TestResult();
  -        res.addListener( this );
  -        for( int i = 0; i < formatters.size(); i++ )
  +        m_res = new TestResult();
  +        m_res.addListener( this );
  +        for( int i = 0; i < m_formatters.size(); i++ )
           {
  -            res.addListener( (TestListener)formatters.get( i ) );
  +            final TestListener listener = (TestListener)m_formatters.get( i );
  +            m_res.addListener( listener );
           }
   
           long start = System.currentTimeMillis();
   
           fireStartTestSuite();
  -        if( exception != null )
  +        if( m_exception != null )
           {// had an exception in the constructor
  -            for( int i = 0; i < formatters.size(); i++ )
  +            for( int i = 0; i < m_formatters.size(); i++ )
               {
  -                ( (TestListener)formatters.get( i ) ).addError( null,
  -                                                                exception );
  +                ( (TestListener)m_formatters.get( i ) ).addError( null,
  +                                                                  m_exception );
               }
  -            junitTest.setCounts( 1, 0, 1 );
  -            junitTest.setRunTime( 0 );
  +            m_junitTest.setCounts( 1, 0, 1 );
  +            m_junitTest.setRunTime( 0 );
           }
           else
           {
   
               ByteArrayOutputStream errStrm = new ByteArrayOutputStream();
  -            systemError = new PrintStream( errStrm );
  +            m_systemError = new PrintStream( errStrm );
   
               ByteArrayOutputStream outStrm = new ByteArrayOutputStream();
  -            systemOut = new PrintStream( outStrm );
  +            m_systemOut = new PrintStream( outStrm );
   
               try
               {
  -                suite.run( res );
  +                m_suite.run( m_res );
               }
               finally
               {
  -                systemError.close();
  -                systemError = null;
  -                systemOut.close();
  -                systemOut = null;
  +                m_systemError.close();
  +                m_systemError = null;
  +                m_systemOut.close();
  +                m_systemOut = null;
                   sendOutAndErr( new String( outStrm.toByteArray() ),
                                  new String( errStrm.toByteArray() ) );
   
  -                junitTest.setCounts( res.runCount(), res.failureCount(),
  -                                     res.errorCount() );
  -                junitTest.setRunTime( System.currentTimeMillis() - start );
  +                m_junitTest.setCounts( m_res.runCount(), m_res.failureCount(),
  +                                       m_res.errorCount() );
  +                m_junitTest.setRunTime( System.currentTimeMillis() - start );
               }
           }
           fireEndTestSuite();
   
  -        if( retCode != SUCCESS || res.errorCount() != 0 )
  +        if( m_retCode != SUCCESS || m_res.errorCount() != 0 )
           {
  -            retCode = ERRORS;
  +            m_retCode = ERRORS;
           }
  -        else if( res.failureCount() != 0 )
  +        else if( m_res.failureCount() != 0 )
           {
  -            retCode = FAILURES;
  +            m_retCode = FAILURES;
           }
       }
   
  @@ -585,8 +584,6 @@
        * Interface TestListener. <p>
        *
        * A new Test is started.
  -     *
  -     * @param t Description of Parameter
        */
       public void startTest( Test t )
       {
  @@ -594,46 +591,53 @@
   
       protected void handleErrorOutput( String line )
       {
  -        if( systemError != null )
  +        if( m_systemError != null )
           {
  -            systemError.println( line );
  +            m_systemError.println( line );
           }
       }
   
       protected void handleOutput( String line )
       {
  -        if( systemOut != null )
  +        if( m_systemOut != null )
           {
  -            systemOut.println( line );
  +            m_systemOut.println( line );
           }
       }
   
       private void fireEndTestSuite()
  +        throws TaskException
       {
  -        for( int i = 0; i < formatters.size(); i++ )
  +        final int size = m_formatters.size();
  +        for( int i = 0; i < size; i++ )
           {
  -            ( (JUnitResultFormatter)formatters.get( i ) ).endTestSuite( junitTest );
  +            final JUnitResultFormatter formatter =
  +                (JUnitResultFormatter)m_formatters.get( i );
  +            formatter.endTestSuite( m_junitTest );
           }
       }
   
       private void fireStartTestSuite()
  +        throws TaskException
       {
  -        for( int i = 0; i < formatters.size(); i++ )
  +        final int size = m_formatters.size();
  +        for( int i = 0; i < size; i++ )
           {
  -            ( (JUnitResultFormatter)formatters.get( i ) ).startTestSuite( junitTest );
  +            final JUnitResultFormatter formatter = (JUnitResultFormatter)m_formatters.get( i );
  +            formatter.startTestSuite( m_junitTest );
           }
       }
   
       private void sendOutAndErr( String out, String err )
       {
  -        for( int i = 0; i < formatters.size(); i++ )
  +        final int size = m_formatters.size();
  +        for( int i = 0; i < size; i++ )
           {
  -            JUnitResultFormatter formatter =
  -                ( (JUnitResultFormatter)formatters.get( i ) );
  +            final JUnitResultFormatter formatter =
  +                (JUnitResultFormatter)m_formatters.get( i );
   
               formatter.setSystemOutput( out );
               formatter.setSystemError( err );
           }
       }
  -
  -}// JUnitTestRunner
  +}
  
  
  
  1.6       +5 -4      jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLJUnitResultFormatter.java
  
  Index: XMLJUnitResultFormatter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLJUnitResultFormatter.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- XMLJUnitResultFormatter.java	23 Dec 2001 06:31:58 -0000	1.5
  +++ XMLJUnitResultFormatter.java	6 Jan 2002 02:28:02 -0000	1.6
  @@ -224,13 +224,14 @@
           Properties props = suite.getProperties();
           if( props != null )
           {
  -            Iterator e = props.propertyNames();
  +            final Iterator e = props.keySet().iterator();
               while( e.hasNext() )
               {
  -                String name = (String)e.next();
  -                Element propElement = doc.createElement( PROPERTY );
  +                final String name = (String)e.next();
  +                final String value = props.getProperty( name );
  +                final Element propElement = doc.createElement( PROPERTY );
                   propElement.setAttribute( ATTR_NAME, name );
  -                propElement.setAttribute( ATTR_VALUE, props.getProperty( name ) );
  +                propElement.setAttribute( ATTR_VALUE, value );
                   propsElement.appendChild( propElement );
               }
           }
  
  
  
  1.13      +18 -15    jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregator.java
  
  Index: XMLResultAggregator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregator.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- XMLResultAggregator.java	1 Jan 2002 09:13:46 -0000	1.12
  +++ XMLResultAggregator.java	6 Jan 2002 02:28:02 -0000	1.13
  @@ -17,7 +17,6 @@
   import java.util.Iterator;
   import javax.xml.parsers.DocumentBuilder;
   import javax.xml.parsers.DocumentBuilderFactory;
  -import org.apache.avalon.excalibur.io.FileUtil;
   import org.apache.avalon.framework.ExceptionUtil;
   import org.apache.myrmidon.api.TaskException;
   import org.apache.tools.ant.DirectoryScanner;
  @@ -43,9 +42,10 @@
    *
    * @author <a href="mailto:sbailliez@imediation.com">Stephane Bailliez</a>
    */
  -public class XMLResultAggregator extends Task implements XMLConstants
  +public class XMLResultAggregator
  +    extends Task
  +    implements XMLConstants
   {
  -
       /**
        * the default directory: <tt>.</tt> . It is resolved from the project
        * directory
  @@ -147,7 +147,7 @@
       public void execute()
           throws TaskException
       {
  -        Element rootElement = createDocument();
  +        final Element rootElement = createDocument();
           File destFile = getDestinationFile();
           // write the document
           try
  @@ -176,6 +176,7 @@
        * @return the destination file where should be written the result file.
        */
       protected File getDestinationFile()
  +        throws TaskException
       {
           if( toFile == null )
           {
  @@ -183,7 +184,7 @@
           }
           if( toDir == null )
           {
  -            toDir = FileUtil.resolveFile( getBaseDirectory(), DEFAULT_DIR );
  +            toDir = resolveFile( DEFAULT_DIR );
           }
           return new File( toDir, toFile );
       }
  @@ -194,22 +195,23 @@
        * @return all files in the fileset that end with a '.xml'.
        */
       protected File[] getFiles()
  +        throws TaskException
       {
  -        ArrayList v = new ArrayList();
  +        final ArrayList v = new ArrayList();
           final int size = filesets.size();
           for( int i = 0; i < size; i++ )
           {
  -            FileSet fs = (FileSet)filesets.get( i );
  -            DirectoryScanner ds = fs.getDirectoryScanner();
  -            ds.scan();
  -            String[] f = ds.getIncludedFiles();
  -            for( int j = 0; j < f.length; j++ )
  +            final FileSet fileSet = (FileSet)filesets.get( i );
  +            final DirectoryScanner scanner = fileSet.getDirectoryScanner();
  +            scanner.scan();
  +            final String[] includes = scanner.getIncludedFiles();
  +            for( int j = 0; j < includes.length; j++ )
               {
  -                String pathname = f[ j ];
  +                final String pathname = includes[ j ];
                   if( pathname.endsWith( ".xml" ) )
                   {
  -                    File file = new File( ds.getBasedir(), pathname );
  -                    file = FileUtil.resolveFile( getBaseDirectory(), file.getPath() );
  +                    File file = new File( scanner.getBasedir(), pathname );
  +                    file = resolveFile( file.getPath() );
                       v.add( file );
                   }
               }
  @@ -257,6 +259,7 @@
        * @return the root element of DOM tree that aggregates all testsuites.
        */
       protected Element createDocument()
  +        throws TaskException
       {
           // create the dom tree
           DocumentBuilder builder = getDocumentBuilder();
  @@ -265,7 +268,7 @@
           doc.appendChild( rootElement );
   
           // get all files and add them to the document
  -        File[] files = getFiles();
  +        final File[] files = getFiles();
           for( int i = 0; i < files.length; i++ )
           {
               try
  
  
  
  1.4       +2 -2      jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/Xalan1Executor.java
  
  Index: Xalan1Executor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/Xalan1Executor.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Xalan1Executor.java	23 Dec 2001 06:31:58 -0000	1.3
  +++ Xalan1Executor.java	6 Jan 2002 02:28:02 -0000	1.4
  @@ -27,8 +27,8 @@
       {
           XSLTProcessor processor = XSLTProcessorFactory.getProcessor();
           // need to quote otherwise it breaks because of "extra illegal tokens"
  -        processor.setStylesheetParam( "output.dir", "'" + caller.toDir.getAbsolutePath() + "'" );
  -        XSLTInputSource xml_src = new XSLTInputSource( caller.document );
  +        processor.setStylesheetParam( "output.dir", "'" + caller.getToDir().getAbsolutePath() + "'" );
  +        XSLTInputSource xml_src = new XSLTInputSource( caller.getDocument() );
           String system_id = caller.getStylesheetSystemId();
           XSLTInputSource xsl_src = new XSLTInputSource( system_id );
           OutputStream os = getOutputStream();
  
  
  
  1.4       +2 -2      jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/Xalan2Executor.java
  
  Index: Xalan2Executor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/Xalan2Executor.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Xalan2Executor.java	23 Dec 2001 06:31:58 -0000	1.3
  +++ Xalan2Executor.java	6 Jan 2002 02:28:02 -0000	1.4
  @@ -31,9 +31,9 @@
           String system_id = caller.getStylesheetSystemId();
           Source xsl_src = new StreamSource( system_id );
           Transformer tformer = tfactory.newTransformer( xsl_src );
  -        Source xml_src = new DOMSource( caller.document );
  +        Source xml_src = new DOMSource( caller.getDocument() );
           OutputStream os = getOutputStream();
  -        tformer.setParameter( "output.dir", caller.toDir.getAbsolutePath() );
  +        tformer.setParameter( "output.dir", caller.getToDir().getAbsolutePath() );
           Result result = new StreamResult( os );
           tformer.transform( xml_src, result );
       }
  
  
  
  1.5       +2 -2      jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/XalanExecutor.java
  
  Index: XalanExecutor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/XalanExecutor.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- XalanExecutor.java	23 Dec 2001 06:31:58 -0000	1.4
  +++ XalanExecutor.java	6 Jan 2002 02:28:02 -0000	1.5
  @@ -95,7 +95,7 @@
       protected OutputStream getOutputStream()
           throws IOException
       {
  -        if( caller.FRAMES.equals( caller.format ) )
  +        if( caller.FRAMES.equals( caller.getFormat() ) )
           {
               // dummy output for the framed report
               // it's all done by extension...
  @@ -103,7 +103,7 @@
           }
           else
           {
  -            return new FileOutputStream( new File( caller.toDir, "junit-noframes.html" ) );
  +            return new FileOutputStream( new File( caller.getToDir(), "junit-noframes.html" ) );
           }
       }
   
  
  
  
  1.1                  jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/CompoundIterator.java
  
  Index: CompoundIterator.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.tools.ant.taskdefs.optional.junit;
  
  import java.util.Iterator;
  import java.util.NoSuchElementException;
  
  /**
   * Convenient enumeration over an array of enumeration. For example: <pre>
   * Iterator e1 = v1.iterator();
   * while (e1.hasNext()){
   *    // do something
   * }
   * Iterator e2 = v2.iterator();
   * while (e2.hasNext()){
   *    // do the same thing
   * }
   * </pre> can be written as: <pre>
   * Iterator[] enums = { v1.iterator(), v2.iterator() };
   * Iterator e = Iterators.fromCompound(enums);
   * while (e.hasNext()){
   *    // do something
   * }
   * </pre> Note that the enumeration will skip null elements in the array. The
   * following is thus possible: <pre>
   * Iterator[] enums = { v1.iterator(), null, v2.iterator() }; // a null enumeration in the array
   * Iterator e = Iterators.fromCompound(enums);
   * while (e.hasNext()){
   *    // do something
   * }
   * </pre>
   *
   * @author <a href="mailto:sbailliez@imediation.com">Stephane Bailliez</a>
   */
  class CompoundIterator
      implements Iterator
  {
      /**
       * index in the enums array
       */
      private int index = 0;
  
      /**
       * enumeration array
       */
      private Iterator[] enumArray;
  
      public CompoundIterator( Iterator[] enumarray )
      {
          this.enumArray = enumarray;
      }
  
      /**
       * Tests if this enumeration contains more elements.
       *
       * @return <code>true</code> if and only if this enumeration object contains
       *      at least one more element to provide; <code>false</code> otherwise.
       */
      public boolean hasNext()
      {
          while( index < enumArray.length )
          {
              if( enumArray[ index ] != null && enumArray[ index ].hasNext() )
              {
                  return true;
              }
              index++;
          }
          return false;
      }
  
      /**
       * Returns the next element of this enumeration if this enumeration object
       * has at least one more element to provide.
       *
       * @return the next element of this enumeration.
       * @throws NoSuchElementException if no more elements exist.
       */
      public Object next()
          throws NoSuchElementException
      {
          if( hasNext() )
          {
              return enumArray[ index ].next();
          }
          throw new NoSuchElementException();
      }
  
      public void remove()
          throws UnsupportedOperationException
      {
          throw new UnsupportedOperationException();
      }
  }
  
  
  
  
  1.1                  jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/NodeListImpl.java
  
  Index: NodeListImpl.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included  with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.tools.ant.taskdefs.optional.junit;
  
  import java.util.ArrayList;
  import org.w3c.dom.Node;
  import org.w3c.dom.NodeList;
  
  /**
   * custom implementation of a nodelist
   */
  public class NodeListImpl
      extends ArrayList
      implements NodeList
  {
      public int getLength()
      {
          return size();
      }
  
      public Node item( final int i )
      {
          try
          {
              return (Node)get( i );
          }
          catch( final ArrayIndexOutOfBoundsException aioobe )
          {
              return null;// conforming to NodeList interface
          }
      }
  }
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message