[jboss-svn-commits] JBL Code SVN: r36836 - in labs/jbosstm/trunk/qa: tests/src/org/jboss/jbossts/qa and 2 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Mar 17 07:15:25 EDT 2011


Author: jhalliday
Date: 2011-03-17 07:15:25 -0400 (Thu, 17 Mar 2011)
New Revision: 36836

Added:
   labs/jbosstm/trunk/qa/tests/src/org/jboss/jbossts/qa/DefaultTimeout/
   labs/jbosstm/trunk/qa/tests/src/org/jboss/jbossts/qa/DefaultTimeout/Test01.java
   labs/jbosstm/trunk/qa/tests/src/org/jboss/jbossts/qa/DefaultTimeout/Test02.java
   labs/jbosstm/trunk/qa/tests/src/org/jboss/jbossts/qa/junit/testgroup/TestGroup_defaulttimeout.java
Modified:
   labs/jbosstm/trunk/qa/run-tests.xml
Log:
Add default timeout tests. JBTM-112


Modified: labs/jbosstm/trunk/qa/run-tests.xml
===================================================================
--- labs/jbosstm/trunk/qa/run-tests.xml	2011-03-16 22:01:56 UTC (rev 36835)
+++ labs/jbosstm/trunk/qa/run-tests.xml	2011-03-17 11:15:25 UTC (rev 36836)
@@ -45,7 +45,8 @@
     <target name="scratch">
 
         <antcall target="junit-tests">
-            <param name="tests" value="jtsremote"/>
+            <param name="tests" value="defaulttimeout"/>
+            <!--<param name="additional.elements" value="org.jboss.jbossts.qa.junit.ExecutionWrapper"/>-->
         </antcall>
 
     </target>
@@ -111,6 +112,8 @@
         <antcall target="junit-tests"><param name="tests" value="otsserver"/></antcall>
         <!-- jtsremote : 9 tests, 3 minutes -->
         <antcall target="junit-tests"><param name="tests" value="jtsremote"/></antcall>
+        <!-- defaulttimeout : 2 tests, 2 minutes -->
+        <antcall target="junit-tests"><param name="tests" value="defaulttimeout"/></antcall>
 
 
         <!-- rawresources01_1 : 6 tests, 1 minute -->
@@ -352,6 +355,7 @@
         <property name="names" value=".*"/>
 
         <!-- pass in param to override this. By default, the TaskImpl.properties are not modified -->
+        <!--<property name="additional.elements" value="org.jboss.jbossts.qa.junit.ExecutionWrapper"/>-->
         <property name="additional.elements" value=""/>
 
         <!-- TODO support JTA mode testing of JTS .jar files? -
@@ -361,7 +365,7 @@
 
         <!-- this runs forked because the product config file it uses has relative paths in it, so we need to guarantee
             the working dir is the same as the location of this script. -->
-        <junit printsummary="yes" haltonfailure="yes" fork="true" dir="${basedir}">
+        <junit printsummary="yes" haltonfailure="no" fork="true" dir="${basedir}" showoutput="false">
             <classpath>
 
                 <!--
@@ -401,7 +405,7 @@
             <sysproperty key="additional.elements" value="${additional.elements}"/>
 
             <!--<jvmarg value="-Xdebug"/>-->
-            <!--<jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5006"/>-->
+            <!--<jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5007"/>-->
 
         </junit>
 

Added: labs/jbosstm/trunk/qa/tests/src/org/jboss/jbossts/qa/DefaultTimeout/Test01.java
===================================================================
--- labs/jbosstm/trunk/qa/tests/src/org/jboss/jbossts/qa/DefaultTimeout/Test01.java	                        (rev 0)
+++ labs/jbosstm/trunk/qa/tests/src/org/jboss/jbossts/qa/DefaultTimeout/Test01.java	2011-03-17 11:15:25 UTC (rev 36836)
@@ -0,0 +1,96 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and/or its affiliates,
+ * 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) 2011,
+ * @author JBoss, by Red Hat.
+ */
+package org.jboss.jbossts.qa.DefaultTimeout;
+
+import com.arjuna.ats.arjuna.common.arjPropertyManager;
+
+import org.jboss.jbossts.qa.Utils.OAInterface;
+import org.jboss.jbossts.qa.Utils.ORBInterface;
+
+import javax.transaction.Status;
+import javax.transaction.TransactionManager;
+import javax.transaction.RollbackException;
+
+/**
+ * Test default timeout causes rollback by the reaper.
+ * Commit attempt after timeout should fail with RollbackException.
+ *
+ * Note: build time unit tests jta|jtax SimpleTest|RollbackTest are similar
+ * but use custom (short) timeout value so as not to delay the build.
+ *
+ * @author Jonathan Halliday (jonathan.halliday at redhat.com), 2011-03
+ */
+public class Test01
+{
+	public static void main(String[] args)
+	{
+		try
+		{
+			ORBInterface.initORB(args, null);
+			OAInterface.initOA();
+
+			boolean correct = true;
+
+            TransactionManager transactionManager = com.arjuna.ats.jta.TransactionManager.transactionManager();
+
+            transactionManager.begin();
+
+			try
+			{
+                Thread.sleep( (1000*arjPropertyManager.getCoordinatorEnvironmentBean().getDefaultTimeout()) + 1000 );
+
+                correct = (transactionManager.getStatus() == Status.STATUS_ROLLEDBACK);
+
+				transactionManager.commit();
+				correct = false;
+			}
+			catch (RollbackException rollbackException)
+			{
+			}
+
+			if (correct)
+			{
+				System.out.println("Passed");
+			}
+			else
+			{
+				System.out.println("Failed");
+			}
+		}
+		catch (Exception exception)
+		{
+			System.out.println("Failed");
+			System.err.println("Test01.main: " + exception);
+			exception.printStackTrace(System.err);
+		}
+
+		try
+		{
+			OAInterface.shutdownOA();
+			ORBInterface.shutdownORB();
+		}
+		catch (Exception exception)
+		{
+			System.err.println("Test01.main: " + exception);
+			exception.printStackTrace(System.err);
+		}
+	}
+}
\ No newline at end of file

Added: labs/jbosstm/trunk/qa/tests/src/org/jboss/jbossts/qa/DefaultTimeout/Test02.java
===================================================================
--- labs/jbosstm/trunk/qa/tests/src/org/jboss/jbossts/qa/DefaultTimeout/Test02.java	                        (rev 0)
+++ labs/jbosstm/trunk/qa/tests/src/org/jboss/jbossts/qa/DefaultTimeout/Test02.java	2011-03-17 11:15:25 UTC (rev 36836)
@@ -0,0 +1,97 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and/or its affiliates,
+ * 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) 2011,
+ * @author JBoss, by Red Hat.
+ */
+package org.jboss.jbossts.qa.DefaultTimeout;
+
+import com.arjuna.ats.arjuna.common.arjPropertyManager;
+
+import org.jboss.jbossts.qa.Utils.OAInterface;
+import org.jboss.jbossts.qa.Utils.ORBInterface;
+
+import javax.transaction.Status;
+import javax.transaction.TransactionManager;
+
+/**
+ * Test default timeout causes rollback by the reaper.
+ *
+ * Rollback attempt after timeout should work ok, as it's a nullop on
+ * tx that is already rolled back.
+ * 
+ * Note: build time unit tests jta|jtax SimpleTest|RollbackTest are similar
+ * but use custom (short) timeout value so as not to delay the build.
+ *
+ * @author Jonathan Halliday (jonathan.halliday at redhat.com), 2011-03
+ */
+public class Test02
+{
+	public static void main(String[] args)
+	{
+		try
+		{
+			ORBInterface.initORB(args, null);
+			OAInterface.initOA();
+
+			boolean correct = true;
+
+            TransactionManager transactionManager = com.arjuna.ats.jta.TransactionManager.transactionManager();
+
+            transactionManager.begin();
+
+			try
+			{
+                Thread.sleep( (1000*arjPropertyManager.getCoordinatorEnvironmentBean().getDefaultTimeout()) + 1000 );
+
+                correct = (transactionManager.getStatus() == Status.STATUS_ROLLEDBACK);
+
+				transactionManager.rollback();
+			}
+			catch (Exception exception)
+			{
+                correct = false;
+			}
+
+			if (correct)
+			{
+				System.out.println("Passed");
+			}
+			else
+			{
+				System.out.println("Failed");
+			}
+		}
+		catch (Exception exception)
+		{
+			System.out.println("Failed");
+			System.err.println("Test01.main: " + exception);
+			exception.printStackTrace(System.err);
+		}
+
+		try
+		{
+			OAInterface.shutdownOA();
+			ORBInterface.shutdownORB();
+		}
+		catch (Exception exception)
+		{
+			System.err.println("Test01.main: " + exception);
+			exception.printStackTrace(System.err);
+		}
+	}
+}
\ No newline at end of file

Added: labs/jbosstm/trunk/qa/tests/src/org/jboss/jbossts/qa/junit/testgroup/TestGroup_defaulttimeout.java
===================================================================
--- labs/jbosstm/trunk/qa/tests/src/org/jboss/jbossts/qa/junit/testgroup/TestGroup_defaulttimeout.java	                        (rev 0)
+++ labs/jbosstm/trunk/qa/tests/src/org/jboss/jbossts/qa/junit/testgroup/TestGroup_defaulttimeout.java	2011-03-17 11:15:25 UTC (rev 36836)
@@ -0,0 +1,23 @@
+package org.jboss.jbossts.qa.junit.testgroup;
+
+import org.jboss.jbossts.qa.junit.TestGroupBase;
+
+import org.jboss.jbossts.qa.junit.*;
+import org.junit.*;
+
+public class TestGroup_defaulttimeout extends TestGroupBase
+{
+    public TestGroup_defaulttimeout() {
+        isRecoveryManagerNeeded = false;
+    }
+
+	@Test public void defaulttimeout_Test01()
+	{
+        startAndWaitForClient(org.jboss.jbossts.qa.DefaultTimeout.Test01.class);
+    }
+
+	@Test public void defaulttimeout_Test02()
+	{
+        startAndWaitForClient(org.jboss.jbossts.qa.DefaultTimeout.Test02.class);
+    }
+}
\ No newline at end of file



More information about the jboss-svn-commits mailing list