1 17 18 package org.apache.geronimo.transaction.manager; 19 20 import javax.transaction.Transaction ; 21 import javax.transaction.xa.XAResource ; 22 23 import junit.framework.TestCase; 24 25 27 public class ProtocolTest extends TestCase { 28 29 private TransactionManagerImpl tm; 30 private MockResourceManager mrm1, mrm2; 31 private MockResource mr11, mr12, mr21, mr22; 32 33 protected void setUp() throws Exception { 34 tm = new TransactionManagerImpl(); 35 mrm1 = new MockResourceManager(true); 36 mrm2 = new MockResourceManager(true); 37 mr11 = new MockResource(mrm1, "mr11"); 38 mr12 = new MockResource(mrm1, "mr12"); 39 mr21 = new MockResource(mrm2, "mr21"); 40 mr22 = new MockResource(mrm2, "mr22"); 41 } 42 43 public void testOnePhaseCommit() throws Exception { 44 tm.begin(); 45 Transaction tx = tm.getTransaction(); 46 tx.enlistResource(mr11); 47 tx.delistResource(mr11, XAResource.TMSUSPEND); 48 tm.commit(); 49 } 50 51 public void testOnePhaseCommiTwoResources() throws Exception { 52 tm.begin(); 53 Transaction tx = tm.getTransaction(); 54 tx.enlistResource(mr11); 55 tx.delistResource(mr11, XAResource.TMSUSPEND); 56 tx.enlistResource(mr12); 57 tx.delistResource(mr12, XAResource.TMSUSPEND); 58 tm.commit(); 59 } 60 public void testTwoPhaseCommit() throws Exception { 61 tm.begin(); 62 Transaction tx = tm.getTransaction(); 63 tx.enlistResource(mr11); 64 tx.delistResource(mr11, XAResource.TMSUSPEND); 65 tx.enlistResource(mr21); 66 tx.delistResource(mr21, XAResource.TMSUSPEND); 67 tm.commit(); 68 } 69 public void testTwoPhaseCommit4Resources() throws Exception { 70 tm.begin(); 71 Transaction tx = tm.getTransaction(); 72 tx.enlistResource(mr11); 73 tx.delistResource(mr11, XAResource.TMSUSPEND); 74 tx.enlistResource(mr12); 75 tx.delistResource(mr12, XAResource.TMSUSPEND); 76 tx.enlistResource(mr21); 77 tx.delistResource(mr21, XAResource.TMSUSPEND); 78 tx.enlistResource(mr22); 79 tx.delistResource(mr22, XAResource.TMSUSPEND); 80 tm.commit(); 81 } 82 83 } 84 | Popular Tags |