c.put("/one/two", "key1", "value");
GlobalTransaction gtx = c.getCurrentTransaction(tx, true);
TransactionTable table = c.getTransactionTable();
OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
assertNotNull(mgr.getTransaction());
WriteCommand command = entry.getModifications().get(0);
mgr.commit();
GlobalTransaction remoteGtx = new GlobalTransaction();
Address mockAddress = EasyMock.createNiceMock(Address.class);
remoteGtx.setAddress(mockAddress);
//hack the method call to make it have the remote globalTransaction
command.setGlobalTransaction(remoteGtx);
//call our remote method
List<WriteCommand> cacheCommands = injectDataVersion(entry.getModifications());
OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(remoteGtx, cacheCommands, (Address) remoteGtx.getAddress(), false);
TestingUtil.replicateCommand(c, prepareCommand);
//our thread should be null
assertNull(mgr.getTransaction());
// there should be a registration for the remote globalTransaction
assertNotNull(table.get(remoteGtx));
assertNotNull(table.getLocalTransaction(remoteGtx));
//assert that this is populated
// assertEquals(1, table.get(remoteGtx).getModifications().size());
//assert that the remote prepare has populated the local workspace
assertEquals(3, entry.getTransactionWorkSpace().getNodes().size());
List<?> calls = dummy.getAllCalled();
assertEquals(OptimisticPrepareCommand.class, calls.get(2));
assertEquals(1, c.getTransactionTable().getNumGlobalTransactions());
assertEquals(1, c.getTransactionTable().getNumLocalTransactions());