Example usage for org.apache.hadoop.io.serializer JavaSerialization JavaSerialization

List of usage examples for org.apache.hadoop.io.serializer JavaSerialization JavaSerialization

Introduction

In this page you can find the example usage for org.apache.hadoop.io.serializer JavaSerialization JavaSerialization.

Prototype

JavaSerialization

Source Link

Usage

From source file:org.apache.ignite.internal.processors.hadoop.GridHadoopSerializationWrapperSelfTest.java

License:Apache License

/**
 * Tests read/write of Integer via native JavaleSerialization.
 * @throws Exception If fails.//from  ww w  . j a  v a 2s.  c o m
 */
public void testIntJavaSerialization() throws Exception {
    GridHadoopSerialization ser = new GridHadoopSerializationWrapper(new JavaSerialization(), Integer.class);

    ByteArrayOutputStream buf = new ByteArrayOutputStream();

    DataOutput out = new DataOutputStream(buf);

    ser.write(out, 3);
    ser.write(out, -5);
    ser.close();

    DataInput in = new DataInputStream(new ByteArrayInputStream(buf.toByteArray()));

    assertEquals(3, ((Integer) ser.read(in, null)).intValue());
    assertEquals(-5, ((Integer) ser.read(in, null)).intValue());
}

From source file:org.apache.ignite.internal.processors.hadoop.HadoopSerializationWrapperSelfTest.java

License:Apache License

/**
 * Tests read/write of Integer via native JavaleSerialization.
 * @throws Exception If fails.//from   w  w w . ja  va2 s.c  o m
 */
public void testIntJavaSerialization() throws Exception {
    HadoopSerialization ser = new HadoopSerializationWrapper(new JavaSerialization(), Integer.class);

    ByteArrayOutputStream buf = new ByteArrayOutputStream();

    DataOutput out = new DataOutputStream(buf);

    ser.write(out, 3);
    ser.write(out, -5);
    ser.close();

    DataInput in = new DataInputStream(new ByteArrayInputStream(buf.toByteArray()));

    assertEquals(3, ((Integer) ser.read(in, null)).intValue());
    assertEquals(-5, ((Integer) ser.read(in, null)).intValue());
}