use of com.alibaba.dubbo.common.serialize.ObjectOutput in project dubbo by alibaba.
the class FstSerializationTest method test_Byte.
@Test
public void test_Byte() throws Exception {
ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
objectOutput.writeByte((byte) 123);
objectOutput.flushBuffer();
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);
assertEquals((byte) 123, deserialize.readByte());
}
use of com.alibaba.dubbo.common.serialize.ObjectOutput 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.ObjectOutput in project dubbo by alibaba.
the class AbstractSerializationPersionFailTest method test_PersonList.
@Test
public void test_PersonList() throws Exception {
List<Person> args = new ArrayList<Person>();
args.add(new Person());
try {
ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
objectOutput.writeObject(args);
fail();
} catch (NotSerializableException expected) {
} catch (IllegalStateException expected) {
assertThat(expected.getMessage(), containsString("Serialized class com.alibaba.dubbo.common.model.Person must implement java.io.Serializable"));
}
}
use of com.alibaba.dubbo.common.serialize.ObjectOutput in project dubbo by alibaba.
the class AbstractSerializationPersionFailTest method test_StringPersonMap.
@Test
public void test_StringPersonMap() throws Exception {
Map<String, Person> args = new HashMap<String, Person>();
args.put("1", new Person());
try {
ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
objectOutput.writeObject(args);
fail();
} catch (NotSerializableException expected) {
} catch (IllegalStateException expected) {
assertThat(expected.getMessage(), containsString("Serialized class com.alibaba.dubbo.common.model.Person must implement java.io.Serializable"));
}
}
use of com.alibaba.dubbo.common.serialize.ObjectOutput in project dubbo by alibaba.
the class AbstractSerializationPersionFailTest method test_PersonListList.
@Test
public void test_PersonListList() throws Exception {
List<List<Person>> args = new ArrayList<List<Person>>();
List<Person> sublist = new ArrayList<Person>();
sublist.add(new Person());
args.add(sublist);
try {
ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
objectOutput.writeObject(args);
fail();
} catch (NotSerializableException expected) {
} catch (IllegalStateException expected) {
assertThat(expected.getMessage(), containsString("Serialized class com.alibaba.dubbo.common.model.Person must implement java.io.Serializable"));
}
}
Aggregations