use of org.apache.dubbo.common.serialize.ObjectOutput in project dubbo by alibaba.
the class AbstractSerializationTest method assertObject.
@SuppressWarnings("unchecked")
public <T> void assertObject(T data) 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);
assertEquals(data, (T) deserialize.readObject());
try {
deserialize.readObject();
fail();
} catch (IOException expected) {
}
}
use of org.apache.dubbo.common.serialize.ObjectOutput 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 org.apache.dubbo.common.serialize.ObjectOutput in project dubbo by alibaba.
the class AbstractProtobufSerializationTest method test_UtfString.
@Test
public void test_UtfString() throws Exception {
ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
objectOutput.writeUTF("123中华人民共和国");
objectOutput.flushBuffer();
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);
assertEquals("123中华人民共和国", deserialize.readUTF());
try {
deserialize.readUTF();
fail();
} catch (Exception expected) {
expected.printStackTrace();
}
}
use of org.apache.dubbo.common.serialize.ObjectOutput in project dubbo by alibaba.
the class AbstractProtobufSerializationTest 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 (Exception expected) {
expected.printStackTrace();
}
}
use of org.apache.dubbo.common.serialize.ObjectOutput in project dubbo by alibaba.
the class AbstractProtobufSerializationTest 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 (Exception expected) {
expected.printStackTrace();
}
}
Aggregations