[jboss-svn-commits] JBL Code SVN: r31898 - in labs/jbosstm/trunk/ArjunaJTA: jta/classes/com/arjuna/ats/internal/jta/resources/arjunacore and 5 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Mar 1 16:45:08 EST 2010


Author: mark.little at jboss.com
Date: 2010-03-01 16:45:06 -0500 (Mon, 01 Mar 2010)
New Revision: 31898

Added:
   labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/basic/ErrorHandlerUnitTest.java
   labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/common/DummyRecoverableXAConnection.java
Modified:
   labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/IndirectRecoverableConnection.java
   labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/resources/arjunacore/XAResourceRecord.java
   labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/xa/RecoverableXAConnection.java
   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/common/TestResource.java
   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/UserTransactionUnitTest.java
   labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/twophase/XAResourceRecordUnitTest.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

Modified: labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/IndirectRecoverableConnection.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/IndirectRecoverableConnection.java	2010-03-01 18:08:46 UTC (rev 31897)
+++ labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/IndirectRecoverableConnection.java	2010-03-01 21:45:06 UTC (rev 31898)
@@ -34,16 +34,11 @@
 import com.arjuna.ats.jdbc.common.jdbcPropertyManager;
 import com.arjuna.ats.jdbc.logging.*;
 
-import com.arjuna.ats.internal.jdbc.drivers.modifiers.ModifierFactory;
 import com.arjuna.ats.internal.jdbc.drivers.modifiers.ConnectionModifier;
 
-import com.arjuna.ats.arjuna.common.*;
 import com.arjuna.ats.arjuna.state.*;
 
-import com.arjuna.ats.jta.*;
 import com.arjuna.ats.jta.xa.RecoverableXAConnection;
-import com.arjuna.ats.jta.xa.XAModifier;
-import com.arjuna.ats.jta.exceptions.NotImplementedException;
 
 import com.arjuna.common.util.logging.*;
 

Modified: labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/resources/arjunacore/XAResourceRecord.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/resources/arjunacore/XAResourceRecord.java	2010-03-01 18:08:46 UTC (rev 31897)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/resources/arjunacore/XAResourceRecord.java	2010-03-01 21:45:06 UTC (rev 31898)
@@ -968,16 +968,6 @@
 		    return XARecoveryResource.WAITING_FOR_RECOVERY;
 	}
 
-	public static AbstractRecord create()
-	{
-		return new XAResourceRecord();
-	}
-
-	public static void remove(AbstractRecord toDelete)
-	{
-		toDelete = null;
-	}
-
 	/**
 	 * @message com.arjuna.ats.internal.jta.resources.arjunacore.savestate
 	 *          [com.arjuna.ats.internal.jta.resources.arjunacore.savestate]

Modified: labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/xa/RecoverableXAConnection.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/xa/RecoverableXAConnection.java	2010-03-01 18:08:46 UTC (rev 31897)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/xa/RecoverableXAConnection.java	2010-03-01 21:45:06 UTC (rev 31898)
@@ -31,16 +31,12 @@
 
 package com.arjuna.ats.jta.xa;
 
-import com.arjuna.ats.arjuna.common.*;
 import com.arjuna.ats.arjuna.state.*;
 
 import java.sql.*;
 import javax.sql.*;
-import javax.transaction.*;
 import javax.transaction.xa.*;
 
-import com.arjuna.ats.jta.exceptions.NotImplementedException;
-
 /**
  * XA connection implementations must provide an implementation
  * of this class.

Added: labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/basic/ErrorHandlerUnitTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/basic/ErrorHandlerUnitTest.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/basic/ErrorHandlerUnitTest.java	2010-03-01 21:45:06 UTC (rev 31898)
@@ -0,0 +1,42 @@
+/*
+ * 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.xa.XAException;
+
+import org.junit.Test;
+
+import com.arjuna.ats.internal.jta.resources.errorhandlers.tibco;
+
+import static org.junit.Assert.*;
+
+public class ErrorHandlerUnitTest
+{
+    @Test
+    public void test() throws Exception
+    {
+        tibco tc = new tibco();
+        
+        assertFalse(tc.notAProblem(new XAException(), false));
+        assertEquals(tc.getXAResourceName(), "");
+    }
+}

Modified: 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-01 18:08:46 UTC (rev 31897)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/basic/UtilsUnitTest.java	2010-03-01 21:45:06 UTC (rev 31898)
@@ -29,6 +29,7 @@
 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;
@@ -149,6 +150,8 @@
         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);
@@ -160,5 +163,12 @@
         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);
     }
 }

Added: labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/common/DummyRecoverableXAConnection.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/common/DummyRecoverableXAConnection.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/common/DummyRecoverableXAConnection.java	2010-03-01 21:45:06 UTC (rev 31898)
@@ -0,0 +1,106 @@
+/*
+ * 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.
+ */
+package com.hp.mwtests.ts.jta.common;
+
+import java.sql.SQLException;
+
+import javax.sql.XAConnection;
+import javax.sql.XADataSource;
+import javax.transaction.Transaction;
+import javax.transaction.xa.XAResource;
+
+import com.arjuna.ats.arjuna.state.InputObjectState;
+import com.arjuna.ats.arjuna.state.OutputObjectState;
+import com.arjuna.ats.jta.xa.RecoverableXAConnection;
+
+public class DummyRecoverableXAConnection implements RecoverableXAConnection
+{
+
+    public void close ()
+    {
+        // TODO Auto-generated method stub
+        
+    }
+
+    public void closeCloseCurrentConnection () throws SQLException
+    {
+        // TODO Auto-generated method stub
+        
+    }
+
+    public XAConnection getConnection () throws SQLException
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public XAConnection getCurrentConnection () throws SQLException
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public XADataSource getDataSource () throws SQLException
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public XAResource getResource () throws SQLException
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public boolean inuse ()
+    {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    public boolean packInto (OutputObjectState os)
+    {
+        return true;
+    }
+
+    public void reset ()
+    {
+        // TODO Auto-generated method stub
+        
+    }
+
+    public boolean setTransaction (Transaction tx)
+    {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    public boolean unpackFrom (InputObjectState os)
+    {
+        return true;
+    }
+
+    public boolean validTransaction (Transaction tx)
+    {
+        // TODO Auto-generated method stub
+        return false;
+    }
+}

Modified: labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/common/TestResource.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/common/TestResource.java	2010-03-01 18:08:46 UTC (rev 31897)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/common/TestResource.java	2010-03-01 21:45:06 UTC (rev 31898)
@@ -27,6 +27,16 @@
 
 public class TestResource implements XAResource
 {
+    public TestResource ()
+    {
+        this(false);
+    }
+    
+    public TestResource (boolean readonly)
+    {
+        _readonly = readonly;
+    }
+    
     public void commit (Xid id, boolean onePhase) throws XAException
 	{
 		System.out.println("XA_COMMIT[" + id + "]");
@@ -56,7 +66,10 @@
 	{
 		System.out.println("XA_PREPARE[" + xid + "]");
 
-		return (XA_OK);
+		if (_readonly)
+		    return XA_RDONLY;
+		else
+		    return XA_OK;
 
 		// throw new XAException();
 	}
@@ -85,4 +98,5 @@
 
 	protected int _timeout = 0;
 
+	private boolean _readonly = false;
 }

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-03-01 18:08:46 UTC (rev 31897)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/twophase/TransactionImpleUnitTest.java	2010-03-01 21:45:06 UTC (rev 31898)
@@ -31,6 +31,7 @@
 
 package com.hp.mwtests.ts.jta.twophase;
 
+import javax.naming.InitialContext;
 import javax.transaction.HeuristicMixedException;
 import javax.transaction.RollbackException;
 import javax.transaction.Status;
@@ -41,6 +42,7 @@
 
 import com.arjuna.ats.internal.arjuna.thread.ThreadActionData;
 import com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple;
+import com.arjuna.ats.jta.TransactionManager;
 import com.arjuna.ats.jta.utils.JTAHelper;
 import com.hp.mwtests.ts.jta.common.DummyXA;
 import com.hp.mwtests.ts.jta.common.FailureXAResource;
@@ -85,6 +87,16 @@
         assertTrue(TransactionImple.getTransactions() != null);
         
         assertEquals(TransactionImple.getTransaction(tx.get_uid()), null);
+        
+        try
+        {
+            tx = (TransactionImple) TransactionManager.transactionManager(new InitialContext());
+        
+            fail();
+        }
+        catch (final Throwable ex)
+        {
+        }
     }
     
     @Test

Modified: labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/twophase/UserTransactionUnitTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/twophase/UserTransactionUnitTest.java	2010-03-01 18:08:46 UTC (rev 31897)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/twophase/UserTransactionUnitTest.java	2010-03-01 21:45:06 UTC (rev 31898)
@@ -31,6 +31,7 @@
 
 package com.hp.mwtests.ts.jta.twophase;
 
+import javax.naming.InitialContext;
 import javax.transaction.NotSupportedException;
 import javax.transaction.RollbackException;
 
@@ -38,6 +39,7 @@
 
 import com.arjuna.ats.internal.arjuna.thread.ThreadActionData;
 import com.arjuna.ats.internal.jta.transaction.arjunacore.UserTransactionImple;
+import com.arjuna.ats.jta.UserTransaction;
 
 import static org.junit.Assert.*;
 
@@ -55,6 +57,16 @@
         assertTrue(ut.toString() != null);
         
         assertEquals(ut.getObjectInstance(null, null, null, null), ut);
+        
+        try
+        {
+            ut = (UserTransactionImple) UserTransaction.userTransaction(new InitialContext());
+        
+            fail();
+        }
+        catch (final Throwable ex)
+        {
+        }
     }
     
     @Test

Modified: labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/twophase/XAResourceRecordUnitTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/twophase/XAResourceRecordUnitTest.java	2010-03-01 18:08:46 UTC (rev 31897)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/twophase/XAResourceRecordUnitTest.java	2010-03-01 21:45:06 UTC (rev 31898)
@@ -33,11 +33,18 @@
 
 import org.junit.Test;
 
+import com.arjuna.ats.arjuna.ObjectType;
+import com.arjuna.ats.arjuna.common.Uid;
 import com.arjuna.ats.arjuna.coordinator.TwoPhaseOutcome;
+import com.arjuna.ats.arjuna.state.InputObjectState;
+import com.arjuna.ats.arjuna.state.OutputObjectState;
 import com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord;
 import com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple;
+import com.arjuna.ats.jta.xa.XidImple;
+import com.hp.mwtests.ts.jta.common.DummyRecoverableXAConnection;
 import com.hp.mwtests.ts.jta.common.DummyXA;
 import com.hp.mwtests.ts.jta.common.FailureXAResource;
+import com.hp.mwtests.ts.jta.common.TestResource;
 
 import static org.junit.Assert.*;
 
@@ -52,9 +59,59 @@
         xares.setValue(obj);
         
         assertTrue(xares.value() != obj);
+        
+        DummyRecoverableXAConnection rc = new DummyRecoverableXAConnection();
+        Object[] params = new Object[1];
+        
+        params[XAResourceRecord.XACONNECTION] = rc;
+        
+        xares = new XAResourceRecord(new TransactionImple(0), new DummyXA(false), new XidImple(new Uid()), params);
+        
+        assertTrue(xares.type() != null);
+        
+        xares.merge(xares);
+        xares.replace(xares);
+        
+        assertTrue(xares.toString() != null);
     }
     
     @Test
+    public void testPackUnpack () throws Exception
+    {
+        XAResourceRecord xares;      
+        DummyRecoverableXAConnection rc = new DummyRecoverableXAConnection();
+        Object[] params = new Object[1];
+        
+        params[XAResourceRecord.XACONNECTION] = rc;
+        
+        xares = new XAResourceRecord(new TransactionImple(0), new DummyXA(false), new XidImple(new Uid()), params);
+        
+        OutputObjectState os = new OutputObjectState();
+        
+        assertTrue(xares.save_state(os, ObjectType.ANDPERSISTENT));
+        
+        InputObjectState is = new InputObjectState(os);
+        
+        assertTrue(xares.restore_state(is, ObjectType.ANDPERSISTENT));
+    }
+    
+    @Test
+    public void testReadonly () throws Exception
+    {
+        XAResourceRecord xares;
+        
+        DummyRecoverableXAConnection rc = new DummyRecoverableXAConnection();
+        Object[] params = new Object[1];
+        
+        params[XAResourceRecord.XACONNECTION] = rc;
+        
+        xares = new XAResourceRecord(new TransactionImple(0), new TestResource(true), new XidImple(new Uid()), params);
+        
+        assertEquals(xares.topLevelCommit(), TwoPhaseOutcome.NOT_PREPARED);
+        assertEquals(xares.topLevelPrepare(), TwoPhaseOutcome.PREPARE_READONLY);
+    }
+    
+    @Test
     public void testCommitFailure () throws Exception
     {
         FailureXAResource fxa = new FailureXAResource(FailureXAResource.FailLocation.commit);

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-01 18:08:46 UTC (rev 31897)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/xa/OnePhaseUnitTest.java	2010-03-01 21:45:06 UTC (rev 31898)
@@ -41,7 +41,9 @@
 import com.arjuna.ats.arjuna.state.InputObjectState;
 import com.arjuna.ats.arjuna.state.OutputObjectState;
 import com.arjuna.ats.internal.jta.resources.arjunacore.XAOnePhaseResource;
+import com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord;
 import com.arjuna.ats.jta.xa.XidImple;
+import com.hp.mwtests.ts.jta.common.DummyRecoverableXAConnection;
 import com.hp.mwtests.ts.jta.common.DummyXA;
 import com.hp.mwtests.ts.jta.common.SampleOnePhaseResource;
 import com.hp.mwtests.ts.jta.common.SampleOnePhaseResource.ErrorType;
@@ -51,6 +53,26 @@
 public class OnePhaseUnitTest
 {
     @Test
+    public void test () throws Exception
+    {
+        DummyRecoverableXAConnection rc = new DummyRecoverableXAConnection();
+        Object[] obj = new Object[1];
+        SampleOnePhaseResource res = new SampleOnePhaseResource();
+        
+        obj[XAResourceRecord.XACONNECTION] = rc;
+        
+        XAOnePhaseResource xares = new XAOnePhaseResource(res, new XidImple(new Uid()), obj);
+        
+        OutputObjectState os = new OutputObjectState();
+        
+        xares.pack(os);
+        
+        InputObjectState is = new InputObjectState(os);
+        
+        xares.unpack(is);
+    }
+    
+    @Test
     public void testInvalid ()
     {
         XAOnePhaseResource xares = new XAOnePhaseResource();



More information about the jboss-svn-commits mailing list