[jboss-svn-commits] JBL Code SVN: r32169 - in labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta: basic and 4 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Mar 22 11:48:35 EDT 2010
Author: mark.little at jboss.com
Date: 2010-03-22 11:48:35 -0400 (Mon, 22 Mar 2010)
New Revision: 32169
Added:
labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/jca/XATerminatorUnitTest.java
labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/utils/
labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/utils/UtilsUnitTest.java
Removed:
labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/basic/UtilsUnitTest.java
Modified:
labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/common/SampleOnePhaseResource.java
labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/xa/OnePhaseUnitTest.java
Log:
https://jira.jboss.org/jira/browse/JBTM-712
Deleted: labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/basic/UtilsUnitTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/basic/UtilsUnitTest.java 2010-03-22 13:33:35 UTC (rev 32168)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/basic/UtilsUnitTest.java 2010-03-22 15:48:35 UTC (rev 32169)
@@ -1,174 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, 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) 2005-2010,
- * @author JBoss Inc.
- */
-
-package com.hp.mwtests.ts.jta.basic;
-
-import javax.transaction.Status;
-import javax.transaction.xa.XAException;
-
-import org.junit.Test;
-
-import com.arjuna.ats.arjuna.common.Uid;
-import com.arjuna.ats.arjuna.coordinator.ActionStatus;
-import com.arjuna.ats.internal.jta.utils.arjunacore.StatusConverter;
-import com.arjuna.ats.internal.jta.xa.XID;
-import com.arjuna.ats.jta.utils.JTAHelper;
-import com.arjuna.ats.jta.utils.XAHelper;
-import com.arjuna.ats.jta.xa.XidImple;
-
-import static org.junit.Assert.*;
-
-public class UtilsUnitTest
-{
- @Test
- public void testJTAHelper () throws Exception
- {
- assertEquals(JTAHelper.stringForm(javax.transaction.Status.STATUS_ACTIVE), "javax.transaction.Status.STATUS_ACTIVE");
- assertEquals(JTAHelper.stringForm(javax.transaction.Status.STATUS_COMMITTED), "javax.transaction.Status.STATUS_COMMITTED");
- assertEquals(JTAHelper.stringForm(javax.transaction.Status.STATUS_MARKED_ROLLBACK), "javax.transaction.Status.STATUS_MARKED_ROLLBACK");
- assertEquals(JTAHelper.stringForm(javax.transaction.Status.STATUS_NO_TRANSACTION), "javax.transaction.Status.STATUS_NO_TRANSACTION");
- assertEquals(JTAHelper.stringForm(javax.transaction.Status.STATUS_PREPARED), "javax.transaction.Status.STATUS_PREPARED");
- assertEquals(JTAHelper.stringForm(javax.transaction.Status.STATUS_PREPARING), "javax.transaction.Status.STATUS_PREPARING");
- assertEquals(JTAHelper.stringForm(javax.transaction.Status.STATUS_ROLLEDBACK), "javax.transaction.Status.STATUS_ROLLEDBACK");
- assertEquals(JTAHelper.stringForm(javax.transaction.Status.STATUS_ROLLING_BACK), "javax.transaction.Status.STATUS_ROLLING_BACK");
- assertEquals(JTAHelper.stringForm(javax.transaction.Status.STATUS_UNKNOWN), "javax.transaction.Status.STATUS_UNKNOWN");
- }
-
- @Test
- public void testStatusConverter () throws Exception
- {
- StatusConverter sc = new StatusConverter();
-
- assertEquals(StatusConverter.convert(ActionStatus.ABORT_ONLY), Status.STATUS_MARKED_ROLLBACK);
- assertEquals(StatusConverter.convert(ActionStatus.ABORTED), Status.STATUS_ROLLEDBACK);
- assertEquals(StatusConverter.convert(ActionStatus.ABORTING), Status.STATUS_ROLLING_BACK);
- assertEquals(StatusConverter.convert(ActionStatus.CLEANUP), Status.STATUS_UNKNOWN);
- assertEquals(StatusConverter.convert(ActionStatus.COMMITTED), Status.STATUS_COMMITTED);
- assertEquals(StatusConverter.convert(ActionStatus.COMMITTING), Status.STATUS_COMMITTING);
- assertEquals(StatusConverter.convert(ActionStatus.CREATED), Status.STATUS_UNKNOWN);
- assertEquals(StatusConverter.convert(ActionStatus.DISABLED), Status.STATUS_UNKNOWN);
- assertEquals(StatusConverter.convert(ActionStatus.H_COMMIT), Status.STATUS_COMMITTED);
- assertEquals(StatusConverter.convert(ActionStatus.H_HAZARD), Status.STATUS_COMMITTED);
- assertEquals(StatusConverter.convert(ActionStatus.H_MIXED), Status.STATUS_COMMITTED);
- assertEquals(StatusConverter.convert(ActionStatus.H_ROLLBACK), Status.STATUS_ROLLEDBACK);
- assertEquals(StatusConverter.convert(ActionStatus.INVALID), Status.STATUS_UNKNOWN);
- assertEquals(StatusConverter.convert(ActionStatus.NO_ACTION), Status.STATUS_NO_TRANSACTION);
- assertEquals(StatusConverter.convert(ActionStatus.PREPARED), Status.STATUS_PREPARED);
- assertEquals(StatusConverter.convert(ActionStatus.PREPARING), Status.STATUS_PREPARING);
- assertEquals(StatusConverter.convert(ActionStatus.RUNNING), Status.STATUS_ACTIVE);
- }
-
- @Test
- public void testXAHelper () throws Exception
- {
- assertTrue(XAHelper.printXAErrorCode(null) != null);
-
- XAException ex = new XAException(XAException.XA_HEURCOM);
- assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XA_HEURCOM");
-
- ex = new XAException(XAException.XA_HEURHAZ);
- assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XA_HEURHAZ");
-
- ex = new XAException(XAException.XA_HEURMIX);
- assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XA_HEURMIX");
-
- ex = new XAException(XAException.XA_HEURRB);
- assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XA_HEURRB");
-
- ex = new XAException(XAException.XA_NOMIGRATE);
- assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XA_NOMIGRATE");
-
- ex = new XAException(XAException.XA_RBCOMMFAIL);
- assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XA_RBCOMMFAIL");
-
- ex = new XAException(XAException.XA_RBDEADLOCK);
- assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XA_RBDEADLOCK");
-
- ex = new XAException(XAException.XA_RBINTEGRITY);
- assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XA_RBINTEGRITY");
-
- ex = new XAException(XAException.XA_RBOTHER);
- assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XA_RBOTHER");
-
- ex = new XAException(XAException.XA_RBPROTO);
- assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XA_RBPROTO");
-
- ex = new XAException(XAException.XA_RBROLLBACK);
- assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XA_RBROLLBACK");
-
- ex = new XAException(XAException.XA_RBTIMEOUT);
- assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XA_RBTIMEOUT");
-
- ex = new XAException(XAException.XA_RBTRANSIENT);
- assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XA_RBTRANSIENT");
-
- ex = new XAException(XAException.XA_RDONLY);
- assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XA_RDONLY");
-
- ex = new XAException(XAException.XA_RETRY);
- assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XA_RETRY");
-
- ex = new XAException(XAException.XAER_RMERR);
- assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XAER_RMERR");
-
- ex = new XAException(XAException.XAER_ASYNC);
- assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XAER_ASYNC");
-
- ex = new XAException(XAException.XAER_DUPID);
- assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XAER_DUPID");
-
- ex = new XAException(XAException.XAER_INVAL);
- assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XAER_INVAL");
-
- ex = new XAException(XAException.XAER_NOTA);
- assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XAER_NOTA");
-
- ex = new XAException(XAException.XAER_OUTSIDE);
- assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XAER_OUTSIDE");
-
- ex = new XAException(XAException.XAER_PROTO);
- assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XAER_PROTO");
-
- ex = new XAException(XAException.XAER_RMFAIL);
- assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XAER_RMFAIL");
-
- assertTrue(XAHelper.printXAErrorCode(new XAException(-1)) != null);
-
- XidImple xid1 = new XidImple(new Uid());
- XidImple xid2 = new XidImple(new Uid());
- XidImple xid3 = new XidImple(xid1);
-
- assertFalse(XAHelper.sameXID(xid1, xid2));
- assertTrue(XAHelper.sameXID(xid1, xid3));
-
- assertTrue(XAHelper.sameTransaction(xid1, xid1));
- assertTrue(XAHelper.sameTransaction(xid1, xid3));
-
- assertTrue(XAHelper.xidToString(xid1) != null);
-
- XID x = new XID();
- x.bqual_length = 1;
- x.gtrid_length = 1;
- x.data = new byte[] { '1', '2' };
-
- assertTrue(x.toString() != null);
- }
-}
Modified: labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/common/SampleOnePhaseResource.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/common/SampleOnePhaseResource.java 2010-03-22 13:33:35 UTC (rev 32168)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/common/SampleOnePhaseResource.java 2010-03-22 15:48:35 UTC (rev 32169)
@@ -26,7 +26,7 @@
public class SampleOnePhaseResource extends TestResource
{
- public enum ErrorType { none, heurcom, heurrb };
+ public enum ErrorType { none, heurcom, heurrb, heurmix, rmerr, nota, inval, proto };
public SampleOnePhaseResource ()
{
@@ -60,6 +60,31 @@
{
if (_heuristic == ErrorType.heurrb)
throw new XAException(XAException.XA_HEURRB);
+ else
+ {
+ if (_heuristic == ErrorType.heurmix)
+ throw new XAException(XAException.XA_HEURMIX);
+ else
+ {
+ if (_heuristic == ErrorType.rmerr)
+ throw new XAException(XAException.XAER_RMERR);
+ else
+ {
+ if (_heuristic == ErrorType.nota)
+ throw new XAException(XAException.XAER_NOTA);
+ else
+ {
+ if (_heuristic == ErrorType.inval)
+ throw new XAException(XAException.XAER_INVAL);
+ else
+ {
+ if (_heuristic == ErrorType.proto)
+ throw new XAException(XAException.XAER_PROTO);
+ }
+ }
+ }
+ }
+ }
}
}
Added: labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/jca/XATerminatorUnitTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/jca/XATerminatorUnitTest.java (rev 0)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/jca/XATerminatorUnitTest.java 2010-03-22 15:48:35 UTC (rev 32169)
@@ -0,0 +1,129 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, 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) 2005-2006,
+ * @author JBoss Inc.
+ */
+/*
+ * Copyright (C) 2004,
+ *
+ * Arjuna Technologies Ltd,
+ * Newcastle upon Tyne,
+ * Tyne and Wear,
+ * UK.
+ *
+ * $Id: xidcheck.java 2342 2006-03-30 13:06:17Z $
+ */
+
+package com.hp.mwtests.ts.jta.jca;
+
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.XAResource;
+
+import org.junit.Test;
+
+import com.arjuna.ats.arjuna.common.Uid;
+import com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinationManager;
+import com.arjuna.ats.internal.jta.transaction.arjunacore.jca.XATerminatorImple;
+import com.arjuna.ats.jta.exceptions.UnexpectedConditionException;
+import com.arjuna.ats.jta.xa.XidImple;
+
+import static org.junit.Assert.*;
+
+public class XATerminatorUnitTest
+{
+ @Test
+ public void test () throws Exception
+ {
+ XATerminatorImple term = new XATerminatorImple();
+ XidImple xid = new XidImple(new Uid());
+ SubordinationManager.getTransactionImporter().importTransaction(xid);
+
+ assertTrue(term.beforeCompletion(xid));
+ assertEquals(term.prepare(xid), XAResource.XA_RDONLY);
+
+ SubordinationManager.getTransactionImporter().importTransaction(xid);
+
+ term.commit(xid, true);
+
+ SubordinationManager.getTransactionImporter().importTransaction(xid);
+
+ term.rollback(xid);
+
+ SubordinationManager.getTransactionImporter().importTransaction(xid);
+
+ term.recover(XAResource.TMSTARTRSCAN);
+ term.recover(XAResource.TMENDRSCAN);
+ }
+
+ @Test
+ public void testUnknownTransaction () throws Exception
+ {
+ XATerminatorImple term = new XATerminatorImple();
+ XidImple xid = new XidImple(new Uid());
+
+ try
+ {
+ term.beforeCompletion(xid);
+
+ fail();
+ }
+ catch (final UnexpectedConditionException ex)
+ {
+ }
+
+ try
+ {
+ term.prepare(xid);
+
+ fail();
+ }
+ catch (final XAException ex)
+ {
+ }
+
+ try
+ {
+ term.commit(xid, false);
+
+ fail();
+ }
+ catch (final XAException ex)
+ {
+ }
+
+ try
+ {
+ term.rollback(xid);
+
+ fail();
+ }
+ catch (final XAException ex)
+ {
+ }
+
+ try
+ {
+ term.forget(xid);
+
+ fail();
+ }
+ catch (final XAException ex)
+ {
+ }
+ }
+}
Copied: labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/utils/UtilsUnitTest.java (from rev 32159, labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/basic/UtilsUnitTest.java)
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/utils/UtilsUnitTest.java (rev 0)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/utils/UtilsUnitTest.java 2010-03-22 15:48:35 UTC (rev 32169)
@@ -0,0 +1,199 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, 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) 2005-2010,
+ * @author JBoss Inc.
+ */
+
+package com.hp.mwtests.ts.jta.utils;
+
+import javax.transaction.Status;
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.Xid;
+
+import org.junit.Test;
+
+import com.arjuna.ats.arjuna.common.Uid;
+import com.arjuna.ats.arjuna.coordinator.ActionStatus;
+import com.arjuna.ats.internal.jta.utils.arjunacore.StatusConverter;
+import com.arjuna.ats.internal.jta.xa.XID;
+import com.arjuna.ats.jta.utils.JTAHelper;
+import com.arjuna.ats.jta.utils.XAHelper;
+import com.arjuna.ats.jta.xa.XidImple;
+
+import static org.junit.Assert.*;
+
+class DummyXid implements Xid
+{
+ public byte[] getBranchQualifier ()
+ {
+ return _branch;
+ }
+
+ public int getFormatId ()
+ {
+ return 0;
+ }
+
+ public byte[] getGlobalTransactionId ()
+ {
+ return _gtid;
+ }
+
+ private byte[] _branch = {1, 2};
+ private byte[] _gtid = {3, 4};
+}
+
+
+public class UtilsUnitTest
+{
+ @Test
+ public void testJTAHelper () throws Exception
+ {
+ assertEquals(JTAHelper.stringForm(javax.transaction.Status.STATUS_ACTIVE), "javax.transaction.Status.STATUS_ACTIVE");
+ assertEquals(JTAHelper.stringForm(javax.transaction.Status.STATUS_COMMITTED), "javax.transaction.Status.STATUS_COMMITTED");
+ assertEquals(JTAHelper.stringForm(javax.transaction.Status.STATUS_MARKED_ROLLBACK), "javax.transaction.Status.STATUS_MARKED_ROLLBACK");
+ assertEquals(JTAHelper.stringForm(javax.transaction.Status.STATUS_NO_TRANSACTION), "javax.transaction.Status.STATUS_NO_TRANSACTION");
+ assertEquals(JTAHelper.stringForm(javax.transaction.Status.STATUS_PREPARED), "javax.transaction.Status.STATUS_PREPARED");
+ assertEquals(JTAHelper.stringForm(javax.transaction.Status.STATUS_PREPARING), "javax.transaction.Status.STATUS_PREPARING");
+ assertEquals(JTAHelper.stringForm(javax.transaction.Status.STATUS_ROLLEDBACK), "javax.transaction.Status.STATUS_ROLLEDBACK");
+ assertEquals(JTAHelper.stringForm(javax.transaction.Status.STATUS_ROLLING_BACK), "javax.transaction.Status.STATUS_ROLLING_BACK");
+ assertEquals(JTAHelper.stringForm(javax.transaction.Status.STATUS_UNKNOWN), "javax.transaction.Status.STATUS_UNKNOWN");
+ }
+
+ @Test
+ public void testStatusConverter () throws Exception
+ {
+ StatusConverter sc = new StatusConverter();
+
+ assertEquals(StatusConverter.convert(ActionStatus.ABORT_ONLY), Status.STATUS_MARKED_ROLLBACK);
+ assertEquals(StatusConverter.convert(ActionStatus.ABORTED), Status.STATUS_ROLLEDBACK);
+ assertEquals(StatusConverter.convert(ActionStatus.ABORTING), Status.STATUS_ROLLING_BACK);
+ assertEquals(StatusConverter.convert(ActionStatus.CLEANUP), Status.STATUS_UNKNOWN);
+ assertEquals(StatusConverter.convert(ActionStatus.COMMITTED), Status.STATUS_COMMITTED);
+ assertEquals(StatusConverter.convert(ActionStatus.COMMITTING), Status.STATUS_COMMITTING);
+ assertEquals(StatusConverter.convert(ActionStatus.CREATED), Status.STATUS_UNKNOWN);
+ assertEquals(StatusConverter.convert(ActionStatus.DISABLED), Status.STATUS_UNKNOWN);
+ assertEquals(StatusConverter.convert(ActionStatus.H_COMMIT), Status.STATUS_COMMITTED);
+ assertEquals(StatusConverter.convert(ActionStatus.H_HAZARD), Status.STATUS_COMMITTED);
+ assertEquals(StatusConverter.convert(ActionStatus.H_MIXED), Status.STATUS_COMMITTED);
+ assertEquals(StatusConverter.convert(ActionStatus.H_ROLLBACK), Status.STATUS_ROLLEDBACK);
+ assertEquals(StatusConverter.convert(ActionStatus.INVALID), Status.STATUS_UNKNOWN);
+ assertEquals(StatusConverter.convert(ActionStatus.NO_ACTION), Status.STATUS_NO_TRANSACTION);
+ assertEquals(StatusConverter.convert(ActionStatus.PREPARED), Status.STATUS_PREPARED);
+ assertEquals(StatusConverter.convert(ActionStatus.PREPARING), Status.STATUS_PREPARING);
+ assertEquals(StatusConverter.convert(ActionStatus.RUNNING), Status.STATUS_ACTIVE);
+ }
+
+ @Test
+ public void testXAHelper () throws Exception
+ {
+ assertTrue(XAHelper.printXAErrorCode(null) != null);
+
+ XAException ex = new XAException(XAException.XA_HEURCOM);
+ assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XA_HEURCOM");
+
+ ex = new XAException(XAException.XA_HEURHAZ);
+ assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XA_HEURHAZ");
+
+ ex = new XAException(XAException.XA_HEURMIX);
+ assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XA_HEURMIX");
+
+ ex = new XAException(XAException.XA_HEURRB);
+ assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XA_HEURRB");
+
+ ex = new XAException(XAException.XA_NOMIGRATE);
+ assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XA_NOMIGRATE");
+
+ ex = new XAException(XAException.XA_RBCOMMFAIL);
+ assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XA_RBCOMMFAIL");
+
+ ex = new XAException(XAException.XA_RBDEADLOCK);
+ assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XA_RBDEADLOCK");
+
+ ex = new XAException(XAException.XA_RBINTEGRITY);
+ assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XA_RBINTEGRITY");
+
+ ex = new XAException(XAException.XA_RBOTHER);
+ assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XA_RBOTHER");
+
+ ex = new XAException(XAException.XA_RBPROTO);
+ assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XA_RBPROTO");
+
+ ex = new XAException(XAException.XA_RBROLLBACK);
+ assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XA_RBROLLBACK");
+
+ ex = new XAException(XAException.XA_RBTIMEOUT);
+ assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XA_RBTIMEOUT");
+
+ ex = new XAException(XAException.XA_RBTRANSIENT);
+ assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XA_RBTRANSIENT");
+
+ ex = new XAException(XAException.XA_RDONLY);
+ assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XA_RDONLY");
+
+ ex = new XAException(XAException.XA_RETRY);
+ assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XA_RETRY");
+
+ ex = new XAException(XAException.XAER_RMERR);
+ assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XAER_RMERR");
+
+ ex = new XAException(XAException.XAER_ASYNC);
+ assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XAER_ASYNC");
+
+ ex = new XAException(XAException.XAER_DUPID);
+ assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XAER_DUPID");
+
+ ex = new XAException(XAException.XAER_INVAL);
+ assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XAER_INVAL");
+
+ ex = new XAException(XAException.XAER_NOTA);
+ assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XAER_NOTA");
+
+ ex = new XAException(XAException.XAER_OUTSIDE);
+ assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XAER_OUTSIDE");
+
+ ex = new XAException(XAException.XAER_PROTO);
+ assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XAER_PROTO");
+
+ ex = new XAException(XAException.XAER_RMFAIL);
+ assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XAER_RMFAIL");
+
+ assertTrue(XAHelper.printXAErrorCode(new XAException(-1)) != null);
+
+ XidImple xid1 = new XidImple(new Uid());
+ XidImple xid2 = new XidImple(new Uid());
+ XidImple xid3 = new XidImple(xid1);
+
+ assertFalse(XAHelper.sameXID(xid1, xid2));
+ assertTrue(XAHelper.sameXID(xid1, xid3));
+
+ assertTrue(XAHelper.sameTransaction(xid1, xid1));
+ assertTrue(XAHelper.sameTransaction(xid1, xid3));
+
+ assertTrue(XAHelper.xidToString(xid1) != null);
+
+ XID x = new XID();
+ x.bqual_length = 1;
+ x.gtrid_length = 1;
+ x.data = new byte[] { '1', '2' };
+
+ assertTrue(x.toString() != null);
+
+ XAHelper.xidToString(new DummyXid());
+ }
+}
Modified: labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/xa/OnePhaseUnitTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/xa/OnePhaseUnitTest.java 2010-03-22 13:33:35 UTC (rev 32168)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/xa/OnePhaseUnitTest.java 2010-03-22 15:48:35 UTC (rev 32169)
@@ -73,6 +73,35 @@
}
@Test
+ public void testFailure () throws Exception
+ {
+ SampleOnePhaseResource res = new SampleOnePhaseResource(ErrorType.heurmix);
+ XAOnePhaseResource xares = new XAOnePhaseResource(res, new XidImple(new Uid()), null);
+
+ assertEquals(xares.commit(), TwoPhaseOutcome.HEURISTIC_HAZARD);
+
+ res = new SampleOnePhaseResource(ErrorType.rmerr);
+ xares = new XAOnePhaseResource(res, new XidImple(new Uid()), null);
+
+ assertEquals(xares.commit(), TwoPhaseOutcome.ONE_PHASE_ERROR);
+
+ res = new SampleOnePhaseResource(ErrorType.nota);
+ xares = new XAOnePhaseResource(res, new XidImple(new Uid()), null);
+
+ assertEquals(xares.commit(), TwoPhaseOutcome.HEURISTIC_HAZARD);
+
+ res = new SampleOnePhaseResource(ErrorType.inval);
+ xares = new XAOnePhaseResource(res, new XidImple(new Uid()), null);
+
+ assertEquals(xares.commit(), TwoPhaseOutcome.HEURISTIC_HAZARD);
+
+ res = new SampleOnePhaseResource(ErrorType.proto);
+ xares = new XAOnePhaseResource(res, new XidImple(new Uid()), null);
+
+ assertEquals(xares.commit(), TwoPhaseOutcome.ONE_PHASE_ERROR);
+ }
+
+ @Test
public void testInvalid ()
{
XAOnePhaseResource xares = new XAOnePhaseResource();
More information about the jboss-svn-commits
mailing list