use of com.alibaba.dubbo.common.serialize.ObjectInput in project dubbo by alibaba.
the class AbstractSerializationTest method test_Short.
@Test
public void test_Short() throws Exception {
ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
objectOutput.writeShort((short) 123);
objectOutput.flushBuffer();
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);
assertEquals((short) 123, deserialize.readShort());
try {
deserialize.readShort();
fail();
} catch (IOException expected) {
}
}
use of com.alibaba.dubbo.common.serialize.ObjectInput 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.
}
Aggregations