This patch enables running web tests using HtmlUnit. Since not all tests,
particularly layout tests, can run successfully on HtmlUnit, the patch
introduces an annotation @DoNotRunWith. Test methods or classes marked with the
annotation are not run on the platforms specified in the annotation's argument.

There is an additional build target test.web.htmlunit that runs web tests using
HtmlUnit's emulation of FF3. All tests pass currently.

Patch by: amitmanjhi
Review by: scottb,jat




git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@5844 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/build.xml b/user/build.xml
index 7c68dbd..ab524f4 100755
--- a/user/build.xml
+++ b/user/build.xml
@@ -45,6 +45,26 @@
     <pathelement location="test_i18n_${gwt.i18n.test.InnerClassChar}" />
   </path>
 
+  <!--
+    Classpaths added for htmlunit libs 
+  -->
+  <path id="htmlunit.libs">
+    <pathelement location="${gwt.tools.lib}/apache/commons/commons-codec-1.3.jar" />
+    <pathelement location="${gwt.tools.lib}/tomcat/commons-collections-3.1.jar" />
+    <pathelement location="${gwt.tools.lib}/apache/commons/commons-httpclient-3.1.jar" />
+    <pathelement location="${gwt.tools.lib}/apache/commons/commons-io-1.4.jar" />
+    <pathelement location="${gwt.tools.lib}/apache/commons/commons-lang-2.4.jar" />
+    <pathelement location="${gwt.tools.lib}/tomcat/commons-logging-1.1.jar" />
+    <pathelement location="${gwt.tools.lib}/cssparser/cssparser-0.9.5.jar" />
+    <pathelement location="${gwt.tools.lib}/htmlunit/htmlunit-2.5.jar" />
+    <pathelement location="${gwt.tools.lib}/htmlunit/htmlunit-core-js-2.5.jar" />
+    <pathelement location="${gwt.tools.lib}/nekohtml/nekohtml-1.9.12.jar" />
+    <pathelement location="${gwt.tools.lib}/xalan/xalan-2.7.1.jar" />
+    <pathelement location="${gwt.tools.lib}/xerces/serializer-2.7.1.jar" />
+    <pathelement location="${gwt.tools.lib}/xerces/xercesImpl-2.8.1.jar" />
+    <pathelement location="${gwt.tools.lib}/xerces/xml-apis-1.3.04.jar" />
+    <pathelement location="${gwt.tools.lib}/w3c/sac/sac-1.3.jar" />
+  </path>
   <!-- Platform shouldn't matter here, just picking one -->
   <property.ensure name="gwt.dev.jar" location="${gwt.build.lib}/gwt-dev-${build.host.platform}.jar" />
 
@@ -59,6 +79,7 @@
         <pathelement location="${gwt.tools.lib}/w3c/sac/sac-1.3.jar" />
         <pathelement location="${gwt.tools.lib}/w3c/flute/flute-1.3.jar" />
         <pathelement location="${gwt.dev.jar}" />
+        <path refid="htmlunit.libs" />
       </classpath>
     </gwt.javac>
 
@@ -85,6 +106,7 @@
         <pathelement location="${gwt.tools.lib}/junit/junit-3.8.1.jar" />
         <pathelement location="${gwt.tools.lib}/selenium/selenium-java-client-driver.jar" />
         <pathelement location="${gwt.dev.jar}" />
+        <path refid="htmlunit.libs" />
       </classpath>
     </gwt.javac>
   </target>
@@ -168,6 +190,16 @@
     </gwt.junit>
   </target>
 
+  <target name="test.web.htmlunit" depends="compile, compile.tests" description="Run htmlunit web-mode tests for this project.">
+    <!-- TODO: add more browsers later -->
+    <gwt.junit test.args="${test.args} -htmlunit FF3" test.out="${junit.out}/${build.host.platform}-htmlunit-web-mode" test.cases="default.web.tests" >
+      <extraclasspaths>
+        <path refid="test.extraclasspath" />
+        <path refid="htmlunit.libs" />
+      </extraclasspaths>
+    </gwt.junit>
+  </target>
+  
   <target name="test.web.disableClassMetadata" depends="compile, compile.tests" description="Run only web-mode tests for this project.">
     <gwt.junit test.args="${test.args} -XdisableClassMetadata -out www -web -batch module" test.out="${junit.out}/${build.host.platform}-web-mode-disableClassMetadata" test.cases="default.web.tests" >
       <extraclasspaths>
@@ -202,6 +234,7 @@
       <antcall target="test.noserver"/>
       <antcall target="test.web"/>
       <antcall target="test.web.disableClassMetadata"/>
+      <antcall target="test.web.htmlunit"/>
       <antcall target="test.web.draft"/>
     </parallel>
     </limit>