JtaBeforeCompletionMessage extends TXMessage { @Override protected boolean operateOnTx(TXId txId, ClusterDistributionManager dm) { InternalCache cache = dm.getCache(); TXManagerImpl txMgr = cache.getTXMgr(); if (logger.isDebugEnabled()) { logger.debug("JTA: Calling beforeCompletion for :{}", txId); } if (txMgr.isHostedTxRecentlyCompleted(txId)) { return true; } txMgr.getTXState().beforeCompletion(); return true; } JtaBeforeCompletionMessage();  JtaBeforeCompletionMessage(int txUniqId, InternalDistributedMember onBehalfOfClientMember,
      ReplyProcessor21 processor); static ReliableReplyProcessor21 send(Cache cache, int txUniqId,
      InternalDistributedMember onBehalfOfClientMember, DistributedMember recipient); @Override int getDSFID();  }
@Test public void testBeforeCompletionNotInvokedIfJTACompleted() throws Exception { InternalCache cache = mock(InternalCache.class); TXManagerImpl txMgr = mock(TXManagerImpl.class); ClusterDistributionManager distributionManager = mock(ClusterDistributionManager.class); TXId txId = mock(TXId.class); when(distributionManager.getCache()).thenReturn(cache); when(cache.getTXMgr()).thenReturn(txMgr); when(txMgr.isHostedTxRecentlyCompleted(txId)).thenReturn(true); when(txMgr.getTXState()).thenReturn(mock(TXStateProxyImpl.class)); JtaBeforeCompletionMessage message = new JtaBeforeCompletionMessage(1, mock(InternalDistributedMember.class), mock(ReplyProcessor21.class)); message.operateOnTx(txId, distributionManager); verify(txMgr, never()).getTXState(); }