use of com.amazon.ion.IonValue in project jackson-dataformats-binary by FasterXML.
the class EnumAsIonSymbolSerializationTest method testUsingToString.
@Test
public void testUsingToString() throws Exception {
final IonValue EXP = ION_SYSTEM.singleValue("some_value");
Assert.assertEquals(EXP, newMapper(false, true).writeValueAsIonValue(SomeEnum.SOME_VALUE));
Assert.assertEquals(EXP, newMapper(true, true).writeValueAsIonValue(SomeEnum.SOME_VALUE));
}
use of com.amazon.ion.IonValue 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());
}
use of com.amazon.ion.IonValue in project jackson-dataformats-binary by FasterXML.
the class IonParserTest method testParserCapabilities.
@Test
public void testParserCapabilities() throws Exception {
IonSystem ion = IonSystemBuilder.standard().build();
Integer intValue = Integer.MAX_VALUE;
IonValue ionInt = ion.newInt(intValue);
try (IonParser p = new IonFactory().createParser(ObjectReadContext.empty(), ionInt)) {
// 15-Jan-2021, tatu: 2.14 added this setting, not enabled in
// default set
Assert.assertTrue(p.streamReadCapabilities().isEnabled(StreamReadCapability.EXACT_FLOATS));
}
}
use of com.amazon.ion.IonValue in project jackson-dataformats-binary by FasterXML.
the class PolymorphicRoundtripTest method testWithDateAsTimestamp.
@Test
public void testWithDateAsTimestamp() throws IOException {
resolveAllTypes = true;
ObjectMapper ionDateMapper = IonObjectMapper.builder().addModule(new IonAnnotationModule()).enable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS).build();
long etime = 1449191916000L;
java.util.Date uDate = new java.util.Date(etime);
java.sql.Date sDate = new java.sql.Date(etime);
// java.util.Date can serialize properly
String serialized = ionDateMapper.writeValueAsString(uDate);
IonValue ionVal = ionSystem.singleValue(serialized);
Assert.assertEquals("Expected date to be serialized into an int", IonType.INT, ionVal.getType());
// java.sql.Date can serialize properly
serialized = ionDateMapper.writeValueAsString(sDate);
ionVal = ionSystem.singleValue(serialized);
Assert.assertEquals("Expected date to be serialized into an int", IonType.INT, ionVal.getType());
}
use of com.amazon.ion.IonValue in project jackson-dataformats-binary by FasterXML.
the class IonValueDeserializerTest method shouldBeAbleToDeserializeAnnotatedNullStruct.
@Test
public void shouldBeAbleToDeserializeAnnotatedNullStruct() throws Exception {
IonValue ion = ion("foo::null.struct");
IonValue data = ION_VALUE_MAPPER.readValue(ion, IonValue.class);
assertEquals(ion, data);
assertEquals(1, data.getTypeAnnotations().length);
assertEquals("foo", data.getTypeAnnotations()[0]);
}
Aggregations