cache.put("/one/two", "key1", pojo);
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();
GlobalTransaction remoteGtx = new GlobalTransaction();
remoteGtx.setAddress(new TestAddress());
//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(), false);
try
{
TestingUtil.getRemoteDelegate(cache)._replicate(prepareMethod);
}
catch (Throwable t)
{
fail();
}
//our thread should be null
assertNull(mgr.getTransaction());
// there should be a registration for the remote gtx
assertNotNull(table.get(remoteGtx));
assertNotNull(table.getLocalTransaction(remoteGtx));
//assert that this is populated
//assert that the remote prepare has populated the local workspace
assertEquals(3, entry.getTransactionWorkSpace().getNodes().size());
List calls = dummy.getAllCalledIds();
assertEquals(MethodDeclarations.optimisticPrepareMethod_id, calls.get(2));
assertEquals(1, cache.getTransactionTable().getNumGlobalTransactions());