Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save vladimirdolzhenko/67403eab2f908e8d8ee4f9c6aaa345f5 to your computer and use it in GitHub Desktop.
Save vladimirdolzhenko/67403eab2f908e8d8ee4f9c6aaa345f5 to your computer and use it in GitHub Desktop.
package com.fasterxml.jackson.perf.data;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectReader;
import org.junit.Test;
import java.io.IOException;
public class JsonNoInternReadVanillaTestCase {
private static final ObjectMapper MAPPER;
private static final InputConverter JSON_CONV;
static {
final JsonFactory factory = new JsonFactory();
factory.disable(JsonFactory.Feature.INTERN_FIELD_NAMES);
factory.disable(JsonFactory.Feature.CANONICALIZE_FIELD_NAMES);
MAPPER = new ObjectMapper(factory);
JSON_CONV = InputConverter.stdConverter(MAPPER);
}
protected final InputConverter FULL_CONVERTER;
protected final ObjectReader UNTYPED_READER;
protected final ObjectReader NODE_READER;
public JsonNoInternReadVanillaTestCase() {
FULL_CONVERTER = JSON_CONV;
ObjectReader r;
r = MAPPER.readerFor(Object.class);
UNTYPED_READER = r;
r = MAPPER.readerFor(JsonNode.class);
NODE_READER = r;
}
@Test
public void readUntypedCitmCatalog() throws Exception {
read(FULL_CONVERTER.bytes(InputData.CITM_CATALOG_WS), UNTYPED_READER);
}
@Test
public void readUntypedWebxml() throws Exception {
read(FULL_CONVERTER.bytes(InputData.WEBXML_WS), UNTYPED_READER);
}
@Test
public void readUntypedMenu() throws Exception {
read(FULL_CONVERTER.bytes(InputData.MENU_WS), UNTYPED_READER);
}
@Test
public void readUntypedMediaItem() throws Exception {
read(FULL_CONVERTER.mediaItemAsBytes(), UNTYPED_READER);
}
/*
/**********************************************************************
/* JsonNode reading tests
/**********************************************************************
*/
@Test
public void readNodeCitmCatalog() throws Exception {
read(FULL_CONVERTER.bytes(InputData.CITM_CATALOG_WS), NODE_READER);
}
@Test
public void readNodeWebxml() throws Exception {
read(FULL_CONVERTER.bytes(InputData.WEBXML_WS), NODE_READER);
}
@Test
public void readNodeMenu() throws Exception {
read(FULL_CONVERTER.bytes(InputData.MENU_WS), NODE_READER);
}
@Test
public void readNodeMediaItem() throws Exception {
read(FULL_CONVERTER.mediaItemAsBytes(), NODE_READER);
}
protected Object read(byte[] input, ObjectReader reader) throws IOException {
return reader.readValue(input);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment