use of com.hazelcast.internal.nio.Packet in project hazelcast by hazelcast.
the class OperationRunnerImplTest method runPacket_whenBroken.
@Test(expected = HazelcastSerializationException.class)
public void runPacket_whenBroken() throws Exception {
Operation op = new DummyOperation();
setCallId(op, 1000 * 1000);
Packet packet = toPacket(local, remote, op);
byte[] bytes = packet.toByteArray();
for (int k = 0; k < bytes.length; k++) {
bytes[k]++;
}
operationRunner.run(packet);
}
use of com.hazelcast.internal.nio.Packet in project hazelcast by hazelcast.
the class OutboundResponseHandlerTest method sendResponse_whenThrowable.
@Test
public void sendResponse_whenThrowable() {
Exception exception = new Exception();
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, exception);
// verify that the right object was send
ErrorResponse expectedResponse = new ErrorResponse(exception, op.getCallId(), op.isUrgent());
assertEquals(serializationService.toData(expectedResponse), argument.getValue());
}
use of com.hazelcast.internal.nio.Packet in project hazelcast by hazelcast.
the class OutboundResponseHandlerTest method testToBackupAckPacket.
private void testToBackupAckPacket(int callId, boolean urgent) {
Packet packet = handler.toBackupAckPacket(callId, urgent);
HeapData expected = serializationService.toData(new BackupAckResponse(callId, urgent));
assertEquals(expected, new HeapData(packet.toByteArray()));
}
use of com.hazelcast.internal.nio.Packet in project hazelcast by hazelcast.
the class OutboundResponseHandlerTest method sendResponse_whenPortable.
@Test
public void sendResponse_whenPortable() {
Object response = new PortableAddress("Sesame Street", 1);
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
NormalResponse expected = new NormalResponse(response, op.getCallId(), 0, op.isUrgent());
assertEquals(serializationService.toData(expected), argument.getValue());
}
use of com.hazelcast.internal.nio.Packet in project hazelcast by hazelcast.
the class PacketDispatcherTest method whenEventPacket.
@Test
public void whenEventPacket() {
Packet packet = new Packet().setPacketType(Packet.Type.EVENT);
dispatcher.accept(packet);
verify(eventService).accept(packet);
verifyZeroInteractions(responseHandler, operationExecutor, invocationMonitor, jetService);
}
Aggregations