use of com.alipay.sofa.rpc.codec.jackson.model.DemoRequest2 in project sofa-rpc by sofastack.
the class JacksonSerializerTest method testJacksonFeature.
@Test
public void testJacksonFeature() throws UnsupportedEncodingException {
try {
JacksonSerializer serializer = new JacksonSerializer();
serializer.decode(new ByteArrayWrapperByteBuf("{\"a\":1}".getBytes("UTF-8")), DemoRequest.class, null);
Assert.fail();
} catch (SofaRpcException e) {
// ok
} catch (Throwable e) {
Assert.fail();
}
try {
JacksonSerializer serializer = new JacksonSerializer();
serializer.encode(new DemoRequest2(), null);
Assert.fail();
} catch (SofaRpcException e) {
// ok
} catch (Throwable e) {
Assert.fail();
}
System.setProperty("sofa.rpc.codec.jackson.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES", "false");
JacksonSerializer serializer = new JacksonSerializer();
serializer.decode(new ByteArrayWrapperByteBuf("{\"a\":1}".getBytes("UTF-8")), DemoRequest.class, null);
System.setProperty("sofa.rpc.codec.jackson.SerializationFeature.FAIL_ON_EMPTY_BEANS", "false");
serializer = new JacksonSerializer();
serializer.encode(new DemoRequest2(), null);
System.setProperty("sofa.rpc.codec.jackson.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES", "true");
System.setProperty("sofa.rpc.codec.jackson.SerializationFeature.FAIL_ON_EMPTY_BEANS", "true");
}
Aggregations