use of com.hazelcast.internal.nio.Packet in project hazelcast by hazelcast.
the class OutboundResponseHandlerTest method testToNormalResponsePacket.
private void testToNormalResponsePacket(Object value, int callId, int backupAcks, boolean urgent) {
Packet packet = handler.toNormalResponsePacket(callId, backupAcks, urgent, value);
HeapData expected = serializationService.toData(new NormalResponse(value, callId, backupAcks, urgent));
assertEquals(expected, new HeapData(packet.toByteArray()));
}
use of com.hazelcast.internal.nio.Packet in project hazelcast by hazelcast.
the class OutboundResponseHandlerTest method sendResponse_whenTimeoutResponse.
@Test
public void sendResponse_whenTimeoutResponse() {
CallTimeoutResponse response = new CallTimeoutResponse(10, false);
Operation op = createDummyOperation(10);
ArgumentCaptor<Packet> argument = ArgumentCaptor.forClass(Packet.class);
when(connectionManager.transmit(argument.capture(), eq(thatAddress), anyInt())).thenReturn(true);
// make the call
handler.sendResponse(op, response);
// verify that the right object was send
assertEquals(serializationService.toData(response), argument.getValue());
}
use of com.hazelcast.internal.nio.Packet in project hazelcast by hazelcast.
the class OutboundResponseHandlerTest method sendResponse_whenErrorResponse.
@Test
public void sendResponse_whenErrorResponse() {
ErrorResponse response = new ErrorResponse(new Exception(), 10, false);
Operation op = createDummyOperation(10);
ArgumentCaptor<Packet> argument = ArgumentCaptor.forClass(Packet.class);
when(connectionManager.transmit(argument.capture(), eq(thatAddress), anyInt())).thenReturn(true);
// make the call
handler.sendResponse(op, response);
// verify that the right object was send
assertEquals(serializationService.toData(response), argument.getValue());
}
use of com.hazelcast.internal.nio.Packet in project hazelcast by hazelcast.
the class PacketDispatcherTest method whenOperationPacket.
@Test
public void whenOperationPacket() {
Packet packet = new Packet().setPacketType(Packet.Type.OPERATION);
dispatcher.accept(packet);
verify(operationExecutor).accept(packet);
verifyZeroInteractions(responseHandler, eventService, invocationMonitor, jetService);
}
use of com.hazelcast.internal.nio.Packet in project hazelcast by hazelcast.
the class PacketDispatcherTest method whenOperationResponsePacket.
@Test
public void whenOperationResponsePacket() {
Packet packet = new Packet().setPacketType(Packet.Type.OPERATION).raiseFlags(FLAG_OP_RESPONSE);
dispatcher.accept(packet);
verify(responseHandler).accept(packet);
verifyZeroInteractions(operationExecutor, eventService, invocationMonitor, jetService);
}
Aggregations