[seam-commits] Seam SVN: r13796 - in branches/community/Seam_2_2/src/test/ftest: examples and 1 other directory.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Wed Oct 6 08:41:31 EDT 2010


Author: plenyi at redhat.com
Date: 2010-10-06 08:41:30 -0400 (Wed, 06 Oct 2010)
New Revision: 13796

Modified:
   branches/community/Seam_2_2/src/test/ftest/build.xml
   branches/community/Seam_2_2/src/test/ftest/examples/build.xml
Log:
Solution for JBQA-3275.

Modified: branches/community/Seam_2_2/src/test/ftest/build.xml
===================================================================
--- branches/community/Seam_2_2/src/test/ftest/build.xml	2010-10-05 13:25:56 UTC (rev 13795)
+++ branches/community/Seam_2_2/src/test/ftest/build.xml	2010-10-06 12:41:30 UTC (rev 13796)
@@ -51,6 +51,93 @@
 	<target name="testall" description="Run functional testsuite based on container property">
 		<fail unless="container">Please set container property.</fail>
 		<antcall target="testall.${container}" />
+      <echo message="Rewriting ftest output xml files." />
+      <groovy>
+         <classpath>
+            <pathelement location="../../../lib/ftest/xmlunit.jar" />
+         </classpath>
+         <![CDATA[
+            import org.custommonkey.xmlunit.Diff
+            import org.custommonkey.xmlunit.XMLUnit
+            import groovy.xml.StreamingMarkupBuilder
+
+            def container = System.getProperty("CONTAINER");
+            def slurper = new XmlSlurper();
+            def builder = new StreamingMarkupBuilder();
+            builder.encoding = "UTF-8";
+
+            /*
+               edit $(SEAM)/test-output/testng-results.xml
+                  remove elements containing 'setUp' or 'tearDown' - failures incorrectly counted as testcases
+                  replace 'SKIP' with 'FAIL'
+                     insert child '<exception class="java.lang.Error"><message><![CDATA[Deployment in error.] ]></message><full-stacktrace><![CDATA[ ] ]></full-stacktrace></exception>'
+            */
+            def xmlFile = new File("../../../test-output/testng-results.xml");
+            println "../../../test-output/testng-results.xml";
+            assert xmlFile.exists() && xmlFile.isFile();
+
+            def root = slurper.parse(xmlFile);
+            def serviceMethods = root.suite.test.class."test-method".findAll { it. at signature == "setUp()" || it. at signature == "tearDown()" }
+            serviceMethods.each { it.replaceNode {} }
+            def skippedMethods = root.suite.test.class."test-method".findAll { it. at status == "SKIP" }
+            skippedMethods.each {
+               it.attributes().put("status", "FAIL");
+               it.appendNode { exception(class:'java.lang.Error') { message("Deployment in error.") } }
+            }
+
+            def writer = new FileWriter("../../../test-output/testng-results-edit.xml");
+            writer << "<testng-results>";
+            writer << builder.bind(root.getBody());
+            writer << "</testng-results>";
+            writer.close();
+            
+            ant.delete(file:'../../../test-output/testng-results.xml');
+            ant.move(file:'../../../test-output/testng-results-edit.xml',tofile:'../../../test-output/testng-results.xml');
+
+            /*
+               for each ${SEAM}/${EXAMPLE} example/
+                  edit ${SEAM}/${EXAMPLE} example/${EXAMPLE}_${CONTAINER}.xml
+                     remove elements containing '@' - beforeMethod and afterMethod failures incorrectly counted as testcases
+                     replace '<skipped />' with '<failure message="Test skipped." type="java.lang.Error" />'
+            */
+            def testOutDir = new File("../../../test-output");
+            assert testOutDir.exists() && testOutDir.isDirectory();
+            testOutDir.eachDir { dir ->
+               if (dir.getName().endsWith("example")) {
+                  def exampleName;
+                  dir.eachFile { f ->
+                     if (f.getName().endsWith(container + ".xml")) {
+                        exampleName = f.getName().split("_" + container + ".xml")[0];
+                     }
+                  }
+                  def xmlFilePath = "../../../test-output/" + dir.getName() + "/" + exampleName + "_" + container + ".xml";
+                  def xmlFileEditPath = "../../../test-output/" + dir.getName() + "/" + exampleName + "_" + container + "-edit.xml";
+                  xmlFile = new File(xmlFilePath);
+                  println xmlFilePath;
+                  assert xmlFile.exists() && xmlFile.isFile();
+                  
+                  root = slurper.parse(xmlFile);
+                  def tsName = root.attributes().get("name");
+                  def tsTime = root.attributes().get("time");
+                  def tsTests = root.attributes().get("tests");
+                  serviceMethods = root.testcase.findAll { it. at name.toString().contains("@") }
+
+                  serviceMethods.each { it.replaceNode {} }
+                  root.testcase.skipped.replaceNode { node -> failure(message:'Test skipped.',type:'java.lang.Error.') }
+
+                  writer = new FileWriter(xmlFileEditPath);
+                  writer << "<" + "?xml version=\"1.0\" encoding=\"UTF-8\" ?" + ">";
+                  writer << '<testsuite name="' + tsName + '" failures="0" tests="' + tsTests + '" time="' + tsTime + '" errors="' + tsTests + '">';
+                  writer << builder.bind(root.getBody());
+                  writer << "</testsuite>";
+                  writer.close();
+                  
+                  ant.delete(file:xmlFilePath);
+                  ant.move(file:xmlFileEditPath,tofile:xmlFilePath);
+               }
+            }
+         ]]>
+      </groovy>
 	</target>
 
 	<target name="testall.jboss4" description="Run functional testsuite for JBoss 4">
@@ -169,6 +256,93 @@
 	<target name="test" description="Run tests for single example. Container selection is based on the value of container property">
 		<fail unless="container">Please set container property.</fail>
 		<antcall target="test.${container}" />
+      <echo message="Rewriting ftest output xml files." />
+      <groovy>
+         <classpath>
+            <pathelement location="../../../lib/ftest/xmlunit.jar" />
+         </classpath>
+         <![CDATA[
+            import org.custommonkey.xmlunit.Diff
+            import org.custommonkey.xmlunit.XMLUnit
+            import groovy.xml.StreamingMarkupBuilder
+
+            def container = System.getProperty("CONTAINER");
+            def slurper = new XmlSlurper();
+            def builder = new StreamingMarkupBuilder();
+            builder.encoding = "UTF-8";
+
+            /*
+               edit $(SEAM)/test-output/testng-results.xml
+                  remove elements containing 'setUp' or 'tearDown' - failures incorrectly counted as testcases
+                  replace 'SKIP' with 'FAIL'
+                     insert child '<exception class="java.lang.Error"><message><![CDATA[Deployment in error.] ]></message><full-stacktrace><![CDATA[ ] ]></full-stacktrace></exception>'
+            */
+            def xmlFile = new File("../../../test-output/testng-results.xml");
+            println "../../../test-output/testng-results.xml";
+            assert xmlFile.exists() && xmlFile.isFile();
+
+            def root = slurper.parse(xmlFile);
+            def serviceMethods = root.suite.test.class."test-method".findAll { it. at signature == "setUp()" || it. at signature == "tearDown()" }
+            serviceMethods.each { it.replaceNode {} }
+            def skippedMethods = root.suite.test.class."test-method".findAll { it. at status == "SKIP" }
+            skippedMethods.each {
+               it.attributes().put("status", "FAIL");
+               it.appendNode { exception(class:'java.lang.Error') { message("Deployment in error.") } }
+            }
+
+            def writer = new FileWriter("../../../test-output/testng-results-edit.xml");
+            writer << "<testng-results>";
+            writer << builder.bind(root.getBody());
+            writer << "</testng-results>";
+            writer.close();
+            
+            ant.delete(file:'../../../test-output/testng-results.xml');
+            ant.move(file:'../../../test-output/testng-results-edit.xml',tofile:'../../../test-output/testng-results.xml');
+
+            /*
+               for each ${SEAM}/${EXAMPLE} example/
+                  edit ${SEAM}/${EXAMPLE} example/${EXAMPLE}_${CONTAINER}.xml
+                     remove elements containing '@' - beforeMethod and afterMethod failures incorrectly counted as testcases
+                     replace '<skipped />' with '<failure message="Test skipped." type="java.lang.Error" />'
+            */
+            def testOutDir = new File("../../../test-output");
+            assert testOutDir.exists() && testOutDir.isDirectory();
+            testOutDir.eachDir { dir ->
+               if (dir.getName().endsWith("example")) {
+                  def exampleName;
+                  dir.eachFile { f ->
+                     if (f.getName().endsWith(container + ".xml")) {
+                        exampleName = f.getName().split("_" + container + ".xml")[0];
+                     }
+                  }
+                  def xmlFilePath = "../../../test-output/" + dir.getName() + "/" + exampleName + "_" + container + ".xml";
+                  def xmlFileEditPath = "../../../test-output/" + dir.getName() + "/" + exampleName + "_" + container + "-edit.xml";
+                  xmlFile = new File(xmlFilePath);
+                  println xmlFilePath;
+                  assert xmlFile.exists() && xmlFile.isFile();
+                  
+                  root = slurper.parse(xmlFile);
+                  def tsName = root.attributes().get("name");
+                  def tsTime = root.attributes().get("time");
+                  def tsTests = root.attributes().get("tests");
+                  serviceMethods = root.testcase.findAll { it. at name.toString().contains("@") }
+
+                  serviceMethods.each { it.replaceNode {} }
+                  root.testcase.skipped.replaceNode { node -> failure(message:'Test skipped.',type:'java.lang.Error.') }
+
+                  writer = new FileWriter(xmlFileEditPath);
+                  writer << "<" + "?xml version=\"1.0\" encoding=\"UTF-8\" ?" + ">";
+                  writer << '<testsuite name="' + tsName + '" failures="0" tests="' + tsTests + '" time="' + tsTime + '" errors="' + tsTests + '">';
+                  writer << builder.bind(root.getBody());
+                  writer << "</testsuite>";
+                  writer.close();
+                  
+                  ant.delete(file:xmlFilePath);
+                  ant.move(file:xmlFileEditPath,tofile:xmlFilePath);
+               }
+            }
+         ]]>
+      </groovy>
 	</target>
 
 	<target name="test.jboss4" description="Run tests for single example on JBoss 4">
@@ -315,7 +489,9 @@
 		<attribute name="message" default="Running functional tests on @{name} example" />
 		<sequential>
 			<groovy>
+            <arg value="@{name}" />
 				<![CDATA[
+            	System.setProperty("EXAMPLE", args[0]);
 				def testExamplesRunSoFar = properties['testExamplesRunSoFar'] == null ? 0 : Integer.valueOf(properties['testExamplesRunSoFar']);
 				def jbossDeploymentsRestart = properties['jboss.deployments.restart'] == null ? 0 : Integer.valueOf(properties['jboss.deployments.restart']);
 				if (jbossDeploymentsRestart > 0 && testExamplesRunSoFar > 0 && testExamplesRunSoFar % jbossDeploymentsRestart  == 0 ) {

Modified: branches/community/Seam_2_2/src/test/ftest/examples/build.xml
===================================================================
--- branches/community/Seam_2_2/src/test/ftest/examples/build.xml	2010-10-05 13:25:56 UTC (rev 13795)
+++ branches/community/Seam_2_2/src/test/ftest/examples/build.xml	2010-10-06 12:41:30 UTC (rev 13796)
@@ -169,6 +169,11 @@
 		<!-- TODO start JBoss -->
 		<!-- clean example -->
 		<ant antfile="${seam.dir}/examples/${example.name}/build.xml" target="clean" inheritall="false" dir="${seam.dir}/examples/${example.name}" />
+      <groovy>
+         <![CDATA[
+            System.clearProperty("TIMEOUT");
+         ]]>
+      </groovy>
 
 		<!-- deploy the example-->
 		<antcall target="deploy.example" />
@@ -217,36 +222,56 @@
 			<propertyset refid="deploy.properties" />
 		</ant>
 		<!-- wait for the application to be active -->
-		<!-- TODO is there a better way? -->
-		<echo>Waiting ${wait.time} seconds for ${absolute.wait.url}</echo>
-		<waitfor maxwait="${wait.time}" maxwaitunit="second" timeoutproperty="timeout">
-			<and>
-				<!-- wait for the application to not throw 404 -->
-				<http url="${absolute.wait.url}" errorsBeginAt="404" />
-			</and>
-		</waitfor>
+      <groovy>
+         <arg value="${container}" />
+         <![CDATA[
+         System.setProperty("CONTAINER", args[0]);
+         
+         def waitTime = properties.get("wait.time");
+         def waitUrl = properties.get("absolute.wait.url");
+         
+         ant.echo("Waiting " + waitTime + " seconds for " + waitUrl);
+         ant.waitfor(maxwait:waitTime,maxwaitunit:'second',timeoutproperty:'timeout') {
+            ant.http(url:waitUrl,errorsBeginAt:'404');
+         }
+         
+         if (properties.timeout != null) {
+            System.setProperty("TIMEOUT", System.getProperty("EXAMPLE"));
+         }
+         ]]>
+      </groovy>
 	</target>
 	
 	<target name="farm.example" depends="container.properties">
-			<property name="absolute.wait.url" value="${selenium.browser.url.cluster}${wait.url}" />
-			<echo>Deploying ${example.name} example to farm directory of ${container} using ${farm.target} target</echo>
-			<ant antfile="${seam.dir}/examples/${example.name}/build.xml" target="${farm.target}" inheritall="false" dir="${seam.dir}/examples/${example.name}">
-				<property name="jboss.home" value="${container.home}" />
-				<property name="tomcat.home" value="${container.home}" />				
-				<property name="session.replication" value="true" />
-				<property name="distributable" value="true" />				
-				<propertyset refid="deploy.properties" />
-			</ant>
-			<!-- wait for the application to be active -->
-			<!-- TODO is there a better way? -->
-			<echo>Waiting ${wait.time} seconds for ${absolute.wait.url}</echo>
-			<waitfor maxwait="${wait.time}" maxwaitunit="second">
-				<and>
-					<!-- wait for the application to not throw 404 -->
-					<http url="${absolute.wait.url}" errorsBeginAt="404" />
-				</and>
-			</waitfor>
-		</target>
+      <property name="absolute.wait.url" value="${selenium.browser.url.cluster}${wait.url}" />
+      <echo>Deploying ${example.name} example to farm directory of ${container} using ${farm.target} target</echo>
+      <ant antfile="${seam.dir}/examples/${example.name}/build.xml" target="${farm.target}" inheritall="false" dir="${seam.dir}/examples/${example.name}">
+         <property name="jboss.home" value="${container.home}" />
+         <property name="tomcat.home" value="${container.home}" />				
+         <property name="session.replication" value="true" />
+         <property name="distributable" value="true" />				
+         <propertyset refid="deploy.properties" />
+      </ant>
+      <!-- wait for the application to be active -->
+      <groovy>
+         <arg value="${container}" />
+         <![CDATA[
+         System.setProperty("CONTAINER", args[0]);
+         
+         def waitTime = properties.get("wait.time");
+         def waitUrl = properties.get("absolute.wait.url");
+         
+         ant.echo("Waiting " + waitTime + " seconds for " + waitUrl);
+         ant.waitfor(maxwait:waitTime,maxwaitunit:'second',timeoutproperty:'timeout') {
+            ant.http(url:waitUrl,errorsBeginAt:'404');
+         }
+         
+         if (properties.timeout != null) {
+            System.setProperty("TIMEOUT", System.getProperty("EXAMPLE"));
+         }
+         ]]>
+      </groovy>
+   </target>
 
 	<target name="undeploy.example" depends="container.properties">
 		<echo>Undeploying example ${example.name} from ${container} using ${undeploy.target} target</echo>
@@ -374,6 +399,7 @@
 				<exclusion groupId="log4j" artifactId="log4j" />
 			</dependency>
 			<dependency groupId="org.subethamail" artifactId="subethasmtp-wiser" version="1.2" />
+         <dependency groupId="xmlunit" artifactId="xmlunit" version="1.3" />
 		</copyInlineDependencies>
 		<property name="copy.selenium.done" value="true" />
 	</target>



More information about the seam-commits mailing list