[seam-commits] Seam SVN: r13823 - branches/community/Seam_2_2/src/test/ftest.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Mon Oct 11 03:24:25 EDT 2010
Author: plenyi at redhat.com
Date: 2010-10-11 03:24:25 -0400 (Mon, 11 Oct 2010)
New Revision: 13823
Modified:
branches/community/Seam_2_2/src/test/ftest/build.xml
Log:
JBQA-3275 Minor changes and quick bug fixes.
Modified: branches/community/Seam_2_2/src/test/ftest/build.xml
===================================================================
--- branches/community/Seam_2_2/src/test/ftest/build.xml 2010-10-10 16:49:49 UTC (rev 13822)
+++ branches/community/Seam_2_2/src/test/ftest/build.xml 2010-10-11 07:24:25 UTC (rev 13823)
@@ -46,98 +46,11 @@
</path>
<!-- TODO : should the libs be in seam/lib and managed with mvn? -->
- <taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy" classpath="../../../lib/groovy-all.jar"/>
+ <taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy" classpath="../../../lib/ftest/groovy-all.jar"/>
<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">
@@ -177,6 +90,7 @@
<testexample name="wicket-runtime" />
<antcall target="stop.selenium.server" />
<antcall target="stop.container" />
+ <testoutRewrite container="${container}" />
</target>
<target name="testall.jboss5" description="Run functional testsuite for JBoss 5">
@@ -222,6 +136,7 @@
<testexample name="wicket-runtime" />
<antcall target="stop.selenium.server" />
<antcall target="stop.container" />
+ <testoutRewrite container="${container}" />
</target>
<target name="testall.jboss-embedded" description="Run functional testsuite for JBoss Embedded">
@@ -240,6 +155,7 @@
<testexample name="jpa" />
<testexample name="hibernate" />
<antcall target="stop.selenium.server" />
+ <testoutRewrite container="${container}" />
</target>
<target name="testall.tomcat6" description="Run functional testsuite for Tomcat 6">
@@ -251,118 +167,36 @@
<testexample name="hibernate" />
<antcall target="stop.selenium.server" />
+ <testoutRewrite container="${container}" />
</target>
<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">
<property name="container" value="jboss4" />
<antcall target="test.single.example" />
+ <testoutRewrite container="${container}" />
</target>
<target name="test.jboss5" description="Run tests for single example on JBoss 5">
<property name="container" value="jboss5" />
<antcall target="test.single.example" />
+ <testoutRewrite container="${container}" />
</target>
<target name="test.tomcat6" description="Run tests for single example on Tomcat 6">
<property name="container" value="tomcat6" />
<antcall target="test.single.example" />
+ <testoutRewrite container="${container}" />
</target>
<target name="test.jboss-embedded" description="Run tests for single example on JBoss Embedded">
<property name="container" value="jboss-embedded" />
<antcall target="test.single.example" />
+ <testoutRewrite container="${container}" />
</target>
<target name="test.single.example">
@@ -556,6 +390,100 @@
<property name="container" value="${container}" />
</ant>
</target>
+
+ <macrodef name="testoutRewrite">
+ <attribute name="container" />
+ <sequential>
+ <echo message="Rewriting ftest output xml files." />
+ <groovy>
+ <arg value="@{container}" />
+ <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 = args[0];
+ 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>
+ </sequential>
+ </macrodef>
+
</project>
More information about the seam-commits
mailing list