Search in sources :

Example 36 with ObjectDataInput

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

Example 37 with ObjectDataInput

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

Example 38 with ObjectDataInput

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

Example 39 with ObjectDataInput

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

Example 40 with ObjectDataInput

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);
}
Also used : GlobalSerializerConfig(com.hazelcast.config.GlobalSerializerConfig) SerializerConfig(com.hazelcast.config.SerializerConfig) ObjectDataOutput(com.hazelcast.nio.ObjectDataOutput) SerializationConfig(com.hazelcast.config.SerializationConfig) SerializationService(com.hazelcast.internal.serialization.SerializationService) Data(com.hazelcast.internal.serialization.Data) StreamSerializer(com.hazelcast.nio.serialization.StreamSerializer) ObjectDataInput(com.hazelcast.nio.ObjectDataInput) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

ObjectDataInput (com.hazelcast.nio.ObjectDataInput)80 Test (org.junit.Test)35 QuickTest (com.hazelcast.test.annotation.QuickTest)32 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)24 BufferObjectDataInput (com.hazelcast.internal.nio.BufferObjectDataInput)17 FieldKind (com.hazelcast.nio.serialization.FieldKind)16 IOException (java.io.IOException)13 ObjectDataOutput (com.hazelcast.nio.ObjectDataOutput)12 Nullable (javax.annotation.Nullable)9 GlobalSerializerConfig (com.hazelcast.config.GlobalSerializerConfig)7 SerializationConfig (com.hazelcast.config.SerializationConfig)6 StreamSerializer (com.hazelcast.nio.serialization.StreamSerializer)6 Data (com.hazelcast.nio.serialization.Data)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 Data (com.hazelcast.internal.serialization.Data)3 SerializationService (com.hazelcast.internal.serialization.SerializationService)3 DefaultSerializationServiceBuilder (com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder)3 HeapData (com.hazelcast.internal.serialization.impl.HeapData)3 SerializationService (com.hazelcast.spi.serialization.SerializationService)3 SerializerConfig (com.hazelcast.config.SerializerConfig)2