Author: stevel
Date: Mon Oct 29 10:41:35 2007
New Revision: 589763

URL: http://svn.apache.org/viewvc?rev=589763&view=rev
Log:
discussion on junit triggered me to look at this task; fix some things the IDE 
warned about on localisation.

Modified:
    
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java

Modified: 
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
URL: 
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java?rev=589763&r1=589762&r2=589763&view=diff
==============================================================================
--- 
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
 (original)
+++ 
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
 Mon Oct 29 10:41:35 2007
@@ -39,6 +39,7 @@
 import java.util.Map;
 import java.util.Properties;
 import java.util.Vector;
+import java.util.Locale;
 
 import org.apache.tools.ant.AntClassLoader;
 import org.apache.tools.ant.BuildException;
@@ -831,10 +832,10 @@
 
     /**
      * 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.
      */
-    protected void execute(List tests) throws BuildException {
+    protected void execute(List testList) throws BuildException {
         JUnitTest test = null;
         // Create a temporary file to pass the test cases to run to
         // the runner (one test case per line)
@@ -843,7 +844,7 @@
         try {
             writer =
                 new PrintWriter(new BufferedWriter(new FileWriter(casesFile)));
-            Iterator iter = tests.iterator();
+            Iterator iter = testList.iterator();
             while (iter.hasNext()) {
                 test = (JUnitTest) iter.next();
                 writer.print(test.getName());
@@ -895,6 +896,7 @@
      * the test could probably hang forever.
      * @param casesFile list of test cases to execute. Can be <tt>null</tt>,
      * 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,
      * or if the junit process can not be forked
      */
@@ -1049,6 +1051,7 @@
 
     /**
      * Adding ant runtime.
+     * @param cmd command to run
      */
     private void checkIncludeAntRuntime(CommandlineJava cmd) {
         if (includeAntRuntime) {
@@ -1070,10 +1073,20 @@
         }
     }
 
+
+    /**
+     * 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) {
         if (summary) {
             String prefix = "";
-            if ("withoutanderr".equalsIgnoreCase(summaryValue)) {
+            if (equalsWithOutAndErr(summaryValue)) {
                 prefix = "OutErr";
             }
             cmd.createArgument()
@@ -1086,6 +1099,7 @@
     /**
      * Check the path for multiple different versions of
      * ant.
+     * @param cmd command to execute
      */
     private void checkForkedPath(CommandlineJava cmd) {
         if (forkedPathChecked) {
@@ -1244,6 +1258,7 @@
      * Execute inside VM.
      * @param arg one JUnitTest
      * @throws BuildException under unspecified circumstances
+     * @return the results
      */
     private TestResultHolder executeInVM(JUnitTest arg) throws BuildException {
         JUnitTest test = (JUnitTest) arg.clone();
@@ -1288,8 +1303,7 @@
 
                 JUnitTaskMirror.SummaryJUnitResultFormatterMirror f =
                     delegate.newSummaryJUnitResultFormatter();
-                f.setWithOutAndErr("withoutanderr"
-                                   .equalsIgnoreCase(summaryValue));
+                f.setWithOutAndErr(equalsWithOutAndErr(summaryValue));
                 f.setOutput(getDefaultOutput());
                 runner.addFormatter(f);
             }
@@ -1807,7 +1821,7 @@
     }
 
     /**
-     * A value class that contains thee result of a test.
+     * A value class that contains the result of a test.
      */
     protected class TestResultHolder {
         // CheckStyle:VisibilityModifier OFF - bc



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to