use of org.neo4j.kernel.ha.com.master.MasterImpl.Monitor in project neo4j by neo4j.
the class MasterImplTest method shouldAllowStartNewTransactionAfterClientSessionWasRemovedOnTimeout.
@Test
public void shouldAllowStartNewTransactionAfterClientSessionWasRemovedOnTimeout() throws Throwable {
//Given
MasterImpl.SPI spi = mockedSpi();
DefaultConversationSPI conversationSpi = mockedConversationSpi();
Monitor monitor = mock(Monitor.class);
Config config = config();
Client client = mock(Client.class);
ConversationManager conversationManager = new ConversationManager(conversationSpi, config);
int machineId = 1;
MasterImpl master = new MasterImpl(spi, conversationManager, monitor, config);
when(spi.isAccessible()).thenReturn(true);
when(conversationSpi.acquireClient()).thenReturn(client);
master.start();
HandshakeResult handshake = master.handshake(1, newStoreIdForCurrentVersion()).response();
RequestContext requestContext = new RequestContext(handshake.epoch(), machineId, 0, 0, 0);
// When
master.newLockSession(requestContext);
master.acquireSharedLock(requestContext, ResourceTypes.NODE, 1L);
conversationManager.stop(requestContext);
master.newLockSession(requestContext);
//Then
Map<Integer, Collection<RequestContext>> transactions = master.getOngoingTransactions();
assertEquals(1, transactions.size());
assertThat(transactions.get(machineId), org.hamcrest.Matchers.hasItem(requestContext));
}
Aggregations