use of org.apache.dubbo.common.serialize.model.Person in project dubbo by alibaba.
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 by alibaba.
the class AbstractSerializationPersonFailTest 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(FAIL_STRING));
}
}
use of org.apache.dubbo.common.serialize.model.Person in project dubbo by alibaba.
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 by alibaba.
the class FastJsonObjectInputTest method testReadObjectWithTowType.
@Test
public void testReadObjectWithTowType() throws Exception {
fastJsonObjectInput = new FastJsonObjectInput(new StringReader("[{\"name\":\"John\",\"age\":30},{\"name\":\"Born\",\"age\":24}]"));
Method methodReturnType = getClass().getMethod("towLayer");
Type type = methodReturnType.getGenericReturnType();
List<Person> o = fastJsonObjectInput.readObject(List.class, type);
assertTrue(o instanceof List);
assertTrue(o.get(0) instanceof Person);
assertThat(o.size(), is(2));
assertThat(o.get(1).getName(), is("Born"));
}
use of org.apache.dubbo.common.serialize.model.Person in project dubbo by alibaba.
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));
}
Aggregations