use of com.hazelcast.nio.serialization.PortableReader 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());
}
use of com.hazelcast.nio.serialization.PortableReader in project hazelcast by hazelcast.
the class DefaultPortableReaderQuickTest method reusingTheReader_multipleCalls_stateResetCorreclty.
@Test
public void reusingTheReader_multipleCalls_stateResetCorreclty() throws IOException {
PortableReader reader = reader(PORSCHE);
assertEquals("rear", reader.readUTF("wheels[1].name"));
assertEquals(300, reader.readInt("engine.power"));
assertEquals(46, reader.readInt("wheels[0].serial[0]"));
try {
reader.readFloat("wheels[0].serial[0]");
fail();
} catch (Exception ignored) {
}
assertEquals("front", reader.readUTF("wheels[0].name"));
assertEquals(45, reader.readInt("wheels[1].serial[0]"));
try {
reader.readIntArray("name");
fail();
} catch (Exception ignored) {
}
assertEquals(15, reader.readInt("engine.chip.power"));
assertEquals("Porsche", reader.readUTF("name"));
}
Aggregations