use of com.alibaba.dubbo.common.serialize.ObjectInput in project dubbo by alibaba.
the class AbstractSerializationTest method assertObjectArray.
// ================ Array Type ================
<T> void assertObjectArray(T[] data, Class<T[]> clazz) throws Exception {
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, clazz.cast(deserialize.readObject()));
try {
deserialize.readObject();
fail();
} catch (IOException expected) {
}
}
use of com.alibaba.dubbo.common.serialize.ObjectInput in project dubbo by alibaba.
the class AbstractSerializationTest method test_Long.
@Test
public void test_Long() throws Exception {
ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
objectOutput.writeLong(123L);
objectOutput.flushBuffer();
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);
assertEquals(123L, deserialize.readLong());
try {
deserialize.readLong();
fail();
} catch (IOException expected) {
}
}
use of com.alibaba.dubbo.common.serialize.ObjectInput in project dubbo by alibaba.
the class AbstractSerializationTest method test_Integer.
@Test
public void test_Integer() throws Exception {
ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
objectOutput.writeInt(1);
objectOutput.flushBuffer();
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);
int i = deserialize.readInt();
assertEquals(1, i);
try {
deserialize.readInt();
fail();
} catch (IOException expected) {
}
}
use of com.alibaba.dubbo.common.serialize.ObjectInput in project dubbo by alibaba.
the class AbstractSerializationTest method test_BizExceptionNoDefaultConstructor_WithType.
@Test
public void test_BizExceptionNoDefaultConstructor_WithType() throws Exception {
BizExceptionNoDefaultConstructor e = new BizExceptionNoDefaultConstructor("Hello");
ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
objectOutput.writeObject(e);
objectOutput.flushBuffer();
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);
Object read = deserialize.readObject(BizExceptionNoDefaultConstructor.class);
assertEquals("Hello", ((BizExceptionNoDefaultConstructor) read).getMessage());
}
use of com.alibaba.dubbo.common.serialize.ObjectInput in project dubbo by alibaba.
the class AbstractSerializationTest method test_longArray.
@Test
public void test_longArray() throws Exception {
long[] data = new long[] { 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, (long[]) deserialize.readObject());
try {
deserialize.readObject();
fail();
} catch (IOException expected) {
}
}
Aggregations