You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by do...@apache.org on 2001/12/16 01:36:01 UTC
cvs commit: jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit AggregateTransformer.java BaseTest.java BatchTest.java BriefJUnitResultFormatter.java DOMUtil.java Enumerations.java FormatterElement.java JUnitResultFormatter.java JUnitTask.java JUnitTest.java JUnitTestRunner.java JUnitVersionHelper.java PlainJUnitResultFormatter.java SummaryJUnitResultFormatter.java XMLJUnitResultFormatter.java XMLResultAggregator.java Xalan1Executor.java Xalan2Executor.java XalanExecutor.java
donaldp 01/12/15 16:36:01
Modified: proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit
AggregateTransformer.java BaseTest.java
BatchTest.java BriefJUnitResultFormatter.java
DOMUtil.java Enumerations.java
FormatterElement.java JUnitResultFormatter.java
JUnitTask.java JUnitTest.java JUnitTestRunner.java
JUnitVersionHelper.java
PlainJUnitResultFormatter.java
SummaryJUnitResultFormatter.java
XMLJUnitResultFormatter.java
XMLResultAggregator.java Xalan1Executor.java
Xalan2Executor.java XalanExecutor.java
Log:
BuildException -> TaskException
Removed uneeded imports.
Processed code through style formatter.
Revision Changes Path
1.3 +10 -12 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.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AggregateTransformer.java 2001/12/15 14:55:58 1.2
+++ AggregateTransformer.java 2001/12/16 00:36:00 1.3
@@ -6,6 +6,7 @@
* the LICENSE file.
*/
package org.apache.tools.ant.taskdefs.optional.junit;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -14,17 +15,14 @@
import java.net.URL;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
-import org.apache.tools.ant.BuildException;
+import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
-import org.apache.tools.ant.util.FileUtils;
import org.apache.tools.ant.types.EnumeratedAttribute;
+import org.apache.tools.ant.util.FileUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-
-
-
/**
* Transform a JUnit xml report. The default transformation generates an html
* report in either framed or non-framed style. The non-framed style is
@@ -121,7 +119,7 @@
}
public void transform()
- throws BuildException
+ throws TaskException
{
checkOptions();
final long t0 = System.currentTimeMillis();
@@ -133,7 +131,7 @@
}
catch( Exception e )
{
- throw new BuildException( "Errors while applying transformations", e );
+ throw new TaskException( "Errors while applying transformations", e );
}
final long dt = System.currentTimeMillis() - t0;
task.log( "Transform time: " + dt + "ms" );
@@ -144,10 +142,10 @@
* file directly. Much more for testing purposes.
*
* @param xmlfile xml file to be processed
- * @exception BuildException Description of Exception
+ * @exception TaskException Description of Exception
*/
protected void setXmlfile( File xmlfile )
- throws BuildException
+ throws TaskException
{
try
{
@@ -165,7 +163,7 @@
}
catch( Exception e )
{
- throw new BuildException( "Error while parsing document: " + xmlfile, e );
+ throw new TaskException( "Error while parsing document: " + xmlfile, e );
}
}
@@ -209,10 +207,10 @@
/**
* check for invalid options
*
- * @exception BuildException Description of Exception
+ * @exception TaskException Description of Exception
*/
protected void checkOptions()
- throws BuildException
+ throws TaskException
{
// set the destination directory relative from the project if needed.
if( toDir == null )
1.2 +1 -0 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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- BaseTest.java 2001/12/15 12:06:28 1.1
+++ BaseTest.java 2001/12/16 00:36:00 1.2
@@ -6,6 +6,7 @@
* the LICENSE file.
*/
package org.apache.tools.ant.taskdefs.optional.junit;
+
import java.io.File;
import java.util.Vector;
1.2 +9 -8 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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- BatchTest.java 2001/12/15 12:06:28 1.1
+++ BatchTest.java 2001/12/16 00:36:00 1.2
@@ -6,6 +6,7 @@
* the LICENSE file.
*/
package org.apache.tools.ant.taskdefs.optional.junit;
+
import java.io.File;
import java.util.Enumeration;
import java.util.Vector;
@@ -103,7 +104,7 @@
v.ensureCapacity( v.size() + tests.length );
for( int i = 0; i < tests.length; i++ )
{
- v.addElement( tests[i] );
+ v.addElement( tests[ i ] );
}
}
@@ -125,13 +126,13 @@
final int size = this.filesets.size();
for( int j = 0; j < size; j++ )
{
- FileSet fs = ( FileSet )filesets.elementAt( j );
+ FileSet fs = (FileSet)filesets.elementAt( j );
DirectoryScanner ds = fs.getDirectoryScanner( project );
ds.scan();
String[] f = ds.getIncludedFiles();
for( int k = 0; k < f.length; k++ )
{
- String pathname = f[k];
+ String pathname = f[ k ];
if( pathname.endsWith( ".java" ) )
{
v.addElement( pathname.substring( 0, pathname.length() - ".java".length() ) );
@@ -143,7 +144,7 @@
}
}
- String[] files = new String[v.size()];
+ String[] files = new String[ v.size() ];
v.copyInto( files );
return files;
}
@@ -157,11 +158,11 @@
private JUnitTest[] createAllJUnitTest()
{
String[] filenames = getFilenames();
- JUnitTest[] tests = new JUnitTest[filenames.length];
+ JUnitTest[] tests = new JUnitTest[ filenames.length ];
for( int i = 0; i < tests.length; i++ )
{
- String classname = javaToClass( filenames[i] );
- tests[i] = createJUnitTest( classname );
+ String classname = javaToClass( filenames[ i ] );
+ tests[ i ] = createJUnitTest( classname );
}
return tests;
}
@@ -190,7 +191,7 @@
Enumeration list = this.formatters.elements();
while( list.hasMoreElements() )
{
- test.addFormatter( ( FormatterElement )list.nextElement() );
+ test.addFormatter( (FormatterElement)list.nextElement() );
}
return test;
}
1.2 +19 -11 jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/BriefJUnitResultFormatter.java
Index: BriefJUnitResultFormatter.java
===================================================================
RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/BriefJUnitResultFormatter.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- BriefJUnitResultFormatter.java 2001/12/15 12:06:28 1.1
+++ BriefJUnitResultFormatter.java 2001/12/16 00:36:00 1.2
@@ -6,9 +6,10 @@
* the LICENSE file.
*/
package org.apache.tools.ant.taskdefs.optional.junit;
+
import junit.framework.AssertionFailedError;
import junit.framework.Test;
-import org.apache.tools.ant.BuildException;
+import org.apache.myrmidon.api.TaskException;
/**
* Prints plain text output of the test to a specified Writer. Inspired by the
@@ -117,7 +118,7 @@
*/
public void addFailure( Test test, AssertionFailedError t )
{
- addFailure( test, ( Throwable )t );
+ addFailure( test, (Throwable)t );
}
/**
@@ -125,16 +126,18 @@
*
* @param test Description of Parameter
*/
- public void endTest( Test test ) { }
+ public void endTest( Test test )
+ {
+ }
/**
* The whole testsuite ended.
*
* @param suite Description of Parameter
- * @exception BuildException Description of Exception
+ * @exception TaskException Description of Exception
*/
public void endTestSuite( JUnitTest suite )
- throws BuildException
+ throws TaskException
{
String newLine = System.getProperty( "line.separator" );
StringBuffer sb = new StringBuffer( "Testsuite: " );
@@ -182,15 +185,16 @@
}
finally
{
- if( m_out != ( Object )System.out &&
- m_out != ( Object )System.err )
+ if( m_out != (Object)System.out &&
+ m_out != (Object)System.err )
{
try
{
m_out.close();
}
catch( java.io.IOException e )
- {}
+ {
+ }
}
}
}
@@ -201,16 +205,20 @@
*
* @param test Description of Parameter
*/
- public void startTest( Test test ) { }
+ public void startTest( Test test )
+ {
+ }
/**
* The whole testsuite started.
*
* @param suite Description of Parameter
- * @exception BuildException Description of Exception
+ * @exception TaskException Description of Exception
*/
public void startTestSuite( JUnitTest suite )
- throws BuildException { }
+ throws TaskException
+ {
+ }
/**
* Format an error and print it.
1.2 +42 -40 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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DOMUtil.java 2001/12/15 12:06:28 1.1
+++ DOMUtil.java 2001/12/16 00:36:00 1.2
@@ -6,6 +6,7 @@
* the LICENSE file.
*/
package org.apache.tools.ant.taskdefs.optional.junit;
+
import java.util.Vector;
import org.w3c.dom.Attr;
import org.w3c.dom.CDATASection;
@@ -30,8 +31,9 @@
/**
* unused constructor
*/
- private DOMUtil() { }
-
+ private DOMUtil()
+ {
+ }
/**
* Iterate over the children of a given node and return the first node that
@@ -58,7 +60,7 @@
if( child != null && child.getNodeType() == Node.ELEMENT_NODE &&
child.getNodeName().equals( tagname ) )
{
- return ( Element )child;
+ return (Element)child;
}
}
return null;
@@ -77,7 +79,7 @@
{
if( node instanceof Element )
{
- Element element = ( Element )node;
+ Element element = (Element)node;
return element.getAttribute( name );
}
return null;
@@ -101,44 +103,44 @@
Node copy = null;
final Document doc = parent.getOwnerDocument();
- switch ( child.getNodeType() )
+ switch( child.getNodeType() )
{
- case Node.CDATA_SECTION_NODE:
- copy = doc.createCDATASection( ( ( CDATASection )child ).getData() );
- break;
- case Node.COMMENT_NODE:
- copy = doc.createComment( ( ( Comment )child ).getData() );
- break;
- case Node.DOCUMENT_FRAGMENT_NODE:
- copy = doc.createDocumentFragment();
- break;
- case Node.ELEMENT_NODE:
- final Element elem = doc.createElement( ( ( Element )child ).getTagName() );
- copy = elem;
- final NamedNodeMap attributes = child.getAttributes();
- if( attributes != null )
- {
- final int size = attributes.getLength();
- for( int i = 0; i < size; i++ )
+ case Node.CDATA_SECTION_NODE:
+ copy = doc.createCDATASection( ( (CDATASection)child ).getData() );
+ break;
+ case Node.COMMENT_NODE:
+ copy = doc.createComment( ( (Comment)child ).getData() );
+ break;
+ case Node.DOCUMENT_FRAGMENT_NODE:
+ copy = doc.createDocumentFragment();
+ break;
+ case Node.ELEMENT_NODE:
+ final Element elem = doc.createElement( ( (Element)child ).getTagName() );
+ copy = elem;
+ final NamedNodeMap attributes = child.getAttributes();
+ if( attributes != null )
{
- final Attr attr = ( Attr )attributes.item( i );
- elem.setAttribute( attr.getName(), attr.getValue() );
+ final int size = attributes.getLength();
+ for( int i = 0; i < size; i++ )
+ {
+ final Attr attr = (Attr)attributes.item( i );
+ elem.setAttribute( attr.getName(), attr.getValue() );
+ }
}
- }
- break;
- case Node.ENTITY_REFERENCE_NODE:
- copy = doc.createEntityReference( child.getNodeName() );
- break;
- case Node.PROCESSING_INSTRUCTION_NODE:
- final ProcessingInstruction pi = ( ProcessingInstruction )child;
- copy = doc.createProcessingInstruction( pi.getTarget(), pi.getData() );
- break;
- case Node.TEXT_NODE:
- copy = doc.createTextNode( ( ( Text )child ).getData() );
- break;
- default:
- // this should never happen
- throw new IllegalStateException( "Invalid node type: " + child.getNodeType() );
+ break;
+ case Node.ENTITY_REFERENCE_NODE:
+ copy = doc.createEntityReference( child.getNodeName() );
+ break;
+ case Node.PROCESSING_INSTRUCTION_NODE:
+ final ProcessingInstruction pi = (ProcessingInstruction)child;
+ copy = doc.createProcessingInstruction( pi.getTarget(), pi.getData() );
+ break;
+ case Node.TEXT_NODE:
+ copy = doc.createTextNode( ( (Text)child ).getData() );
+ break;
+ default:
+ // this should never happen
+ throw new IllegalStateException( "Invalid node type: " + child.getNodeType() );
}
// okay we have a copy of the child, now the child becomes the parent
@@ -238,7 +240,7 @@
{
try
{
- return ( Node )elementAt( i );
+ return (Node)elementAt( i );
}
catch( ArrayIndexOutOfBoundsException e )
{
1.2 +7 -5 jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/Enumerations.java
Index: Enumerations.java
===================================================================
RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/Enumerations.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Enumerations.java 2001/12/15 12:06:28 1.1
+++ Enumerations.java 2001/12/16 00:36:00 1.2
@@ -6,6 +6,7 @@
* the LICENSE file.
*/
package org.apache.tools.ant.taskdefs.optional.junit;
+
import java.util.Enumeration;
import java.util.NoSuchElementException;
@@ -18,7 +19,9 @@
public final class Enumerations
{
- private Enumerations() { }
+ private Enumerations()
+ {
+ }
/**
* creates an enumeration from an array of objects.
@@ -46,7 +49,6 @@
}
-
/**
* Convenient enumeration over an array of objects.
*
@@ -99,7 +101,7 @@
{
if( hasMoreElements() )
{
- Object o = array[pos];
+ Object o = array[ pos ];
pos++;
return o;
}
@@ -162,7 +164,7 @@
{
while( index < enumArray.length )
{
- if( enumArray[index] != null && enumArray[index].hasMoreElements() )
+ if( enumArray[ index ] != null && enumArray[ index ].hasMoreElements() )
{
return true;
}
@@ -183,7 +185,7 @@
{
if( hasMoreElements() )
{
- return enumArray[index].nextElement();
+ return enumArray[ index ].nextElement();
}
throw new NoSuchElementException();
}
1.3 +10 -9 jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/FormatterElement.java
Index: FormatterElement.java
===================================================================
RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/FormatterElement.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- FormatterElement.java 2001/12/15 14:55:58 1.2
+++ FormatterElement.java 2001/12/16 00:36:00 1.3
@@ -6,10 +6,11 @@
* the LICENSE file.
*/
package org.apache.tools.ant.taskdefs.optional.junit;
+
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
-import org.apache.tools.ant.BuildException;
+import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.types.EnumeratedAttribute;
/**
@@ -171,11 +172,11 @@
}
JUnitResultFormatter createFormatter()
- throws BuildException
+ throws TaskException
{
if( classname == null )
{
- throw new BuildException( "you must specify type or classname" );
+ throw new TaskException( "you must specify type or classname" );
}
Class f = null;
@@ -185,7 +186,7 @@
}
catch( ClassNotFoundException e )
{
- throw new BuildException( "Error", e );
+ throw new TaskException( "Error", e );
}
Object o = null;
@@ -195,19 +196,19 @@
}
catch( InstantiationException e )
{
- throw new BuildException( "Error", e );
+ throw new TaskException( "Error", e );
}
catch( IllegalAccessException e )
{
- throw new BuildException( "Error", e );
+ throw new TaskException( "Error", e );
}
if( !( o instanceof JUnitResultFormatter ) )
{
- throw new BuildException( classname + " is not a JUnitResultFormatter" );
+ throw new TaskException( classname + " is not a JUnitResultFormatter" );
}
- JUnitResultFormatter r = ( JUnitResultFormatter )o;
+ JUnitResultFormatter r = (JUnitResultFormatter)o;
if( useFile && outFile != null )
{
@@ -217,7 +218,7 @@
}
catch( java.io.IOException e )
{
- throw new BuildException( "Error", e );
+ throw new TaskException( "Error", e );
}
}
r.setOutput( out );
1.2 +6 -5 jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitResultFormatter.java
Index: JUnitResultFormatter.java
===================================================================
RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitResultFormatter.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- JUnitResultFormatter.java 2001/12/15 12:06:28 1.1
+++ JUnitResultFormatter.java 2001/12/16 00:36:00 1.2
@@ -6,9 +6,10 @@
* the LICENSE file.
*/
package org.apache.tools.ant.taskdefs.optional.junit;
+
import java.io.OutputStream;
import junit.framework.TestListener;
-import org.apache.tools.ant.BuildException;
+import org.apache.myrmidon.api.TaskException;
/**
* This Interface describes classes that format the results of a JUnit testrun.
@@ -21,19 +22,19 @@
* The whole testsuite started.
*
* @param suite Description of Parameter
- * @exception BuildException Description of Exception
+ * @exception TaskException Description of Exception
*/
void startTestSuite( JUnitTest suite )
- throws BuildException;
+ throws TaskException;
/**
* The whole testsuite ended.
*
* @param suite Description of Parameter
- * @exception BuildException Description of Exception
+ * @exception TaskException Description of Exception
*/
void endTestSuite( JUnitTest suite )
- throws BuildException;
+ throws TaskException;
/**
* Sets the stream the formatter is supposed to write its results to.
1.3 +43 -41 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.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- JUnitTask.java 2001/12/15 14:55:58 1.2
+++ JUnitTask.java 2001/12/16 00:36:00 1.3
@@ -6,6 +6,7 @@
* the LICENSE file.
*/
package org.apache.tools.ant.taskdefs.optional.junit;
+
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -16,8 +17,8 @@
import java.util.Properties;
import java.util.Random;
import java.util.Vector;
+import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.AntClassLoader;
-import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.taskdefs.Execute;
@@ -149,7 +150,7 @@
Enumeration enum = allTests();
while( enum.hasMoreElements() )
{
- BaseTest test = ( BaseTest )enum.nextElement();
+ BaseTest test = (BaseTest)enum.nextElement();
test.setErrorProperty( propertyName );
}
}
@@ -167,7 +168,7 @@
Enumeration enum = allTests();
while( enum.hasMoreElements() )
{
- BaseTest test = ( BaseTest )enum.nextElement();
+ BaseTest test = (BaseTest)enum.nextElement();
test.setFailureProperty( propertyName );
}
}
@@ -186,7 +187,7 @@
Enumeration enum = allTests();
while( enum.hasMoreElements() )
{
- BaseTest test = ( BaseTest )enum.nextElement();
+ BaseTest test = (BaseTest)enum.nextElement();
test.setFiltertrace( value );
}
}
@@ -206,7 +207,7 @@
Enumeration enum = allTests();
while( enum.hasMoreElements() )
{
- BaseTest test = ( BaseTest )enum.nextElement();
+ BaseTest test = (BaseTest)enum.nextElement();
test.setFork( value );
}
}
@@ -223,7 +224,7 @@
Enumeration enum = allTests();
while( enum.hasMoreElements() )
{
- BaseTest test = ( BaseTest )enum.nextElement();
+ BaseTest test = (BaseTest)enum.nextElement();
test.setHaltonerror( value );
}
}
@@ -240,7 +241,7 @@
Enumeration enum = allTests();
while( enum.hasMoreElements() )
{
- BaseTest test = ( BaseTest )enum.nextElement();
+ BaseTest test = (BaseTest)enum.nextElement();
test.setHaltonfailure( value );
}
}
@@ -373,15 +374,15 @@
/**
* Runs the testcase.
*
- * @exception BuildException Description of Exception
+ * @exception TaskException Description of Exception
*/
public void execute()
- throws BuildException
+ throws TaskException
{
Enumeration list = getIndividualTests();
while( list.hasMoreElements() )
{
- JUnitTest test = ( JUnitTest )list.nextElement();
+ JUnitTest test = (JUnitTest)list.nextElement();
if( test.shouldRun( project ) )
{
execute( test );
@@ -419,13 +420,13 @@
*/
protected Enumeration getIndividualTests()
{
- Enumeration[] enums = new Enumeration[batchTests.size() + 1];
+ Enumeration[] enums = new Enumeration[ batchTests.size() + 1 ];
for( int i = 0; i < batchTests.size(); i++ )
{
- BatchTest batchtest = ( BatchTest )batchTests.elementAt( i );
- enums[i] = batchtest.elements();
+ BatchTest batchtest = (BatchTest)batchTests.elementAt( i );
+ enums[ i ] = batchtest.elements();
}
- enums[enums.length - 1] = tests.elements();
+ enums[ enums.length - 1 ] = tests.elements();
return Enumerations.fromCompound( enums );
}
@@ -437,6 +438,7 @@
* @return The Output value
*/
protected File getOutput( FormatterElement fe, JUnitTest test )
+ throws TaskException
{
if( fe.getUseFile() )
{
@@ -468,7 +470,7 @@
int pling = u.indexOf( "!" );
String jarName = u.substring( 9, pling );
log( "Implicitly adding " + jarName + " to classpath",
- Project.MSG_DEBUG );
+ Project.MSG_DEBUG );
createClasspath().setLocation( new File( ( new File( jarName ) ).getAbsolutePath() ) );
}
else if( u.startsWith( "file:" ) )
@@ -476,13 +478,13 @@
int tail = u.indexOf( resource );
String dirName = u.substring( 5, tail );
log( "Implicitly adding " + dirName + " to classpath",
- Project.MSG_DEBUG );
+ Project.MSG_DEBUG );
createClasspath().setLocation( new File( ( new File( dirName ) ).getAbsolutePath() ) );
}
else
{
log( "Don\'t know how to handle resource URL " + u,
- Project.MSG_DEBUG );
+ Project.MSG_DEBUG );
}
}
else
@@ -500,10 +502,10 @@
/**
* @return <tt>null</tt> if there is a timeout value, otherwise the watchdog
* instance.
- * @exception BuildException Description of Exception
+ * @exception TaskException Description of Exception
*/
protected ExecuteWatchdog createWatchdog()
- throws BuildException
+ throws TaskException
{
if( timeout == null )
{
@@ -516,10 +518,10 @@
* Run the tests.
*
* @param test Description of Parameter
- * @exception BuildException Description of Exception
+ * @exception TaskException Description of Exception
*/
protected void execute( JUnitTest test )
- throws BuildException
+ throws TaskException
{
// set the default values if not specified
//@todo should be moved to the test class instead.
@@ -558,10 +560,10 @@
if( errorOccurredHere || failureOccurredHere )
{
if( errorOccurredHere && test.getHaltonerror()
- || failureOccurredHere && test.getHaltonfailure() )
+ || failureOccurredHere && test.getHaltonfailure() )
{
- throw new BuildException( "Test " + test.getName() + " failed"
- + ( wasKilled ? " (timeout)" : "" ) );
+ throw new TaskException( "Test " + test.getName() + " failed"
+ + ( wasKilled ? " (timeout)" : "" ) );
}
else
{
@@ -618,12 +620,12 @@
* 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 BuildException Description of Exception
+ * @exception TaskException Description of Exception
*/
private int executeAsForked( JUnitTest test, ExecuteWatchdog watchdog )
- throws BuildException
+ throws TaskException
{
- CommandlineJava cmd = ( CommandlineJava )commandline.clone();
+ CommandlineJava cmd = (CommandlineJava)commandline.clone();
cmd.setClassname( "org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner" );
cmd.createArgument().setValue( test.getName() );
@@ -640,7 +642,7 @@
final FormatterElement[] feArray = mergeFormatters( test );
for( int i = 0; i < feArray.length; i++ )
{
- FormatterElement fe = feArray[i];
+ FormatterElement fe = feArray[ i ];
formatterArg.append( "formatter=" );
formatterArg.append( fe.getClassname() );
File outFile = getOutput( fe, test );
@@ -658,7 +660,7 @@
cmd.createArgument().setValue( "propsfile=" + propsFile.getAbsolutePath() );
Hashtable p = project.getProperties();
Properties props = new Properties();
- for( Enumeration enum = p.keys(); enum.hasMoreElements(); )
+ for( Enumeration enum = p.keys(); enum.hasMoreElements(); )
{
Object key = enum.nextElement();
props.put( key, p.get( key ) );
@@ -671,7 +673,7 @@
}
catch( java.io.IOException e )
{
- throw new BuildException( "Error creating temporary properties file.", e );
+ throw new TaskException( "Error creating temporary properties file.", e );
}
Execute execute = new Execute( new LogStreamHandler( this, Project.MSG_INFO, Project.MSG_WARN ), watchdog );
@@ -690,12 +692,12 @@
}
catch( IOException e )
{
- throw new BuildException( "Process fork failed.", e );
+ throw new TaskException( "Process fork failed.", e );
}
finally
{
if( !propsFile.delete() )
- throw new BuildException( "Could not delete temporary properties file." );
+ throw new TaskException( "Could not delete temporary properties file." );
}
return retVal;
@@ -706,10 +708,10 @@
*
* @param test Description of Parameter
* @return Description of the Returned Value
- * @exception BuildException Description of Exception
+ * @exception TaskException Description of Exception
*/
private int executeInVM( JUnitTest test )
- throws BuildException
+ throws TaskException
{
test.setProperties( project.getProperties() );
if( dir != null )
@@ -752,7 +754,7 @@
final FormatterElement[] feArray = mergeFormatters( test );
for( int i = 0; i < feArray.length; i++ )
{
- FormatterElement fe = feArray[i];
+ FormatterElement fe = feArray[ i ];
File outFile = getOutput( fe, test );
if( outFile != null )
{
@@ -779,9 +781,9 @@
private FormatterElement[] mergeFormatters( JUnitTest test )
{
- Vector feVector = ( Vector )formatters.clone();
+ Vector feVector = (Vector)formatters.clone();
test.addFormattersTo( feVector );
- FormatterElement[] feArray = new FormatterElement[feVector.size()];
+ FormatterElement[] feArray = new FormatterElement[ feVector.size() ];
feVector.copyInto( feArray );
return feArray;
}
@@ -796,15 +798,15 @@
public String[] getValues()
{
return new String[]{"true", "yes", "false", "no",
- "on", "off", "withOutAndErr"};
+ "on", "off", "withOutAndErr"};
}
public boolean asBoolean()
{
return "true".equals( value )
- || "on".equals( value )
- || "yes".equals( value )
- || "withOutAndErr".equals( value );
+ || "on".equals( value )
+ || "yes".equals( value )
+ || "withOutAndErr".equals( value );
}
}
1.2 +6 -3 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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- JUnitTest.java 2001/12/15 12:06:28 1.1
+++ JUnitTest.java 2001/12/16 00:36:00 1.2
@@ -6,6 +6,7 @@
* the LICENSE file.
*/
package org.apache.tools.ant.taskdefs.optional.junit;
+
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Properties;
@@ -48,7 +49,9 @@
// and deal with it. (SB)
private long runs, failures, errors;
- public JUnitTest() { }
+ public JUnitTest()
+ {
+ }
public JUnitTest( String name )
{
@@ -93,7 +96,7 @@
public void setProperties( Hashtable p )
{
props = new Properties();
- for( Enumeration enum = p.keys(); enum.hasMoreElements(); )
+ for( Enumeration enum = p.keys(); enum.hasMoreElements(); )
{
Object key = enum.nextElement();
props.put( key, p.get( key ) );
@@ -107,7 +110,7 @@
public FormatterElement[] getFormatters()
{
- FormatterElement[] fes = new FormatterElement[formatters.size()];
+ FormatterElement[] fes = new FormatterElement[ formatters.size() ];
formatters.copyInto( fes );
return fes;
}
1.2 +38 -33 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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- JUnitTestRunner.java 2001/12/15 12:06:28 1.1
+++ JUnitTestRunner.java 2001/12/16 00:36:00 1.2
@@ -6,6 +6,7 @@
* the LICENSE file.
*/
package org.apache.tools.ant.taskdefs.optional.junit;
+
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.File;
@@ -25,8 +26,8 @@
import junit.framework.TestListener;
import junit.framework.TestResult;
import junit.framework.TestSuite;
+import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.AntClassLoader;
-import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.util.StringUtils;
@@ -76,12 +77,12 @@
"junit.framework.TestResult",
"junit.framework.TestSuite",
"junit.framework.Assert.", // don't filter AssertionFailure
- "junit.swingui.TestRunner",
+ "junit.swingui.TestRunner",
"junit.awtui.TestRunner",
"junit.textui.TestRunner",
"java.lang.reflect.Method.invoke(",
"org.apache.tools.ant."
- };
+ };
private static Vector fromCmdLine = new Vector();
@@ -184,7 +185,7 @@
try
{
// check if there is a suite method
- suiteMethod = testClass.getMethod( "suite", new Class[0] );
+ suiteMethod = testClass.getMethod( "suite", new Class[ 0 ] );
}
catch( Exception e )
{
@@ -198,7 +199,7 @@
// 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] );
+ suite = (Test)suiteMethod.invoke( null, new Class[ 0 ] );
}
else
{
@@ -357,43 +358,43 @@
for( int i = 1; i < args.length; i++ )
{
- if( args[i].startsWith( "haltOnError=" ) )
+ if( args[ i ].startsWith( "haltOnError=" ) )
{
- haltError = Project.toBoolean( args[i].substring( 12 ) );
+ haltError = Project.toBoolean( args[ i ].substring( 12 ) );
}
- else if( args[i].startsWith( "haltOnFailure=" ) )
+ else if( args[ i ].startsWith( "haltOnFailure=" ) )
{
- haltFail = Project.toBoolean( args[i].substring( 14 ) );
+ haltFail = Project.toBoolean( args[ i ].substring( 14 ) );
}
- else if( args[i].startsWith( "filtertrace=" ) )
+ else if( args[ i ].startsWith( "filtertrace=" ) )
{
- stackfilter = Project.toBoolean( args[i].substring( 12 ) );
+ stackfilter = Project.toBoolean( args[ i ].substring( 12 ) );
}
- else if( args[i].startsWith( "formatter=" ) )
+ else if( args[ i ].startsWith( "formatter=" ) )
{
try
{
- createAndStoreFormatter( args[i].substring( 10 ) );
+ createAndStoreFormatter( args[ i ].substring( 10 ) );
}
- catch( BuildException be )
+ catch( TaskException be )
{
System.err.println( be.getMessage() );
System.exit( ERRORS );
}
}
- else if( args[i].startsWith( "propsfile=" ) )
+ else if( args[ i ].startsWith( "propsfile=" ) )
{
- FileInputStream in = new FileInputStream( args[i].substring( 10 ) );
+ FileInputStream in = new FileInputStream( args[ i ].substring( 10 ) );
props.load( in );
in.close();
}
}
- JUnitTest t = new JUnitTest( args[0] );
+ JUnitTest t = new JUnitTest( args[ 0 ] );
// Add/overlay system properties on the properties from the Ant project
Hashtable p = System.getProperties();
- for( Enumeration enum = p.keys(); enum.hasMoreElements(); )
+ for( Enumeration enum = p.keys(); enum.hasMoreElements(); )
{
Object key = enum.nextElement();
props.put( key, p.get( key ) );
@@ -412,10 +413,10 @@
* )?
*
* @param line Description of Parameter
- * @exception BuildException Description of Exception
+ * @exception TaskException Description of Exception
*/
private static void createAndStoreFormatter( String line )
- throws BuildException
+ throws TaskException
{
FormatterElement fe = new FormatterElement();
int pos = line.indexOf( ',' );
@@ -435,7 +436,7 @@
{
for( int i = 0; i < DEFAULT_TRACE_FILTERS.length; i++ )
{
- if( line.indexOf( DEFAULT_TRACE_FILTERS[i] ) > 0 )
+ if( line.indexOf( DEFAULT_TRACE_FILTERS[ i ] ) > 0 )
{
return true;
}
@@ -447,7 +448,7 @@
{
for( int i = 0; i < fromCmdLine.size(); i++ )
{
- runner.addFormatter( ( JUnitResultFormatter )fromCmdLine.elementAt( i ) );
+ runner.addFormatter( (JUnitResultFormatter)fromCmdLine.elementAt( i ) );
}
}
@@ -503,7 +504,7 @@
*/
public void addFailure( Test test, AssertionFailedError t )
{
- addFailure( test, ( Throwable )t );
+ addFailure( test, (Throwable)t );
}
public void addFormatter( JUnitResultFormatter f )
@@ -518,7 +519,9 @@
*
* @param test Description of Parameter
*/
- public void endTest( Test test ) { }
+ public void endTest( Test test )
+ {
+ }
public void run()
{
@@ -526,7 +529,7 @@
res.addListener( this );
for( int i = 0; i < formatters.size(); i++ )
{
- res.addListener( ( TestListener )formatters.elementAt( i ) );
+ res.addListener( (TestListener)formatters.elementAt( i ) );
}
long start = System.currentTimeMillis();
@@ -536,8 +539,8 @@
{// had an exception in the constructor
for( int i = 0; i < formatters.size(); i++ )
{
- ( ( TestListener )formatters.elementAt( i ) ).addError( null,
- exception );
+ ( (TestListener)formatters.elementAt( i ) ).addError( null,
+ exception );
}
junitTest.setCounts( 1, 0, 1 );
junitTest.setRunTime( 0 );
@@ -562,10 +565,10 @@
systemOut.close();
systemOut = null;
sendOutAndErr( new String( outStrm.toByteArray() ),
- new String( errStrm.toByteArray() ) );
+ new String( errStrm.toByteArray() ) );
junitTest.setCounts( res.runCount(), res.failureCount(),
- res.errorCount() );
+ res.errorCount() );
junitTest.setRunTime( System.currentTimeMillis() - start );
}
}
@@ -588,7 +591,9 @@
*
* @param t Description of Parameter
*/
- public void startTest( Test t ) { }
+ public void startTest( Test t )
+ {
+ }
protected void handleErrorOutput( String line )
{
@@ -610,7 +615,7 @@
{
for( int i = 0; i < formatters.size(); i++ )
{
- ( ( JUnitResultFormatter )formatters.elementAt( i ) ).endTestSuite( junitTest );
+ ( (JUnitResultFormatter)formatters.elementAt( i ) ).endTestSuite( junitTest );
}
}
@@ -618,7 +623,7 @@
{
for( int i = 0; i < formatters.size(); i++ )
{
- ( ( JUnitResultFormatter )formatters.elementAt( i ) ).startTestSuite( junitTest );
+ ( (JUnitResultFormatter)formatters.elementAt( i ) ).startTestSuite( junitTest );
}
}
@@ -627,7 +632,7 @@
for( int i = 0; i < formatters.size(); i++ )
{
JUnitResultFormatter formatter =
- ( ( JUnitResultFormatter )formatters.elementAt( i ) );
+ ( (JUnitResultFormatter)formatters.elementAt( i ) );
formatter.setSystemOutput( out );
formatter.setSystemError( err );
1.2 +10 -6 jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitVersionHelper.java
Index: JUnitVersionHelper.java
===================================================================
RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitVersionHelper.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- JUnitVersionHelper.java 2001/12/15 12:06:28 1.1
+++ JUnitVersionHelper.java 2001/12/16 00:36:00 1.2
@@ -6,6 +6,7 @@
* the LICENSE file.
*/
package org.apache.tools.ant.taskdefs.optional.junit;
+
import java.lang.reflect.Method;
import junit.framework.Test;
import junit.framework.TestCase;
@@ -15,27 +16,29 @@
* releases.
*
* @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
public class JUnitVersionHelper
{
private static Method testCaseName = null;
+
static
{
try
{
- testCaseName = TestCase.class.getMethod( "getName", new Class[0] );
+ testCaseName = TestCase.class.getMethod( "getName", new Class[ 0 ] );
}
catch( NoSuchMethodException e )
{
// pre JUnit 3.7
try
{
- testCaseName = TestCase.class.getMethod( "name", new Class[0] );
+ testCaseName = TestCase.class.getMethod( "name", new Class[ 0 ] );
}
catch( NoSuchMethodException e2 )
- {}
+ {
+ }
}
}
@@ -54,10 +57,11 @@
{
try
{
- return ( String )testCaseName.invoke( t, new Object[0] );
+ return (String)testCaseName.invoke( t, new Object[ 0 ] );
}
catch( Throwable e )
- {}
+ {
+ }
}
return "unknown";
}
1.2 +16 -12 jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/PlainJUnitResultFormatter.java
Index: PlainJUnitResultFormatter.java
===================================================================
RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/PlainJUnitResultFormatter.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PlainJUnitResultFormatter.java 2001/12/15 12:06:28 1.1
+++ PlainJUnitResultFormatter.java 2001/12/16 00:36:00 1.2
@@ -6,6 +6,7 @@
* the LICENSE file.
*/
package org.apache.tools.ant.taskdefs.optional.junit;
+
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
@@ -15,7 +16,7 @@
import junit.framework.AssertionFailedError;
import junit.framework.Test;
import junit.framework.TestCase;
-import org.apache.tools.ant.BuildException;
+import org.apache.myrmidon.api.TaskException;
/**
* Prints plain text output of the test to a specified Writer.
@@ -111,7 +112,7 @@
*/
public void addFailure( Test test, AssertionFailedError t )
{
- addFailure( test, ( Throwable )t );
+ addFailure( test, (Throwable)t );
}
/**
@@ -126,16 +127,16 @@
synchronized( wri )
{
wri.print( "Testcase: "
- + JUnitVersionHelper.getTestCaseName( test ) );
+ + JUnitVersionHelper.getTestCaseName( test ) );
if( Boolean.TRUE.equals( failed.get( test ) ) )
{
return;
}
- Long l = ( Long )testStarts.get( test );
+ Long l = (Long)testStarts.get( test );
wri.println( " took "
- + nf.format( ( System.currentTimeMillis() - l.longValue() )
- / 1000.0 )
- + " sec" );
+ + nf.format( ( System.currentTimeMillis() - l.longValue() )
+ / 1000.0 )
+ + " sec" );
}
}
@@ -143,10 +144,10 @@
* The whole testsuite ended.
*
* @param suite Description of Parameter
- * @exception BuildException Description of Exception
+ * @exception TaskException Description of Exception
*/
public void endTestSuite( JUnitTest suite )
- throws BuildException
+ throws TaskException
{
String newLine = System.getProperty( "line.separator" );
StringBuffer sb = new StringBuffer( "Testsuite: " );
@@ -195,7 +196,7 @@
}
catch( IOException ioex )
{
- throw new BuildException( "Unable to write output", ioex );
+ throw new TaskException( "Unable to write output", ioex );
}
finally
{
@@ -206,7 +207,8 @@
out.close();
}
catch( IOException e )
- {}
+ {
+ }
}
}
}
@@ -230,7 +232,9 @@
*
* @param suite Description of Parameter
*/
- public void startTestSuite( JUnitTest suite ) { }
+ public void startTestSuite( JUnitTest suite )
+ {
+ }
private void formatError( String type, Test test, Throwable t )
{
1.2 +26 -12 jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/SummaryJUnitResultFormatter.java
Index: SummaryJUnitResultFormatter.java
===================================================================
RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/SummaryJUnitResultFormatter.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SummaryJUnitResultFormatter.java 2001/12/15 12:06:28 1.1
+++ SummaryJUnitResultFormatter.java 2001/12/16 00:36:00 1.2
@@ -6,12 +6,13 @@
* the LICENSE file.
*/
package org.apache.tools.ant.taskdefs.optional.junit;
+
import java.io.IOException;
import java.io.OutputStream;
import java.text.NumberFormat;
import junit.framework.AssertionFailedError;
import junit.framework.Test;
-import org.apache.tools.ant.BuildException;
+import org.apache.myrmidon.api.TaskException;
/**
* Prints short summary output of the test to Ant's logging system.
@@ -38,7 +39,9 @@
/**
* Empty
*/
- public SummaryJUnitResultFormatter() { }
+ public SummaryJUnitResultFormatter()
+ {
+ }
public void setOutput( OutputStream out )
{
@@ -71,7 +74,9 @@
* @param test The feature to be added to the Error attribute
* @param t The feature to be added to the Error attribute
*/
- public void addError( Test test, Throwable t ) { }
+ public void addError( Test test, Throwable t )
+ {
+ }
/**
* Empty
@@ -79,7 +84,9 @@
* @param test The feature to be added to the Failure attribute
* @param t The feature to be added to the Failure attribute
*/
- public void addFailure( Test test, Throwable t ) { }
+ public void addFailure( Test test, Throwable t )
+ {
+ }
/**
* Interface TestListener for JUnit > 3.4. <p>
@@ -91,7 +98,7 @@
*/
public void addFailure( Test test, AssertionFailedError t )
{
- addFailure( test, ( Throwable )t );
+ addFailure( test, (Throwable)t );
}
/**
@@ -99,16 +106,18 @@
*
* @param test Description of Parameter
*/
- public void endTest( Test test ) { }
+ public void endTest( Test test )
+ {
+ }
/**
* The whole testsuite ended.
*
* @param suite Description of Parameter
- * @exception BuildException Description of Exception
+ * @exception TaskException Description of Exception
*/
public void endTestSuite( JUnitTest suite )
- throws BuildException
+ throws TaskException
{
String newLine = System.getProperty( "line.separator" );
StringBuffer sb = new StringBuffer( "Tests run: " );
@@ -144,7 +153,7 @@
}
catch( IOException ioex )
{
- throw new BuildException( "Unable to write summary output", ioex );
+ throw new TaskException( "Unable to write summary output", ioex );
}
finally
{
@@ -155,7 +164,8 @@
out.close();
}
catch( IOException e )
- {}
+ {
+ }
}
}
}
@@ -165,12 +175,16 @@
*
* @param t Description of Parameter
*/
- public void startTest( Test t ) { }
+ public void startTest( Test t )
+ {
+ }
/**
* Empty
*
* @param suite Description of Parameter
*/
- public void startTestSuite( JUnitTest suite ) { }
+ public void startTestSuite( JUnitTest suite )
+ {
+ }
}
1.2 +18 -16 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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XMLJUnitResultFormatter.java 2001/12/15 12:06:29 1.1
+++ XMLJUnitResultFormatter.java 2001/12/16 00:36:00 1.2
@@ -6,11 +6,10 @@
* the LICENSE file.
*/
package org.apache.tools.ant.taskdefs.optional.junit;
+
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
-import java.io.StringWriter;
import java.io.Writer;
import java.util.Enumeration;
import java.util.Hashtable;
@@ -20,7 +19,7 @@
import junit.framework.AssertionFailedError;
import junit.framework.Test;
import junit.framework.TestCase;
-import org.apache.tools.ant.BuildException;
+import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.util.DOMElementWriter;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -58,7 +57,9 @@
*/
private Element rootElement;
- public XMLJUnitResultFormatter() { }
+ public XMLJUnitResultFormatter()
+ {
+ }
private static DocumentBuilder getDocumentBuilder()
{
@@ -123,7 +124,7 @@
*/
public void addFailure( Test test, AssertionFailedError t )
{
- addFailure( test, ( Throwable )t );
+ addFailure( test, (Throwable)t );
}
/**
@@ -135,21 +136,21 @@
*/
public void endTest( Test test )
{
- Element currentTest = ( Element )testElements.get( test );
- Long l = ( Long )testStarts.get( test );
+ Element currentTest = (Element)testElements.get( test );
+ Long l = (Long)testStarts.get( test );
currentTest.setAttribute( ATTR_TIME,
- "" + ( ( System.currentTimeMillis() - l.longValue() )
- / 1000.0 ) );
+ "" + ( ( System.currentTimeMillis() - l.longValue() )
+ / 1000.0 ) );
}
/**
* The whole testsuite ended.
*
* @param suite Description of Parameter
- * @exception BuildException Description of Exception
+ * @exception TaskException Description of Exception
*/
public void endTestSuite( JUnitTest suite )
- throws BuildException
+ throws TaskException
{
rootElement.setAttribute( ATTR_TESTS, "" + suite.runCount() );
rootElement.setAttribute( ATTR_FAILURES, "" + suite.failureCount() );
@@ -167,7 +168,7 @@
}
catch( IOException exc )
{
- throw new BuildException( "Unable to write log file", exc );
+ throw new TaskException( "Unable to write log file", exc );
}
finally
{
@@ -180,7 +181,8 @@
wri.close();
}
catch( IOException e )
- {}
+ {
+ }
}
}
}
@@ -200,7 +202,7 @@
Element currentTest = doc.createElement( TESTCASE );
currentTest.setAttribute( ATTR_NAME,
- JUnitVersionHelper.getTestCaseName( t ) );
+ JUnitVersionHelper.getTestCaseName( t ) );
rootElement.appendChild( currentTest );
testElements.put( t, currentTest );
}
@@ -225,7 +227,7 @@
Enumeration e = props.propertyNames();
while( e.hasMoreElements() )
{
- String name = ( String )e.nextElement();
+ String name = (String)e.nextElement();
Element propElement = doc.createElement( PROPERTY );
propElement.setAttribute( ATTR_NAME, name );
propElement.setAttribute( ATTR_VALUE, props.getProperty( name ) );
@@ -245,7 +247,7 @@
Element currentTest = null;
if( test != null )
{
- currentTest = ( Element )testElements.get( test );
+ currentTest = (Element)testElements.get( test );
}
else
{
1.3 +16 -18 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.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- XMLResultAggregator.java 2001/12/15 14:55:58 1.2
+++ XMLResultAggregator.java 2001/12/16 00:36:00 1.3
@@ -6,30 +6,29 @@
* the LICENSE file.
*/
package org.apache.tools.ant.taskdefs.optional.junit;
+
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
-import java.io.StringWriter;
import java.util.Enumeration;
import java.util.Vector;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
-import org.apache.tools.ant.BuildException;
+import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.util.DOMElementWriter;
-import org.apache.tools.ant.util.StringUtils;
import org.apache.tools.ant.util.FileUtils;
+import org.apache.tools.ant.util.StringUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
-
/**
* <p>
*
@@ -132,7 +131,6 @@
filesets.addElement( fs );
}
-
public AggregateTransformer createReport()
{
AggregateTransformer transformer = new AggregateTransformer( this );
@@ -144,11 +142,11 @@
* Aggregate all testsuites into a single document and write it to the
* specified directory and file.
*
- * @throws BuildException thrown if there is a serious error while writing
+ * @throws TaskException thrown if there is a serious error while writing
* the document.
*/
public void execute()
- throws BuildException
+ throws TaskException
{
Element rootElement = createDocument();
File destFile = getDestinationFile();
@@ -159,14 +157,14 @@
}
catch( IOException e )
{
- throw new BuildException( "Unable to write test aggregate to '" + destFile + "'", e );
+ throw new TaskException( "Unable to write test aggregate to '" + destFile + "'", e );
}
// apply transformation
Enumeration enum = transformers.elements();
while( enum.hasMoreElements() )
{
AggregateTransformer transformer =
- ( AggregateTransformer )enum.nextElement();
+ (AggregateTransformer)enum.nextElement();
transformer.setXmlDocument( rootElement.getOwnerDocument() );
transformer.transform();
}
@@ -202,13 +200,13 @@
final int size = filesets.size();
for( int i = 0; i < size; i++ )
{
- FileSet fs = ( FileSet )filesets.elementAt( i );
+ FileSet fs = (FileSet)filesets.elementAt( i );
DirectoryScanner ds = fs.getDirectoryScanner( project );
ds.scan();
String[] f = ds.getIncludedFiles();
for( int j = 0; j < f.length; j++ )
{
- String pathname = f[j];
+ String pathname = f[ j ];
if( pathname.endsWith( ".xml" ) )
{
File file = new File( ds.getBasedir(), pathname );
@@ -219,7 +217,7 @@
}
}
- File[] files = new File[v.size()];
+ File[] files = new File[ v.size() ];
v.copyInto( files );
return files;
}
@@ -247,7 +245,7 @@
// a missing . might imply no package at all. Don't get fooled.
String pkgName = ( pos == -1 ) ? "" : fullclassname.substring( 0, pos );
String classname = ( pos == -1 ) ? fullclassname : fullclassname.substring( pos + 1 );
- Element copy = ( Element )DOMUtil.importNode( root, testsuite );
+ Element copy = (Element)DOMUtil.importNode( root, testsuite );
// modify the name attribute and set the package
copy.setAttribute( ATTR_NAME, classname );
@@ -276,11 +274,11 @@
{
try
{
- log( "Parsing file: '" + files[i] + "'", Project.MSG_VERBOSE );
+ log( "Parsing file: '" + files[ i ] + "'", Project.MSG_VERBOSE );
//XXX there seems to be a bug in xerces 1.3.0 that doesn't like file object
// will investigate later. It does not use the given directory but
// the vm dir instead ? Works fine with crimson.
- Document testsuiteDoc = builder.parse( "file:///" + files[i].getAbsolutePath() );
+ Document testsuiteDoc = builder.parse( "file:///" + files[ i ].getAbsolutePath() );
Element elem = testsuiteDoc.getDocumentElement();
// make sure that this is REALLY a testsuite.
if( TESTSUITE.equals( elem.getNodeName() ) )
@@ -290,19 +288,19 @@
else
{
// issue a warning.
- log( "the file " + files[i] + " is not a valid testsuite XML document", Project.MSG_WARN );
+ log( "the file " + files[ i ] + " is not a valid testsuite XML document", Project.MSG_WARN );
}
}
catch( SAXException e )
{
// a testcase might have failed and write a zero-length document,
// It has already failed, but hey.... mm. just put a warning
- log( "The file " + files[i] + " is not a valid XML document. It is possibly corrupted.", Project.MSG_WARN );
+ log( "The file " + files[ i ] + " is not a valid XML document. It is possibly corrupted.", Project.MSG_WARN );
log( StringUtils.getStackTrace( e ), Project.MSG_DEBUG );
}
catch( IOException e )
{
- log( "Error while accessing file " + files[i] + ": " + e.getMessage(), Project.MSG_ERR );
+ log( "Error while accessing file " + files[ i ] + ": " + e.getMessage(), Project.MSG_ERR );
}
}
return rootElement;
1.2 +1 -0 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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Xalan1Executor.java 2001/12/15 12:06:29 1.1
+++ Xalan1Executor.java 2001/12/16 00:36:00 1.2
@@ -6,6 +6,7 @@
* the LICENSE file.
*/
package org.apache.tools.ant.taskdefs.optional.junit;
+
import java.io.OutputStream;
import org.apache.xalan.xslt.XSLTInputSource;
import org.apache.xalan.xslt.XSLTProcessor;
1.2 +1 -0 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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Xalan2Executor.java 2001/12/15 12:06:29 1.1
+++ Xalan2Executor.java 2001/12/16 00:36:00 1.2
@@ -6,6 +6,7 @@
* the LICENSE file.
*/
package org.apache.tools.ant.taskdefs.optional.junit;
+
import java.io.OutputStream;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
1.2 +6 -5 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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XalanExecutor.java 2001/12/15 12:06:29 1.1
+++ XalanExecutor.java 2001/12/16 00:36:00 1.2
@@ -6,13 +6,14 @@
* the LICENSE file.
*/
package org.apache.tools.ant.taskdefs.optional.junit;
+
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.reflect.Field;
-import org.apache.tools.ant.BuildException;
+import org.apache.myrmidon.api.TaskException;
/**
* Command class that encapsulate specific behavior for each Xalan version. The
@@ -34,11 +35,11 @@
*
* @param caller object containing the transformation information.
* @return Description of the Returned Value
- * @throws BuildException thrown if it could not find a valid xalan
+ * @throws TaskException thrown if it could not find a valid xalan
* executor.
*/
static XalanExecutor newInstance( AggregateTransformer caller )
- throws BuildException
+ throws TaskException
{
Class procVersion = null;
XalanExecutor executor = null;
@@ -52,12 +53,12 @@
try
{
procVersion = Class.forName( "org.apache.xalan.xslt.XSLProcessorVersion" );
- executor = ( XalanExecutor )Class.forName(
+ executor = (XalanExecutor)Class.forName(
"org.apache.tools.ant.taskdefs.optional.junit.Xalan1Executor" ).newInstance();
}
catch( Exception xalan1missing )
{
- throw new BuildException( "Could not find xalan2 nor xalan1 in the classpath. Check http://xml.apache.org/xalan-j" );
+ throw new TaskException( "Could not find xalan2 nor xalan1 in the classpath. Check http://xml.apache.org/xalan-j" );
}
}
String version = getXalanVersion( procVersion );
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>