Browse Source

discussion on junit triggered me to look at this task; fix some things the IDE warned about on localisation.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@589763 13f79535-47bb-0310-9956-ffa450edef68
master
Steve Loughran 18 years ago
parent
commit
4afd11bb11
1 changed files with 21 additions and 7 deletions
  1. +21
    -7
      src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java

+ 21
- 7
src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java View File

@@ -39,6 +39,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
import java.util.Vector; import java.util.Vector;
import java.util.Locale;


import org.apache.tools.ant.AntClassLoader; import org.apache.tools.ant.AntClassLoader;
import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildException;
@@ -831,10 +832,10 @@ public class JUnitTask extends Task {


/** /**
* Execute a list of tests in a single forked Java VM. * Execute a list of tests in a single forked Java VM.
* @param tests the list of tests to execute.
* @param testList the list of tests to execute.
* @throws BuildException on error. * @throws BuildException on error.
*/ */
protected void execute(List tests) throws BuildException {
protected void execute(List testList) throws BuildException {
JUnitTest test = null; JUnitTest test = null;
// Create a temporary file to pass the test cases to run to // Create a temporary file to pass the test cases to run to
// the runner (one test case per line) // the runner (one test case per line)
@@ -843,7 +844,7 @@ public class JUnitTask extends Task {
try { try {
writer = writer =
new PrintWriter(new BufferedWriter(new FileWriter(casesFile))); new PrintWriter(new BufferedWriter(new FileWriter(casesFile)));
Iterator iter = tests.iterator();
Iterator iter = testList.iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
test = (JUnitTest) iter.next(); test = (JUnitTest) iter.next();
writer.print(test.getName()); writer.print(test.getName());
@@ -895,6 +896,7 @@ public class JUnitTask extends Task {
* the test could probably hang forever. * the test could probably hang forever.
* @param casesFile list of test cases to execute. Can be <tt>null</tt>, * @param casesFile list of test cases to execute. Can be <tt>null</tt>,
* in this case only one test is executed. * in this case only one test is executed.
* @return the test results from the JVM itself.
* @throws BuildException in case of error creating a temporary property file, * @throws BuildException in case of error creating a temporary property file,
* or if the junit process can not be forked * or if the junit process can not be forked
*/ */
@@ -1049,6 +1051,7 @@ public class JUnitTask extends Task {


/** /**
* Adding ant runtime. * Adding ant runtime.
* @param cmd command to run
*/ */
private void checkIncludeAntRuntime(CommandlineJava cmd) { private void checkIncludeAntRuntime(CommandlineJava cmd) {
if (includeAntRuntime) { if (includeAntRuntime) {
@@ -1070,10 +1073,20 @@ public class JUnitTask extends Task {
} }
} }



/**
* check for the parameter being "withoutanderr" in a locale-independent way.
* @param summaryOption the summary option -can be null
* @return true if the run should be withoutput and error
*/
private boolean equalsWithOutAndErr(String summaryOption) {
return summaryOption != null && "withoutanderr".equals(summaryOption.toLowerCase(Locale.ENGLISH));
}

private void checkIncludeSummary(CommandlineJava cmd) { private void checkIncludeSummary(CommandlineJava cmd) {
if (summary) { if (summary) {
String prefix = ""; String prefix = "";
if ("withoutanderr".equalsIgnoreCase(summaryValue)) {
if (equalsWithOutAndErr(summaryValue)) {
prefix = "OutErr"; prefix = "OutErr";
} }
cmd.createArgument() cmd.createArgument()
@@ -1086,6 +1099,7 @@ public class JUnitTask extends Task {
/** /**
* Check the path for multiple different versions of * Check the path for multiple different versions of
* ant. * ant.
* @param cmd command to execute
*/ */
private void checkForkedPath(CommandlineJava cmd) { private void checkForkedPath(CommandlineJava cmd) {
if (forkedPathChecked) { if (forkedPathChecked) {
@@ -1244,6 +1258,7 @@ public class JUnitTask extends Task {
* Execute inside VM. * Execute inside VM.
* @param arg one JUnitTest * @param arg one JUnitTest
* @throws BuildException under unspecified circumstances * @throws BuildException under unspecified circumstances
* @return the results
*/ */
private TestResultHolder executeInVM(JUnitTest arg) throws BuildException { private TestResultHolder executeInVM(JUnitTest arg) throws BuildException {
JUnitTest test = (JUnitTest) arg.clone(); JUnitTest test = (JUnitTest) arg.clone();
@@ -1288,8 +1303,7 @@ public class JUnitTask extends Task {


JUnitTaskMirror.SummaryJUnitResultFormatterMirror f = JUnitTaskMirror.SummaryJUnitResultFormatterMirror f =
delegate.newSummaryJUnitResultFormatter(); delegate.newSummaryJUnitResultFormatter();
f.setWithOutAndErr("withoutanderr"
.equalsIgnoreCase(summaryValue));
f.setWithOutAndErr(equalsWithOutAndErr(summaryValue));
f.setOutput(getDefaultOutput()); f.setOutput(getDefaultOutput());
runner.addFormatter(f); runner.addFormatter(f);
} }
@@ -1807,7 +1821,7 @@ public class JUnitTask extends Task {
} }


/** /**
* A value class that contains thee result of a test.
* A value class that contains the result of a test.
*/ */
protected class TestResultHolder { protected class TestResultHolder {
// CheckStyle:VisibilityModifier OFF - bc // CheckStyle:VisibilityModifier OFF - bc


Loading…
Cancel
Save