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