use of com.hazelcast.nio.ObjectDataInput in project hazelcast by hazelcast.
the class AbstractDataStreamIntegrationTest method testByte.
@Test
public void testByte() throws IOException {
out.write(Byte.MAX_VALUE);
out.write(Byte.MIN_VALUE);
out.write(0);
ObjectDataInput in = getDataInputFromOutput();
assertEquals(Byte.MAX_VALUE, in.readByte());
assertEquals(Byte.MIN_VALUE, in.readByte());
assertEquals(0, in.readByte());
}
use of com.hazelcast.nio.ObjectDataInput in project hazelcast by hazelcast.
the class AbstractDataStreamIntegrationTest method testDouble.
@Test
public void testDouble() throws IOException {
out.writeDouble(Double.MIN_VALUE);
out.writeDouble(-1);
out.writeDouble(Math.PI);
out.writeDouble(Double.MAX_VALUE);
ObjectDataInput in = getDataInputFromOutput();
assertEquals(Double.MIN_VALUE, in.readDouble(), 1e-10D);
assertEquals(-1, in.readDouble(), 1e-10D);
assertEquals(Math.PI, in.readDouble(), 1e-10D);
assertEquals(Double.MAX_VALUE, in.readDouble(), 1e-10D);
}
use of com.hazelcast.nio.ObjectDataInput in project hazelcast by hazelcast.
the class AbstractDataStreamIntegrationTest method testInt.
@Test
public void testInt() throws IOException {
out.writeInt(Integer.MAX_VALUE);
out.writeInt(Integer.MIN_VALUE);
out.writeInt(-1);
out.writeInt(132);
ObjectDataInput in = getDataInputFromOutput();
assertEquals(Integer.MAX_VALUE, in.readInt());
assertEquals(Integer.MIN_VALUE, in.readInt());
assertEquals(-1, in.readInt());
assertEquals(132, in.readInt());
}
use of com.hazelcast.nio.ObjectDataInput in project hazelcast by hazelcast.
the class AbstractDataStreamIntegrationTest method testBoolean.
@Test
public void testBoolean() throws IOException {
out.writeBoolean(false);
out.writeBoolean(true);
ObjectDataInput in = getDataInputFromOutput();
assertFalse(in.readBoolean());
assertTrue(in.readBoolean());
}
use of com.hazelcast.nio.ObjectDataInput in project hazelcast by hazelcast.
the class SerializationIssueTest method testEmptyData.
@Test
public void testEmptyData() {
SerializationConfig serializationConfig = new SerializationConfig().addSerializerConfig(new SerializerConfig().setTypeClass(SingletonValue.class).setImplementation(new StreamSerializer<SingletonValue>() {
@Override
public void write(ObjectDataOutput out, SingletonValue v) throws IOException {
}
@Override
public SingletonValue read(ObjectDataInput in) throws IOException {
return new SingletonValue();
}
@Override
public int getTypeId() {
return 123;
}
@Override
public void destroy() {
}
}));
SerializationService ss1 = new DefaultSerializationServiceBuilder().setConfig(serializationConfig).build();
Data data = ss1.toData(new SingletonValue());
Assert.assertNotNull(data);
SerializationService ss2 = new DefaultSerializationServiceBuilder().setConfig(serializationConfig).build();
Object o = ss2.toObject(data);
Assert.assertEquals(new SingletonValue(), o);
}
Aggregations