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()));
}
Aggregations