use of com.alibaba.dubbo.common.serialize.ObjectInput in project dubbo by alibaba.
the class FstSerializationTest method test_Bool.
@Test
public void test_Bool() throws Exception {
ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
objectOutput.writeBool(false);
objectOutput.flushBuffer();
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);
assertFalse(deserialize.readBool());
}
use of com.alibaba.dubbo.common.serialize.ObjectInput in project dubbo by alibaba.
the class FstSerializationTest 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());
}
use of com.alibaba.dubbo.common.serialize.ObjectInput in project dubbo by alibaba.
the class FstSerializationTest method assertObjectArrayWithType.
<T> void assertObjectArrayWithType(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(clazz)));
}
use of com.alibaba.dubbo.common.serialize.ObjectInput in project dubbo by alibaba.
the class FstSerializationTest method test_Bool_Multi.
@Test
public void test_Bool_Multi() throws Exception {
boolean[] array = new boolean[100];
for (int i = 0; i < array.length; i++) {
array[i] = random.nextBoolean();
}
ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
for (boolean b : array) {
objectOutput.writeBool(b);
}
objectOutput.flushBuffer();
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);
for (boolean b : array) {
assertEquals(b, deserialize.readBool());
}
}
use of com.alibaba.dubbo.common.serialize.ObjectInput in project dubbo by alibaba.
the class FstSerializationTest method test_BizException_WithType.
@Test
public void test_BizException_WithType() throws Exception {
BizException e = new BizException("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(BizException.class);
assertEquals("Hello", ((BizException) read).getMessage());
}
Aggregations