Search in sources :

Example 66 with ObjectDataInput

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

the class AbstractDataStreamIntegrationTest method testDoubleArray.

@Test
public void testDoubleArray() throws IOException {
    double[] arr = new double[] { Double.MIN_VALUE, -1, Math.PI, Double.MAX_VALUE };
    out.writeDoubleArray(arr);
    ObjectDataInput in = getDataInputFromOutput();
    assertArrayEquals(arr, in.readDoubleArray(), 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 67 with ObjectDataInput

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

the class AbstractDataStreamIntegrationTest method testFloatArray.

@Test
public void testFloatArray() throws IOException {
    float[] arr = new float[] { Float.MIN_VALUE, -1, Float.MAX_VALUE };
    out.writeFloatArray(arr);
    ObjectDataInput in = getDataInputFromOutput();
    assertArrayEquals(arr, in.readFloatArray(), 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 68 with ObjectDataInput

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

the class AbstractDataStreamIntegrationTest method testCharArray.

@Test
public void testCharArray() throws IOException {
    char[] arr = new char[] { Character.MIN_VALUE, Character.MAX_VALUE };
    out.writeCharArray(arr);
    ObjectDataInput in = getDataInputFromOutput();
    assertArrayEquals(arr, in.readCharArray());
}
Also used : ObjectDataInput(com.hazelcast.nio.ObjectDataInput) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 69 with ObjectDataInput

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

the class AbstractDataStreamIntegrationTest method testUTF.

@Test
public void testUTF() throws IOException {
    String s1 = "Vim is a text editor that is upwards compatible to Vi. It can be used to edit all kinds of plain text.";
    String s2 = "簡単なものから複雑なものまで、具体的な例を使って説明しています。本のように最初から順を追って読んでください。";
    out.writeString(s1);
    out.writeString(s2);
    ObjectDataInput in = getDataInputFromOutput();
    assertEquals(s1, in.readString());
    assertEquals(s2, in.readString());
}
Also used : ObjectDataInput(com.hazelcast.nio.ObjectDataInput) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 70 with ObjectDataInput

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

the class SerializationV1Portable method readPortable.

@Override
public void readPortable(PortableReader in) throws IOException {
    this.aByte = in.readByte("1");
    this.aBoolean = in.readBoolean("2");
    this.character = in.readChar("3");
    this.aShort = in.readShort("4");
    this.integer = in.readInt("5");
    this.aLong = in.readLong("6");
    this.aFloat = in.readFloat("7");
    this.aDouble = in.readDouble("8");
    this.string = in.readString("9");
    this.bytes = in.readByteArray("a1");
    this.booleans = in.readBooleanArray("a2");
    this.chars = in.readCharArray("a3");
    this.shorts = in.readShortArray("a4");
    this.ints = in.readIntArray("a5");
    this.longs = in.readLongArray("a6");
    this.floats = in.readFloatArray("a7");
    this.doubles = in.readDoubleArray("a8");
    this.strings = in.readStringArray("a9");
    this.innerPortable = in.readPortable("p");
    ObjectDataInput rawDataInput = in.getRawDataInput();
    boolean isNotNull = rawDataInput.readBoolean();
    if (isNotNull) {
        SerializationV1DataSerializable dataserializable = new SerializationV1DataSerializable();
        dataserializable.readData(rawDataInput);
        this.dataSerializable = dataserializable;
    }
}
Also used : ObjectDataInput(com.hazelcast.nio.ObjectDataInput) SerializationV1DataSerializable(com.hazelcast.internal.serialization.impl.SerializationV1DataSerializable)

Aggregations

ObjectDataInput (com.hazelcast.nio.ObjectDataInput)81 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