I was using elements before they were configured. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270948 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -127,7 +127,7 @@ public final class ClientElement extends ProjectComponent { | |||||
| // must appended to classpath to avoid conflicts. | // must appended to classpath to avoid conflicts. | ||||
| JUnitHelper.addClasspathEntry(createClasspath(), "/junit/framework/TestCase.class"); | JUnitHelper.addClasspathEntry(createClasspath(), "/junit/framework/TestCase.class"); | ||||
| JUnitHelper.addClasspathEntry(createClasspath(), "/org/apache/tools/ant/Task.class"); | JUnitHelper.addClasspathEntry(createClasspath(), "/org/apache/tools/ant/Task.class"); | ||||
| JUnitHelper.addClasspathEntry(createClasspath(), "/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.class"); | |||||
| JUnitHelper.addClasspathEntry(createClasspath(), "/org/apache/tools/ant/taskdefs/optional/junit/remote/TestRunner.class"); | |||||
| } | } | ||||
| protected void doExecute() throws BuildException { | protected void doExecute() throws BuildException { | ||||
| @@ -161,7 +161,7 @@ public final class ClientElement extends ProjectComponent { | |||||
| TestCollector te = (TestCollector) testCollectors.elementAt(i); | TestCollector te = (TestCollector) testCollectors.elementAt(i); | ||||
| tests[i] = te.collectTests(); | tests[i] = te.collectTests(); | ||||
| } | } | ||||
| return Enumerations.fromCompound(tests); | |||||
| return new CompoundEnumeration(tests); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -54,6 +54,7 @@ | |||||
| package org.apache.tools.ant.taskdefs.optional.junit; | package org.apache.tools.ant.taskdefs.optional.junit; | ||||
| import java.io.OutputStream; | import java.io.OutputStream; | ||||
| import java.io.File; | |||||
| import java.util.Properties; | import java.util.Properties; | ||||
| import java.util.StringTokenizer; | import java.util.StringTokenizer; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| @@ -62,6 +63,7 @@ import org.apache.tools.ant.BuildException; | |||||
| import org.apache.tools.ant.taskdefs.optional.junit.formatter.BriefFormatter; | import org.apache.tools.ant.taskdefs.optional.junit.formatter.BriefFormatter; | ||||
| import org.apache.tools.ant.taskdefs.optional.junit.formatter.Formatter; | import org.apache.tools.ant.taskdefs.optional.junit.formatter.Formatter; | ||||
| import org.apache.tools.ant.taskdefs.optional.junit.formatter.XMLFormatter; | import org.apache.tools.ant.taskdefs.optional.junit.formatter.XMLFormatter; | ||||
| import org.apache.tools.ant.taskdefs.optional.junit.formatter.PlainFormatter; | |||||
| import org.apache.tools.ant.types.EnumeratedAttribute; | import org.apache.tools.ant.types.EnumeratedAttribute; | ||||
| /** | /** | ||||
| @@ -92,7 +94,7 @@ public class FormatterElement { | |||||
| private Vector filters = new Vector(); | private Vector filters = new Vector(); | ||||
| /** the parameters set for configuration purposes */ | /** the parameters set for configuration purposes */ | ||||
| private Properties params = new Properties(); | |||||
| private Vector params = new Vector(); | |||||
| /** | /** | ||||
| * set an existing type of formatter. | * set an existing type of formatter. | ||||
| @@ -139,7 +141,7 @@ public class FormatterElement { | |||||
| * Add a parameter that can be used for configuration. | * Add a parameter that can be used for configuration. | ||||
| */ | */ | ||||
| public void addParam(Parameter param) { | public void addParam(Parameter param) { | ||||
| params.setProperty(param.getName(), param.getValue()); | |||||
| params.addElement(param); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -174,9 +176,16 @@ public class FormatterElement { | |||||
| FilterElement fe = (FilterElement) filters.elementAt(i); | FilterElement fe = (FilterElement) filters.elementAt(i); | ||||
| f = fe.createFilterFormatter(f); | f = fe.createFilterFormatter(f); | ||||
| } | } | ||||
| // create properties from parameters | |||||
| Properties props = new Properties(); | |||||
| for (int i = 0; i < params.size(); i++){ | |||||
| Parameter param = (Parameter)params.elementAt(i); | |||||
| props.put(param.getName(), param.getValue()); | |||||
| } | |||||
| // it is assumed here that the filters are chaining til the | // it is assumed here that the filters are chaining til the | ||||
| // wrapped formatter. | // wrapped formatter. | ||||
| f.init(params); | |||||
| f.init(props); | |||||
| return f; | return f; | ||||
| } | } | ||||
| @@ -186,7 +195,7 @@ public class FormatterElement { | |||||
| */ | */ | ||||
| public final static class TypeAttribute extends EnumeratedAttribute { | public final static class TypeAttribute extends EnumeratedAttribute { | ||||
| private final static String[] VALUES = {"plain", "xml", "brief"}; | private final static String[] VALUES = {"plain", "xml", "brief"}; | ||||
| private final static String[] CLASSNAMES = {"xxx", XMLFormatter.class.getName(), BriefFormatter.class.getName()}; | |||||
| private final static String[] CLASSNAMES = {PlainFormatter.class.getName(), XMLFormatter.class.getName(), BriefFormatter.class.getName()}; | |||||
| public String[] getValues() { | public String[] getValues() { | ||||
| return VALUES; | return VALUES; | ||||
| @@ -206,6 +215,10 @@ public class FormatterElement { | |||||
| this.name = name; | this.name = name; | ||||
| } | } | ||||
| public void setLocation(File file) { | |||||
| setValue(file.getAbsolutePath()); | |||||
| } | |||||
| public void setValue(String value) { | public void setValue(String value) { | ||||
| this.value = value; | this.value = value; | ||||
| } | } | ||||
| @@ -76,7 +76,7 @@ import org.apache.tools.ant.taskdefs.optional.junit.remote.Server; | |||||
| public final class ServerElement extends ProjectComponent { | public final class ServerElement extends ProjectComponent { | ||||
| /** formatters that write the tests results */ | /** formatters that write the tests results */ | ||||
| private Vector formatters = new Vector(); | |||||
| private Vector formatterElements = new Vector(); | |||||
| /** port to run the server on. Default to 6666 */ | /** port to run the server on. Default to 6666 */ | ||||
| private int port = 6666; | private int port = 6666; | ||||
| @@ -99,9 +99,11 @@ public final class ServerElement extends ProjectComponent { | |||||
| public void execute() throws BuildException { | public void execute() throws BuildException { | ||||
| // configure the server... | // configure the server... | ||||
| Server server = new Server(port); | Server server = new Server(port); | ||||
| Enumeration listeners = formatters.elements(); | |||||
| Enumeration listeners = formatterElements.elements(); | |||||
| while (listeners.hasMoreElements()) { | while (listeners.hasMoreElements()) { | ||||
| server.addListener((TestRunListener) listeners.nextElement()); | |||||
| FormatterElement fe = (FormatterElement)listeners.nextElement(); | |||||
| Formatter formatter = fe.createFormatter(); | |||||
| server.addListener( formatter ); | |||||
| } | } | ||||
| // and run it. It will stop once a client has finished. | // and run it. It will stop once a client has finished. | ||||
| server.start(); | server.start(); | ||||
| @@ -125,7 +127,6 @@ public final class ServerElement extends ProjectComponent { | |||||
| /** add a new formatter element */ | /** add a new formatter element */ | ||||
| public void addFormatter(FormatterElement fe) { | public void addFormatter(FormatterElement fe) { | ||||
| Formatter f = fe.createFormatter(); | |||||
| formatters.addElement(f); | |||||
| formatterElements.addElement(fe); | |||||
| } | } | ||||
| } | } | ||||
| @@ -70,7 +70,7 @@ public class TestElement implements TestCollector { | |||||
| //@fixme, a path is needed for a test. | //@fixme, a path is needed for a test. | ||||
| public Enumeration collectTests() { | public Enumeration collectTests() { | ||||
| return Enumerations.fromArray(new String[]{name}); | |||||
| return new ArrayEnumeration(new String[]{name}); | |||||
| } | } | ||||
| // Ant bean setters | // Ant bean setters | ||||