// once we enlist ensure that the 5 acks are merged ok, the first timne we do this there is nothing to merge in
// the global tx
// so all acks are just copied
trans.enlistResource(res1);
SessionState sstate = (SessionState)((DelegateSupport)sess1.getDelegate()).getState();
ClientTransaction clientTransaction = rm.getTx(sstate.getCurrentTxId());
assertEquals("to many session states", clientTransaction.getSessionStates().size(), 1);
ClientTransaction.SessionTxState sessionTxState = (ClientTransaction.SessionTxState)clientTransaction.getSessionStates()
.get(0);
assertEquals("wrong number of acks", 5, sessionTxState.getAcks().size());
trans.delistResource(res1, XAResource.TMSUCCESS);
for (int i = 5; i < 10; i++)
{
TextMessage textMessage = (TextMessage)cons.receive();
assertEquals("delistedwork" + i, textMessage.getText());
}
// now reenlist and make sure that there are now 10 acks, this time around a merge will be done with the first
// 5 acks
//
trans.enlistResource(res1);
clientTransaction = rm.getTx(sstate.getCurrentTxId());
assertEquals("to many session states", clientTransaction.getSessionStates().size(), 1);
sessionTxState = (ClientTransaction.SessionTxState)clientTransaction.getSessionStates().get(0);
assertEquals("wrong number of acks", 10, sessionTxState.getAcks().size());
tm.commit();
}