Search in sources :

Example 1 with ObjectReadContext

use of com.fasterxml.jackson.core.ObjectReadContext in project jackson-dataformats-binary by FasterXML.

the class IonParserTest method testFloatType.

@Test
public void testFloatType() throws IOException {
    final ObjectReadContext ctxt = ObjectReadContext.empty();
    final byte[] data = "{ score:0.291e0 }".getBytes();
    IonSystem ion = IonSystemBuilder.standard().build();
    final IonValue ionFloat = ion.newFloat(Float.MAX_VALUE);
    IonReader reader = ionFloat.getSystem().newReader(data, 0, data.length);
    // Find the object
    reader.next();
    // Step into the object
    reader.stepIn();
    // Step next.
    reader.next();
    final IonParser floatParser = ionFactory.createParser(ctxt, reader);
    Assert.assertEquals(JsonParser.NumberType.DOUBLE, floatParser.getNumberType());
}
Also used : IonValue(com.amazon.ion.IonValue) IonSystem(com.amazon.ion.IonSystem) IonReader(com.amazon.ion.IonReader) ObjectReadContext(com.fasterxml.jackson.core.ObjectReadContext) Test(org.junit.Test)

Example 2 with ObjectReadContext

use of com.fasterxml.jackson.core.ObjectReadContext in project jackson-core by FasterXML.

the class JsonParserClosedCaseTest method parsers.

/**
 * Creates a list of parsers to tests.
 *
 * @return List of Object[2]. Object[0] is is the name of the class, Object[1] is instance itself.
 * @throws IOException when closing stream fails.
 */
@Parameters(name = "{0}")
public static Collection<Object[]> parsers() throws IOException {
    ByteArrayInputStream inputStream = new ByteArrayInputStream(new byte[] { '{', '}' });
    ObjectReadContext ctxt = ObjectReadContext.empty();
    return closeParsers(JSON_F.createParser(ctxt, new InputStreamReader(inputStream)), JSON_F.createParser(ctxt, inputStream), JSON_F.createParser(ctxt, new MockDataInput("{}")));
}
Also used : MockDataInput(com.fasterxml.jackson.core.testsupport.MockDataInput) ObjectReadContext(com.fasterxml.jackson.core.ObjectReadContext) Parameters(org.junit.runners.Parameterized.Parameters)

Aggregations

ObjectReadContext (com.fasterxml.jackson.core.ObjectReadContext)2 IonReader (com.amazon.ion.IonReader)1 IonSystem (com.amazon.ion.IonSystem)1 IonValue (com.amazon.ion.IonValue)1 MockDataInput (com.fasterxml.jackson.core.testsupport.MockDataInput)1 Test (org.junit.Test)1 Parameters (org.junit.runners.Parameterized.Parameters)1