use of com.alibaba.dubbo.common.serialize.ObjectOutput in project dubbo by alibaba.
the class FstSerializationTest method test_floatArray.
@Test
public void test_floatArray() throws Exception {
float[] data = new float[] { 37F, -3.14F, 123456.7F };
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, (float[]) deserialize.readObject(), 0.0001F);
try {
deserialize.readObject();
fail();
} catch (IOException expected) {
}
}
use of com.alibaba.dubbo.common.serialize.ObjectOutput in project dubbo by alibaba.
the class FstSerializationTest 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) {
}
}
use of com.alibaba.dubbo.common.serialize.ObjectOutput in project dubbo by alibaba.
the class FstSerializationTest 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.ObjectOutput in project dubbo by alibaba.
the class FstSerializationTest method test_Float.
@Test
public void test_Float() throws Exception {
ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
objectOutput.writeFloat(1.28F);
objectOutput.flushBuffer();
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);
assertTrue(1.28F == deserialize.readFloat());
}
use of com.alibaba.dubbo.common.serialize.ObjectOutput in project dubbo by alibaba.
the class FstSerializationTest method test_URL_mutable_withType.
// ================ final field test ================
@Test
public void test_URL_mutable_withType() throws Exception {
URL data = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan&noValue");
ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
objectOutput.writeObject(data);
objectOutput.flushBuffer();
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);
URL actual = (URL) deserialize.readObject(URL.class);
assertEquals(data, actual);
assertEquals(data.getParameters(), actual.getParameters());
try {
deserialize.readObject();
fail();
} catch (IOException expected) {
}
}
Aggregations