use of org.neo4j.kernel.ha.com.master.MasterImpl.SPI in project neo4j by neo4j.
the class MasterImplTest method shouldAllowCommitIfClientHoldsNoLocks.
@Test
public void shouldAllowCommitIfClientHoldsNoLocks() throws Throwable {
// Given
MasterImpl.SPI spi = mock(MasterImpl.SPI.class);
Config config = config();
DefaultConversationSPI conversationSpi = mockedConversationSpi();
ConversationManager conversationManager = new ConversationManager(conversationSpi, config);
Client locks = mock(Client.class);
when(locks.trySharedLock(ResourceTypes.SCHEMA, ResourceTypes.schemaResource())).thenReturn(true);
when(spi.isAccessible()).thenReturn(true);
when(spi.getTransactionChecksum(anyLong())).thenReturn(1L);
when(conversationSpi.acquireClient()).thenReturn(locks);
mockEmptyResponse(spi);
MasterImpl master = new MasterImpl(spi, conversationManager, mock(MasterImpl.Monitor.class), config);
master.start();
HandshakeResult handshake = master.handshake(1, newStoreIdForCurrentVersion()).response();
int no_lock_session = -1;
RequestContext ctx = new RequestContext(handshake.epoch(), 1, no_lock_session, 0, 0);
TransactionRepresentation tx = mock(TransactionRepresentation.class);
// When
master.commit(ctx, tx);
// Then
verify(spi).applyPreparedTransaction(tx);
}
Aggregations