use of com.alibaba.dubbo.common.serialize.ObjectInput 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.ObjectInput 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) {
}
}
use of com.alibaba.dubbo.common.serialize.ObjectInput in project dubbo by alibaba.
the class FstSerializationTest 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()));
}
use of com.alibaba.dubbo.common.serialize.ObjectInput in project dubbo by alibaba.
the class FstSerializationTest method assertObjectWithType.
<T> void assertObjectWithType(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);
assertEquals(data, (T) deserialize.readObject(clazz));
}
use of com.alibaba.dubbo.common.serialize.ObjectInput in project dubbo by alibaba.
the class FstSerializationTest 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) {
}
}
Aggregations