geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: rev 54119 - in geronimo/trunk/modules/transaction/src: java/org/apache/geronimo/transaction java/org/apache/geronimo/transaction/manager test/org/apache/geronimo/transaction/context
Date Fri, 08 Oct 2004 22:11:52 GMT
Author: djencks
Date: Fri Oct  8 15:11:51 2004
New Revision: 54119

Modified:
   geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/TransactionManagerProxy.java
   geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/manager/TransactionManagerImpl.java
   geronimo/trunk/modules/transaction/src/test/org/apache/geronimo/transaction/context/TransactionContextManagerTest.java
Log:
a couple more tests and tweaks

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
Fri Oct  8 15:11:51 2004
@@ -217,9 +217,9 @@
     //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");
-        }
+//        if (threadTx.get() != null) {
+//            throw new XAException("Transaction already associated with current thread");
+//        }
         TransactionProxy transactionProxy = new TransactionProxy(importer.importXid(xid));
 //        threadTx.set(transactionProxy);
         return transactionProxy;

Modified: geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/manager/TransactionManagerImpl.java
==============================================================================
--- geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/manager/TransactionManagerImpl.java
(original)
+++ geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/manager/TransactionManagerImpl.java
Fri Oct  8 15:11:51 2004
@@ -125,11 +125,11 @@
     }
 
     public Transaction importXid(Xid xid) throws XAException, SystemException {
-        if (getStatus() != Status.STATUS_NO_TRANSACTION) {
-            throw new XAException("Transaction already active in this thread");
-        }
+//        if (getStatus() != Status.STATUS_NO_TRANSACTION) {
+//            throw new XAException("Transaction already active in this thread");
+//        }
         TransactionImpl tx = new TransactionImpl(xid, xidFactory, txnLog);
-        threadTx.set(tx);
+//        threadTx.set(tx);
         return tx;
     }
 

Modified: geronimo/trunk/modules/transaction/src/test/org/apache/geronimo/transaction/context/TransactionContextManagerTest.java
==============================================================================
--- geronimo/trunk/modules/transaction/src/test/org/apache/geronimo/transaction/context/TransactionContextManagerTest.java
(original)
+++ geronimo/trunk/modules/transaction/src/test/org/apache/geronimo/transaction/context/TransactionContextManagerTest.java
Fri Oct  8 15:11:51 2004
@@ -1,14 +1,36 @@
+/**
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
 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.ImportedTransactionActiveException;
+import org.apache.geronimo.transaction.TransactionManagerProxy;
 import org.apache.geronimo.transaction.manager.XidFactory;
+import org.apache.geronimo.transaction.manager.XidFactoryImpl;
 
 /**
+ *
+ *
+ * @version $Rev: 54013 $ $Date: 2004-10-07 13:49:55 -0700 (Thu, 07 Oct 2004) $
+ *
  */
 public class TransactionContextManagerTest extends TestCase {
 
@@ -32,5 +54,28 @@
         transactionContextManager.end(xid);
         transactionContextManager.prepare(xid);
         transactionContextManager.commit(xid, false);
+    }
+
+    public void testNoConcurrentWorkSameXid() throws Exception {
+        Xid xid = xidFactory.createXid();
+        transactionContextManager.begin(xid, 0);
+        try {
+            transactionContextManager.begin(xid, 0);
+            fail("should not be able begin same xid twice");
+        } catch (ImportedTransactionActiveException e) {
+            //expected
+        }
+    }
+
+    public void testOnlyOneImportedTxAtATime() throws Exception {
+        Xid xid1 = xidFactory.createXid();
+        Xid xid2 = xidFactory.createXid();
+        transactionContextManager.begin(xid1, 0);
+        try {
+            transactionContextManager.begin(xid2, 0);
+            fail("should not be able to begin a 2nd tx without ending the first");
+        } catch (IllegalStateException e) {
+            //expected
+        }
     }
 }

Mime
View raw message