Search in sources :

Example 31 with ObjectDataInput

use of com.hazelcast.nio.ObjectDataInput in project hazelcast by hazelcast.

the class AbstractDataStreamIntegrationTest method testShort.

@Test
public void testShort() throws IOException {
    // negative shorts
    out.writeShort(Short.MIN_VALUE);
    out.writeShort(-250);
    // positive shorts
    out.writeShort(132);
    out.writeShort(Short.MAX_VALUE);
    ObjectDataInput input = getDataInputFromOutput();
    assertEquals(Short.MIN_VALUE, input.readShort());
    assertEquals(-250, input.readShort());
    assertEquals(132, input.readShort());
    assertEquals(Short.MAX_VALUE, input.readShort());
}
Also used : ObjectDataInput(com.hazelcast.nio.ObjectDataInput) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 32 with ObjectDataInput

use of com.hazelcast.nio.ObjectDataInput in project hazelcast by hazelcast.

the class AbstractDataStreamIntegrationTest method testFloat.

@Test
public void testFloat() throws IOException {
    out.writeFloat(Float.MIN_VALUE);
    out.writeFloat(-1);
    out.writeFloat(Float.MAX_VALUE);
    ObjectDataInput in = getDataInputFromOutput();
    assertEquals(Float.MIN_VALUE, in.readFloat(), 1e-10F);
    assertEquals(-1, in.readFloat(), 1e-10F);
    assertEquals(Float.MAX_VALUE, in.readFloat(), 1e-10F);
}
Also used : ObjectDataInput(com.hazelcast.nio.ObjectDataInput) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 33 with ObjectDataInput

use of com.hazelcast.nio.ObjectDataInput in project hazelcast by hazelcast.

the class AbstractDataStreamIntegrationTest method testShortArray.

@Test
public void testShortArray() throws IOException {
    short[] arr = new short[] { Short.MIN_VALUE, -250, 132, Short.MAX_VALUE };
    out.writeShortArray(arr);
    ObjectDataInput in = getDataInputFromOutput();
    assertArrayEquals(arr, in.readShortArray());
}
Also used : ObjectDataInput(com.hazelcast.nio.ObjectDataInput) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 34 with ObjectDataInput

use of com.hazelcast.nio.ObjectDataInput in project hazelcast by hazelcast.

the class AbstractDataStreamIntegrationTest method testBooleanArray.

@Test
public void testBooleanArray() throws IOException {
    boolean[] arr = new boolean[] { true, false };
    out.writeBooleanArray(arr);
    ObjectDataInput in = getDataInputFromOutput();
    assertArrayEquals(arr, in.readBooleanArray());
}
Also used : ObjectDataInput(com.hazelcast.nio.ObjectDataInput) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 35 with ObjectDataInput

use of com.hazelcast.nio.ObjectDataInput in project hazelcast by hazelcast.

the class AbstractDataStreamIntegrationTest method testUnsignedShort.

@Test
public void testUnsignedShort() throws IOException {
    // unsigned short, out of range of signed short
    out.writeShort(Short.MAX_VALUE + 200);
    out.writeShort(Short.MAX_VALUE + 1);
    out.writeShort(0xFFFF);
    ObjectDataInput input = getDataInputFromOutput();
    assertEquals(Short.MAX_VALUE + 200, input.readUnsignedShort());
    assertEquals(Short.MAX_VALUE + 1, input.readUnsignedShort());
    assertEquals(0xFFFF, input.readUnsignedShort());
}
Also used : ObjectDataInput(com.hazelcast.nio.ObjectDataInput) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) 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