[jboss-svn-commits] JBL Code SVN: r35320 - in labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta: utils and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Sep 27 20:28:20 EDT 2010
Author: mark.little at jboss.com
Date: 2010-09-27 20:28:19 -0400 (Mon, 27 Sep 2010)
New Revision: 35320
Added:
labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/utils/JNDIManagerUnitTest.java
Modified:
labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/twophase/TransactionImpleUnitTest.java
Log:
https://jira.jboss.org/browse/JBTM-712
Modified: labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/twophase/TransactionImpleUnitTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/twophase/TransactionImpleUnitTest.java 2010-09-27 23:18:33 UTC (rev 35319)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/twophase/TransactionImpleUnitTest.java 2010-09-28 00:28:19 UTC (rev 35320)
@@ -31,12 +31,15 @@
package com.hp.mwtests.ts.jta.twophase;
+import java.lang.reflect.Method;
+
import javax.naming.InitialContext;
import javax.transaction.HeuristicMixedException;
import javax.transaction.RollbackException;
import javax.transaction.Status;
import javax.transaction.SystemException;
import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
import org.junit.Test;
@@ -44,8 +47,10 @@
import com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple;
import com.arjuna.ats.jta.TransactionManager;
import com.arjuna.ats.jta.utils.JTAHelper;
+import com.arjuna.ats.jta.xa.XidImple;
import com.hp.mwtests.ts.jta.common.DummyXA;
import com.hp.mwtests.ts.jta.common.FailureXAResource;
+import com.hp.mwtests.ts.jta.common.RecoveryXAResource;
import com.hp.mwtests.ts.jta.common.Synchronization;
import com.hp.mwtests.ts.jta.common.FailureXAResource.FailLocation;
@@ -86,8 +91,13 @@
tx.delistResource(res, XAResource.TMSUSPEND);
- tx.commit();
+ tx.commit();
+ assertTrue(tx.getRemainingTimeoutMills() != -1);
+ assertTrue(tx.getTimeout() != -1);
+ assertEquals(tx.getSynchronizations().size(), 0);
+ assertEquals(tx.getResources().size(), 1);
+
TxImpleOverride.remove(tx);
assertTrue(TransactionImple.getTransactions() != null);
@@ -106,6 +116,25 @@
}
@Test
+ public void testThreadIsActive () throws Exception
+ {
+ Class[] parameterTypes = new Class[1];
+ TransactionImple tx = new TransactionImple(0);
+
+ parameterTypes[0] = XAResource.class;
+
+ Method m = tx.getClass().getDeclaredMethod("threadIsActive", parameterTypes);
+ m.setAccessible(true);
+
+ Object[] parameters = new Object[1];
+ parameters[0] = new RecoveryXAResource();
+
+ Boolean res = (Boolean) m.invoke(tx, parameters);
+
+ assertFalse(res.booleanValue());
+ }
+
+ @Test
public void testEnlist () throws Exception
{
ThreadActionData.purgeActions();
Added: labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/utils/JNDIManagerUnitTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/utils/JNDIManagerUnitTest.java (rev 0)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/utils/JNDIManagerUnitTest.java 2010-09-28 00:28:19 UTC (rev 35320)
@@ -0,0 +1,161 @@
+/*
+ * 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.naming.InitialContext;
+
+import org.junit.Test;
+
+import com.arjuna.ats.jta.utils.JNDIManager;
+
+import static org.junit.Assert.*;
+
+public class JNDIManagerUnitTest
+{
+ @Test
+ public void testBind () throws Exception
+ {
+ try
+ {
+ JNDIManager.bindJTAImplementation();
+
+ fail();
+ }
+ catch (final Exception ex)
+ {
+ }
+
+ try
+ {
+ JNDIManager.bindJTAImplementations(new InitialContext());
+
+ fail();
+ }
+ catch (final Exception ex)
+ {
+ }
+
+ try
+ {
+ JNDIManager.bindJTATransactionManagerImplementation();
+
+ fail();
+ }
+ catch (final Exception ex)
+ {
+ }
+
+ try
+ {
+ JNDIManager.bindJTATransactionManagerImplementation(new InitialContext());
+
+ fail();
+ }
+ catch (final Exception ex)
+ {
+ }
+
+ try
+ {
+ JNDIManager.bindJTATransactionSynchronizationRegistryImplementation();
+
+ fail();
+ }
+ catch (final Exception ex)
+ {
+ }
+
+ try
+ {
+ JNDIManager.bindJTATransactionSynchronizationRegistryImplementation(new InitialContext());
+
+ fail();
+ }
+ catch (final Exception ex)
+ {
+ }
+
+ try
+ {
+ JNDIManager.bindJTAUserTransactionImplementation();
+
+ fail();
+ }
+ catch (final Exception ex)
+ {
+ }
+
+ try
+ {
+ JNDIManager.bindJTAUserTransactionImplementation(new InitialContext());
+
+ fail();
+ }
+ catch (final Exception ex)
+ {
+ }
+ }
+
+ @Test
+ public void testUnbind () throws Exception
+ {
+ try
+ {
+ JNDIManager.unbindJTATransactionManagerImplementation();
+
+ fail();
+ }
+ catch (final Exception ex)
+ {
+ }
+
+ try
+ {
+ JNDIManager.unbindJTATransactionManagerImplementation(new InitialContext());
+
+ fail();
+ }
+ catch (final Exception ex)
+ {
+ }
+
+ try
+ {
+ JNDIManager.unbindJTATransactionSynchronizationRegistryImplementation();
+
+ fail();
+ }
+ catch (final Exception ex)
+ {
+ }
+
+ try
+ {
+ JNDIManager.unbindJTATransactionSynchronizationRegistryImplementation(new InitialContext());
+
+ fail();
+ }
+ catch (final Exception ex)
+ {
+ }
+ }
+}
More information about the jboss-svn-commits
mailing list