Search in sources :

Example 1 with XidFactoryImpl

use of org.apache.aries.transaction.internal.XidFactoryImpl in project aries by apache.

the class XidFactoryImplTest method testAriesFactory.

@Test
public void testAriesFactory() throws Exception {
    XidFactory factory = new XidFactoryImpl("hi".getBytes());
    Xid id1 = factory.createXid();
    Xid id2 = factory.createXid();
    assertFalse("Should not match new: " + id1, factory.matchesGlobalId(id1.getGlobalTransactionId()));
    assertFalse("Should not match new: " + id2, factory.matchesGlobalId(id2.getGlobalTransactionId()));
    Xid b_id1 = factory.createBranch(id1, 1);
    Xid b_id2 = factory.createBranch(id2, 1);
    assertFalse("Should not match new branch: " + b_id1, factory.matchesBranchId(b_id1.getBranchQualifier()));
    assertFalse("Should not match new branch: " + b_id2, factory.matchesBranchId(b_id2.getBranchQualifier()));
    Thread.sleep(5);
    XidFactory factory2 = new XidFactoryImpl("hi".getBytes());
    assertTrue("Should match old: " + id1, factory2.matchesGlobalId(id1.getGlobalTransactionId()));
    assertTrue("Should match old: " + id2, factory2.matchesGlobalId(id2.getGlobalTransactionId()));
    assertTrue("Should match old branch: " + b_id1, factory2.matchesBranchId(b_id1.getBranchQualifier()));
    assertTrue("Should match old branch: " + b_id2, factory2.matchesBranchId(b_id2.getBranchQualifier()));
}
Also used : Xid(javax.transaction.xa.Xid) XidFactoryImpl(org.apache.aries.transaction.internal.XidFactoryImpl) XidFactory(org.apache.geronimo.transaction.manager.XidFactory) Test(org.junit.Test)

Aggregations

Xid (javax.transaction.xa.Xid)1 XidFactoryImpl (org.apache.aries.transaction.internal.XidFactoryImpl)1 XidFactory (org.apache.geronimo.transaction.manager.XidFactory)1 Test (org.junit.Test)1