geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: rev 54013 - in geronimo/trunk/modules/transaction/src: java/org/apache/geronimo/transaction java/org/apache/geronimo/transaction/context test/org/apache/geronimo/transaction test/org/apache/geronimo/transaction/context
Date Thu, 07 Oct 2004 20:49:56 GMT
Author: djencks
Date: Thu Oct  7 13:49:55 2004
New Revision: 54013

Added:
   geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/ImportedTransactionActiveException.java
   geronimo/trunk/modules/transaction/src/test/org/apache/geronimo/transaction/context/
   geronimo/trunk/modules/transaction/src/test/org/apache/geronimo/transaction/context/TransactionContextManagerTest.java
Modified:
   geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/GeronimoTransactionManager.java
   geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/TransactionManagerProxy.java
   geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/XAWork.java
   geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/ContainerTransactionContext.java
   geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/TransactionContextManager.java
   geronimo/trunk/modules/transaction/src/test/org/apache/geronimo/transaction/TransactionManagerProxyTest.java
Log:
fix a lot of problems with imported xids, add a very basic test

Modified: geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/GeronimoTransactionManager.java
==============================================================================
--- geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/GeronimoTransactionManager.java
(original)
+++ geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/GeronimoTransactionManager.java
Thu Oct  7 13:49:55 2004
@@ -70,15 +70,8 @@
         infoFactory.addReference("TransactionLog", TransactionLog.class);
         infoFactory.addReference("ResourceManagers", ResourceManager.class);
 
-        infoFactory.addOperation("setTransactionTimeout", new Class[]{int.class});
-        infoFactory.addOperation("begin");
-        infoFactory.addOperation("getStatus");
-        infoFactory.addOperation("getTransaction");
-        infoFactory.addOperation("suspend");
-        infoFactory.addOperation("resume", new Class[]{Transaction.class});
-        infoFactory.addOperation("commit");
-        infoFactory.addOperation("rollback");
-        infoFactory.addOperation("setRollbackOnly");
+        infoFactory.addInterface(TransactionManager.class);
+        infoFactory.addInterface(XidImporter.class);
 
         infoFactory.setConstructor(new String[]{"TransactionLog", "ResourceManagers"});
 

Added: geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/ImportedTransactionActiveException.java
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/ImportedTransactionActiveException.java
Thu Oct  7 13:49:55 2004
@@ -0,0 +1,19 @@
+package org.apache.geronimo.transaction;
+
+import javax.transaction.xa.Xid;
+
+/**
+ */
+public class ImportedTransactionActiveException extends Exception {
+
+    private final Xid xid;
+
+    public ImportedTransactionActiveException(Xid xid) {
+        this.xid = xid;
+    }
+
+    public Xid getXid() {
+        return xid;
+    }
+
+}

Modified: geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/TransactionManagerProxy.java
==============================================================================
--- geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/TransactionManagerProxy.java
(original)
+++ geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/TransactionManagerProxy.java
Thu Oct  7 13:49:55 2004
@@ -215,12 +215,13 @@
 
 
     //XidImporter implementation. Wrap and unwrap TransactionProxy.
+    //the importer functions should not affect the thread context.
     public Transaction importXid(Xid xid) throws XAException, SystemException {
         if (threadTx.get() != null) {
             throw new IllegalStateException("Transaction already associated with current
thread");
         }
         TransactionProxy transactionProxy = new TransactionProxy(importer.importXid(xid));
-        threadTx.set(transactionProxy);
+//        threadTx.set(transactionProxy);
         return transactionProxy;
     }
 
@@ -293,15 +294,8 @@
         infoFactory.addReference("recovery", Recovery.class);
         infoFactory.addReference("resourceManagers", ResourceManager.class);
 
-        infoFactory.addOperation("setTransactionTimeout", new Class[]{int.class});
-        infoFactory.addOperation("begin");
-        infoFactory.addOperation("getStatus");
-        infoFactory.addOperation("getTransaction");
-        infoFactory.addOperation("suspend");
-        infoFactory.addOperation("resume", new Class[]{Transaction.class});
-        infoFactory.addOperation("commit");
-        infoFactory.addOperation("rollback");
-        infoFactory.addOperation("setRollbackOnly");
+        infoFactory.addInterface(TransactionManager.class);
+        infoFactory.addInterface(XidImporter.class);
 
         infoFactory.setConstructor(new String[]{"delegate", "xidImporter", "recovery", "resourceManagers"});
 

Modified: geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/XAWork.java
==============================================================================
--- geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/XAWork.java
(original)
+++ geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/XAWork.java
Thu Oct  7 13:49:55 2004
@@ -29,6 +29,6 @@
  *
  * */
 public interface XAWork {
-    void begin(Xid xid, long txTimeout) throws XAException, InvalidTransactionException,
SystemException;
+    void begin(Xid xid, long txTimeout) throws XAException, InvalidTransactionException,
SystemException, ImportedTransactionActiveException;
     void end(Xid xid) throws XAException, SystemException;
 }

Modified: geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/ContainerTransactionContext.java
==============================================================================
--- geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/ContainerTransactionContext.java
(original)
+++ geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/ContainerTransactionContext.java
Thu Oct  7 13:49:55 2004
@@ -34,10 +34,13 @@
     private final TransactionManager txnManager;
     private Transaction transaction;
 
+    private boolean threadAssociated = false;
+
     public ContainerTransactionContext(TransactionManager txnManager) throws SystemException,
NotSupportedException {
         this.txnManager = txnManager;
         txnManager.begin();
         transaction = txnManager.getTransaction();
+        threadAssociated = true;
     }
 
     public ContainerTransactionContext(TransactionManager txnManager, Transaction transaction)
{
@@ -47,11 +50,13 @@
 
     public void suspend() throws SystemException {
         Transaction suspendedTransaction = txnManager.suspend();
-        assert (transaction == suspendedTransaction) : "suspend did not return our transaction";
+        assert (transaction == suspendedTransaction) : "suspend did not return our transaction.
ours: " + transaction + ", suspended returned: " + suspendedTransaction;
+        threadAssociated = false;
     }
 
     public void resume() throws SystemException, InvalidTransactionException {
         txnManager.resume(transaction);
+        threadAssociated = true;
     }
 
     /**
@@ -113,6 +118,10 @@
             connectorAfterCommit();
             transaction = null;
         }
+    }
+
+    public boolean isThreadAssociated() {
+        return threadAssociated;
     }
 
     //Geronimo connector framework support

Modified: geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/TransactionContextManager.java
==============================================================================
--- geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/TransactionContextManager.java
(original)
+++ geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/TransactionContextManager.java
Thu Oct  7 13:49:55 2004
@@ -33,17 +33,16 @@
 
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoFactory;
+import org.apache.geronimo.transaction.ImportedTransactionActiveException;
 import org.apache.geronimo.transaction.XAWork;
 import org.apache.geronimo.transaction.manager.Recovery;
 import org.apache.geronimo.transaction.manager.XidImporter;
 
 /**
- *
- *
  * @version $Rev$ $Date$
- *
- * */
+ */
 public class TransactionContextManager implements XATerminator, XAWork {
+
     private static final boolean NOT_IN_RECOVERY = false;
     private static final boolean IN_RECOVERY = true;
 
@@ -122,197 +121,166 @@
 
     /**
      * TODO write and use ImportedTransactionContext for this!
-      * @see javax.resource.spi.XATerminator#commit(javax.transaction.xa.Xid, boolean)
-      */
-     public void commit(Xid xid, boolean onePhase) throws XAException {
-         ImportedTransactionInfo txInfo;
-         synchronized (importedTransactions) {
-             txInfo = (ImportedTransactionInfo) importedTransactions.remove(xid);
-         }
-         if (txInfo == null) {
-             throw new XAException("No imported transaction for xid: " + xid);
-         }
-         ContainerTransactionContext containerTransactionContext = txInfo.getContainerTransactionContext();
-
-         try {
-             int status = containerTransactionContext.getTransaction().getStatus();
-             assert status == Status.STATUS_ACTIVE || status == Status.STATUS_PREPARED;
-         } catch (SystemException e) {
-             throw new XAException();
-         }
-         importer.commit(containerTransactionContext.getTransaction(), onePhase);
-     }
-
-     /**
-      * @see javax.resource.spi.XATerminator#forget(javax.transaction.xa.Xid)
-      */
-     public void forget(Xid xid) throws XAException {
-         ImportedTransactionInfo txInfo;
-         synchronized (importedTransactions) {
-             txInfo = (ImportedTransactionInfo) importedTransactions.remove(xid);
-         }
-         if (txInfo == null) {
-             throw new XAException("No imported transaction for xid: " + xid);
-         }
-         Transaction tx = txInfo.getContainerTransactionContext().getTransaction();
-         //todo is there a correct status test here?
+     *
+     * @see javax.resource.spi.XATerminator#commit(javax.transaction.xa.Xid, boolean)
+     */
+    public void commit(Xid xid, boolean onePhase) throws XAException {
+        ContainerTransactionContext containerTransactionContext;
+        synchronized (importedTransactions) {
+            containerTransactionContext = (ContainerTransactionContext) importedTransactions.remove(xid);
+        }
+        if (containerTransactionContext == null) {
+            throw new XAException("No imported transaction for xid: " + xid);
+        }
+
+        try {
+            int status = containerTransactionContext.getTransaction().getStatus();
+            assert status == Status.STATUS_ACTIVE || status == Status.STATUS_PREPARED;
+        } catch (SystemException e) {
+            throw new XAException();
+        }
+        importer.commit(containerTransactionContext.getTransaction(), onePhase);
+    }
+
+    /**
+     * @see javax.resource.spi.XATerminator#forget(javax.transaction.xa.Xid)
+     */
+    public void forget(Xid xid) throws XAException {
+        ContainerTransactionContext containerTransactionContext;
+        synchronized (importedTransactions) {
+            containerTransactionContext = (ContainerTransactionContext) importedTransactions.remove(xid);
+        }
+        if (containerTransactionContext == null) {
+            throw new XAException("No imported transaction for xid: " + xid);
+        }
+        //todo is there a correct status test here?
 //        try {
 //            int status = tx.getStatus();
 //            assert status == Status.STATUS_ACTIVE || status == Status.STATUS_PREPARED;
 //        } catch (SystemException e) {
 //            throw new XAException();
 //        }
-         importer.forget(tx);
-     }
-
-     /**
-      * @see javax.resource.spi.XATerminator#prepare(javax.transaction.xa.Xid)
-      */
-     public int prepare(Xid xid) throws XAException {
-         ImportedTransactionInfo txInfo;
-         synchronized (importedTransactions) {
-             txInfo = (ImportedTransactionInfo) importedTransactions.get(xid);
-         }
-         if (txInfo == null) {
-             throw new XAException("No imported transaction for xid: " + xid);
-         }
-         Transaction tx = txInfo.getContainerTransactionContext().getTransaction();
-         try {
-             int status = tx.getStatus();
-             assert status == Status.STATUS_ACTIVE;
-         } catch (SystemException e) {
-             throw new XAException();
-         }
-         return importer.prepare(tx);
-     }
-
-     /**
-      * @see javax.resource.spi.XATerminator#recover(int)
-      */
-     public Xid[] recover(int flag) throws XAException {
-         if (recoveryState == NOT_IN_RECOVERY) {
-             if ((flag & XAResource.TMSTARTRSCAN) == 0) {
-                 throw new XAException(XAException.XAER_PROTO);
-             }
-             recoveryState = IN_RECOVERY;
-         }
-         if ((flag & XAResource.TMENDRSCAN) != 0) {
-             recoveryState = NOT_IN_RECOVERY;
-         }
-         //we always return all xids in first call.
-         //calling "startrscan" repeatedly starts at beginning of list again.
-         if ((flag & XAResource.TMSTARTRSCAN) != 0) {
-             Map recoveredXidMap = recovery.getExternalXids();
-             Xid[] recoveredXids = new Xid[recoveredXidMap.size()];
-             int i = 0;
-             synchronized (importedTransactions) {
-                 for (Iterator iterator = recoveredXidMap.entrySet().iterator(); iterator.hasNext();)
{
-                     Map.Entry entry = (Map.Entry) iterator.next();
-                     Xid xid = (Xid) entry.getKey();
-                     recoveredXids[i++] = xid;
-                     ImportedTransactionInfo txInfo = new ImportedTransactionInfo(new ContainerTransactionContext(transactionManager,
(Transaction)entry.getValue()));
-                     importedTransactions.put(xid, txInfo);
-                 }
-             }
-             return recoveredXids;
-         } else {
-             return new Xid[0];
-         }
-     }
-
-     /**
-      * @see javax.resource.spi.XATerminator#rollback(javax.transaction.xa.Xid)
-      */
-     public void rollback(Xid xid) throws XAException {
-         ImportedTransactionInfo txInfo;
-         synchronized (importedTransactions) {
-             txInfo = (ImportedTransactionInfo) importedTransactions.remove(xid);
-         }
-         if (txInfo == null) {
-             throw new XAException("No imported transaction for xid: " + xid);
-         }
-         Transaction tx = txInfo.getContainerTransactionContext().getTransaction();
-
-         try {
-             int status = tx.getStatus();
-             assert status == Status.STATUS_ACTIVE || status == Status.STATUS_PREPARED;
-         } catch (SystemException e) {
-             throw new XAException();
-         }
-         importer.rollback(tx);
-     }
-
+        importer.forget(containerTransactionContext.getTransaction());
+    }
 
-    //XAWork implementation
-    public void begin(Xid xid, long txTimeoutMillis) throws XAException, InvalidTransactionException,
SystemException {
-        ImportedTransactionInfo txInfo;
-        boolean old = true;
+    /**
+     * @see javax.resource.spi.XATerminator#prepare(javax.transaction.xa.Xid)
+     */
+    public int prepare(Xid xid) throws XAException {
+        ContainerTransactionContext containerTransactionContext;
         synchronized (importedTransactions) {
-             txInfo = (ImportedTransactionInfo) importedTransactions.get(xid);
-            if (txInfo == null) {
-                try {
-                    Transaction transaction = importer.importXid(xid);
-                    ContainerTransactionContext containerTransactionContext = new ContainerTransactionContext(transactionManager,
transaction);
-                    txInfo = new ImportedTransactionInfo(containerTransactionContext);
-                    old = false;
-                } catch (SystemException e) {
-                    throw (XAException) new XAException("Could not import xid").initCause(e);
-                }
-                importedTransactions.put(xid, txInfo);
-            }
-            if (txInfo.isActive()) {
-                throw new XAException("Xid already active");
-            }
-            txInfo.setActive(true);
+            containerTransactionContext = (ContainerTransactionContext) importedTransactions.get(xid);
         }
-        if (old) {
-            txInfo.getContainerTransactionContext().resume();
+        if (containerTransactionContext == null) {
+            throw new XAException("No imported transaction for xid: " + xid);
         }
-        importer.setTransactionTimeout(txTimeoutMillis);
+        Transaction tx = containerTransactionContext.getTransaction();
+        try {
+            int status = tx.getStatus();
+            assert status == Status.STATUS_ACTIVE;
+        } catch (SystemException e) {
+            throw new XAException();
+        }
+        return importer.prepare(tx);
     }
 
-    public void end(Xid xid) throws XAException, SystemException {
-        synchronized (importedTransactions) {
-            ImportedTransactionInfo txInfo = (ImportedTransactionInfo) importedTransactions.get(xid);
-            if (txInfo == null) {
-                throw new XAException("No imported transaction for xid: " + xid);
+    /**
+     * @see javax.resource.spi.XATerminator#recover(int)
+     */
+    public Xid[] recover(int flag) throws XAException {
+        if (recoveryState == NOT_IN_RECOVERY) {
+            if ((flag & XAResource.TMSTARTRSCAN) == 0) {
+                throw new XAException(XAException.XAER_PROTO);
             }
-            if (!txInfo.isActive()) {
-                throw new XAException("tx not active for xid: " + xid);
+            recoveryState = IN_RECOVERY;
+        }
+        if ((flag & XAResource.TMENDRSCAN) != 0) {
+            recoveryState = NOT_IN_RECOVERY;
+        }
+        //we always return all xids in first call.
+        //calling "startrscan" repeatedly starts at beginning of list again.
+        if ((flag & XAResource.TMSTARTRSCAN) != 0) {
+            Map recoveredXidMap = recovery.getExternalXids();
+            Xid[] recoveredXids = new Xid[recoveredXidMap.size()];
+            int i = 0;
+            synchronized (importedTransactions) {
+                for (Iterator iterator = recoveredXidMap.entrySet().iterator(); iterator.hasNext();)
{
+                    Map.Entry entry = (Map.Entry) iterator.next();
+                    Xid xid = (Xid) entry.getKey();
+                    recoveredXids[i++] = xid;
+                    ContainerTransactionContext containerTransactionContext = new ContainerTransactionContext(transactionManager,
(Transaction) entry.getValue());
+                    importedTransactions.put(xid, containerTransactionContext);
+                }
             }
-            txInfo.getContainerTransactionContext().suspend();
-            txInfo.setActive(false);
+            return recoveredXids;
+        } else {
+            return new Xid[0];
         }
     }
 
-    //todo make an imported transaction context with this info.
-    private static class ImportedTransactionInfo {
-        private final ContainerTransactionContext containerTransactionContext;
-        private boolean active;
-
-        public ImportedTransactionInfo(ContainerTransactionContext containerTransactionContext)
{
-            this.containerTransactionContext = containerTransactionContext;
+    /**
+     * @see javax.resource.spi.XATerminator#rollback(javax.transaction.xa.Xid)
+     */
+    public void rollback(Xid xid) throws XAException {
+        ContainerTransactionContext containerTransactionContext;
+        synchronized (importedTransactions) {
+            containerTransactionContext = (ContainerTransactionContext) importedTransactions.remove(xid);
+        }
+        if (containerTransactionContext == null) {
+            throw new XAException("No imported transaction for xid: " + xid);
         }
+        Transaction tx = containerTransactionContext.getTransaction();
 
-        public ContainerTransactionContext getContainerTransactionContext() {
-            return containerTransactionContext;
+        try {
+            int status = tx.getStatus();
+            assert status == Status.STATUS_ACTIVE || status == Status.STATUS_PREPARED;
+        } catch (SystemException e) {
+            throw new XAException();
         }
+        importer.rollback(tx);
+    }
 
-        public boolean isActive() {
-            return active;
+
+    //XAWork implementation
+    public void begin(Xid xid, long txTimeoutMillis) throws XAException, InvalidTransactionException,
SystemException, ImportedTransactionActiveException {
+        ContainerTransactionContext containerTransactionContext;
+        synchronized (importedTransactions) {
+            containerTransactionContext = (ContainerTransactionContext) importedTransactions.get(xid);
+            if (containerTransactionContext == null) {
+                //this does not associate tx with current thread.
+                Transaction transaction = importer.importXid(xid);
+                containerTransactionContext = new ContainerTransactionContext(transactionManager,
transaction);
+                importedTransactions.put(xid, containerTransactionContext);
+            } else {
+                if (containerTransactionContext.isThreadAssociated()) {
+                    throw new ImportedTransactionActiveException(xid);
+                }
+            }
+            containerTransactionContext.resume();
         }
+        importer.setTransactionTimeout(txTimeoutMillis);
+    }
 
-        public void setActive(boolean active) {
-            this.active = active;
+    public void end(Xid xid) throws XAException, SystemException {
+        synchronized (importedTransactions) {
+            ContainerTransactionContext containerTransactionContext = (ContainerTransactionContext)
importedTransactions.get(xid);
+            if (containerTransactionContext == null) {
+                throw new XAException("No imported transaction for xid: " + xid);
+            }
+            if (!containerTransactionContext.isThreadAssociated()) {
+                throw new XAException("tx not active for containerTransactionContext: " +
containerTransactionContext + ", xid: " + xid);
+            }
+            containerTransactionContext.suspend();
         }
     }
 
+
     public static final GBeanInfo GBEAN_INFO;
 
     static {
         GBeanInfoFactory infoFactory = new GBeanInfoFactory(TransactionContextManager.class);
         infoFactory.addOperation("getContext");
-        infoFactory.addOperation("setContext", new Class[] {TransactionContext.class});
+        infoFactory.addOperation("setContext", new Class[]{TransactionContext.class});
         infoFactory.addOperation("newContainerTransactionContext");
         infoFactory.addOperation("newBeanTransactionContext");
         infoFactory.addOperation("newUnspecifiedTransactionContext");
@@ -324,7 +292,7 @@
         infoFactory.addInterface(XATerminator.class);
         infoFactory.addInterface(XAWork.class);
 
-        infoFactory.setConstructor(new String[] {"TransactionManager", "XidImporter", "Recovery"});
+        infoFactory.setConstructor(new String[]{"TransactionManager", "XidImporter", "Recovery"});
         GBEAN_INFO = infoFactory.getBeanInfo();
     }
 

Modified: geronimo/trunk/modules/transaction/src/test/org/apache/geronimo/transaction/TransactionManagerProxyTest.java
==============================================================================
--- geronimo/trunk/modules/transaction/src/test/org/apache/geronimo/transaction/TransactionManagerProxyTest.java
(original)
+++ geronimo/trunk/modules/transaction/src/test/org/apache/geronimo/transaction/TransactionManagerProxyTest.java
Thu Oct  7 13:49:55 2004
@@ -255,12 +255,14 @@
     public void testSimpleRecovery() throws Exception {
         //create a transaction in our own transaction manager
         Xid xid = xidFactory.createXid();
-        tm.importXid(xid);
-        Transaction tx = tm.getTransaction();
+        Transaction tx = tm.importXid(xid);
+        tm.resume(tx);
+        assertSame(tx, tm.getTransaction());
         tx.enlistResource(r1_2);
         tx.enlistResource(r2_2);
         tx.delistResource(r1_2, XAResource.TMSUCCESS);
         tx.delistResource(r2_2, XAResource.TMSUCCESS);
+        tm.suspend();
         tm.prepare(tx);
         //recover
         resourceManagers.add(rm1);
@@ -276,12 +278,14 @@
         //create a transaction from an external transaction manager.
         XidFactory xidFactory2 = new XidFactoryImpl("tm2".getBytes());
         Xid xid = xidFactory2.createXid();
-        tm.importXid(xid);
-        Transaction tx = tm.getTransaction();
+        Transaction tx = tm.importXid(xid);
+        tm.resume(tx);
+        assertSame(tx, tm.getTransaction());
         tx.enlistResource(r1_2);
         tx.enlistResource(r2_2);
         tx.delistResource(r1_2, XAResource.TMSUCCESS);
         tx.delistResource(r2_2, XAResource.TMSUCCESS);
+        tm.suspend();
         tm.prepare(tx);
         //recover
         resourceManagers.add(rm1);

Added: geronimo/trunk/modules/transaction/src/test/org/apache/geronimo/transaction/context/TransactionContextManagerTest.java
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/transaction/src/test/org/apache/geronimo/transaction/context/TransactionContextManagerTest.java
Thu Oct  7 13:49:55 2004
@@ -0,0 +1,36 @@
+package org.apache.geronimo.transaction.context;
+
+import javax.transaction.xa.Xid;
+
+import junit.framework.TestCase;
+import org.apache.geronimo.transaction.TransactionManagerProxy;
+import org.apache.geronimo.transaction.GeronimoTransactionManager;
+import org.apache.geronimo.transaction.manager.XidFactoryImpl;
+import org.apache.geronimo.transaction.manager.XidFactory;
+
+/**
+ */
+public class TransactionContextManagerTest extends TestCase {
+
+    private TransactionContextManager transactionContextManager;
+    private XidFactory xidFactory = new XidFactoryImpl("geronimo.test.tm".getBytes());
+
+    protected void setUp() throws Exception {
+        TransactionManagerProxy tm = new GeronimoTransactionManager(null, null);
+        transactionContextManager = new TransactionContextManager(tm, tm, tm);
+    }
+
+    protected void tearDown() throws Exception {
+        transactionContextManager = null;
+    }
+
+    public void testImportedTxLifecycle() throws Exception {
+        Xid xid = xidFactory.createXid();
+        transactionContextManager.begin(xid, 0);
+        transactionContextManager.end(xid);
+        transactionContextManager.begin(xid, 0);
+        transactionContextManager.end(xid);
+        transactionContextManager.prepare(xid);
+        transactionContextManager.commit(xid, false);
+    }
+}

Mime
View raw message