[Webtest] [PATCH] Webtest and Ant 1.6.x

Stefan Bodewig webtest@lists.canoo.com
Fri, 20 Feb 2004 08:36:02 +0100


--=-=-=

Hi,

I've seen some reports on this list that Webtest wouldn't work with
Ant 1.6.0.  The reason is that we (the Ant team) have broken backwards
compatibility for third-party TaskContainer implementations and didn't
notice it until after 1.6.0 has been released.

Fortunately there is a way to change the custom TaskContainers in a
way that they will work with both Ant 1.5.x and Ant 1.6.x[1] and the
patch that I've attached (against build 392) should work.  I haven't
tested it thoroughly though since the self test doesn't seem to pass
with an unmodified version of Webtest for me either.

Cheers

        Stefan

Footnotes: 
[1]  http://ant.apache.org/faq.html#unknownelement.taskcontainer

-- 
http://stefanbodewig.blogger.de/


--=-=-=
Content-Disposition: attachment; filename=wt.patch

diff -u -r src/com/canoo/webtest/ant/TestSpecificationTask.java new/com/canoo/webtest/ant/TestSpecificationTask.java
--- src/com/canoo/webtest/ant/TestSpecificationTask.java	Fri Jan 23 20:50:06 2004
+++ new/com/canoo/webtest/ant/TestSpecificationTask.java	Thu Feb 19 13:35:00 2004
@@ -13,6 +13,7 @@
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.Task;
 import org.apache.tools.ant.TaskContainer;
+import org.apache.tools.ant.UnknownElement;
 
 import java.util.List;
 
@@ -33,6 +34,10 @@
     }
 
     public void addTask(Task task) {
+        if (task instanceof UnknownElement) {
+            ((UnknownElement) task).maybeConfigure();
+            task = ((UnknownElement) task).getTask();
+        }
         if (task instanceof Configuration) {
             addConfig((Configuration) task);
         } else if (task instanceof TestStepSequence) {
diff -u -r src/com/canoo/webtest/ant/TestStepSequence.java new/com/canoo/webtest/ant/TestStepSequence.java
--- src/com/canoo/webtest/ant/TestStepSequence.java	Fri Jan 23 20:50:06 2004
+++ new/com/canoo/webtest/ant/TestStepSequence.java	Thu Feb 19 13:30:33 2004
@@ -8,6 +8,7 @@
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Task;
 import org.apache.tools.ant.TaskContainer;
+import org.apache.tools.ant.UnknownElement;
 
 import java.io.*;
 import java.util.ArrayList;
@@ -49,7 +50,10 @@
     }
 
     public void addTask(Task task) {
-
+        if (task instanceof UnknownElement) {
+            ((UnknownElement) task).maybeConfigure();
+            task = ((UnknownElement) task).getTask();
+        }
         Step step = null;
         if (task instanceof NotStep) {
             step = new FailWrapper((NotStep) task);

--=-=-=--