[jboss-svn-commits] JBL Code SVN: r26679 - in labs/jbosstm/trunk/qa: ext and 3 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri May 22 04:21:58 EDT 2009
Author: jhalliday
Date: 2009-05-22 04:21:57 -0400 (Fri, 22 May 2009)
New Revision: 26679
Added:
labs/jbosstm/trunk/qa/TaskImpl.properties
labs/jbosstm/trunk/qa/build-dtfjunit.xml
labs/jbosstm/trunk/qa/ext/junit-4.5.jar
labs/jbosstm/trunk/qa/tests/src/org/jboss/jbossts/qa/junit/
labs/jbosstm/trunk/qa/tests/src/org/jboss/jbossts/qa/junit/Task.java
labs/jbosstm/trunk/qa/tests/src/org/jboss/jbossts/qa/junit/TaskImpl.java
labs/jbosstm/trunk/qa/tests/src/org/jboss/jbossts/qa/junit/TestGroupBase.java
labs/jbosstm/trunk/qa/tests/src/org/jboss/jbossts/qa/junit/XML2JUnit.java
Modified:
labs/jbosstm/trunk/qa/tests/build-jta.xml
labs/jbosstm/trunk/qa/tests/build-jts.xml
Log:
Added prototype XML to JUnit DTF test converter and associated code. JBTM-390
Added: labs/jbosstm/trunk/qa/TaskImpl.properties
===================================================================
--- labs/jbosstm/trunk/qa/TaskImpl.properties (rev 0)
+++ labs/jbosstm/trunk/qa/TaskImpl.properties 2009-05-22 08:21:57 UTC (rev 26679)
@@ -0,0 +1,27 @@
+# command line elements for executing spawned java tasks
+#COMMAND_LINE_0=/usr/local/jdk1.5.0_15/bin/java
+COMMAND_LINE_0=/usr/local/jdk1.6.0_12/bin/java
+COMMAND_LINE_1=-classpath
+#COMMAND_LINE_2=build/lib/jbossjts.jar:build/lib/jbossjts-jacorb.jar:build/etc/:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/lib/ext/jmxri.jar:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/lib/ext/log4j-1.2.14.jar:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/lib/ext/jndi.jar:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/lib/ext/jbossts-common.jar:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/lib/ext/connector-api.jar:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/lib/ext/junit.jar:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/lib/ext/commons-logging-1.1.jar:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/lib/ext/wrapper.jar:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/lib/ext/jta-1_1-classes.zip:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/qa/lib/db2jcc_license_cu.jar:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/qa/lib/postgresql-8.3-603.jdbc3.jar:/home/jhalli/IdeaProjects/j!
boss/jbossts_trunk/qa/build/qa/lib/TestingFramework.jar:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/qa/lib/db2jcc.jar:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/qa/lib/mysql-connector-java-5.1.6-bin.jar:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/qa/lib/sqljdbc.jar:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/qa/lib/ojdbc14.jar:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/qa/lib/jconn2.jar:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/qa/lib/jboss-server-manager-0.1.1.GA.jar:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/qa/lib/jbossts-jts-qa.jar:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/jacorb/lib/idl.jar:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/jacorb/lib/backport-util-concurrent.jar:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/jacorb/lib/jacorb.jar:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/jacorb/lib/antlr-2.7.2.jar:/home/jhalli/IdeaProjects/jboss/jbos!
sts_trunk/qa/build/jacorb/lib/picocontainer-1.2.jar:/home/jhalli/IdeaP
rojects/jboss/jbossts_trunk/qa/build/jacorb/lib/logkit-1.2.jar:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/jacorb/lib/wrapper-3.1.0.jar:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/jacorb/lib/avalon-framework-4.1.5.jar:build/jacorb/etc/:build/qa/lib/ext/fscontext.jar:build/qa/lib/ext/providerutil.jar:
+COMMAND_LINE_2=/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/lib/jbossjts.jar:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/lib/jbossjts-jacorb.jar:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/etc/:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/lib/ext/jmxri.jar:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/lib/ext/log4j-1.2.14.jar:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/lib/ext/jndi.jar:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/lib/ext/jbossts-common.jar:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/lib/ext/connector-api.jar:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/lib/ext/junit.jar:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/lib/ext/commons-logging-1.1.jar:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/lib/ext/wrapper.jar:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/lib/ext/jta-1_1-classes.zip:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/q!
a/lib/db2jcc_license_cu.jar:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/qa/lib/postgresql-8.3-603.jdbc3.jar:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/qa/lib/TestingFramework.jar:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/qa/lib/db2jcc.jar:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/qa/lib/mysql-connector-java-5.1.6-bin.jar:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/qa/lib/sqljdbc.jar:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/qa/lib/ojdbc14.jar:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/qa/lib/jconn2.jar:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/qa/lib/jboss-server-manager-0.1.1.GA.jar:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/qa/lib/jbossts-jts-qa.jar:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/jacorb/lib/idl.jar:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/jacorb/lib/backport-util-concurrent.jar:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/!
build/jacorb/lib/jacorb.jar:/home/jhalli/IdeaProjects/jboss/jbossts_tr
unk/qa/build/jacorb/lib/antlr-2.7.2.jar:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/jacorb/lib/picocontainer-1.2.jar:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/jacorb/lib/logkit-1.2.jar:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/jacorb/lib/wrapper-3.1.0.jar:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/jacorb/lib/avalon-framework-4.1.5.jar:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/build/jacorb/etc/:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/lib/ext/fscontext.jar:/home/jhalli/IdeaProjects/jboss/jbossts_trunk/qa/lib/ext/providerutil.jar
+COMMAND_LINE_3=-Dqa.debug=true
+COMMAND_LINE_4=-DContext.PROVIDER_URL=file:///tmp
+COMMAND_LINE_5=-DContext.INITIAL_CONTEXT_FACTORY=com.sun.jndi.fscontext.RefFSContextFactory
+COMMAND_LINE_6=-Dperformanceprofilestore.dir=build/qa/perf_profiles/
+COMMAND_LINE_7=-Djdbcprofilestore.dir=build/qa/jdbc_profiles
+COMMAND_LINE_8=-Dmemorytestprofilestore.dir=build/qa/memory_profiles/
+COMMAND_LINE_9=-Dots.server.bindname=value_1
+#
+#
+# taqsk arg properties substitutions
+ORBFLAGS_1=
+ORBFLAGS_2=
+1=value_1
+2=value_2
+3=value_3
+4=value_4
+5=value_5
+6=value_6
+# for JTA set to -local for JTS leave blank
+LOCAL_PARAMETER=
+#LOCAL_PARAMETER=-local
Added: labs/jbosstm/trunk/qa/build-dtfjunit.xml
===================================================================
--- labs/jbosstm/trunk/qa/build-dtfjunit.xml (rev 0)
+++ labs/jbosstm/trunk/qa/build-dtfjunit.xml 2009-05-22 08:21:57 UTC (rev 26679)
@@ -0,0 +1,213 @@
+<!--
+ JBoss, Home of Professional Open Source
+ Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ as indicated by the @author tags.
+ See the copyright.txt in the distribution for a
+ full listing of individual contributors.
+ This copyrighted material is made available to anyone wishing to use,
+ modify, copy, or redistribute it subject to the terms and conditions
+ of the GNU Lesser General Public License, v. 2.1.
+ This program is distributed in the hope that it will be useful, but WITHOUT A
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ You should have received a copy of the GNU Lesser General Public License,
+ v.2.1 along with this distribution; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+ (C) 2009,
+ @author JBoss Inc.
+--><project name="dtfjunit" default="compile" basedir=".">
+
+ <!--
+ Build script for experimental JUnit4 version of local DTF.
+
+ lifecycle:
+
+ # build the JBossTS that's going to be tested
+ cd jbossts; ant clean; ant jbossjts
+ # build the normal DTF testsuite
+ cd qa; ant clean; ant
+ # build the JUnit test code
+ ant -f build-dtfjunit.xml compile
+ # generate the JUnit tests from testdef xml
+ ant -f build-dtfjunit.xml generate
+ # run the JUnit tests
+ ant -f build-dtfjunit.xml runtests
+
+ -->
+
+ <property name="jbossts.home" value="build"/>
+
+ <property name="src" location="tests/src"/>
+ <property name="build" location="tests/build/classes"/>
+
+ <path id="build">
+
+ <pathelement location="ext/junit-4.5.jar"/>
+ <pathelement location="ext/jdom.jar"/>
+
+ <fileset dir="${jbossts.home}/lib">
+ <include name="*.jar"/>
+ </fileset>
+ <fileset dir="${jbossts.home}/lib/ext">
+ <include name="*.jar"/>
+ <include name="*.zip"/>
+ </fileset>
+ <pathelement location="${jbossts.home}/etc"/>
+
+ <pathelement location="${jbossts.home}/qa/lib/TestingFramework.jar"/>
+ </path>
+
+
+ <target name="compile" description="compile the source ">
+ <javac srcdir="${src}" destdir="${build}" classpathref="build" debug="true" fork="true">
+ <include name="**/junit/*.java"/>
+ </javac>
+ </target>
+
+ <target name="compile-generated" description="compile the generated test source ">
+ <javac srcdir="${src}" destdir="${build}" classpathref="build" debug="true" fork="true">
+ <include name="**/junit/generated/*.java"/>
+ </javac>
+ </target>
+
+ <target name="runtests" depends="compile-generated">
+
+ <antcall target="run-onegroup"><param name="tests" value="currenttests01"/></antcall>
+ <!--
+ <antcall target="run-onegroup"><param name="tests" value="jtatests01"/></antcall>
+ <antcall target="run-onegroup"><param name="tests" value="otsserver"/></antcall>
+
+ <antcall target="run-onegroup"><param name="tests" value="rawresources01_1"/></antcall>
+ <antcall target="run-onegroup"><param name="tests" value="rawresources01_2"/></antcall>
+ <antcall target="run-onegroup"><param name="tests" value="rawresources01_3"/></antcall>
+ <antcall target="run-onegroup"><param name="tests" value="rawresources02_1"/></antcall>
+ <antcall target="run-onegroup"><param name="tests" value="rawresources02_2"/></antcall>
+ <antcall target="run-onegroup"><param name="tests" value="rawresources02_3"/></antcall>
+
+ <antcall target="run-onegroup"><param name="tests" value="rawsubtransactionawareresources01_1"/></antcall>
+ <antcall target="run-onegroup"><param name="tests" value="rawsubtransactionawareresources01_2"/></antcall>
+ <antcall target="run-onegroup"><param name="tests" value="rawsubtransactionawareresources01_3"/></antcall>
+ <antcall target="run-onegroup"><param name="tests" value="rawsubtransactionawareresources02_1"/></antcall>
+ <antcall target="run-onegroup"><param name="tests" value="rawsubtransactionawareresources02_2"/></antcall>
+ <antcall target="run-onegroup"><param name="tests" value="rawsubtransactionawareresources02_3"/></antcall>
+
+ <antcall target="run-onegroup"><param name="tests" value="crashrecovery01"/></antcall>
+ <antcall target="run-onegroup"><param name="tests" value="crashrecovery02_1"/></antcall>
+
+ <antcall target="run-onegroup"><param name="tests" value="crashrecovery02_2"/></antcall>
+ <antcall target="run-onegroup"><param name="tests" value="crashrecovery03"/></antcall>
+ <antcall target="run-onegroup"><param name="tests" value="crashrecovery04"/></antcall>
+ <antcall target="run-onegroup"><param name="tests" value="crashrecovery05_1"/></antcall>
+ <antcall target="run-onegroup"><param name="tests" value="crashrecovery05_2"/></antcall>
+ <antcall target="run-onegroup"><param name="tests" value="crashrecovery06"/></antcall>
+ <antcall target="run-onegroup"><param name="tests" value="crashrecovery07"/></antcall>
+ <antcall target="run-onegroup"><param name="tests" value="crashrecovery08"/></antcall>
+ <antcall target="run-onegroup"><param name="tests" value="crashrecovery12"/></antcall>
+
+ <antcall target="run-onegroup"><param name="tests" value="jdbcresources01_oracle_thin_jndi"/></antcall>
+ <antcall target="run-onegroup"><param name="tests" value="jdbcresources02_oracle_thin_jndi"/></antcall>
+ <antcall target="run-onegroup"><param name="tests" value="jdbcresources01_mssqlserver_jndi"/></antcall>
+ <antcall target="run-onegroup"><param name="tests" value="jdbcresources02_mssqlserver_jndi"/></antcall>
+ <antcall target="run-onegroup"><param name="tests" value="jdbcresources01_ibmdb2_jndi"/></antcall>
+ <antcall target="run-onegroup"><param name="tests" value="jdbcresources02_ibmdb2_jndi"/></antcall>
+ <antcall target="run-onegroup"><param name="tests" value="jdbcresources01_pgsql_jndi"/></antcall>
+ <antcall target="run-onegroup"><param name="tests" value="jdbcresources02_pgsql_jndi"/></antcall>
+ <antcall target="run-onegroup"><param name="tests" value="jdbcresources01_mysql_jndi"/></antcall>
+ <antcall target="run-onegroup"><param name="tests" value="jdbcresources02_mysql_jndi"/></antcall>
+ <antcall target="run-onegroup"><param name="tests" value="jdbcresources01_sybase_jndi"/></antcall>
+ <antcall target="run-onegroup"><param name="tests" value="jdbcresources02_sybase_jndi"/></antcall>
+ -->
+ </target>
+
+
+ <target name="run-onegroup" depends="compile">
+ <java classname="org.junit.runner.JUnitCore" fork="true">
+ <classpath>
+ <path refid="build"/>
+ <pathelement location="${build}"/>
+ <pathelement location="."/>
+ </classpath>
+ <arg value="org.jboss.jbossts.qa.junit.generated.TestGroup_${tests}"/>
+ </java>
+ </target>
+
+ <target name="generate" depends="compile">
+
+ <delete dir="${src}/org/jboss/jbossts/qa/junit/generated"/>
+ <mkdir dir="${src}/org/jboss/jbossts/qa/junit/generated"/>
+
+ <antcall target="run-generator"><param name="tests" value="currenttests01"/></antcall>
+ <antcall target="run-generator"><param name="tests" value="jtatests01"/></antcall>
+ <antcall target="run-generator"><param name="tests" value="otsserver"/></antcall>
+ <antcall target="run-generator"><param name="tests" value="rawresources01_1"/></antcall>
+ <antcall target="run-generator"><param name="tests" value="rawresources01_2"/></antcall>
+ <antcall target="run-generator"><param name="tests" value="rawresources01_3"/></antcall>
+ <antcall target="run-generator"><param name="tests" value="rawresources02_1"/></antcall>
+ <antcall target="run-generator"><param name="tests" value="rawresources02_2"/></antcall>
+ <antcall target="run-generator"><param name="tests" value="rawresources02_3"/></antcall>
+ <antcall target="run-generator"><param name="tests" value="rawsubtransactionawareresources01_1"/></antcall>
+ <antcall target="run-generator"><param name="tests" value="rawsubtransactionawareresources01_2"/></antcall>
+ <antcall target="run-generator"><param name="tests" value="rawsubtransactionawareresources01_3"/></antcall>
+ <antcall target="run-generator"><param name="tests" value="rawsubtransactionawareresources02_1"/></antcall>
+ <antcall target="run-generator"><param name="tests" value="rawsubtransactionawareresources02_2"/></antcall>
+ <antcall target="run-generator"><param name="tests" value="rawsubtransactionawareresources02_3"/></antcall>
+ <antcall target="run-generator"><param name="tests" value="crashrecovery01"/></antcall>
+ <antcall target="run-generator"><param name="tests" value="crashrecovery02_1"/></antcall>
+ <antcall target="run-generator"><param name="tests" value="crashrecovery02_2"/></antcall>
+ <antcall target="run-generator"><param name="tests" value="crashrecovery03"/></antcall>
+ <antcall target="run-generator"><param name="tests" value="crashrecovery04"/></antcall>
+ <antcall target="run-generator"><param name="tests" value="crashrecovery05_1"/></antcall>
+ <antcall target="run-generator"><param name="tests" value="crashrecovery05_2"/></antcall>
+ <antcall target="run-generator"><param name="tests" value="crashrecovery06"/></antcall>
+ <antcall target="run-generator"><param name="tests" value="crashrecovery07"/></antcall>
+ <antcall target="run-generator"><param name="tests" value="crashrecovery08"/></antcall>
+ <antcall target="run-generator"><param name="tests" value="crashrecovery09"/></antcall>
+ <antcall target="run-generator"><param name="tests" value="crashrecovery10"/></antcall>
+ <antcall target="run-generator"><param name="tests" value="crashrecovery11-oracle_jndi"/></antcall>
+ <antcall target="run-generator"><param name="tests" value="crashrecovery11-mssqlserver_jndi"/></antcall>
+ <antcall target="run-generator"><param name="tests" value="crashrecovery11-ibmdb2_jndi"/></antcall>
+ <antcall target="run-generator"><param name="tests" value="crashrecovery11-pgsql_jndi"/></antcall>
+ <antcall target="run-generator"><param name="tests" value="crashrecovery11-mysql_jndi"/></antcall>
+ <antcall target="run-generator"><param name="tests" value="crashrecovery11-sybase_jndi"/></antcall>
+ <antcall target="run-generator"><param name="tests" value="crashrecovery12"/></antcall>
+ <antcall target="run-generator"><param name="tests" value="jdbcresources01-oracle_thin_jndi"/></antcall>
+ <antcall target="run-generator"><param name="tests" value="jdbcresources02-oracle_thin_jndi"/></antcall>
+ <antcall target="run-generator"><param name="tests" value="jdbcresources01_mssqlserver_jndi"/></antcall>
+ <antcall target="run-generator"><param name="tests" value="jdbcresources02_mssqlserver_jndi"/></antcall>
+ <antcall target="run-generator"><param name="tests" value="jdbcresources01-ibmdb2_jndi"/></antcall>
+ <antcall target="run-generator"><param name="tests" value="jdbcresources02-ibmdb2_jndi"/></antcall>
+ <antcall target="run-generator"><param name="tests" value="jdbcresources01-pgsql_jndi"/></antcall>
+ <antcall target="run-generator"><param name="tests" value="jdbcresources02-pgsql_jndi"/></antcall>
+ <antcall target="run-generator"><param name="tests" value="jdbcresources01-mysql_jndi"/></antcall>
+ <antcall target="run-generator"><param name="tests" value="jdbcresources02-mysql_jndi"/></antcall>
+ <antcall target="run-generator"><param name="tests" value="jdbcresources01-sybase_jndi"/></antcall>
+ <antcall target="run-generator"><param name="tests" value="jdbcresources02-sybase_jndi"/></antcall>
+ <antcall target="run-generator"><param name="tests" value="jdbclocals01-oracle_jndi"/></antcall>
+ <antcall target="run-generator"><param name="tests" value="jdbclocals01-mssql_jndi"/></antcall>
+ <antcall target="run-generator"><param name="tests" value="jdbclocals01-ibmdb2_jndi"/></antcall>
+ <antcall target="run-generator"><param name="tests" value="jdbclocals01-pgsql_jndi"/></antcall>
+ <antcall target="run-generator"><param name="tests" value="jdbclocals01-mysql_jndi"/></antcall>
+ <antcall target="run-generator"><param name="tests" value="jdbclocals01-sybase_jndi"/></antcall>
+
+ </target>
+
+
+ <target name="run-generator">
+
+ <echo message="Processing ${tests}"/>
+
+ <java classname="org.jboss.jbossts.qa.junit.XML2JUnit" fork="true">
+ <classpath>
+ <path refid="build"/>
+ <pathelement location="${build}"/>
+ </classpath>
+ <arg value="testdefs/jbossts-qa-${tests}-testdefs.xml"/>
+ <arg value="${src}/org/jboss/jbossts/qa/junit/generated"/>
+ </java>
+
+ <echo message="Done test group ${tests}"/>
+ </target>
+
+</project>
\ No newline at end of file
Added: labs/jbosstm/trunk/qa/ext/junit-4.5.jar
===================================================================
(Binary files differ)
Property changes on: labs/jbosstm/trunk/qa/ext/junit-4.5.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: labs/jbosstm/trunk/qa/tests/build-jta.xml
===================================================================
--- labs/jbosstm/trunk/qa/tests/build-jta.xml 2009-05-22 03:44:30 UTC (rev 26678)
+++ labs/jbosstm/trunk/qa/tests/build-jta.xml 2009-05-22 08:21:57 UTC (rev 26679)
@@ -92,6 +92,7 @@
<include name="**/org/jboss/jbossts/qa/astests/**/*.java"/>
<exclude name="**/astests/**"/>
+ <exclude name="**/junit/**"/>
<classpath>
<path refid="jta.classpath"/>
Modified: labs/jbosstm/trunk/qa/tests/build-jts.xml
===================================================================
--- labs/jbosstm/trunk/qa/tests/build-jts.xml 2009-05-22 03:44:30 UTC (rev 26678)
+++ labs/jbosstm/trunk/qa/tests/build-jts.xml 2009-05-22 08:21:57 UTC (rev 26679)
@@ -224,6 +224,7 @@
<exclude name="org/jboss/jbossts/qa/ArjunaCore/Common/ClassPathParserTest.java" />
<exclude name="**/${astest.dir}/**/*.java" />
+ <exclude name="**/junit/**"/>
<classpath>
<path refid="jts.classpath"/>
Added: labs/jbosstm/trunk/qa/tests/src/org/jboss/jbossts/qa/junit/Task.java
===================================================================
--- labs/jbosstm/trunk/qa/tests/src/org/jboss/jbossts/qa/junit/Task.java (rev 0)
+++ labs/jbosstm/trunk/qa/tests/src/org/jboss/jbossts/qa/junit/Task.java 2009-05-22 08:21:57 UTC (rev 26679)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2009,
+ * @author JBoss Inc.
+ */
+package org.jboss.jbossts.qa.junit;
+
+/**
+ * Interface for a executable test element i.e. process.
+ *
+ * @author Jonathan Halliday (jonathan.halliday at redhat.com) 2009-05
+ */
+public interface Task
+{
+ public enum TaskType { EXPECT_PASS_FAIL, EXPECT_READY }
+
+ public void perform();
+
+ public void perform(String... params);
+
+ public void start();
+
+ public void start(String... params);
+
+ public void waitFor();
+
+ public void terminate();
+}
Added: labs/jbosstm/trunk/qa/tests/src/org/jboss/jbossts/qa/junit/TaskImpl.java
===================================================================
--- labs/jbosstm/trunk/qa/tests/src/org/jboss/jbossts/qa/junit/TaskImpl.java (rev 0)
+++ labs/jbosstm/trunk/qa/tests/src/org/jboss/jbossts/qa/junit/TaskImpl.java 2009-05-22 08:21:57 UTC (rev 26679)
@@ -0,0 +1,354 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2009,
+ * @author JBoss Inc.
+ */
+package org.jboss.jbossts.qa.junit;
+
+import org.junit.Assert;
+
+import java.util.*;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.io.FileInputStream;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+
+/**
+ * Implementation of the Task abstraction, essentially a test aware wrapper around a spawned process.
+ *
+ * @author Jonathan Halliday (jonathan.halliday at redhat.com) 2009-05
+ */
+public class TaskImpl implements Task
+{
+ private final static String PROPERTIES_FILE = "TaskImpl.properties";
+
+ private static Properties properties;
+ static {
+ try {
+ properties = new Properties();
+ properties.load(new FileInputStream(PROPERTIES_FILE));
+ } catch(Exception e) {
+ throw new ExceptionInInitializerError(e);
+ }
+ }
+
+ private static final Set<TaskImpl> tasks = new HashSet();
+
+ //////////////////
+
+ private Class clazz;
+ private TaskType type;
+ private boolean isRunning;
+ private boolean isDone;
+ private boolean isChecked;
+ Process process;
+ TaskReaderThread taskReaderThread;
+
+ TaskImpl(Class clazz, Task.TaskType type)
+ {
+ if(clazz == null || type == null) {
+ throw new ExceptionInInitializerError("TaskImpl()<ctor> params may not be null");
+ }
+
+ this.clazz = clazz;
+ this.type = type;
+ }
+
+ public void perform() {
+ perform((String[])null);
+ }
+
+ public void perform(String... params)
+ {
+ if(type != TaskType.EXPECT_PASS_FAIL) {
+ throw new RuntimeException("can't perform an EXPECT_READY task");
+ }
+
+ if(isDone || isChecked || isRunning) {
+ throw new RuntimeException("invalid state");
+ }
+
+ String[] command = assembleCommand(clazz.getCanonicalName(), params);
+
+ Assert.assertTrue(tasks.add(this));
+/*
+ int i = 0;
+ for(String string : command) {
+ System.out.println("["+i+"] "+string);
+ i++;
+ }
+*/
+ System.out.println(clazz.getName());
+
+ boolean printedPassed = false;
+ boolean printedFailed = false;
+ try {
+ process = Runtime.getRuntime().exec(command);
+ BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
+ String line;
+ while((line = bufferedReader.readLine()) != null) {
+ if("Passed".equals(line)) {
+ printedPassed = true;
+ }
+ if("Failed".equals(line)) {
+ printedFailed = true;
+ }
+ System.out.println("Line: "+line);
+ }
+
+ process.waitFor();
+ Assert.assertEquals(0, process.exitValue());
+
+ } catch (Exception e) {
+ Assert.fail(e.toString());
+ }
+
+
+ Assert.assertTrue(tasks.remove(this));
+
+ Assert.assertFalse(printedFailed);
+ Assert.assertTrue(printedPassed);
+
+ isDone = true;
+ isChecked = true;
+ }
+
+ public void start()
+ {
+ start((String[])null);
+ }
+
+ public void start(String... params)
+ {
+ if(isDone || isChecked || isRunning) {
+ throw new RuntimeException("invalid state");
+ }
+
+ String[] command = assembleCommand(clazz.getCanonicalName(), params);
+/*
+ int i = 0;
+ for(String string : command) {
+ System.out.println(string+" ");
+ //System.out.println("["+i+"] "+string);
+ i++;
+ }
+*/
+ Assert.assertTrue(tasks.add(this));
+
+ System.out.println(clazz.getName());
+
+ try {
+ process = Runtime.getRuntime().exec(command);
+
+ taskReaderThread = new TaskReaderThread( new BufferedReader(new InputStreamReader(process.getInputStream())) );
+ taskReaderThread.start();
+
+ // TODO deal with it printing Failed
+
+ TaskReaderThread stdErr = new TaskReaderThread( new BufferedReader(new InputStreamReader(process.getErrorStream())) );
+ stdErr.start(); // if we don't consume it the pipe fills up and the process blocks.
+
+ if(type.equals(TaskType.EXPECT_READY)) {
+ taskReaderThread.blockingWaitForReady();
+ System.out.println("got ready");
+ }
+
+ } catch (Exception e) {
+ Assert.fail(e.toString());
+ }
+
+ isRunning = true;
+ }
+
+ public void waitFor()
+ {
+ if(isDone || isChecked || !isRunning) {
+ throw new RuntimeException("invalid state");
+ }
+
+ Assert.assertTrue(tasks.remove(this));
+
+ try {
+ process.waitFor();
+ } catch(Exception e) {
+ Assert.fail(e.toString());
+ }
+ Assert.assertEquals(0, process.exitValue());
+
+ taskReaderThread.checkIsFinishedCleanly();
+
+ if(type.equals(TaskType.EXPECT_PASS_FAIL)) {
+ taskReaderThread.checkPassFail();
+ } else {
+ Assert.fail("should not waitFor EXPECT_READY tasks (use terminate)");
+ }
+
+ isRunning = false;
+ isDone = true;
+ isChecked = true;
+ }
+
+ public void terminate()
+ {
+ if(isDone || isChecked || !isRunning) {
+ throw new RuntimeException("invalid state");
+ }
+
+ Assert.assertTrue(tasks.remove(this));
+
+ try {
+ process.destroy();
+ } catch(Exception e) {
+ Assert.fail(e.toString());
+ }
+
+
+ if(!type.equals(TaskType.EXPECT_READY)) {
+ Assert.fail("Should not terminate EXPECT_PASS_FAIL tasks (use waitFor)");
+ }
+
+ isDone = true;
+ isChecked = true;
+ }
+
+ /////////////////////////
+
+ public static void assertNoTasks() {
+ Assert.assertEquals(0, tasks.size());
+ }
+
+ private String[] assembleCommand(String classname, String[] params) {
+ params = substituteParams(params);
+
+ int i = 0;
+ boolean done = false;
+ List<String> list = new LinkedList();
+ while(!done) {
+ String element = properties.getProperty("COMMAND_LINE_"+i);
+ if(element == null) {
+ done = true;
+ } else {
+ list.add(element);
+ i++;
+ }
+ }
+
+ list.add(classname);
+
+ if(params != null) {
+ for(String param : params) {
+ list.add((param));
+ }
+ }
+
+ return list.toArray(new String[list.size()]);
+ }
+
+ private String[] substituteParams(String[] params) {
+ if(params == null || params.length == 0) {
+ return null;
+ }
+
+ String[] result = new String[params.length];
+
+ for(int i = 0; i < params.length; i++) {
+ if(params[i].startsWith("$(")) {
+ String key = params[i].substring(2, params[i].length()-1);
+ String value = properties.getProperty(key);
+ Assert.assertNotNull("Properties file missing key "+key, value);
+ result[i] = value;
+ } else {
+ result[i] = params[i];
+ }
+ }
+
+ return result;
+ }
+
+ private class TaskReaderThread extends Thread {
+
+ BufferedReader bufferedReader;
+
+ private final AtomicBoolean printedReady = new AtomicBoolean(false);
+ private final AtomicBoolean isFinishedCleanly = new AtomicBoolean(false);
+ private volatile boolean printedPassed = false;
+ private volatile boolean printedFailed = false;
+
+ public void blockingWaitForReady() {
+ synchronized (printedReady) {
+ while(!printedReady.get()) {
+ try {
+ printedReady.wait();
+ } catch (InterruptedException e) {
+ // do nothing
+ }
+ }
+ }
+ }
+
+ public void checkIsFinishedCleanly() {
+
+ try {
+ this.join();
+ } catch(InterruptedException e) {
+ // do nothing
+ }
+
+ Assert.assertTrue(isFinishedCleanly.get());
+ Assert.assertFalse(printedFailed);
+ }
+
+ public void checkPassFail() {
+ Assert.assertFalse(printedFailed);
+ Assert.assertTrue(printedPassed);
+ }
+
+ public TaskReaderThread(BufferedReader bufferedReader) {
+ this.bufferedReader = bufferedReader;
+ }
+
+ public void run() {
+ try {
+ String line;
+ while((line = bufferedReader.readLine()) != null) {
+ if("Ready".equals(line)) {
+ synchronized (printedReady) {
+ printedReady.set(true);
+ printedReady.notify();
+ }
+ }
+ if("Passed".equals(line)) {
+ printedPassed = true;
+ }
+ if("Failed".equals(line)) {
+ printedFailed = true;
+ }
+ System.out.println("Line: "+line);
+ }
+
+ synchronized (isFinishedCleanly) {
+ isFinishedCleanly.set(true);
+ isFinishedCleanly.notify();
+ }
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+}
\ No newline at end of file
Added: labs/jbosstm/trunk/qa/tests/src/org/jboss/jbossts/qa/junit/TestGroupBase.java
===================================================================
--- labs/jbosstm/trunk/qa/tests/src/org/jboss/jbossts/qa/junit/TestGroupBase.java (rev 0)
+++ labs/jbosstm/trunk/qa/tests/src/org/jboss/jbossts/qa/junit/TestGroupBase.java 2009-05-22 08:21:57 UTC (rev 26679)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2009,
+ * @author JBoss Inc.
+ */
+package org.jboss.jbossts.qa.junit;
+
+import org.junit.Before;
+import org.junit.After;
+
+/**
+ * Base class from which all autogenerated test suites inherit common behaviour.
+ *
+ * @author Jonathan Halliday (jonathan.halliday at redhat.com) 2009-05
+ */
+
+public class TestGroupBase {
+
+ @Before public void setUp()
+ {
+ TaskImpl.assertNoTasks();
+ // TODO EmptyObjectStore
+ }
+
+ @After public void tearDown()
+ {
+ TaskImpl.assertNoTasks();
+ }
+
+ public Task createTask(Class clazz, Task.TaskType taskType) {
+ return new TaskImpl(clazz, taskType);
+ }
+}
Added: labs/jbosstm/trunk/qa/tests/src/org/jboss/jbossts/qa/junit/XML2JUnit.java
===================================================================
--- labs/jbosstm/trunk/qa/tests/src/org/jboss/jbossts/qa/junit/XML2JUnit.java (rev 0)
+++ labs/jbosstm/trunk/qa/tests/src/org/jboss/jbossts/qa/junit/XML2JUnit.java 2009-05-22 08:21:57 UTC (rev 26679)
@@ -0,0 +1,344 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2009,
+ * @author JBoss Inc.
+ */
+package org.jboss.jbossts.qa.junit;
+
+import org.jboss.dtf.testframework.coordinator2.TestDefinitionRepository;
+import org.jboss.dtf.testframework.coordinator2.TestDefinition;
+import org.jboss.dtf.testframework.coordinator2.TaskDefinition;
+import org.jboss.dtf.testframework.coordinator2.TaskDefinitionRepository;
+import org.jboss.dtf.testframework.coordinator.Action;
+
+import java.net.URL;
+import java.io.File;
+import java.io.FileWriter;
+import java.util.*;
+
+/**
+ * Utility class that reads DTF -testdef.xml input and writes equivalent JUnit4 tests in .java source format.
+ *
+ * Usage: java org.jboss.dtf.testframework.junit.XML2JUnit <inputfile> <outputdir>
+ * e.g. java org.jboss.dtf.testframework.junit.XML2JUnit mytests-testdefs-xml /My/Tests/Dir
+ *
+ * @author Jonathan Halliday (jonathan.halliday at redhat.com) 2009-05
+ */
+public class XML2JUnit
+{
+ public static void main(String[] args) throws Exception {
+ String testdefsFile = args[0];
+ TestDefinitionRepository testDefinitionRepository = new TestDefinitionRepository(new URL("file://"+(new File(testdefsFile).getAbsolutePath())));
+ TaskDefinitionRepository taskDefinitionRepository = new TaskDefinitionRepository(new URL("file://"+(new File(testdefsFile).getAbsolutePath())));
+
+ XML2JUnit instance = new XML2JUnit(testDefinitionRepository, taskDefinitionRepository);
+
+ String classname = instance.generateHeader();
+
+ instance.generateLifecycle();
+
+ instance.generateTests();
+ instance.generateFooter();
+
+ FileWriter fileWriter = new FileWriter(args[1]+File.separator+classname+".java");
+ fileWriter.write(instance.getBuffer());
+ fileWriter.close();
+ }
+
+
+ TestDefinitionRepository testDefinitionRepository = null;
+ TaskDefinitionRepository taskDefinitionRepository = null;
+ List<TestDefinition> testDefs = null;
+ StringBuilder buffer = null;
+ int nameCount = 0;
+
+ public XML2JUnit(TestDefinitionRepository testDefinitionRepository, TaskDefinitionRepository taskDefinitionRepository) {
+ this.testDefinitionRepository = testDefinitionRepository;
+ this.taskDefinitionRepository = taskDefinitionRepository;
+ this.buffer = new StringBuilder(512*1024);
+ }
+
+ public String getBuffer() {
+ return buffer.toString();
+ }
+
+ public String generateHeader() {
+ Map<String, TestDefinition> testIDs2testDefs = testDefinitionRepository.getTestDefinitionsMap();
+ testDefs = new ArrayList(testIDs2testDefs.values());
+ Collections.sort(testDefs, new TestDefinitionComparator());
+
+ String name = testDefs.get(0).getId().replace("-", "_").toLowerCase();
+ name = name.substring(0, name.lastIndexOf("_"));
+ name = "TestGroup_"+name;
+
+ buffer.append("\n");
+ buffer.append("package org.jboss.jbossts.qa.junit.generated;\n");
+ buffer.append("\n");
+ buffer.append("import org.jboss.jbossts.qa.junit.*;\n");
+ buffer.append("import org.junit.*;\n");
+ buffer.append("\n");
+ buffer.append("// Automatically generated by XML2JUnit\n");
+ buffer.append("public class "+name+" extends TestGroupBase\n");
+ buffer.append("{\n");
+
+ return name;
+ }
+
+ public void generateFooter() {
+ buffer.append("}");
+ }
+
+ public void generateTests() throws Exception {
+ for(TestDefinition testDefinition : testDefs) {
+ buffer.append("\t at Test public void "+testDefinition.getId().replace("-", "_")+"()\n");
+ buffer.append("\t{\n");
+ generateTest(testDefinition);
+ buffer.append("\t}\n\n");
+
+ }
+ }
+
+ private static class TestDefinitionComparator implements Comparator<TestDefinition>
+ {
+ public int compare(TestDefinition o1, TestDefinition o2)
+ {
+ return o1.getId().compareTo(o2.getId());
+ }
+ }
+
+ private TaskDefinition getTaskDef(Action action, TestDefinition testDefinition) throws Exception {
+ TaskDefinition taskDefinition = null;
+ if(action.getType() == Action.PERFORM_TASK || action.getType() == Action.START_TASK) {
+ String groupId = testDefinition.getGroupId();
+ String taskIdToPerform = action.getAssociatedTaskId();
+ taskDefinition = taskDefinitionRepository.getTaskDefinition(groupId, taskIdToPerform);
+ if (taskDefinition == null)
+ {
+ taskDefinition = taskDefinitionRepository.getTaskDefinition(taskIdToPerform);
+ }
+ }
+ return taskDefinition;
+ }
+
+ // identify required contents of setUp and tearDown
+ public void generateLifecycle() throws Exception {
+
+ // EmptyObjectStore is in the test base class, don't generate for it
+ for(TestDefinition testDefinition : testDefs) {
+ ArrayList<Action> actionList = testDefinition.getActionList();
+ for(Action action : actionList) {
+ TaskDefinition taskDefinition = getTaskDef(actionList.get(0), testDefinition);
+ if(taskDefinition == null || !taskDefinition.getClassName().equals("org.jboss.jbossts.qa.Utils.EmptyObjectStore")) {
+ throw new IllegalArgumentException("Test does not start with EmptyObjectStore");
+ }
+ }
+ actionList.remove(0);
+ }
+
+ int startingBufferPosition = buffer.length();
+
+ buffer.append("\n\t at Before public void setUp()\n");
+ buffer.append("\t{\n");
+ buffer.append("\t\tsuper.setUp();\n");
+
+ List<Action> outstandingActions = generateCommonTasks(false, null); // setUp method
+
+ if(outstandingActions.size() > 0) {
+ generateLocalVariables(startingBufferPosition, outstandingActions);
+ }
+
+ buffer.append("\t}\n\n");
+
+ buffer.append("\t at After public void tearDown()\n");
+ buffer.append("\t{\n");
+
+ generateCommonTasks(true, outstandingActions); // tearDown method
+
+ buffer.append("\t\tsuper.tearDown();\n");
+ buffer.append("\t}\n\n");
+ }
+
+ private void generateLocalVariables(int startingBufferPosition, List<Action> actions) throws Exception {
+ for(Action action : actions) {
+ buffer.insert(startingBufferPosition, "\tprotected Task "+action.getAssociatedRuntimeTaskId()+" = null;\n");
+ }
+ }
+
+ private List<Action> generateCommonTasks(boolean fromEnd, List<Action> terminationActions) throws Exception {
+
+ if(terminationActions != null) {
+ for(Action action : terminationActions) {
+ generateTask(action,testDefs.get(0), false);
+ }
+ }
+
+ TaskDefinition candidateCommonTask;
+ List<Action> outstandingActions = new LinkedList<Action>();
+ do {
+ candidateCommonTask = null;
+ for(TestDefinition testDefinition : testDefs) {
+ int index = fromEnd ? (testDefinition.getActionList().size()-1) : 0;
+ Action action = (Action)testDefinition.getActionList().get(index);
+ TaskDefinition taskDef = getTaskDef(action, testDefinition);
+ if(taskDef == null) {
+ break;
+ }
+ if(candidateCommonTask == null
+ && taskDef.getClassName().indexOf(".Server") == -1
+ && taskDef.getClassName().indexOf(".Client") == -1) {
+ candidateCommonTask = taskDef;
+ } else if(candidateCommonTask == null) {
+ continue;
+ } else if(taskDef.getClassName().equals(candidateCommonTask.getClassName())
+ && taskDef.getParameters().equals(candidateCommonTask.getParameters())) {
+ continue;
+ } else {
+ candidateCommonTask = null;
+ break;
+ }
+ }
+ if(candidateCommonTask != null) {
+
+ TestDefinition testDef = testDefs.get(0);
+ int index = fromEnd ? (testDef.getActionList().size()-1) : 0;
+ Action action = (Action)testDef.getActionList().get(index);
+ boolean isSetup = !fromEnd;
+ generateTask(action, testDef, isSetup);
+
+ for(TestDefinition testDefinition : testDefs) {
+ index = fromEnd ? (testDefinition.getActionList().size()-1) : 0;
+ testDefinition.getActionList().remove(index);
+ }
+
+ if(!fromEnd && action.getType() == Action.START_TASK) {
+
+ boolean actionAdded = false;
+ for(TestDefinition testDefinition : testDefs) {
+ ArrayList<Action> actionList = testDefinition.getActionList();
+ Iterator<Action> actionIter = actionList.iterator();
+ while(actionIter.hasNext()) {
+ Action candidateTerminatorAction = actionIter.next();
+ if(candidateTerminatorAction.getAssociatedRuntimeTaskId().equals(action.getAssociatedRuntimeTaskId())
+ && candidateTerminatorAction.getType() == Action.TERMINATE_TASK) {
+ actionIter.remove();
+ if(!actionAdded) {
+ outstandingActions.add(candidateTerminatorAction);
+ actionAdded = true;
+ }
+ break;
+ }
+ }
+ }
+ }
+ }
+ } while (candidateCommonTask != null);
+
+ return outstandingActions;
+ }
+
+ public String[] filterParams(String[] params) {
+ List<String> filteredParams = new ArrayList<String>(params.length);
+ for(String param : params) {
+ if("$(ORBFLAGS_1)".equals(param)
+ || "$(ORBFLAGS_2)".equals(param)) {
+ continue;
+ }
+ filteredParams.add(param);
+ }
+ return filteredParams.toArray(new String[filteredParams.size()]);
+ }
+
+ public void generateTask(Action action, TestDefinition testDefinition, boolean isSetup) throws Exception {
+
+ TaskDefinition taskDefinition = getTaskDef(action, testDefinition);
+
+ switch(action.getType()) {
+ case Action.PERFORM_TASK:
+ String name = (action.getAssociatedRuntimeTaskId() == null ? ("task"+(nameCount++)) : action.getAssociatedRuntimeTaskId());
+ buffer.append("\t\tTask "+name+" = createTask("+taskDefinition.getClassName()+".class, Task.TaskType."+taskDefinition.getTypeText()+");\n");
+ if(action.getParameterList().length != 0) {
+ buffer.append("\t\t"+name+".perform("); // new String[] {
+
+ String[] params = filterParams(action.getParameterList());
+ int length = params.length;
+ for(int i = 0; i < length; i++) {
+ String param = params[i];
+ buffer.append("\""+param+"\"");
+ if(i != length-1) {
+ buffer.append(", ");
+ }
+ }
+ buffer.append(");\n"); // }
+ } else {
+ buffer.append("\t\t"+name+".perform();\n");
+ }
+ break;
+ case Action.START_TASK:
+ if(isSetup) {
+ buffer.append("\t\t"); // use local variable, don't declate a new one
+ } else {
+ buffer.append("\t\tTask ");
+ }
+ buffer.append(action.getAssociatedRuntimeTaskId()+" = createTask("+taskDefinition.getClassName()+".class, Task.TaskType."+taskDefinition.getTypeText()+");\n");
+ if(action.getParameterList().length != 0) {
+ buffer.append("\t\t"+action.getAssociatedRuntimeTaskId()+".start("); // new String[] {
+
+ String[] params = filterParams(action.getParameterList());
+ int length = params.length;
+ for(int i = 0; i < length; i++) {
+ String param = params[i];
+ buffer.append("\""+param+"\"");
+ if(i != length-1) {
+ buffer.append(", ");
+ }
+ }
+ buffer.append(");\n"); // }
+ } else {
+ buffer.append("\t\t"+action.getAssociatedRuntimeTaskId()+".start();\n");
+ }
+ break;
+ case Action.TERMINATE_TASK:
+ buffer.append("\t\t"+action.getAssociatedRuntimeTaskId()+".terminate();\n");
+ break;
+ case Action.WAIT_FOR_TASK:
+ buffer.append("\t\t"+action.getAssociatedRuntimeTaskId()+".waitFor();\n");
+ break;
+ default:
+ throw new IllegalArgumentException("Unknown Action type "+action.getType());
+ }
+ }
+
+ public void generateTest(TestDefinition testDefinition) throws Exception {
+
+ if(testDefinition == null) {
+ throw new IllegalArgumentException("testDefinition must not be null!");
+ }
+
+ if(testDefinition.getNumberOfNodesRequired() != 1) {
+ System.err.println("Unsupported node count "+testDefinition.getNumberOfNodesRequired()+" for test "+testDefinition.getDescription()+", skipping it");
+ return;
+ }
+
+ ArrayList<Action> actionList = testDefinition.getActionList();
+
+ for(Action action : actionList) {
+ generateTask(action, testDefinition, false);
+ }
+ }
+}
+
More information about the jboss-svn-commits
mailing list