use of net.morimekta.test.jackson.Containers in project providence by morimekta.
the class JacksonTest method testJsonSerializerCompat.
@Test
public void testJsonSerializerCompat() throws IOException {
ObjectMapper mapper = new ObjectMapper();
ProvidenceModule.register(mapper);
JsonSerializer compact = new JsonSerializer();
JsonSerializer pretty = new JsonSerializer().pretty();
ByteArrayOutputStream out = new ByteArrayOutputStream();
for (int i = 0; i < 100; ++i) {
Containers containers = generator.generate(Containers.kDescriptor);
out.reset();
compact.serialize(out, containers);
Containers res = mapper.readValue(out.toByteArray(), Containers.class);
assertThat(res, is(equalToMessage(containers)));
out.reset();
pretty.serialize(out, containers);
res = mapper.readValue(out.toByteArray(), Containers.class);
assertThat(res, is(equalToMessage(containers)));
}
}
Aggregations