diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java
index 92e902e3a..ef391ae91 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java
@@ -79,6 +79,7 @@ public class AggregateTransformer {
}
}
+ // CheckStyle:VisibilityModifier OFF - bc
/** Task */
protected Task task;
@@ -123,6 +124,7 @@ public class AggregateTransformer {
privateDBFactory = DocumentBuilderFactory.newInstance();
dbfactory = privateDBFactory;
}
+ // CheckStyle:VisibilityModifier ON
/**
* constructor creating the transformer from the junitreport task.
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/BaseTest.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/BaseTest.java
index 55ef13ea6..13c6c330e 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/BaseTest.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/BaseTest.java
@@ -26,6 +26,7 @@ import java.util.Vector;
*
*/
public abstract class BaseTest {
+ // CheckStyle:VisibilityModifier OFF - bc
protected boolean haltOnError = false;
protected boolean haltOnFail = false;
protected boolean filtertrace = true;
@@ -38,59 +39,110 @@ public abstract class BaseTest {
protected String failureProperty;
protected String errorProperty;
+ // CheckStyle:VisibilityModifier ON
+ /**
+ * Set the filtertrace attribute.
+ * @param value a boolean
value.
+ */
public void setFiltertrace(boolean value) {
filtertrace = value;
}
+ /**
+ * Get the filtertrace attribute.
+ * @return the attribute.
+ */
public boolean getFiltertrace() {
return filtertrace;
}
+ /**
+ * Set the fork attribute.
+ * @param value a boolean
value.
+ */
public void setFork(boolean value) {
fork = value;
}
+ /**
+ * Get the fork attribute.
+ * @return the attribute.
+ */
public boolean getFork() {
return fork;
}
+ /**
+ * Set the haltonerror attribute.
+ * @param value a boolean
value.
+ */
public void setHaltonerror(boolean value) {
haltOnError = value;
}
+ /**
+ * Set the haltonfailure attribute.
+ * @param value a boolean
value.
+ */
public void setHaltonfailure(boolean value) {
haltOnFail = value;
}
+ /**
+ * Get the haltonerror attribute.
+ * @return the attribute.
+ */
public boolean getHaltonerror() {
return haltOnError;
}
+ /**
+ * Get the haltonfailure attribute.
+ * @return the attribute.
+ */
public boolean getHaltonfailure() {
return haltOnFail;
}
+ /**
+ * Set the if attribute.
+ * If this property is present in project,
+ * the test will be run.
+ * @param propertyName the name of the property to look for.
+ */
public void setIf(String propertyName) {
ifProperty = propertyName;
}
+ /**
+ * Set the unless attribute.
+ * If this property is present in project,
+ * the test will *not* be run.
+ * @param propertyName the name of the property to look for.
+ */
public void setUnless(String propertyName) {
unlessProperty = propertyName;
}
+ /**
+ * Allow a formatter nested element.
+ * @param elem a formatter nested element.
+ */
public void addFormatter(FormatterElement elem) {
formatters.addElement(elem);
}
/**
* Sets the destination directory.
+ * @param destDir the destination directory.
*/
public void setTodir(File destDir) {
this.destDir = destDir;
}
/**
+ * Get the destination directory.
* @return the destination directory as an absolute path if it exists
* otherwise return null
*/
@@ -101,18 +153,36 @@ public abstract class BaseTest {
return null;
}
- public java.lang.String getFailureProperty() {
+ /**
+ * Get the failure property name.
+ * @return the name of the property to set on failure.
+ */
+ public String getFailureProperty() {
return failureProperty;
}
+ /**
+ * Set the name of the failure property.
+ * @param failureProperty the name of the property to set if
+ * the test fails.
+ */
public void setFailureProperty(String failureProperty) {
this.failureProperty = failureProperty;
}
- public java.lang.String getErrorProperty() {
+ /**
+ * Get the failure property name.
+ * @return the name of the property to set on failure.
+ */
+ public String getErrorProperty() {
return errorProperty;
}
+ /**
+ * Set the name of the error property.
+ * @param errorProperty the name of the property to set if
+ * the test has an error.
+ */
public void setErrorProperty(String errorProperty) {
this.errorProperty = errorProperty;
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/BatchTest.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/BatchTest.java
index 1cab6bd1b..9da007171 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/BatchTest.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/BatchTest.java
@@ -97,7 +97,7 @@ public final class BatchTest extends BaseTest {
* @return an enumeration of all elements of this batchtest that are
* a JUnitTest instance.
*/
- public final Enumeration elements() {
+ public Enumeration elements() {
JUnitTest[] tests = createAllJUnitTest();
return Enumerations.fromArray(tests);
}
@@ -108,7 +108,7 @@ public final class BatchTest extends BaseTest {
* @param v the vector to which should be added all individual tests of this
* batch test.
*/
- final void addTestsTo(Vector v) {
+ void addTestsTo(Vector v) {
JUnitTest[] tests = createAllJUnitTest();
v.ensureCapacity(v.size() + tests.length);
for (int i = 0; i < tests.length; i++) {
@@ -168,7 +168,7 @@ public final class BatchTest extends BaseTest {
* @param filename the filename to "convert" to a classname.
* @return the classname matching the filename.
*/
- public static final String javaToClass(String filename) {
+ public static String javaToClass(String filename) {
return filename.replace(File.separatorChar, '.').replace('/', '.')
.replace('\\', '.');
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/BriefJUnitResultFormatter.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/BriefJUnitResultFormatter.java
index 0538b91e7..c70aedc4c 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/BriefJUnitResultFormatter.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/BriefJUnitResultFormatter.java
@@ -93,6 +93,7 @@ public class BriefJUnitResultFormatter implements JUnitResultFormatter {
/**
* @see JUnitResultFormatter#setSystemOutput(String)
*/
+ /** {@inheritDoc}. */
public void setSystemOutput(String out) {
systemOutput = out;
}
@@ -100,6 +101,7 @@ public class BriefJUnitResultFormatter implements JUnitResultFormatter {
/**
* @see JUnitResultFormatter#setSystemError(String)
*/
+ /** {@inheritDoc}. */
public void setSystemError(String err) {
systemError = err;
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/DOMUtil.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/DOMUtil.java
index 762432027..9be3f8499 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/DOMUtil.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/DOMUtil.java
@@ -60,6 +60,7 @@ public final class DOMUtil {
* @param filter the filter that children should match.
* @param recurse true if you want the list to be made recursively
* otherwise false.
+ * @return the node list that matches the filter.
*/
public static NodeList listChildNodes(Node parent, NodeFilter filter, boolean recurse) {
NodeListImpl matches = new NodeListImpl();
@@ -85,9 +86,18 @@ public final class DOMUtil {
/** custom implementation of a nodelist */
public static class NodeListImpl extends Vector implements NodeList {
+ /**
+ * Get the number of nodes in the list.
+ * @return the length of the list.
+ */
public int getLength() {
return size();
}
+ /**
+ * Get a particular node.
+ * @param i the index of the node to get.
+ * @return the node if the index is in bounds, null otherwise.
+ */
public Node item(int i) {
try {
return (Node) elementAt(i);
@@ -205,6 +215,7 @@ public final class DOMUtil {
}
}
} catch (DOMException ignored) {
+ // Ignore
}
// bingo append it. (this should normally not be done here)
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/FormatterElement.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/FormatterElement.java
index 64d383414..d07fa732c 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/FormatterElement.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/FormatterElement.java
@@ -59,10 +59,13 @@ public class FormatterElement {
private String ifProperty;
private String unlessProperty;
+ /** xml formatter class */
public static final String XML_FORMATTER_CLASS_NAME =
"org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter";
+ /** brief formatter class */
public static final String BRIEF_FORMATTER_CLASS_NAME =
"org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter";
+ /** plain formatter class */
public static final String PLAIN_FORMATTER_CLASS_NAME =
"org.apache.tools.ant.taskdefs.optional.junit.PlainJUnitResultFormatter";
@@ -78,6 +81,7 @@ public class FormatterElement {
*
*
Sets classname
attribute - so you can't use that
* attribute if you use this one.
+ * @param type the enumerated value to use.
*/
public void setType(TypeAttribute type) {
if ("xml".equals(type.getValue())) {
@@ -95,6 +99,7 @@ public class FormatterElement {
*
Set name of class to be used as the formatter. * *
This class must implement JUnitResultFormatter
+ * @param classname the name of the formatter class.
*/
public void setClassname(String classname) {
this.classname = classname;
@@ -109,15 +114,24 @@ public class FormatterElement {
/**
* Get name of class to be used as the formatter.
+ * @return the name of the class.
*/
public String getClassname() {
return classname;
}
+ /**
+ * Set the extension to use for the report file.
+ * @param ext the extension to use.
+ */
public void setExtension(String ext) {
this.extension = ext;
}
+ /**
+ * Get the extension used for the report file.
+ * @return the extension.
+ */
public String getExtension() {
return extension;
}
@@ -135,6 +149,7 @@ public class FormatterElement {
*
Set output stream for formatter to use. * *
Defaults to standard out.
+ * @param out the output stream to use.
*/
public void setOutput(OutputStream out) {
this.out = out;
@@ -142,6 +157,8 @@ public class FormatterElement {
/**
* Set whether the formatter should log to file.
+ * @param useFile if true use a file, if false send
+ * to standard out.
*/
public void setUseFile(boolean useFile) {
this.useFile = useFile;
@@ -176,6 +193,8 @@ public class FormatterElement {
/**
* Ensures that the selector passes the conditions placed
* on it with if
and unless
properties.
+ * @param t the task the this formatter is used in.
+ * @return true if the formatter should be used.
*/
public boolean shouldUse(Task t) {
if (ifProperty != null && t.getProject().getProperty(ifProperty) == null) {
@@ -215,9 +234,13 @@ public class FormatterElement {
f = Class.forName(classname, true, loader);
}
} catch (ClassNotFoundException e) {
- throw new BuildException("Using loader " + loader + " on class " + classname + ": " + e, e);
+ throw new BuildException(
+ "Using loader " + loader + " on class " + classname
+ + ": " + e, e);
} catch (NoClassDefFoundError e) {
- throw new BuildException("Using loader " + loader + " on class " + classname + ": " + e, e);
+ throw new BuildException(
+ "Using loader " + loader + " on class " + classname
+ + ": " + e, e);
}
Object o = null;
@@ -233,7 +256,8 @@ public class FormatterElement {
throw new BuildException(classname
+ " is not a JUnitResultFormatter");
}
- JUnitTaskMirror.JUnitResultFormatterMirror r = (JUnitTaskMirror.JUnitResultFormatterMirror) o;
+ JUnitTaskMirror.JUnitResultFormatterMirror r =
+ (JUnitTaskMirror.JUnitResultFormatterMirror) o;
if (useFile && outFile != null) {
try {
out = new BufferedOutputStream(new FileOutputStream(outFile));
@@ -251,6 +275,7 @@ public class FormatterElement {
*
Use to enumerate options for type
attribute.
*/
public static class TypeAttribute extends EnumeratedAttribute {
+ /** {@inheritDoc}. */
public String[] getValues() {
return new String[] {"plain", "xml", "brief"};
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitResultFormatter.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitResultFormatter.java
index ba1a7470d..ebfd4559c 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitResultFormatter.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitResultFormatter.java
@@ -27,29 +27,37 @@ import org.apache.tools.ant.BuildException;
* testrun.
*
*/
-public interface JUnitResultFormatter extends TestListener, JUnitTaskMirror.JUnitResultFormatterMirror {
+public interface JUnitResultFormatter
+ extends TestListener, JUnitTaskMirror.JUnitResultFormatterMirror {
/**
* The whole testsuite started.
+ * @param suite the suite.
+ * @throws BuildException on error.
*/
void startTestSuite(JUnitTest suite) throws BuildException;
/**
* The whole testsuite ended.
+ * @param suite the suite.
+ * @throws BuildException on error.
*/
void endTestSuite(JUnitTest suite) throws BuildException;
/**
* Sets the stream the formatter is supposed to write its results to.
+ * @param out the output stream to use.
*/
void setOutput(OutputStream out);
/**
* This is what the test has written to System.out
+ * @param out the string to write.
*/
void setSystemOutput(String out);
/**
* This is what the test has written to System.err
+ * @param err the string to write.
*/
void setSystemError(String err);
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
index 1dec87d30..8ba565bf6 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
@@ -293,7 +293,7 @@ public class JUnitTask extends Task {
* haltonfailure, errorproperty, failureproperty and filtertrace
* can share a forked Java VM, so even if you set the value to
* "once", Ant may need to fork mutliple VMs.
Doesn't have any effect unless fork is true.
- * + * @param cloneVm aboolean
value.
* @since Ant 1.7
*/
public void setCloneVm(boolean cloneVm) {
@@ -822,6 +822,8 @@ public class JUnitTask extends Task {
/**
* Execute a list of tests in a single forked Java VM.
+ * @param tests the list of tests to execute.
+ * @throws BuildException on error.
*/
protected void execute(List tests) throws BuildException {
JUnitTest test = null;
@@ -1088,7 +1090,16 @@ public class JUnitTask extends Task {
}
/**
+ * Handle an input request by this task.
* @see Task#handleInput(byte[], int, int)
+ * This implementation delegates to a runner if it
+ * present.
+ * @param buffer the buffer into which data is to be read.
+ * @param offset the offset into the buffer at which data is stored.
+ * @param length the amount of data to read.
+ *
+ * @return the number of bytes read.
+ * @exception IOException if the data cannot be read.
*
* @since Ant 1.6
*/
@@ -1380,7 +1391,11 @@ public class JUnitTask extends Task {
*/
private void logTimeout(FormatterElement[] feArray, JUnitTest test, String testCase) {
- logVmExit(feArray, test, "Timeout occurred. Please note the time in the report does not reflect the time until the timeout.", testCase);
+ logVmExit(
+ feArray, test,
+ "Timeout occurred. Please note the time in the report does"
+ + " not reflect the time until the timeout.",
+ testCase);
}
/**
@@ -1391,7 +1406,11 @@ public class JUnitTask extends Task {
* @since Ant 1.7
*/
private void logVmCrash(FormatterElement[] feArray, JUnitTest test, String testCase) {
- logVmExit(feArray, test, "Forked Java VM exited abnormally. Please note the time in the report does not reflect the time until the VM exit.", testCase);
+ logVmExit(
+ feArray, test,
+ "Forked Java VM exited abnormally. Please note the time in the report"
+ + " does not reflect the time until the VM exit.",
+ testCase);
}
/**
@@ -1491,6 +1510,8 @@ public class JUnitTask extends Task {
}
/**
+ * Get the command line used to run the tests.
+ * @return the command line.
* @since Ant 1.6.2
*/
protected CommandlineJava getCommandline() {
@@ -1596,15 +1617,21 @@ public class JUnitTask extends Task {
*/
public static final String PER_BATCH = "perBatch";
+ /** No arg constructor. */
public ForkMode() {
super();
}
+ /**
+ * Constructor using a value.
+ * @param value the value to use - once, perTest or perBatch.
+ */
public ForkMode(String value) {
super();
setValue(value);
}
+ /** {@inheritDoc}. */
public String[] getValues() {
return new String[] {ONCE, PER_TEST, PER_BATCH};
}
@@ -1615,7 +1642,9 @@ public class JUnitTask extends Task {
* if the runIndividual argument is true. Returns a collection of
* lists of tests that share the same VM configuration and haven't
* been executed yet.
- *
+ * @param testList the list of tests to be executed or queued.
+ * @param runIndividual if true execute each test individually.
+ * @return a list of tasks to be executed.
* @since 1.6.2
*/
protected Collection executeOrQueue(Enumeration testList,
@@ -1645,7 +1674,10 @@ public class JUnitTask extends Task {
* Logs information about failed tests, potentially stops
* processing (by throwing a BuildException) if a failure/error
* occurred or sets a property.
- *
+ * @param exitValue the exitValue of the test.
+ * @param wasKilled if true, the test had been killed.
+ * @param test the test in question.
+ * @param name the name of the test.
* @since Ant 1.6.2
*/
protected void actOnTestResult(int exitValue, boolean wasKilled,
@@ -1660,7 +1692,9 @@ public class JUnitTask extends Task {
* Logs information about failed tests, potentially stops
* processing (by throwing a BuildException) if a failure/error
* occurred or sets a property.
- *
+ * @param result the result of the test.
+ * @param test the test in question.
+ * @param name the name of the test.
* @since Ant 1.7
*/
protected void actOnTestResult(TestResultHolder result, JUnitTest test,
@@ -1692,23 +1726,44 @@ public class JUnitTask extends Task {
}
}
+ /**
+ * A value class that contains thee result of a test.
+ */
protected class TestResultHolder {
+ // CheckStyle:VisibilityModifier OFF - bc
+ /** the exit code of the test. */
public int exitCode = JUnitTaskMirror.JUnitTestRunnerMirror.ERRORS;
+ /** true if the test timed out */
public boolean timedOut = false;
+ /** true if the test crashed */
public boolean crashed = false;
+ // CheckStyle:VisibilityModifier ON
}
/**
+ * A stream handler for handling the junit task.
* @since Ant 1.7
*/
protected static class JUnitLogOutputStream extends LogOutputStream {
private Task task; // local copy since LogOutputStream.task is private
+ /**
+ * Constructor.
+ * @param task the task being logged.
+ * @param level the log level used to log data written to this stream.
+ */
public JUnitLogOutputStream(Task task, int level) {
super(task, level);
this.task = task;
}
+ /**
+ * Logs a line.
+ * If the line starts with junit.framework.TestListener: set the level
+ * to MSG_VERBOSE.
+ * @param line the line to log.
+ * @param level the logging level to use.
+ */
protected void processLine(String line, int level) {
if (line.startsWith(TESTLISTENER_PREFIX)) {
task.log(line, Project.MSG_VERBOSE);
@@ -1719,9 +1774,16 @@ public class JUnitTask extends Task {
}
/**
+ * A log stream handler for junit.
* @since Ant 1.7
*/
protected static class JUnitLogStreamHandler extends PumpStreamHandler {
+ /**
+ * Constructor.
+ * @param task the task to log.
+ * @param outlevel the level to use for standard output.
+ * @param errlevel the level to use for error output.
+ */
public JUnitLogStreamHandler(Task task, int outlevel, int errlevel) {
super(new JUnitLogOutputStream(task, outlevel),
new LogOutputStream(task, errlevel));
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskMirror.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskMirror.java
index 18e849e84..a830cff49 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskMirror.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskMirror.java
@@ -40,27 +40,61 @@ import org.apache.tools.ant.types.Permissions;
*/
public interface JUnitTaskMirror {
+ /**
+ * Add the formatter to be called when the jvm exits before
+ * the test suite finishs.
+ * @param test the test.
+ * @param formatter the fomatter to use.
+ * @param out the output stream to use.
+ * @param message the message to write out.
+ * @param testCase the name of the test.
+ */
void addVmExit(JUnitTest test, JUnitResultFormatterMirror formatter,
OutputStream out, String message, String testCase);
+ /**
+ * Create a new test runner for a test.
+ * @param test the test to run.
+ * @param haltOnError if true halt the tests if an error occurs.
+ * @param filterTrace if true filter the stack traces.
+ * @param haltOnFailure if true halt the test if a failure occurs.
+ * @param showOutput if true show output.
+ * @param logTestListenerEvents if true log test listener events.
+ * @param classLoader the classloader to use to create the runner.
+ * @return the test runner.
+ */
JUnitTestRunnerMirror newJUnitTestRunner(JUnitTest test, boolean haltOnError,
boolean filterTrace, boolean haltOnFailure, boolean showOutput,
boolean logTestListenerEvents, AntClassLoader classLoader);
+ /**
+ * Create a summary result formatter.
+ * @return the created formatter.
+ */
SummaryJUnitResultFormatterMirror newSummaryJUnitResultFormatter();
- public interface JUnitResultFormatterMirror {
+ /** The interface that JUnitResultFormatter extends. */
+ public interface JUnitResultFormatterMirror {
+ /**
+ * Set the output stream.
+ * @param outputStream the stream to use.
+ */
void setOutput(OutputStream outputStream);
-
}
- public interface SummaryJUnitResultFormatterMirror extends JUnitResultFormatterMirror {
+ /** The interface that SummaryJUnitResultFormatter extends. */
+ public interface SummaryJUnitResultFormatterMirror
+ extends JUnitResultFormatterMirror {
+ /**
+ * Set where standard out and standard error should be included.
+ * @param value if true include the outputs in the summary.
+ */
void setWithOutAndErr(boolean value);
-
}
+ /** Interface that test runners implement. */
public interface JUnitTestRunnerMirror {
/**
@@ -87,12 +121,26 @@ public interface JUnitTaskMirror {
*/
int ERRORS = 2;
+ /**
+ * Permissions for the test run.
+ * @param perm the permissions to use.
+ */
void setPermissions(Permissions perm);
+ /** Run the test. */
void run();
+ /**
+ * Add a formatter to the test.
+ * @param formatter the formatter to use.
+ */
void addFormatter(JUnitResultFormatterMirror formatter);
+ /**
+ * Returns what System.exit() would return in the standalone version.
+ *
+ * @return 2 if errors occurred, 1 if tests failed else 0.
+ */
int getRetCode();
void handleErrorFlush(String output);
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java
index b16117144..c77c89cd1 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java
@@ -543,7 +543,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR
/**
* Permissions for the test run.
* @since Ant 1.6
- * @param permissions
+ * @param permissions the permissions to use.
*/
public void setPermissions(Permissions permissions) {
perm = permissions;
@@ -689,7 +689,8 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR
} else if (args[i].startsWith(Constants.SHOWOUTPUT)) {
showOut = Project.toBoolean(args[i].substring(Constants.SHOWOUTPUT.length()));
} else if (args[i].startsWith(Constants.LOGTESTLISTENEREVENTS)) {
- logTestListenerEvents = Project.toBoolean(args[i].substring(Constants.LOGTESTLISTENEREVENTS.length()));
+ logTestListenerEvents = Project.toBoolean(
+ args[i].substring(Constants.LOGTESTLISTENEREVENTS.length()));
} else if (args[i].startsWith(Constants.OUTPUT_TO_FORMATTERS)) {
outputToFormat = Project.toBoolean(
args[i].substring(Constants.OUTPUT_TO_FORMATTERS.length()));
@@ -828,6 +829,8 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR
/**
* Returns a filtered stack trace.
* This is ripped out of junit.runner.BaseTestRunner.
+ * @param t the exception to filter.
+ * @return the filtered stack trace.
*/
public static String getFilteredTrace(Throwable t) {
String trace = StringUtils.getStackTrace(t);
@@ -836,6 +839,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR
/**
* Filters stack frames from internal JUnit and Ant classes
+ * @param stack the stack trace to filter.
*/
public static String filterStack(String stack) {
if (!filtertrace) {
@@ -936,7 +940,8 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR
return new TestListener() {
public void addError(Test test, Throwable t) {
if (junit4 && t instanceof AssertionFailedError) {
- // JUnit 4 does not distinguish between errors and failures even in the JUnit 3 adapter.
+ // JUnit 4 does not distinguish between errors and failures
+ // even in the JUnit 3 adapter.
// So we need to help it a bit to retain compatibility for JUnit 3 tests.
testListener.addFailure(test, (AssertionFailedError) t);
} else if (junit4 && t.getClass().getName().equals("java.lang.AssertionError")) {
@@ -949,7 +954,8 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR
AssertionFailedError failure = msg != null
? new AssertionFailedError(msg) : new AssertionFailedError();
// To compile on pre-JDK 4 (even though this should always succeed):
- Method initCause = Throwable.class.getMethod("initCause", new Class[] {Throwable.class});
+ Method initCause = Throwable.class.getMethod(
+ "initCause", new Class[] {Throwable.class});
initCause.invoke(failure, new Object[] {t});
testListener.addFailure(test, failure);
} catch (Exception e) {
@@ -996,7 +1002,8 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR
e = res.errors();
while (e.hasMoreElements()) {
Throwable t = ((TestFailure) e.nextElement()).thrownException();
- if (t instanceof AssertionFailedError || t.getClass().getName().equals("java.lang.AssertionError")) {
+ if (t instanceof AssertionFailedError
+ || t.getClass().getName().equals("java.lang.AssertionError")) {
failures++;
} else {
errors++;
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitVersionHelper.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitVersionHelper.java
index 2f558a56f..6f067717b 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitVersionHelper.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitVersionHelper.java
@@ -54,6 +54,8 @@ public class JUnitVersionHelper {
*
* Since Ant 1.7 also checks for JUnit4TestCaseFacade explicitly. * This is used by junit.framework.JUnit4TestAdapter.
+ * @param t the test. + * @return the name of the test. */ public static String getTestCaseName(Test t) { if (t != null && t.getClass().getName().equals("junit.framework.JUnit4TestCaseFacade")) { diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/PlainJUnitResultFormatter.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/PlainJUnitResultFormatter.java index 7280f06f0..acaaa586d 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/PlainJUnitResultFormatter.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/PlainJUnitResultFormatter.java @@ -68,19 +68,23 @@ public class PlainJUnitResultFormatter implements JUnitResultFormatter { private String systemOutput = null; private String systemError = null; + /** No arg constructor */ public PlainJUnitResultFormatter() { inner = new StringWriter(); wri = new PrintWriter(inner); } + /** {@inheritDoc}. */ public void setOutput(OutputStream out) { this.out = out; } + /** {@inheritDoc}. */ public void setSystemOutput(String out) { systemOutput = out; } + /** {@inheritDoc}. */ public void setSystemError(String err) { systemError = err; } @@ -161,6 +165,7 @@ public class PlainJUnitResultFormatter implements JUnitResultFormatter { * Interface TestListener. * *A new Test is started. + * @param t the test. */ public void startTest(Test t) { testStarts.put(t, new Long(System.currentTimeMillis())); @@ -171,6 +176,7 @@ public class PlainJUnitResultFormatter implements JUnitResultFormatter { * Interface TestListener. * *
A Test is finished. + * @param t the test. */ public void endTest(Test test) { if (Boolean.TRUE.equals(failed.get(test))) { @@ -195,6 +201,8 @@ public class PlainJUnitResultFormatter implements JUnitResultFormatter { * Interface TestListener for JUnit <= 3.4. * *
A Test failed. + * @param test the test. + * @param t the exception. */ public void addFailure(Test test, Throwable t) { formatError("\tFAILED", test, t); @@ -204,6 +212,8 @@ public class PlainJUnitResultFormatter implements JUnitResultFormatter { * Interface TestListener for JUnit > 3.4. * *
A Test failed. + * @param test the test. + * @param t the assertion that failed. */ public void addFailure(Test test, AssertionFailedError t) { addFailure(test, (Throwable) t); @@ -213,6 +223,8 @@ public class PlainJUnitResultFormatter implements JUnitResultFormatter { * Interface TestListener. * *
An error occurred while running the test. + * @param test the test. + * @param t the exception. */ public void addError(Test test, Throwable t) { formatError("\tCaused an ERROR", test, t); diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/SummaryJUnitResultFormatter.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/SummaryJUnitResultFormatter.java index 1bc61c510..094630940 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/SummaryJUnitResultFormatter.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/SummaryJUnitResultFormatter.java @@ -30,7 +30,9 @@ import org.apache.tools.ant.BuildException; * */ -public class SummaryJUnitResultFormatter implements JUnitResultFormatter, JUnitTaskMirror.SummaryJUnitResultFormatterMirror { +public class SummaryJUnitResultFormatter + implements JUnitResultFormatter + ,JUnitTaskMirror.SummaryJUnitResultFormatterMirror { /** * Formatter for timings. diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregator.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregator.java index 051512f7c..55674ccd8 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregator.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregator.java @@ -57,6 +57,7 @@ import org.xml.sax.SAXException; */ public class XMLResultAggregator extends Task implements XMLConstants { + // CheckStyle:VisibilityModifier OFF - bc /** the list of all filesets, that should contains the xml to aggregate */ protected Vector filesets = new Vector(); @@ -80,15 +81,19 @@ public class XMLResultAggregator extends Task implements XMLConstants { /** * text checked for in tests, {@value} */ - static final String WARNING_IS_POSSIBLY_CORRUPTED = " is not a valid XML document. It is possibly corrupted."; + static final String WARNING_IS_POSSIBLY_CORRUPTED + = " is not a valid XML document. It is possibly corrupted."; /** * text checked for in tests, {@value} */ - static final String WARNING_INVALID_ROOT_ELEMENT = " is not a valid testsuite XML document"; + static final String WARNING_INVALID_ROOT_ELEMENT + = " is not a valid testsuite XML document"; /** * text checked for in tests, {@value} */ - static final String WARNING_EMPTY_FILE = " is empty.\nThis can be caused by the test JVM exiting unexpectedly"; + static final String WARNING_EMPTY_FILE + = " is empty.\nThis can be caused by the test JVM exiting unexpectedly"; + // CheckStyle:VisibilityModifier ON /** * Generate a report based on the document created by the merge. diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/Xalan2Executor.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/Xalan2Executor.java index 51a9b28e3..de8a0e00a 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/Xalan2Executor.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/Xalan2Executor.java @@ -38,33 +38,35 @@ import org.apache.tools.ant.BuildException; */ public class Xalan2Executor extends XalanExecutor { - private static final String aPack = "org.apache.xalan."; - private static final String sPack = "com.sun.org.apache.xalan."; + private static final String APAC = "org.apache.xalan."; + private static final String SPAC = "com.sun.org.apache.xalan."; private TransformerFactory tfactory = TransformerFactory.newInstance(); + /** {@inheritDoc}. */ protected String getImplementation() throws BuildException { return tfactory.getClass().getName(); } + /** {@inheritDoc}. */ protected String getProcVersion(String classNameImpl) throws BuildException { try { // xalan 2 - if (classNameImpl.equals(aPack + "processor.TransformerFactoryImpl") + if (classNameImpl.equals(APAC + "processor.TransformerFactoryImpl") || - classNameImpl.equals(aPack + "xslt.XSLTProcessorFactory")) { - return getXalanVersion(aPack + "processor.XSLProcessorVersion"); + classNameImpl.equals(APAC + "xslt.XSLTProcessorFactory")) { + return getXalanVersion(APAC + "processor.XSLProcessorVersion"); } // xalan xsltc - if (classNameImpl.equals(aPack + if (classNameImpl.equals(APAC + "xsltc.trax.TransformerFactoryImpl")) { - return getXSLTCVersion(aPack + "xsltc.ProcessorVersion"); + return getXSLTCVersion(APAC + "xsltc.ProcessorVersion"); } // jdk 1.5 xsltc if (classNameImpl - .equals(sPack + "internal.xsltc.trax.TransformerFactoryImpl")) { - return getXSLTCVersion(sPack + .equals(SPAC + "internal.xsltc.trax.TransformerFactoryImpl")) { + return getXSLTCVersion(SPAC + "internal.xsltc.ProcessorVersion"); } throw new BuildException("Could not find a valid processor version" @@ -76,16 +78,17 @@ public class Xalan2Executor extends XalanExecutor { } } + /** {@inheritDoc}. */ void execute() throws Exception { - 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); + String systemId = caller.getStylesheetSystemId(); + Source xslSrc = new StreamSource(systemId); + Transformer tformer = tfactory.newTransformer(xslSrc); + Source xmlSrc = new DOMSource(caller.document); OutputStream os = getOutputStream(); try { tformer.setParameter("output.dir", caller.toDir.getAbsolutePath()); Result result = new StreamResult(os); - tformer.transform(xml_src, result); + tformer.transform(xmlSrc, result); } finally { os.close(); } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/XalanExecutor.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/XalanExecutor.java index 665164012..f4afe0515 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/XalanExecutor.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/XalanExecutor.java @@ -37,8 +37,10 @@ abstract class XalanExecutor { private static final String PACKAGE = "org.apache.tools.ant.taskdefs.optional.junit."; + // CheckStyle:VisibilityModifier OFF - bc /** the transformer caller */ protected AggregateTransformer caller; + // CheckStyle:VisibilityModifier ON /** set the caller for this object. */ private void setCaller(AggregateTransformer caller) {