GlobalTransaction gtx = cache.getCurrentTransaction(tx, true);
TransactionTable table = cache.getTransactionTable();
OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
assertNotNull(mgr.getTransaction());
MethodCall meth = entry.getModifications().get(0);
mgr.commit();
//test local calls
List<?> calls = dummy.getAllCalledIds();
assertEquals(MethodDeclarations.optimisticPrepareMethod_id, calls.get(0));
assertEquals(MethodDeclarations.commitMethod_id, calls.get(1));
assertNull(mgr.getTransaction());
assertEquals(0, cache.getTransactionTable().getNumGlobalTransactions());
assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());
GlobalTransaction remoteGtx = new GlobalTransaction();
remoteGtx.setAddress(new DummyAddress());
// hack the method call to make it have the remote gtx
meth.getArgs()[0] = remoteGtx;
//call our remote method
MethodCall prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod_id, remoteGtx, injectDataVersion(entry.getModifications()), null, remoteGtx.getAddress(), Boolean.FALSE);
try
{
TestingUtil.getRemoteDelegate(cache)._replicate(prepareMethod);
}
catch (Throwable t)
{
fail();
}
//our thread should be null
assertNull(mgr.getTransaction());
assertEquals(1, cache.getTransactionTable().getNumGlobalTransactions());
assertEquals(1, cache.getTransactionTable().getNumLocalTransactions());
// there should be a registration for the remote gtx
assertNotNull(table.get(remoteGtx));
assertNotNull(table.getLocalTransaction(remoteGtx));
//this is not populated until replication interceptor is used
calls = dummy.getAllCalledIds();
assertEquals(MethodDeclarations.optimisticPrepareMethod_id, calls.get(2));
assertNull(mgr.getTransaction());
// call our remote method
MethodCall commitMethod = MethodCallFactory.create(MethodDeclarations.commitMethod_id, remoteGtx, Boolean.TRUE);
try
{
TestingUtil.getRemoteDelegate(cache)._replicate(commitMethod);
}
catch (Throwable t)