use of org.apache.dubbo.common.serialize.ObjectOutput in project dubbo by alibaba.
the class SerializationTest method testObjectOutput.
@Test
public void testObjectOutput() throws IOException {
ObjectOutput objectOutput = mySerialization.serialize(null, mock(OutputStream.class));
assertThat(objectOutput, Matchers.<ObjectOutput>instanceOf(MyObjectOutput.class));
}
use of org.apache.dubbo.common.serialize.ObjectOutput in project dubbo by alibaba.
the class FastJsonSerializationTest method testObjectOutput.
@Test
public void testObjectOutput() throws IOException {
ObjectOutput objectOutput = fastJsonSerialization.serialize(null, mock(OutputStream.class));
assertThat(objectOutput, Matchers.<ObjectOutput>instanceOf(FastJsonObjectOutput.class));
}
use of org.apache.dubbo.common.serialize.ObjectOutput in project dubbo by alibaba.
the class Hessian2SerializationTest 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 Hessian2SerializationTest 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 Hessian2SerializationTest method test_doubleArray_withType.
@Test
public void test_doubleArray_withType() throws Exception {
double[] data = new double[] { 37D, -3.14D, 123456.7D };
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, (double[]) deserialize.readObject(double[].class), 0.0001);
try {
deserialize.readObject(double[].class);
fail();
} catch (ArrayIndexOutOfBoundsException e) {
}
// NOTE: Hessian2 throws ArrayIndexOutOfBoundsException instead of IOException, let's live with this.
}
Aggregations