Search in sources :

Example 56 with Packet

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);
}
Also used : Packet(com.hazelcast.internal.nio.Packet) Operation(com.hazelcast.spi.impl.operationservice.Operation) BlockingOperation(com.hazelcast.spi.impl.operationservice.BlockingOperation) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 57 with 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());
}
Also used : Packet(com.hazelcast.internal.nio.Packet) Operation(com.hazelcast.spi.impl.operationservice.Operation) IOException(java.io.IOException) ErrorResponse(com.hazelcast.spi.impl.operationservice.impl.responses.ErrorResponse) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 58 with Packet

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()));
}
Also used : Packet(com.hazelcast.internal.nio.Packet) BackupAckResponse(com.hazelcast.spi.impl.operationservice.impl.responses.BackupAckResponse) HeapData(com.hazelcast.internal.serialization.impl.HeapData)

Example 59 with Packet

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());
}
Also used : Packet(com.hazelcast.internal.nio.Packet) Operation(com.hazelcast.spi.impl.operationservice.Operation) NormalResponse(com.hazelcast.spi.impl.operationservice.impl.responses.NormalResponse) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 60 with Packet

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);
}
Also used : Packet(com.hazelcast.internal.nio.Packet) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

Packet (com.hazelcast.internal.nio.Packet)65 Test (org.junit.Test)46 QuickTest (com.hazelcast.test.annotation.QuickTest)41 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)19 Operation (com.hazelcast.spi.impl.operationservice.Operation)11 ByteBuffer (java.nio.ByteBuffer)10 NormalResponse (com.hazelcast.spi.impl.operationservice.impl.responses.NormalResponse)9 AssertTask (com.hazelcast.test.AssertTask)6 PacketIOHelper (com.hazelcast.internal.nio.PacketIOHelper)5 SerializationConcurrencyTest (com.hazelcast.internal.serialization.impl.SerializationConcurrencyTest)3 OperationRunner (com.hazelcast.spi.impl.operationexecutor.OperationRunner)3 IOException (java.io.IOException)3 Address (com.hazelcast.cluster.Address)2 MemberHandshake (com.hazelcast.internal.cluster.impl.MemberHandshake)2 HandlerStatus (com.hazelcast.internal.networking.HandlerStatus)2 InternalSerializationService (com.hazelcast.internal.serialization.InternalSerializationService)2 HeapData (com.hazelcast.internal.serialization.impl.HeapData)2 ServerConnection (com.hazelcast.internal.server.ServerConnection)2 ServerConnectionManager (com.hazelcast.internal.server.ServerConnectionManager)2 OperationRunnerFactory (com.hazelcast.spi.impl.operationexecutor.OperationRunnerFactory)2