use of org.apache.dubbo.common.serialize.model.Person in project dubbo-spi-extensions by apache.
the class AvroObjectInputOutputTest method testWriteReadObject.
@Test
public void testWriteReadObject() throws IOException, ClassNotFoundException {
Person p = new Person();
p.setAge(30);
p.setName("abc");
avroObjectOutput.writeObject(p);
avroObjectOutput.flushBuffer();
pos.close();
Person result = avroObjectInput.readObject(Person.class);
assertThat(result, not(nullValue()));
assertThat(result.getName(), is("abc"));
assertThat(result.getAge(), is(30));
}
use of org.apache.dubbo.common.serialize.model.Person in project dubbo-spi-extensions by apache.
the class AvroObjectInputOutputTest method testWriteReadObjectWithoutClass.
@Test
public void testWriteReadObjectWithoutClass() throws IOException, ClassNotFoundException {
Person p = new Person();
p.setAge(30);
p.setName("abc");
avroObjectOutput.writeObject(p);
avroObjectOutput.flushBuffer();
pos.close();
// 这里会丢失所有信息
Object result = avroObjectInput.readObject();
assertThat(result, not(nullValue()));
// assertThat(result.getName(), is("abc"));
// assertThat(result.getAge(), is(30));
}
use of org.apache.dubbo.common.serialize.model.Person in project dubbo-spi-extensions by apache.
the class AbstractSerializationPersonFailTest 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(FAIL_STRING));
}
}
use of org.apache.dubbo.common.serialize.model.Person in project dubbo-spi-extensions by apache.
the class AbstractSerializationPersonFailTest method test_IntPersonMap.
@Test
public void test_IntPersonMap() throws Exception {
Map<Integer, Person> args = new HashMap<Integer, 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(FAIL_STRING));
}
}
use of org.apache.dubbo.common.serialize.model.Person in project dubbo-spi-extensions by apache.
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));
}
}
Aggregations