@Before public void setup() { initMocks(this); when(cache.getDistributedSystem()).thenReturn(distributedSystem); when(distributedSystem.getDistributionManager()).thenReturn(distributionManager); when(region.getCache()).thenReturn(cache); when(region.getDistributionManager()).thenReturn(distributionManager); when(txStateProxy.isInProgress()).thenReturn(true); originalTxManager = TXManagerImpl.getCurrentInstanceForTest(); // The constructor sets the new tx manager as currentInstance txManager = spy(new TXManagerImpl(mock(CachePerfStats.class), cache)); txManager.setTXState(txStateProxy); txManager.setDistributed(false); when(cache.getTxManager()).thenReturn(txManager); }
@Test public void noNewTxProcessingAfterTXManagerImplClosed() throws Exception { txMgr = new TXManagerImpl(null, cache); when(msg.getPartitionedRegion()).thenReturn(pr); when(msg.getStartPartitionMessageProcessingTime(pr)).thenReturn(startTime); when(msg.getTXManagerImpl(cache)).thenReturn(txMgr); when(msg.canParticipateInTransaction()).thenReturn(true); when(msg.canStartRemoteTransaction()).thenReturn(true); msg.process(dm); txMgr.close(); msg.process(dm); verify(msg, times(1)).operateOnPartitionedRegion(dm, pr, startTime); } }
@Before public void setUp() { cache = Fakes.cache(); dm = mock(ClusterDistributionManager.class); txMgr = new TXManagerImpl(mock(CachePerfStats.class), cache); txid = new TXId(null, 0); msg = mock(DestroyMessage.class); txCommitMsg = mock(TXCommitMessage.class); member = mock(InternalDistributedMember.class); completedTxid = new TXId(member, 1); notCompletedTxid = new TXId(member, 2); latch = new CountDownLatch(1); rollbackMsg = new TXRemoteRollbackMessage(); commitMsg = new TXRemoteCommitMessage(); when(this.msg.canStartRemoteTransaction()).thenReturn(true); when(this.msg.canParticipateInTransaction()).thenReturn(true); spyCache = spy(Fakes.cache()); InternalDistributedSystem distributedSystem = mock(InternalDistributedSystem.class); doReturn(distributedSystem).when(spyCache).getDistributedSystem(); when(distributedSystem.getDistributionManager()).thenReturn(dm); when(distributedSystem.getDistributedMember()).thenReturn(member); spyTxMgr = spy(new TXManagerImpl(mock(CachePerfStats.class), spyCache)); timer = mock(SystemTimer.class); doReturn(timer).when(spyCache).getCCPTimer(); }
CachePerfStats.enableClockStats = this.system.getConfig().getEnableTimeStatistics(); this.transactionManager = new TXManagerImpl(this.cachePerfStats, this); this.dm.addMembershipListener(this.transactionManager);