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 b99b8da31..dc404d659 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 @@ -88,7 +88,7 @@ import java.net.URL; * created by Erich Gamma and Kent Beck. JUnit can be found at http://www.junit.org. * - *

JUnitTask can run a single specific JUnitTest using the test element. + *

JUnitTask can run a single specific JUnitTest using the test element. * For example, the following target

  *   <target name="test-int-chars" depends="jar-test">
  *       <echo message="testing international characters"/>
@@ -98,13 +98,13 @@ import java.net.URL;
  *           <test name="org.apache.ecs.InternationalCharTest" />
  *       </junit>
  *   </target>
- * 
runs a single junit test (org.apache.ecs.InternationalCharTest) - * in the current VM using the path with id classpath as classpath + * runs a single junit test (org.apache.ecs.InternationalCharTest) + * in the current VM using the path with id classpath as classpath * and presents the results formatted using the standard plain formatter on the command line. * - *

This task can also run batches of tests. - * The batchtest element creates a BatchTest based on a fileset. - * This allows, for example, all classes found in directory to be run as testcases. + *

This task can also run batches of tests. + * The batchtest element creates a BatchTest based on a fileset. + * This allows, for example, all classes found in directory to be run as testcases. * For example,

  * <target name="run-tests" depends="dump-info,compile-tests" if="junit.present">
  *   <junit printsummary="no" haltonfailure="yes" fork="${junit.fork}">
@@ -123,17 +123,17 @@ import java.net.URL;
  * (under the top ${tests.dir}, of course) and creates JUnitTest's for each one.
  *
  * 

Of course, <junit> and <batch> elements can be combined - * for more complex tests. For an example, see the ant build.xml target run-tests + * for more complex tests. For an example, see the ant build.xml target run-tests * (the second example is an edited version). - * + * *

To spawn a new Java VM to prevent interferences between - * different testcases, you need to enable fork. + * different testcases, you need to enable fork. * A number of attributes and elements allow you to set up how this JVM runs. *

* @author Thomas Haas * @author Stefan Bodewig @@ -157,11 +157,11 @@ public class JUnitTask extends Task { private String summaryValue = ""; private boolean filtertrace = true; private JUnitTestRunner runner = null; - + /** - * Tells this task whether to smartly filter the stack frames of JUnit testcase - * errors and failures before reporting them. This property is applied on all - * BatchTest (batchtest) and JUnitTest (test) however it can possibly be + * Tells this task whether to smartly filter the stack frames of JUnit testcase + * errors and failures before reporting them. This property is applied on all + * BatchTest (batchtest) and JUnitTest (test) however it can possibly be * overridden by their own properties. * @param value false if it should not filter, otherwise true */ @@ -172,7 +172,7 @@ public class JUnitTask extends Task { test.setFiltertrace(value); } } - + /** * Tells this task to halt when there is an error in a test. * this property is applied on all BatchTest (batchtest) and JUnitTest (test) @@ -257,16 +257,17 @@ public class JUnitTask extends Task { summary = value.asBoolean(); } - /** + /** * Print summary enumeration values. */ public static class SummaryAttribute extends EnumeratedAttribute { public String[] getValues() { - return new String[] {"true", "yes", "false", "no", + return new String[] {"true", "yes", "false", "no", "on", "off", "withOutAndErr"}; } public boolean asBoolean() { + String value = getValue(); return "true".equals(value) || "on".equals(value) || "yes".equals(value) @@ -332,7 +333,7 @@ public class JUnitTask extends Task { public void addSysproperty(Environment.Variable sysp) { commandline.addSysproperty(sysp); } - + /** * <classpath> allows classpath to be set for tests. */ @@ -437,7 +438,7 @@ public class JUnitTask extends Task { +(wasKilled ? " (timeout)" : ""), location); } else { - log("TEST "+test.getName()+" FAILED" + log("TEST "+test.getName()+" FAILED" + (wasKilled ? " (timeout)" : ""), Project.MSG_ERR); if (errorOccurredHere && test.getErrorProperty() != null) { project.setProperty(test.getErrorProperty(), "true"); @@ -489,7 +490,7 @@ public class JUnitTask extends Task { // Create a temporary file to pass the Ant properties to the forked test File propsFile = new File("junit" + (new Random(System.currentTimeMillis())).nextLong() + ".properties"); cmd.createArgument().setValue("propsfile=" + propsFile.getAbsolutePath()); - Hashtable p = project.getProperties(); + Hashtable p = project.getProperties(); Properties props = new Properties(); for (Enumeration enum = p.keys(); enum.hasMoreElements(); ) { Object key = enum.nextElement(); @@ -511,7 +512,7 @@ public class JUnitTask extends Task { } log("Executing: "+cmd.toString(), Project.MSG_VERBOSE); - int retVal; + int retVal; try { retVal = execute.execute(); } catch (IOException e) { @@ -526,7 +527,7 @@ public class JUnitTask extends Task { // in VM is not very nice since it could probably hang the // whole build. IMHO this method should be avoided and it would be best // to remove it in future versions. TBD. (SBa) - + protected void handleOutput(String line) { if (runner != null) { @@ -536,7 +537,7 @@ public class JUnitTask extends Task { super.handleOutput(line); } } - + protected void handleErrorOutput(String line) { if (runner != null) { runner.handleErrorOutput(line); @@ -545,7 +546,7 @@ public class JUnitTask extends Task { super.handleErrorOutput(line); } } - + /** * Execute inside VM. */ @@ -565,7 +566,7 @@ public class JUnitTask extends Task { Path classpath = commandline.getClasspath(); if (classpath != null) { cl = new AntClassLoader(null, project, classpath, false); - log("Using CLASSPATH " + cl.getClasspath(), + log("Using CLASSPATH " + cl.getClasspath(), Project.MSG_VERBOSE); // make sure the test will be accepted as a TestCase @@ -577,7 +578,7 @@ public class JUnitTask extends Task { if (summary) { log("Running " + test.getName(), Project.MSG_INFO); - SummaryJUnitResultFormatter f = + SummaryJUnitResultFormatter f = new SummaryJUnitResultFormatter(); f.setWithOutAndErr( "withoutanderr".equalsIgnoreCase( summaryValue )); f.setOutput( getDefaultOutput() ); @@ -675,17 +676,17 @@ public class JUnitTask extends Task { if (u.startsWith("jar:file:")) { int pling = u.indexOf("!"); String jarName = u.substring(9, pling); - log("Implicitly adding "+jarName+" to classpath", + log("Implicitly adding "+jarName+" to classpath", Project.MSG_DEBUG); createClasspath().setLocation(new File((new File(jarName)).getAbsolutePath())); } else if (u.startsWith("file:")) { int tail = u.indexOf(resource); String dirName = u.substring(5, tail); - log("Implicitly adding "+dirName+" to classpath", + log("Implicitly adding "+dirName+" to classpath", Project.MSG_DEBUG); createClasspath().setLocation(new File((new File(dirName)).getAbsolutePath())); } else { - log("Don\'t know how to handle resource URL "+u, + log("Don\'t know how to handle resource URL "+u, Project.MSG_DEBUG); } } else { diff --git a/src/main/org/apache/tools/ant/types/EnumeratedAttribute.java b/src/main/org/apache/tools/ant/types/EnumeratedAttribute.java index 241f7544d..dc07375b9 100644 --- a/src/main/org/apache/tools/ant/types/EnumeratedAttribute.java +++ b/src/main/org/apache/tools/ant/types/EnumeratedAttribute.java @@ -70,22 +70,24 @@ public abstract class EnumeratedAttribute { /** * The selected value in this enumeration. */ - protected String value; + private String value; /** * the index of the selected value in the array. */ - protected int index; + private int index; /** * This is the only method a subclass needs to implement. * * @return an array holding all possible values of the enumeration. + * The order of elements must be fixed so that indexOfValue(String) + * always return the same index for the same value. */ public abstract String[] getValues(); /** bean constructor */ - public EnumeratedAttribute(){ + protected EnumeratedAttribute(){ } /**