use of org.apache.dubbo.common.serialize.ObjectOutput in project dubbo by alibaba.
the class Hessian2PersonOkTest method test_shortArray_withType.
@Test
public void test_shortArray_withType() throws Exception {
short[] data = new short[] { 37, 39, 12 };
ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
objectOutput.writeObject(data);
objectOutput.flushBuffer();
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);
assertArrayEquals(data, (short[]) deserialize.readObject(short[].class));
try {
deserialize.readObject(short[].class);
fail();
} catch (ArrayIndexOutOfBoundsException e) {
}
// NOTE: Hessian2 throws ArrayIndexOutOfBoundsException instead of IOException, let's live with this.
}
use of org.apache.dubbo.common.serialize.ObjectOutput in project dubbo by alibaba.
the class Hessian2PersonOkTest method test_floatArray_withType.
@Test
public void test_floatArray_withType() throws Exception {
float[] data = new float[] { 37F, -3.14F, 123456.7F };
ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
objectOutput.writeObject(data);
objectOutput.flushBuffer();
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);
assertArrayEquals(data, (float[]) deserialize.readObject(), 0.0001F);
try {
deserialize.readObject(float[].class);
fail();
} catch (ArrayIndexOutOfBoundsException e) {
}
// NOTE: Hessian2 throws ArrayIndexOutOfBoundsException instead of IOException, let's live with this.
}
use of org.apache.dubbo.common.serialize.ObjectOutput in project dubbo by alibaba.
the class AvroSerializationTest method testObjectOutput.
@Test
public void testObjectOutput() throws IOException {
ObjectOutput objectOutput = avroSerialization.serialize(null, mock(OutputStream.class));
assertThat(objectOutput, Matchers.<ObjectOutput>instanceOf(AvroObjectOutput.class));
}
use of org.apache.dubbo.common.serialize.ObjectOutput in project dubbo by alibaba.
the class Hessian2PersonOkTest method test_intArray_withType.
@Test
public void test_intArray_withType() throws Exception {
int[] data = new int[] { 234, 0, -1 };
ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
objectOutput.writeObject(data);
objectOutput.flushBuffer();
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);
assertArrayEquals(data, (int[]) deserialize.readObject());
try {
deserialize.readObject(int[].class);
fail();
} catch (ArrayIndexOutOfBoundsException e) {
}
// NOTE: Hessian2 throws ArrayIndexOutOfBoundsException instead of IOException, let's live with this.
}
use of org.apache.dubbo.common.serialize.ObjectOutput in project dubbo by alibaba.
the class Hessian2PersonOkTest method test_StringArray_withType.
@Test
public void test_StringArray_withType() throws Exception {
String[] data = new String[] { "1", "b" };
ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
objectOutput.writeObject(data);
objectOutput.flushBuffer();
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);
assertArrayEquals(data, deserialize.readObject(String[].class));
try {
deserialize.readObject(String[].class);
fail();
} catch (ArrayIndexOutOfBoundsException e) {
}
// NOTE: Hessian2 throws ArrayIndexOutOfBoundsException instead of IOException, let's live with this.
}
Aggregations