use of org.neo4j.com.storecopy.ResponseUnpacker in project neo4j by neo4j.
the class TestCommunication method masterResponseShouldNotBeUnpackedIfRequestTypeDoesNotRequire.
@Test
public void masterResponseShouldNotBeUnpackedIfRequestTypeDoesNotRequire() {
// Given
ResponseUnpacker responseUnpacker = mock(ResponseUnpacker.class);
MadeUpClient client = builder.clientWith(responseUnpacker);
addToLifeAndStart(builder.server(), client);
// When
client.sendDataStream(new KnownDataByteChannel(100));
// Then
verifyZeroInteractions(responseUnpacker);
}
use of org.neo4j.com.storecopy.ResponseUnpacker in project neo4j by neo4j.
the class TestCommunication method masterResponseShouldBeUnpackedIfRequestTypeRequires.
@Test
@SuppressWarnings("rawtypes")
public void masterResponseShouldBeUnpackedIfRequestTypeRequires() throws Exception {
// Given
ResponseUnpacker responseUnpacker = mock(ResponseUnpacker.class);
MadeUpClient client = builder.clientWith(responseUnpacker);
addToLifeAndStart(builder.server(), client);
// When
client.multiply(42, 42);
// Then
ArgumentCaptor<Response> captor = ArgumentCaptor.forClass(Response.class);
verify(responseUnpacker).unpackResponse(captor.capture(), eq(NO_OP_TX_HANDLER));
assertEquals(storeIdToUse, captor.getValue().getStoreId());
assertEquals(42 * 42, captor.getValue().response());
}
use of org.neo4j.com.storecopy.ResponseUnpacker in project neo4j by neo4j.
the class MasterClientTest method clientShouldReadAndApplyTransactionLogsOnNewLockSessionRequest.
@Test
public void clientShouldReadAndApplyTransactionLogsOnNewLockSessionRequest() throws Throwable {
// Given
MasterImpl master = spy(newMasterImpl(mockMasterImplSpiWith(StoreId.DEFAULT)));
doReturn(voidResponseWithTransactionLogs()).when(master).newLockSession(any(RequestContext.class));
newMasterServer(master);
Dependencies deps = mock(Dependencies.class);
TransactionCommitProcess commitProcess = mock(TransactionCommitProcess.class);
when(deps.commitProcess()).thenReturn(commitProcess);
when(deps.logService()).thenReturn(NullLogService.getInstance());
when(deps.kernelTransactions()).thenReturn(mock(KernelTransactions.class));
ResponseUnpacker unpacker = life.add(new TransactionCommittingResponseUnpacker(deps, DEFAULT_BATCH_SIZE, 0));
MasterClient masterClient = newMasterClient320(StoreId.DEFAULT, unpacker);
// When
masterClient.newLockSession(new RequestContext(1, 2, 3, 4, 5));
// Then
verify(commitProcess).commit(any(TransactionToApply.class), any(CommitEvent.class), any(TransactionApplicationMode.class));
}
use of org.neo4j.com.storecopy.ResponseUnpacker in project neo4j by neo4j.
the class MasterClientTest method endLockSessionDoesNotUnpackResponse.
@Test
public void endLockSessionDoesNotUnpackResponse() throws Throwable {
StoreId storeId = new StoreId(1, 2, 3, 4, 5);
long txChecksum = 123;
long lastAppliedTx = 5;
ResponseUnpacker responseUnpacker = mock(ResponseUnpacker.class);
MasterImpl.SPI masterImplSPI = MasterImplTest.mockedSpi(storeId);
when(masterImplSPI.packTransactionObligationResponse(any(RequestContext.class), Matchers.anyObject())).thenReturn(Response.empty());
when(masterImplSPI.getTransactionChecksum(anyLong())).thenReturn(txChecksum);
newMasterServer(masterImplSPI);
MasterClient client = newMasterClient320(storeId, responseUnpacker);
HandshakeResult handshakeResult;
try (Response<HandshakeResult> handshakeResponse = client.handshake(1, storeId)) {
handshakeResult = handshakeResponse.response();
}
verify(responseUnpacker).unpackResponse(any(Response.class), any(TxHandler.class));
reset(responseUnpacker);
RequestContext context = new RequestContext(handshakeResult.epoch(), 1, 1, lastAppliedTx, txChecksum);
client.endLockSession(context, false);
verify(responseUnpacker, never()).unpackResponse(any(Response.class), any(TxHandler.class));
}
Aggregations