use of com.fasterxml.jackson.dataformat.smile.testutil.PrefixOutputDecorator in project jackson-dataformats-binary by FasterXML.
the class StreamingDecoratorsTest method testOutputDecorators.
public void testOutputDecorators() throws Exception {
final byte[] DOC = _smileDoc(" 137");
// important! Do not add document header for this test
final SmileFactory streamF = smileFactoryBuilder(false, false, false).outputDecorator(new PrefixOutputDecorator(DOC)).build();
final SmileMapper mapper = SmileMapper.builder(streamF).build();
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
JsonGenerator g = mapper.createGenerator(bytes);
g.writeString("foo");
g.close();
JsonParser p = mapper.createParser(bytes.toByteArray());
assertToken(JsonToken.VALUE_NUMBER_INT, p.nextToken());
assertEquals(137, p.getIntValue());
assertToken(JsonToken.VALUE_STRING, p.nextToken());
assertEquals("foo", p.getText());
assertNull(p.nextToken());
p.close();
}
Aggregations