use of com.fasterxml.jackson.module.afterburner.AfterburnerModule in project jackson-module-afterburner by FasterXML.
the class TestDeserializePerf method main.
public static void main(String[] args) throws Exception {
// JsonFactory f = new org.codehaus.jackson.smile.SmileFactory();
JsonFactory f = new JsonFactory();
ObjectMapper mapperSlow = new ObjectMapper(f);
ObjectMapper mapperFast = new ObjectMapper(f);
// !!! TEST -- to get profile info, comment out:
// mapperSlow.registerModule(new AfterburnerModule());
mapperFast.registerModule(new AfterburnerModule());
new TestDeserializePerf().testWith(mapperSlow, mapperFast);
}
use of com.fasterxml.jackson.module.afterburner.AfterburnerModule in project jackson-module-afterburner by FasterXML.
the class VLTBet method testIssue.
public void testIssue() throws Exception {
// create this ridiculously complicated object
ItemData data = new ItemData();
data.denomination = 100;
Item item = new Item();
item.data = data;
item.productId = 123;
List<Item> itemList = new ArrayList<Item>();
itemList.add(item);
PlaceOrderRequest order = new PlaceOrderRequest();
order.orderId = 68723496;
order.userId = "123489043";
order.amount = 250;
order.status = "placed";
order.items = itemList;
final Date now = new Date(999999L);
order.createdAt = now;
order.updatedAt = now;
ObjectMapper vanillaMapper = new ObjectMapper();
ObjectMapper abMapper = new ObjectMapper();
abMapper.registerModule(new AfterburnerModule());
// First: ensure that serialization produces identical output
String origJson = vanillaMapper.writerWithDefaultPrettyPrinter().writeValueAsString(order);
String abJson = abMapper.writerWithDefaultPrettyPrinter().writeValueAsString(order);
assertEquals(origJson, abJson);
// Then read the string and turn it back into an object
// this will cause an exception unless the AfterburnerModule is commented out
order = abMapper.readValue(abJson, PlaceOrderRequest.class);
assertNotNull(order);
assertEquals(250, order.amount);
}
Aggregations