use of org.apache.dubbo.common.serialize.ObjectOutput in project dubbo by alibaba.
the class KryoSerialization2Test method testObject.
@Test
public void testObject() throws IOException, ClassNotFoundException {
ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
objectOutput.writeObject(bigPerson);
objectOutput.flushBuffer();
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);
assertEquals(bigPerson, BigPerson.class.cast(deserialize.readObject(BigPerson.class)));
try {
deserialize.readObject(BigPerson.class);
fail();
} catch (IOException expected) {
}
}
use of org.apache.dubbo.common.serialize.ObjectOutput in project dubbo by alibaba.
the class AbstractSerializationPersonFailTest 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(FAIL_STRING));
}
}
use of org.apache.dubbo.common.serialize.ObjectOutput in project dubbo by alibaba.
the class AbstractSerializationPersonFailTest method test_PersonSet.
@Test
public void test_PersonSet() throws Exception {
Set<Person> args = new HashSet<Person>();
args.add(new Person());
try {
ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
objectOutput.writeObject(args);
fail();
} catch (NotSerializableException expected) {
} catch (IllegalStateException expected) {
System.out.println("--------" + expected.getMessage());
assertThat(expected.getMessage(), containsString(FAIL_STRING));
}
}
use of org.apache.dubbo.common.serialize.ObjectOutput in project dubbo by alibaba.
the class AbstractSerializationPersonFailTest method test_StringPersonListMap.
@Test
public void test_StringPersonListMap() throws Exception {
Map<String, List<Person>> args = new HashMap<String, List<Person>>();
List<Person> sublist = new ArrayList<Person>();
sublist.add(new Person());
args.put("1", sublist);
try {
ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
objectOutput.writeObject(args);
fail();
} catch (NotSerializableException expected) {
} catch (IllegalStateException expected) {
assertThat(expected.getMessage(), containsString(FAIL_STRING));
}
}
use of org.apache.dubbo.common.serialize.ObjectOutput in project dubbo by alibaba.
the class AbstractSerializationPersonFailTest method test_Person.
@Test
public void test_Person() throws Exception {
try {
ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
objectOutput.writeObject(new Person());
fail();
} catch (NotSerializableException expected) {
} catch (IllegalStateException expected) {
assertThat(expected.getMessage(), containsString(FAIL_STRING));
}
}
Aggregations