use of com.alibaba.dubbo.common.serialize.ObjectInput in project dubbo by alibaba.
the class FstSerializationTest method test_Double.
// ================== Util methods ==================
@Test
public void test_Double() throws Exception {
ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
objectOutput.writeDouble(1.28);
objectOutput.flushBuffer();
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);
assertTrue(1.28 == deserialize.readDouble());
}
use of com.alibaba.dubbo.common.serialize.ObjectInput in project dubbo by alibaba.
the class AbstractSerializationTest method test_Double.
// ================== Util methods ==================
@Test
public void test_Double() throws Exception {
ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
objectOutput.writeDouble(1.28);
objectOutput.flushBuffer();
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);
assertTrue(1.28 == deserialize.readDouble());
try {
deserialize.readDouble();
fail();
} catch (IOException expected) {
}
}
use of com.alibaba.dubbo.common.serialize.ObjectInput in project dubbo by alibaba.
the class AbstractSerializationTest method test_shortArray.
@Test
public void test_shortArray() 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());
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_Bytes.
@Test
public void test_Bytes() throws Exception {
ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
objectOutput.writeBytes("123中华人民共和国".getBytes());
objectOutput.flushBuffer();
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);
assertArrayEquals("123中华人民共和国".getBytes(), deserialize.readBytes());
try {
deserialize.readBytes();
fail();
} catch (IOException expected) {
}
}
use of com.alibaba.dubbo.common.serialize.ObjectInput in project dubbo by alibaba.
the class AbstractSerializationTest method test_charArray_withType.
@Test
public void test_charArray_withType() throws Exception {
char[] data = new char[] { 'a', '中', '无' };
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, (char[]) deserialize.readObject(char[].class));
try {
deserialize.readObject(char[].class);
fail();
} catch (IOException expected) {
}
}
Aggregations