Search in sources :

Example 1 with PortablePartitionLostEvent

use of com.hazelcast.spi.impl.PortablePartitionLostEvent in project hazelcast by hazelcast.

the class ClientPartitionLostListenerTest method test_portableMapPartitionLostEvent_serialization.

@Test
public void test_portableMapPartitionLostEvent_serialization() throws IOException {
    final Address source = new Address();
    final PortablePartitionLostEvent event = new PortablePartitionLostEvent(1, 2, source);
    final PortableWriter writer = mock(PortableWriter.class);
    final ObjectDataOutput output = mock(ObjectDataOutput.class);
    when(writer.getRawDataOutput()).thenReturn(output);
    event.writePortable(writer);
    verify(writer).writeInt("p", 1);
    verify(writer).writeInt("l", 2);
    verify(output).writeObject(source);
}
Also used : PortablePartitionLostEvent(com.hazelcast.spi.impl.PortablePartitionLostEvent) ObjectDataOutput(com.hazelcast.nio.ObjectDataOutput) Address(com.hazelcast.nio.Address) HazelcastTestSupport.getAddress(com.hazelcast.test.HazelcastTestSupport.getAddress) PortableWriter(com.hazelcast.nio.serialization.PortableWriter) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 2 with PortablePartitionLostEvent

use of com.hazelcast.spi.impl.PortablePartitionLostEvent in project hazelcast by hazelcast.

the class ClientPartitionLostListenerTest method test_portableMapPartitionLostEvent_deserialization.

@Test
public void test_portableMapPartitionLostEvent_deserialization() throws IOException {
    final Address source = new Address();
    final PortablePartitionLostEvent event = new PortablePartitionLostEvent();
    final PortableReader reader = mock(PortableReader.class);
    final ObjectDataInput input = mock(ObjectDataInput.class);
    when(reader.getRawDataInput()).thenReturn(input);
    when(reader.readInt("p")).thenReturn(1);
    when(reader.readInt("l")).thenReturn(2);
    when(input.readObject()).thenReturn(source);
    event.readPortable(reader);
    assertEquals(1, event.getPartitionId());
    assertEquals(2, event.getLostBackupCount());
    assertEquals(source, event.getSource());
}
Also used : PortablePartitionLostEvent(com.hazelcast.spi.impl.PortablePartitionLostEvent) Address(com.hazelcast.nio.Address) HazelcastTestSupport.getAddress(com.hazelcast.test.HazelcastTestSupport.getAddress) ObjectDataInput(com.hazelcast.nio.ObjectDataInput) PortableReader(com.hazelcast.nio.serialization.PortableReader) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

Address (com.hazelcast.nio.Address)2 PortablePartitionLostEvent (com.hazelcast.spi.impl.PortablePartitionLostEvent)2 HazelcastTestSupport.getAddress (com.hazelcast.test.HazelcastTestSupport.getAddress)2 ParallelTest (com.hazelcast.test.annotation.ParallelTest)2 QuickTest (com.hazelcast.test.annotation.QuickTest)2 Test (org.junit.Test)2 ObjectDataInput (com.hazelcast.nio.ObjectDataInput)1 ObjectDataOutput (com.hazelcast.nio.ObjectDataOutput)1 PortableReader (com.hazelcast.nio.serialization.PortableReader)1 PortableWriter (com.hazelcast.nio.serialization.PortableWriter)1