diff --git a/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/EnumAsIonSymbolSerializer.java b/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/EnumAsIonSymbolSerializer.java index 95ac9e3b1..bd09d6d1a 100644 --- a/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/EnumAsIonSymbolSerializer.java +++ b/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/EnumAsIonSymbolSerializer.java @@ -19,11 +19,7 @@ import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.SerializationFeature; -import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper; import com.fasterxml.jackson.databind.ser.std.StdScalarSerializer; diff --git a/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/IonFactory.java b/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/IonFactory.java index 0c7843af8..6824d49d4 100644 --- a/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/IonFactory.java +++ b/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/IonFactory.java @@ -14,32 +14,16 @@ package com.fasterxml.jackson.dataformat.ion; -import java.io.CharArrayReader; -import java.io.Closeable; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.Reader; -import java.io.Writer; - -import com.fasterxml.jackson.core.JsonEncoding; -import com.fasterxml.jackson.core.JsonFactory; -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.ObjectCodec; -import com.fasterxml.jackson.core.Version; +import java.io.*; + +import com.amazon.ion.*; +import com.amazon.ion.system.IonSystemBuilder; + +import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.core.io.IOContext; import com.fasterxml.jackson.core.io.UTF8Writer; import com.fasterxml.jackson.core.util.TextBuffer; -import com.amazon.ion.IonReader; -import com.amazon.ion.IonSystem; -import com.amazon.ion.IonValue; -import com.amazon.ion.IonWriter; -import com.amazon.ion.system.IonSystemBuilder; - /** * Sub-class of {@link JsonFactory} that will work on Ion content, instead of JSON * content. diff --git a/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/IonFactoryBuilder.java b/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/IonFactoryBuilder.java index 35feaa85b..5a921f86b 100644 --- a/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/IonFactoryBuilder.java +++ b/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/IonFactoryBuilder.java @@ -1,10 +1,10 @@ package com.fasterxml.jackson.dataformat.ion; -import com.fasterxml.jackson.core.TSFBuilder; - import com.amazon.ion.IonSystem; import com.amazon.ion.system.IonSystemBuilder; +import com.fasterxml.jackson.core.TSFBuilder; + /** * {@link com.fasterxml.jackson.core.TSFBuilder} * implementation for constructing {@link IonFactory} instances. diff --git a/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/IonGenerator.java b/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/IonGenerator.java index 5207a31ee..3409802dc 100644 --- a/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/IonGenerator.java +++ b/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/IonGenerator.java @@ -14,32 +14,21 @@ package com.fasterxml.jackson.dataformat.ion; -import java.io.Closeable; -import java.io.Flushable; -import java.io.IOException; +import java.io.*; import java.math.BigDecimal; import java.math.BigInteger; import java.nio.charset.StandardCharsets; import java.util.Calendar; -import com.fasterxml.jackson.core.Base64Variant; -import com.fasterxml.jackson.core.FormatFeature; -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.ObjectCodec; -import com.fasterxml.jackson.core.StreamWriteCapability; -import com.fasterxml.jackson.core.StreamWriteConstraints; -import com.fasterxml.jackson.core.Version; +import com.amazon.ion.*; + +import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.core.base.GeneratorBase; import com.fasterxml.jackson.core.io.IOContext; import com.fasterxml.jackson.core.json.JsonWriteContext; import com.fasterxml.jackson.core.util.JacksonFeatureSet; import com.fasterxml.jackson.dataformat.ion.polymorphism.IonAnnotationTypeSerializer; -import com.amazon.ion.IonType; -import com.amazon.ion.IonValue; -import com.amazon.ion.IonWriter; -import com.amazon.ion.Timestamp; - /** * Implementation of {@link JsonGenerator} that will use an underlying * {@link IonWriter} for actual writing of content. diff --git a/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/IonObjectMapper.java b/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/IonObjectMapper.java index 95366bde5..81a02a222 100644 --- a/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/IonObjectMapper.java +++ b/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/IonObjectMapper.java @@ -17,6 +17,9 @@ import java.io.IOException; import java.util.Date; +import com.amazon.ion.*; +import com.amazon.ion.system.IonSystemBuilder; + import com.fasterxml.jackson.core.Version; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.JavaType; @@ -24,13 +27,6 @@ import com.fasterxml.jackson.databind.cfg.MapperBuilder; import com.fasterxml.jackson.databind.module.SimpleModule; -import com.amazon.ion.IonDatagram; -import com.amazon.ion.IonReader; -import com.amazon.ion.IonSystem; -import com.amazon.ion.IonValue; -import com.amazon.ion.IonWriter; -import com.amazon.ion.system.IonSystemBuilder; - /** * Specialization of {@link ObjectMapper} that will set underlying * {@link com.fasterxml.jackson.core.JsonFactory} diff --git a/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/IonParser.java b/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/IonParser.java index bf5653267..32784cbc8 100644 --- a/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/IonParser.java +++ b/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/IonParser.java @@ -19,13 +19,14 @@ import java.math.BigDecimal; import java.math.BigInteger; +import com.amazon.ion.*; +import com.amazon.ion.system.IonSystemBuilder; + import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.core.base.ParserMinimalBase; import com.fasterxml.jackson.core.io.IOContext; import com.fasterxml.jackson.core.json.JsonReadContext; import com.fasterxml.jackson.core.util.JacksonFeatureSet; -import com.amazon.ion.*; -import com.amazon.ion.system.IonSystemBuilder; /** * Implementation of {@link JsonParser} that will use an underlying diff --git a/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/IonSymbolSerializer.java b/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/IonSymbolSerializer.java index dc01b48c7..1aa96c6ec 100644 --- a/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/IonSymbolSerializer.java +++ b/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/IonSymbolSerializer.java @@ -19,10 +19,7 @@ import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper; import com.fasterxml.jackson.databind.ser.std.StdScalarSerializer; diff --git a/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/IonTimestampDeserializers.java b/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/IonTimestampDeserializers.java index 8c690d0de..27c9527ae 100644 --- a/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/IonTimestampDeserializers.java +++ b/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/IonTimestampDeserializers.java @@ -16,12 +16,13 @@ import java.io.IOException; +import com.amazon.ion.Timestamp; + import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonToken; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.deser.std.DateDeserializers.DateDeserializer; import com.fasterxml.jackson.databind.deser.std.DateDeserializers.SqlDateDeserializer; -import com.amazon.ion.Timestamp; /** * A date deserializer that uses native Ion timestamps instead of JSON strings. diff --git a/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/IonTimestampSerializers.java b/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/IonTimestampSerializers.java index bb9b90c7f..e5bf6d924 100644 --- a/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/IonTimestampSerializers.java +++ b/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/IonTimestampSerializers.java @@ -19,7 +19,6 @@ import java.util.TimeZone; import com.fasterxml.jackson.core.JsonGenerator; - import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.ser.std.StdScalarSerializer; diff --git a/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/ionvalue/DeserializersEx.java b/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/ionvalue/DeserializersEx.java index 2e9e036da..037090c6c 100644 --- a/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/ionvalue/DeserializersEx.java +++ b/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/ionvalue/DeserializersEx.java @@ -14,16 +14,13 @@ package com.fasterxml.jackson.dataformat.ion.ionvalue; -import com.fasterxml.jackson.databind.BeanDescription; -import com.fasterxml.jackson.databind.DeserializationConfig; -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonMappingException; +import com.amazon.ion.IonContainer; +import com.amazon.ion.IonValue; + +import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.jsontype.TypeDeserializer; import com.fasterxml.jackson.databind.module.SimpleDeserializers; import com.fasterxml.jackson.databind.type.CollectionType; -import com.amazon.ion.IonContainer; -import com.amazon.ion.IonValue; class DeserializersEx extends SimpleDeserializers { diff --git a/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/ionvalue/IonValueDeserializer.java b/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/ionvalue/IonValueDeserializer.java index 73010db12..0835a989b 100644 --- a/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/ionvalue/IonValueDeserializer.java +++ b/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/ionvalue/IonValueDeserializer.java @@ -16,16 +16,13 @@ import java.io.IOException; +import com.amazon.ion.*; + import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.util.AccessPattern; import com.fasterxml.jackson.dataformat.ion.IonParser; -import com.amazon.ion.IonSystem; -import com.amazon.ion.IonValue; -import com.amazon.ion.Timestamp; /** * Deserializer that knows how to deserialize an IonValue. diff --git a/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/ionvalue/IonValueMapper.java b/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/ionvalue/IonValueMapper.java index 95e837d13..bdda0ab82 100644 --- a/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/ionvalue/IonValueMapper.java +++ b/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/ionvalue/IonValueMapper.java @@ -16,16 +16,14 @@ import java.io.IOException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.PropertyNamingStrategy; -import com.fasterxml.jackson.dataformat.ion.EnumAsIonSymbolModule; -import com.fasterxml.jackson.dataformat.ion.IonFactory; -import com.fasterxml.jackson.dataformat.ion.IonObjectMapper; - import com.amazon.ion.IonSystem; import com.amazon.ion.IonValue; import com.amazon.ion.system.IonSystemBuilder; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.PropertyNamingStrategy; +import com.fasterxml.jackson.dataformat.ion.*; + /** * Supports serializing Ion to POJO and back using the Jackson Ion framework. * diff --git a/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/ionvalue/IonValueModule.java b/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/ionvalue/IonValueModule.java index 99c24e697..6b1879b20 100644 --- a/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/ionvalue/IonValueModule.java +++ b/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/ionvalue/IonValueModule.java @@ -14,11 +14,11 @@ package com.fasterxml.jackson.dataformat.ion.ionvalue; +import com.amazon.ion.Timestamp; + import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.dataformat.ion.PackageVersion; -import com.amazon.ion.Timestamp; - /** * A module which allows for the direct serialization to and from IonValue fields. The POJO can declare fields of type * IonValue (or a subclass) and the direct value will be provided. diff --git a/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/ionvalue/IonValueSerializer.java b/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/ionvalue/IonValueSerializer.java index fa6287550..247b0fb15 100644 --- a/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/ionvalue/IonValueSerializer.java +++ b/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/ionvalue/IonValueSerializer.java @@ -16,13 +16,13 @@ import java.io.IOException; +import com.amazon.ion.IonValue; + import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.ser.std.StdScalarSerializer; import com.fasterxml.jackson.dataformat.ion.IonGenerator; -import com.amazon.ion.IonValue; - /** * Serializer that knows how to serialize an IonValue. */ diff --git a/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/ionvalue/TimestampDeserializer.java b/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/ionvalue/TimestampDeserializer.java index b6c0fb7d7..c6be43cb0 100644 --- a/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/ionvalue/TimestampDeserializer.java +++ b/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/ionvalue/TimestampDeserializer.java @@ -16,10 +16,11 @@ import java.io.IOException; +import com.amazon.ion.Timestamp; + import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.JsonDeserializer; -import com.amazon.ion.Timestamp; /** * Deserializer that knows how to deserialize a Timestamp. diff --git a/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/ionvalue/TimestampSerializer.java b/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/ionvalue/TimestampSerializer.java index a90ec490f..7866b7aa8 100644 --- a/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/ionvalue/TimestampSerializer.java +++ b/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/ionvalue/TimestampSerializer.java @@ -16,13 +16,13 @@ import java.io.IOException; +import com.amazon.ion.Timestamp; + import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.ser.std.StdScalarSerializer; import com.fasterxml.jackson.dataformat.ion.IonGenerator; -import com.amazon.ion.Timestamp; - /** * Serializer that knows how to serialize a Timestamp. */ diff --git a/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/jsr310/IonJavaTimeModule.java b/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/jsr310/IonJavaTimeModule.java index 13e3fbbae..b3a8cb491 100644 --- a/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/jsr310/IonJavaTimeModule.java +++ b/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/jsr310/IonJavaTimeModule.java @@ -1,11 +1,8 @@ package com.fasterxml.jackson.dataformat.ion.jsr310; -import java.time.Instant; -import java.time.OffsetDateTime; -import java.time.ZonedDateTime; +import java.time.*; import com.fasterxml.jackson.databind.module.SimpleModule; - import com.fasterxml.jackson.dataformat.ion.PackageVersion; /** diff --git a/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/jsr310/IonTimestampInstantDeserializer.java b/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/jsr310/IonTimestampInstantDeserializer.java index 92594293f..9e7b65b8e 100644 --- a/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/jsr310/IonTimestampInstantDeserializer.java +++ b/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/jsr310/IonTimestampInstantDeserializer.java @@ -2,24 +2,17 @@ import java.io.IOException; import java.math.BigDecimal; -import java.time.Instant; -import java.time.OffsetDateTime; -import java.time.ZoneId; -import java.time.ZoneOffset; -import java.time.ZonedDateTime; +import java.time.*; import java.time.temporal.Temporal; import java.util.function.BiFunction; import com.amazon.ion.Timestamp; + import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat.Feature; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.BeanProperty; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.deser.ContextualDeserializer; import com.fasterxml.jackson.databind.deser.std.StdScalarDeserializer; diff --git a/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/jsr310/IonTimestampInstantSerializer.java b/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/jsr310/IonTimestampInstantSerializer.java index 771fa77ea..b7ff276af 100644 --- a/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/jsr310/IonTimestampInstantSerializer.java +++ b/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/jsr310/IonTimestampInstantSerializer.java @@ -1,11 +1,7 @@ package com.fasterxml.jackson.dataformat.ion.jsr310; import java.io.IOException; -import java.time.Instant; -import java.time.OffsetDateTime; -import java.time.ZoneId; -import java.time.ZoneOffset; -import java.time.ZonedDateTime; +import java.time.*; import java.time.temporal.Temporal; import java.util.function.BiFunction; import java.util.function.Function; @@ -13,11 +9,7 @@ import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat.Feature; import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.BeanProperty; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.SerializationFeature; -import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.ser.ContextualSerializer; import com.fasterxml.jackson.databind.ser.std.StdScalarSerializer; import com.fasterxml.jackson.dataformat.ion.IonGenerator; diff --git a/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/polymorphism/IonAnnotationTypeDeserializer.java b/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/polymorphism/IonAnnotationTypeDeserializer.java index 6217b2b58..981c8ad22 100644 --- a/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/polymorphism/IonAnnotationTypeDeserializer.java +++ b/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/polymorphism/IonAnnotationTypeDeserializer.java @@ -17,13 +17,8 @@ import java.io.IOException; import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.BeanProperty; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.core.*; +import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.jsontype.TypeDeserializer; import com.fasterxml.jackson.databind.jsontype.TypeIdResolver; import com.fasterxml.jackson.databind.jsontype.impl.TypeDeserializerBase; diff --git a/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/polymorphism/IonAnnotationTypeResolverBuilder.java b/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/polymorphism/IonAnnotationTypeResolverBuilder.java index bc11939e9..414894773 100644 --- a/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/polymorphism/IonAnnotationTypeResolverBuilder.java +++ b/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/polymorphism/IonAnnotationTypeResolverBuilder.java @@ -17,15 +17,8 @@ import java.util.Collection; import com.fasterxml.jackson.annotation.JsonTypeInfo; - -import com.fasterxml.jackson.databind.DeserializationConfig; -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.SerializationConfig; -import com.fasterxml.jackson.databind.jsontype.NamedType; -import com.fasterxml.jackson.databind.jsontype.TypeDeserializer; -import com.fasterxml.jackson.databind.jsontype.TypeIdResolver; -import com.fasterxml.jackson.databind.jsontype.TypeResolverBuilder; -import com.fasterxml.jackson.databind.jsontype.TypeSerializer; +import com.fasterxml.jackson.databind.*; +import com.fasterxml.jackson.databind.jsontype.*; /** * A {@link TypeResolverBuilder} which produces {@link TypeSerializer}s and {@link TypeDeserializer}s that use diff --git a/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/polymorphism/IonAnnotationTypeSerializer.java b/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/polymorphism/IonAnnotationTypeSerializer.java index abf45cfc5..1df2e8e7f 100644 --- a/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/polymorphism/IonAnnotationTypeSerializer.java +++ b/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/polymorphism/IonAnnotationTypeSerializer.java @@ -15,8 +15,7 @@ package com.fasterxml.jackson.dataformat.ion.polymorphism; import com.fasterxml.jackson.annotation.JsonTypeInfo.As; - -import com.fasterxml.jackson.core.*; +import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.type.WritableTypeId; import com.fasterxml.jackson.databind.BeanProperty; import com.fasterxml.jackson.databind.jsontype.TypeIdResolver; diff --git a/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/util/CloseSafeUTF8Writer.java b/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/util/CloseSafeUTF8Writer.java index 7d04dbf26..576f73795 100644 --- a/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/util/CloseSafeUTF8Writer.java +++ b/ion/src/main/java/com/fasterxml/jackson/dataformat/ion/util/CloseSafeUTF8Writer.java @@ -14,9 +14,7 @@ package com.fasterxml.jackson.dataformat.ion.util; -import java.io.IOException; -import java.io.OutputStream; -import java.io.Writer; +import java.io.*; import com.fasterxml.jackson.core.io.IOContext; import com.fasterxml.jackson.core.io.UTF8Writer; diff --git a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/DataBindReadTest.java b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/DataBindReadTest.java index c82fd5c4c..4ad848d28 100644 --- a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/DataBindReadTest.java +++ b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/DataBindReadTest.java @@ -14,20 +14,16 @@ package com.fasterxml.jackson.dataformat.ion; -import java.io.*; +import java.io.IOException; -import org.junit.Test; +import com.amazon.ion.*; +import com.amazon.ion.system.IonSystemBuilder; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.databind.ObjectMapper; -import com.amazon.ion.IonReader; -import com.amazon.ion.IonStruct; -import com.amazon.ion.IonSystem; -import com.amazon.ion.IonType; -import com.amazon.ion.IonValue; -import com.amazon.ion.system.IonSystemBuilder; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class DataBindReadTest { static class MyBean { diff --git a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/DataBindRoundtripTest.java b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/DataBindRoundtripTest.java index 1ec062cc0..5b7bad92d 100644 --- a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/DataBindRoundtripTest.java +++ b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/DataBindRoundtripTest.java @@ -14,12 +14,6 @@ package com.fasterxml.jackson.dataformat.ion; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - import java.io.ByteArrayOutputStream; import java.io.IOException; import java.math.BigDecimal; @@ -27,17 +21,15 @@ import java.util.Collections; import java.util.List; -import org.junit.Test; +import com.amazon.ion.*; +import com.amazon.ion.system.IonSystemBuilder; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; - import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import com.amazon.ion.IonStruct; -import com.amazon.ion.IonSystem; -import com.amazon.ion.IonValue; -import com.amazon.ion.system.IonSystemBuilder; +import static org.junit.jupiter.api.Assertions.*; /** * Simple unit tests to check that write-then-read works as expected @@ -154,7 +146,7 @@ public void testIonRoot() throws IOException { Bean bean = m.readValue(root, Bean.class); assertNotNull(bean); - assertEquals(bean.a, "test"); + assertEquals("test", bean.a); assertEquals(0.25, bean.b, 0.0); assertArrayEquals(new byte[0], bean.data); assertTrue(bean.state); diff --git a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/DataBindWriteTest.java b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/DataBindWriteTest.java index 922877cfc..c3b2aa454 100644 --- a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/DataBindWriteTest.java +++ b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/DataBindWriteTest.java @@ -14,26 +14,16 @@ package com.fasterxml.jackson.dataformat.ion; -import com.amazon.ion.IonDatagram; -import com.amazon.ion.IonList; -import com.amazon.ion.IonReader; -import com.amazon.ion.IonStruct; -import com.amazon.ion.IonSystem; -import com.amazon.ion.IonType; -import com.amazon.ion.IonWriter; -import com.amazon.ion.system.IonBinaryWriterBuilder; -import com.amazon.ion.system.IonReaderBuilder; -import com.amazon.ion.system.IonSystemBuilder; -import com.amazon.ion.system.IonTextWriterBuilder; -import com.amazon.ion.system.IonWriterBuilder; -import org.junit.Before; -import org.junit.Test; - import java.io.ByteArrayOutputStream; import java.io.IOException; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import com.amazon.ion.*; +import com.amazon.ion.system.*; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; public class DataBindWriteTest { @@ -47,7 +37,7 @@ static class MyBean { IonSystem ion = IonSystemBuilder.standard().build(); IonDatagram expectedMyBean; - @Before + @BeforeEach public void initializeExpectedMyBean() { expectedMyBean = ion.newDatagram(); IonStruct struct = ion.newEmptyStruct(); @@ -61,7 +51,7 @@ public void initializeExpectedMyBean() { IonDatagram expectedArray; - @Before + @BeforeEach public void initializeExpectedArray() { expectedArray = ion.newDatagram(); IonList list = ion.newEmptyList(); diff --git a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/DatabindNumberRoundtrip490Test.java b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/DatabindNumberRoundtrip490Test.java index c944cb69f..92b12e4d0 100644 --- a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/DatabindNumberRoundtrip490Test.java +++ b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/DatabindNumberRoundtrip490Test.java @@ -1,11 +1,13 @@ package com.fasterxml.jackson.dataformat.ion; -import java.util.*; -import org.junit.Test; +import java.util.Collections; +import java.util.Map; + +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.databind.ObjectMapper; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.assertEquals; // for [dataformats-binary#490] public class DatabindNumberRoundtrip490Test diff --git a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/DatabindRead303Test.java b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/DatabindRead303Test.java index 23f5b7f77..06c264928 100644 --- a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/DatabindRead303Test.java +++ b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/DatabindRead303Test.java @@ -2,11 +2,11 @@ import java.net.URL; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.core.exc.StreamReadException; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.fail; public class DatabindRead303Test { diff --git a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/EnumAsIonSymbolSerializationTest.java b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/EnumAsIonSymbolSerializationTest.java index 3569772ec..c08576e05 100644 --- a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/EnumAsIonSymbolSerializationTest.java +++ b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/EnumAsIonSymbolSerializationTest.java @@ -14,13 +14,15 @@ package com.fasterxml.jackson.dataformat.ion; -import org.junit.Assert; -import org.junit.Test; import com.amazon.ion.IonSystem; import com.amazon.ion.IonValue; import com.amazon.ion.system.IonSystemBuilder; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.SerializationFeature; +import static org.junit.jupiter.api.Assertions.assertEquals; + public class EnumAsIonSymbolSerializationTest { private enum SomeEnum { @@ -38,9 +40,9 @@ public String toString() { public void testUsingName() throws Exception { final IonValue EXP = ION_SYSTEM.singleValue("SOME_VALUE"); - Assert.assertEquals(EXP, + assertEquals(EXP, newMapper(false, false).writeValueAsIonValue(SomeEnum.SOME_VALUE)); - Assert.assertEquals(EXP, + assertEquals(EXP, newMapper(true, false).writeValueAsIonValue(SomeEnum.SOME_VALUE)); } @@ -48,9 +50,9 @@ public void testUsingName() throws Exception public void testUsingToString() throws Exception { final IonValue EXP = ION_SYSTEM.singleValue("some_value"); - Assert.assertEquals(EXP, + assertEquals(EXP, newMapper(false, true).writeValueAsIonValue(SomeEnum.SOME_VALUE)); - Assert.assertEquals(EXP, + assertEquals(EXP, newMapper(true, true).writeValueAsIonValue(SomeEnum.SOME_VALUE)); } diff --git a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/GenerateSexpTest.java b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/GenerateSexpTest.java index 22562cd55..91b19dd6e 100644 --- a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/GenerateSexpTest.java +++ b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/GenerateSexpTest.java @@ -18,18 +18,20 @@ import java.io.IOException; import java.util.Arrays; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - import com.amazon.ion.IonSystem; import com.amazon.ion.IonWriter; import com.amazon.ion.system.IonSystemBuilder; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.JsonSerializer; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * End to end test verifying we can serialize sexps */ @@ -38,7 +40,7 @@ public class GenerateSexpTest { private IonSystem ionSystem; private IonObjectMapper mapper; - @Before + @BeforeEach public void setup() { this.ionSystem = IonSystemBuilder.standard().build(); this.mapper = IonObjectMapper.builder(ionSystem).build(); @@ -46,14 +48,14 @@ public void setup() { @Test public void topLevel() throws IOException { - Assert.assertEquals( + assertEquals( ionSystem.singleValue("(foo \"bar\")"), mapper.writeValueAsIonValue(new SexpObject("foo", "bar"))); } @Test public void inList() throws IOException { - Assert.assertEquals( + assertEquals( ionSystem.singleValue("[(foo \"bar\"), (baz \"qux\")]"), mapper.writeValueAsIonValue( Arrays.asList(new SexpObject("foo", "bar"), new SexpObject("baz", "qux")))); @@ -61,21 +63,21 @@ public void inList() throws IOException { @Test public void inObject() throws IOException { - Assert.assertEquals( + assertEquals( ionSystem.singleValue("{sexpField:(foo \"bar\")}"), mapper.writeValueAsIonValue(new SexpObjectContainer(new SexpObject("foo", "bar")))); } @Test public void inOtherSexp() throws IOException { - Assert.assertEquals( + assertEquals( ionSystem.singleValue("(foo (bar \"baz\"))"), mapper.writeValueAsIonValue(new SexpObject("foo", new SexpObject("bar", "baz")))); } @Test public void generatorUsedInStreamingWriteText() throws IOException { - Assert.assertArrayEquals("(foo 0)".getBytes(), toBytes(new SexpObject("foo", 0), mapper)); + assertArrayEquals("(foo 0)".getBytes(), toBytes(new SexpObject("foo", 0), mapper)); } @Test @@ -90,7 +92,7 @@ public void generatorUsedInStreamingWriteBinary() throws IOException { } mapper.setCreateBinaryWriters(true); - Assert.assertArrayEquals(expectedBytes, toBytes(new SexpObject("foo", 0), mapper)); + assertArrayEquals(expectedBytes, toBytes(new SexpObject("foo", 0), mapper)); } private byte[] toBytes(Object object, IonObjectMapper mapper) throws IOException { diff --git a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/IonFactoryTest.java b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/IonFactoryTest.java index ce3d70ee1..fb34d5364 100644 --- a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/IonFactoryTest.java +++ b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/IonFactoryTest.java @@ -1,14 +1,15 @@ package com.fasterxml.jackson.dataformat.ion; -import com.amazon.ion.IonReader; -import com.fasterxml.jackson.core.JsonParser; -import org.junit.Test; - import java.io.ByteArrayInputStream; import java.io.StringReader; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import com.amazon.ion.IonReader; +import org.junit.jupiter.api.Test; + +import com.fasterxml.jackson.core.JsonParser; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class IonFactoryTest { diff --git a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/IonGeneratorTest.java b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/IonGeneratorTest.java index f2c18269d..4d442320a 100644 --- a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/IonGeneratorTest.java +++ b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/IonGeneratorTest.java @@ -14,25 +14,20 @@ package com.fasterxml.jackson.dataformat.ion; -import org.junit.Test; -import org.junit.Before; -import com.fasterxml.jackson.core.JsonGenerationException; -import com.fasterxml.jackson.databind.JsonNode; +import java.util.*; -import com.amazon.ion.IonDatagram; -import com.amazon.ion.IonValue; -import com.amazon.ion.IonStruct; -import com.amazon.ion.IonSystem; +import com.amazon.ion.*; import com.amazon.ion.system.IonSystemBuilder; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import java.util.Map; -import java.util.HashMap; -import java.util.Collections; +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.databind.JsonNode; -import static org.hamcrest.Matchers.is; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.hamcrest.Matchers.is; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; public class IonGeneratorTest { private static final Map testObject; @@ -59,7 +54,7 @@ public class IonGeneratorTest { private IonValue testObjectIon; private JsonNode testObjectTree; - @Before + @BeforeEach public void setUp() throws Exception { final IonFactory factory = new IonFactory(); diff --git a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/IonNumberOverflowTest.java b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/IonNumberOverflowTest.java index d99f10adc..6201d5ade 100644 --- a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/IonNumberOverflowTest.java +++ b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/IonNumberOverflowTest.java @@ -1,15 +1,15 @@ package com.fasterxml.jackson.dataformat.ion; +import java.math.BigInteger; + import org.hamcrest.Matchers; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.core.exc.InputCoercionException; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; - -import java.math.BigInteger; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; // for [dataformats-ion#428] public class IonNumberOverflowTest diff --git a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/IonParserTest.java b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/IonParserTest.java index 6c66a4eaf..5f498903e 100644 --- a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/IonParserTest.java +++ b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/IonParserTest.java @@ -14,22 +14,17 @@ package com.fasterxml.jackson.dataformat.ion; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.core.StreamReadCapability; - -import org.junit.Assert; - -import com.amazon.ion.IonReader; -import com.amazon.ion.IonSystem; -import com.amazon.ion.IonValue; -import com.amazon.ion.system.IonSystemBuilder; - import java.io.IOException; import java.math.BigDecimal; import java.math.BigInteger; -import org.junit.Test; + +import com.amazon.ion.*; +import com.amazon.ion.system.IonSystemBuilder; +import org.junit.jupiter.api.Test; + +import com.fasterxml.jackson.core.*; + +import static org.junit.jupiter.api.Assertions.*; @SuppressWarnings("resource") public class IonParserTest @@ -41,51 +36,51 @@ public void testGetNumberTypeAndValue() throws Exception { Integer intValue = Integer.MAX_VALUE; IonValue ionInt = ion.newInt(intValue); IonParser intParser = new IonFactory().createParser(ionInt); - Assert.assertEquals(JsonToken.VALUE_NUMBER_INT, intParser.nextToken()); - Assert.assertEquals(JsonParser.NumberType.INT, intParser.getNumberType()); - Assert.assertEquals(JsonParser.NumberTypeFP.UNKNOWN, intParser.getNumberTypeFP()); - Assert.assertEquals(intValue, intParser.getNumberValue()); + assertEquals(JsonToken.VALUE_NUMBER_INT, intParser.nextToken()); + assertEquals(JsonParser.NumberType.INT, intParser.getNumberType()); + assertEquals(JsonParser.NumberTypeFP.UNKNOWN, intParser.getNumberTypeFP()); + assertEquals(intValue, intParser.getNumberValue()); Long longValue = Long.MAX_VALUE; IonValue ionLong = ion.newInt(longValue); IonParser longParser = new IonFactory().createParser(ionLong); - Assert.assertEquals(JsonToken.VALUE_NUMBER_INT, longParser.nextToken()); - Assert.assertEquals(JsonParser.NumberType.LONG, longParser.getNumberType()); - Assert.assertEquals(JsonParser.NumberTypeFP.UNKNOWN, intParser.getNumberTypeFP()); - Assert.assertEquals(longValue, longParser.getNumberValue()); + assertEquals(JsonToken.VALUE_NUMBER_INT, longParser.nextToken()); + assertEquals(JsonParser.NumberType.LONG, longParser.getNumberType()); + assertEquals(JsonParser.NumberTypeFP.UNKNOWN, intParser.getNumberTypeFP()); + assertEquals(longValue, longParser.getNumberValue()); BigInteger bigIntValue = new BigInteger(Long.MAX_VALUE + "1"); IonValue ionBigInt = ion.newInt(bigIntValue); IonParser bigIntParser = new IonFactory().createParser(ionBigInt); - Assert.assertEquals(JsonToken.VALUE_NUMBER_INT, bigIntParser.nextToken()); - Assert.assertEquals(JsonParser.NumberType.BIG_INTEGER, bigIntParser.getNumberType()); - Assert.assertEquals(JsonParser.NumberTypeFP.UNKNOWN, intParser.getNumberTypeFP()); - Assert.assertEquals(bigIntValue, bigIntParser.getNumberValue()); + assertEquals(JsonToken.VALUE_NUMBER_INT, bigIntParser.nextToken()); + assertEquals(JsonParser.NumberType.BIG_INTEGER, bigIntParser.getNumberType()); + assertEquals(JsonParser.NumberTypeFP.UNKNOWN, intParser.getNumberTypeFP()); + assertEquals(bigIntValue, bigIntParser.getNumberValue()); Double decimalValue = Double.MAX_VALUE; IonValue ionDecimal = ion.newDecimal(decimalValue); IonParser decimalParser = new IonFactory().createParser(ionDecimal); - Assert.assertEquals(JsonToken.VALUE_NUMBER_FLOAT, decimalParser.nextToken()); - Assert.assertEquals(JsonParser.NumberType.BIG_DECIMAL, decimalParser.getNumberType()); - Assert.assertEquals(JsonParser.NumberTypeFP.BIG_DECIMAL, decimalParser.getNumberTypeFP()); - Assert.assertEquals(0, new BigDecimal("" + decimalValue).compareTo((BigDecimal) decimalParser.getNumberValue())); + assertEquals(JsonToken.VALUE_NUMBER_FLOAT, decimalParser.nextToken()); + assertEquals(JsonParser.NumberType.BIG_DECIMAL, decimalParser.getNumberType()); + assertEquals(JsonParser.NumberTypeFP.BIG_DECIMAL, decimalParser.getNumberTypeFP()); + assertEquals(0, new BigDecimal("" + decimalValue).compareTo((BigDecimal) decimalParser.getNumberValue())); Double floatValue = Double.MAX_VALUE; IonValue ionFloat = ion.newFloat(floatValue); IonParser floatParser = new IonFactory().createParser(ionFloat); - Assert.assertEquals(JsonToken.VALUE_NUMBER_FLOAT, floatParser.nextToken()); - Assert.assertEquals(JsonParser.NumberType.DOUBLE, floatParser.getNumberType()); + assertEquals(JsonToken.VALUE_NUMBER_FLOAT, floatParser.nextToken()); + assertEquals(JsonParser.NumberType.DOUBLE, floatParser.getNumberType()); // [dataformats-binary#490]: float coerces to double - Assert.assertEquals(JsonParser.NumberTypeFP.DOUBLE64, floatParser.getNumberTypeFP()); - Assert.assertEquals(floatValue, floatParser.getNumberValue()); + assertEquals(JsonParser.NumberTypeFP.DOUBLE64, floatParser.getNumberTypeFP()); + assertEquals(floatValue, floatParser.getNumberValue()); BigDecimal bigDecimalValue = new BigDecimal(Double.MAX_VALUE + "1"); IonValue ionBigDecimal = ion.newDecimal(bigDecimalValue); IonParser bigDecimalParser = new IonFactory().createParser(ionBigDecimal); - Assert.assertEquals(JsonToken.VALUE_NUMBER_FLOAT, bigDecimalParser.nextToken()); - Assert.assertEquals(JsonParser.NumberType.BIG_DECIMAL, bigDecimalParser.getNumberType()); - Assert.assertEquals(JsonParser.NumberTypeFP.BIG_DECIMAL, bigDecimalParser.getNumberTypeFP()); - Assert.assertEquals(0, bigDecimalValue.compareTo((BigDecimal) bigDecimalParser.getNumberValue())); + assertEquals(JsonToken.VALUE_NUMBER_FLOAT, bigDecimalParser.nextToken()); + assertEquals(JsonParser.NumberType.BIG_DECIMAL, bigDecimalParser.getNumberType()); + assertEquals(JsonParser.NumberTypeFP.BIG_DECIMAL, bigDecimalParser.getNumberTypeFP()); + assertEquals(0, bigDecimalValue.compareTo((BigDecimal) bigDecimalParser.getNumberValue())); } @Test @@ -105,7 +100,7 @@ public void testFloatType() throws IOException { // does not initialize state. For now, `IonParser.getNumberType()` has // special handling allowing this case but that should not be needed final IonParser floatParser = new IonFactory().createParser(reader); - Assert.assertEquals(JsonParser.NumberType.DOUBLE, floatParser.getNumberType()); + assertEquals(JsonParser.NumberType.DOUBLE, floatParser.getNumberType()); } @Test @@ -120,7 +115,7 @@ public void testGetTypeId() throws IOException { parser.nextToken(); // advance to find START_OBJECT - Assert.assertEquals(className, parser.getTypeId()); + assertEquals(className, parser.getTypeId()); } @Test @@ -133,61 +128,69 @@ public void testParserCapabilities() throws Exception { try (IonParser p = new IonFactory().createParser(ionInt)) { // 15-Jan-2021, tatu: 2.14 added this setting, not enabled in // default set - Assert.assertTrue(p.getReadCapabilities().isEnabled(StreamReadCapability.EXACT_FLOATS)); + assertTrue(p.getReadCapabilities().isEnabled(StreamReadCapability.EXACT_FLOATS)); } } - @Test(expected = JsonParseException.class) + @Test public void testIonExceptionIsWrapped() throws IOException { - IonFactory f = new IonFactory(); - try (IonParser parser = (IonParser) f.createParser("[ 12, true ) ]")) { - Assert.assertEquals(JsonToken.START_ARRAY, parser.nextToken()); - Assert.assertEquals(JsonToken.VALUE_NUMBER_INT, parser.nextValue()); - Assert.assertEquals(12, parser.getIntValue()); - Assert.assertEquals(JsonToken.VALUE_TRUE, parser.nextValue()); - parser.nextValue(); - } + assertThrows(JsonParseException.class, () -> { + IonFactory f = new IonFactory(); + try (IonParser parser = (IonParser) f.createParser("[ 12, true ) ]")) { + assertEquals(JsonToken.START_ARRAY, parser.nextToken()); + assertEquals(JsonToken.VALUE_NUMBER_INT, parser.nextValue()); + assertEquals(12, parser.getIntValue()); + assertEquals(JsonToken.VALUE_TRUE, parser.nextValue()); + parser.nextValue(); + } + }); } - @Test(expected = JsonParseException.class) + @Test public void testUnknownSymbolExceptionForValueIsWrapped() throws IOException { - IonFactory f = new IonFactory(); - try (IonParser parser = (IonParser) f.createParser("[ 12, $99 ]")) { - Assert.assertEquals(JsonToken.START_ARRAY, parser.nextToken()); - Assert.assertEquals(JsonToken.VALUE_NUMBER_INT, parser.nextValue()); - Assert.assertEquals(12, parser.getIntValue()); - Assert.assertEquals(JsonToken.VALUE_STRING, parser.nextValue()); - parser.getValueAsString(); // Should encounter unknown symbol and fail - } + assertThrows(JsonParseException.class, () -> { + IonFactory f = new IonFactory(); + try (IonParser parser = (IonParser) f.createParser("[ 12, $99 ]")) { + assertEquals(JsonToken.START_ARRAY, parser.nextToken()); + assertEquals(JsonToken.VALUE_NUMBER_INT, parser.nextValue()); + assertEquals(12, parser.getIntValue()); + assertEquals(JsonToken.VALUE_STRING, parser.nextValue()); + parser.getValueAsString(); // Should encounter unknown symbol and fail + } + }); } - @Test(expected = JsonParseException.class) + @Test public void testUnknownSymbolExceptionForFieldNameIsWrapped() throws IOException { - IonFactory f = new IonFactory(); - try (IonParser parser = (IonParser) f.createParser("{ a: 1, $99: 2 }")) { - Assert.assertEquals(JsonToken.START_OBJECT, parser.nextToken()); - Assert.assertEquals(JsonToken.FIELD_NAME, parser.nextToken()); - Assert.assertEquals("a", parser.currentName()); - Assert.assertEquals("a", parser.getText()); - Assert.assertEquals("a", parser.getValueAsString()); - Assert.assertEquals("a", parser.getValueAsString("b")); - Assert.assertEquals(JsonToken.VALUE_NUMBER_INT, parser.nextValue()); - Assert.assertEquals(1, parser.getIntValue()); - parser.nextValue(); // Should encounter unknown symbol and fail - } + assertThrows(JsonParseException.class, () -> { + IonFactory f = new IonFactory(); + try (IonParser parser = (IonParser) f.createParser("{ a: 1, $99: 2 }")) { + assertEquals(JsonToken.START_OBJECT, parser.nextToken()); + assertEquals(JsonToken.FIELD_NAME, parser.nextToken()); + assertEquals("a", parser.currentName()); + assertEquals("a", parser.getText()); + assertEquals("a", parser.getValueAsString()); + assertEquals("a", parser.getValueAsString("b")); + assertEquals(JsonToken.VALUE_NUMBER_INT, parser.nextValue()); + assertEquals(1, parser.getIntValue()); + parser.nextValue(); // Should encounter unknown symbol and fail + } + }); } - @Test(expected = JsonParseException.class) + @Test public void testUnknownSymbolExceptionForAnnotationIsWrapped() throws IOException { - IonFactory f = new IonFactory(); - try (IonParser parser = (IonParser) f.createParser("{ a: $99::1 }")) { - Assert.assertEquals(JsonToken.START_OBJECT, parser.nextToken()); - Assert.assertEquals(JsonToken.FIELD_NAME, parser.nextToken()); - Assert.assertEquals("a", parser.currentName()); - Assert.assertEquals(JsonToken.VALUE_NUMBER_INT, parser.nextValue()); - Assert.assertEquals(1, parser.getIntValue()); - parser.getTypeAnnotations(); // Should encounter unknown symbol and fail - } + assertThrows(JsonParseException.class, () -> { + IonFactory f = new IonFactory(); + try (IonParser parser = (IonParser) f.createParser("{ a: $99::1 }")) { + assertEquals(JsonToken.START_OBJECT, parser.nextToken()); + assertEquals(JsonToken.FIELD_NAME, parser.nextToken()); + assertEquals("a", parser.currentName()); + assertEquals(JsonToken.VALUE_NUMBER_INT, parser.nextValue()); + assertEquals(1, parser.getIntValue()); + parser.getTypeAnnotations(); // Should encounter unknown symbol and fail + } + }); } } diff --git a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/IonTimestampDeser251Test.java b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/IonTimestampDeser251Test.java index 1781ddb08..49ec5db29 100644 --- a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/IonTimestampDeser251Test.java +++ b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/IonTimestampDeser251Test.java @@ -1,18 +1,16 @@ package com.fasterxml.jackson.dataformat.ion; -import org.junit.Test; - import com.amazon.ion.Timestamp; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; - import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; - import com.fasterxml.jackson.dataformat.ion.ionvalue.IonValueModule; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; // For [dataformats-binary#251] public class IonTimestampDeser251Test diff --git a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/IonTimestampRoundTripTest.java b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/IonTimestampRoundTripTest.java index a59e6b327..e72f6dec1 100644 --- a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/IonTimestampRoundTripTest.java +++ b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/IonTimestampRoundTripTest.java @@ -17,21 +17,16 @@ import java.io.IOException; import java.util.Date; -import org.junit.Assert; -import org.junit.Test; +import com.amazon.ion.*; +import com.amazon.ion.system.IonSystemBuilder; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.core.JsonGenerationException; - import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.json.JsonMapper; -import com.amazon.ion.IonDatagram; -import com.amazon.ion.IonLoader; -import com.amazon.ion.IonSystem; -import com.amazon.ion.IonType; -import com.amazon.ion.IonValue; -import com.amazon.ion.system.IonSystemBuilder; +import static org.junit.jupiter.api.Assertions.assertEquals; public class IonTimestampRoundTripTest { IonSystem ionSystem = IonSystemBuilder.standard().build(); @@ -48,10 +43,10 @@ public void testDateRoundTrip() throws IOException { IonDatagram dgram = loader.load(val); IonValue ionVal = dgram.iterator().next(); - Assert.assertEquals("Expected date to be serialized into an IonTimestamp", IonType.TIMESTAMP, ionVal.getType()); + assertEquals(IonType.TIMESTAMP, ionVal.getType(), "Expected date to be serialized into an IonTimestamp"); Date returned = m.readValue(val, Date.class); - Assert.assertEquals("Date result not the same as serialized value.", date, returned); + assertEquals(date, returned, "Date result not the same as serialized value."); } @@ -64,7 +59,7 @@ public void testMillisCompatibility() throws IOException { String val = m.writeValueAsString(date); Date returned = m.readValue(val, Date.class); - Assert.assertEquals("Date result not the same as serialized value.", date, returned); + assertEquals(date, returned, "Date result not the same as serialized value."); } /** * Test if the JoiMapper can read all forms of dates generated by non-JoiMappers @@ -88,7 +83,7 @@ public void testNonJoiCompatibility() throws IOException { Date millisBack = joiM.readValue(dateInMillis, Date.class); Date formattedBack = joiM.readValue(dateFormatted, Date.class); - Assert.assertEquals("Date result not the same as serialized value.", date, millisBack); - Assert.assertEquals("Date result not the same as serialized value.", date, formattedBack); + assertEquals(date, millisBack, "Date result not the same as serialized value."); + assertEquals(date, formattedBack, "Date result not the same as serialized value."); } } diff --git a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/PolymorphicRoundtripTest.java b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/PolymorphicRoundtripTest.java index 185376530..2533da5ee 100644 --- a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/PolymorphicRoundtripTest.java +++ b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/PolymorphicRoundtripTest.java @@ -14,25 +14,18 @@ package com.fasterxml.jackson.dataformat.ion; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import java.io.IOException; import java.util.ArrayList; import java.util.List; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import com.amazon.ion.*; +import com.amazon.ion.system.IonSystemBuilder; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; - import com.fasterxml.jackson.core.Version; - -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.annotation.JsonTypeResolver; import com.fasterxml.jackson.databind.cfg.MapperConfig; import com.fasterxml.jackson.databind.jsontype.PolymorphicTypeValidator; @@ -41,14 +34,9 @@ import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.databind.type.TypeFactory; import com.fasterxml.jackson.dataformat.ion.ionvalue.IonValueMapper; -import com.fasterxml.jackson.dataformat.ion.polymorphism.IonAnnotationIntrospector; -import com.fasterxml.jackson.dataformat.ion.polymorphism.IonAnnotationTypeResolverBuilder; -import com.fasterxml.jackson.dataformat.ion.polymorphism.MultipleTypeIdResolver; +import com.fasterxml.jackson.dataformat.ion.polymorphism.*; -import com.amazon.ion.IonSystem; -import com.amazon.ion.IonType; -import com.amazon.ion.IonValue; -import com.amazon.ion.system.IonSystemBuilder; +import static org.junit.jupiter.api.Assertions.*; public class PolymorphicRoundtripTest { @@ -63,7 +51,7 @@ public class PolymorphicRoundtripTest { String preferredTypeId = null; // if asked to resolve from multiple ids, choose this one. IonSystem ionSystem = IonSystemBuilder.standard().build(); - @Before + @BeforeEach public void reset() { resolveAllTypes = false; preferredTypeId = null; @@ -91,7 +79,7 @@ public void testSubclass() throws IOException { assertEquals(original.field, deserialized.field); assertEquals(original.child.someField, deserialized.child.someField); - assertTrue(deserialized.child instanceof ChildBeanSub); + assertInstanceOf(ChildBeanSub.class, deserialized.child); assertEquals(((ChildBeanSub) original.child).extraField, ((ChildBeanSub) deserialized.child).extraField); } @@ -104,7 +92,7 @@ public void testTopLevelPolymorphism() throws IOException { mapper.registerModule(new IonAnnotationModule()); String serialized = mapper.writeValueAsString(original); Object obj = mapper.readValue(serialized, Object.class); - assertTrue(obj instanceof Bean); + assertInstanceOf(Bean.class, obj); Bean deserialized = (Bean) obj; assertEquals(original.field, deserialized.field); assertEquals(original.child.someField, deserialized.child.someField); @@ -124,21 +112,21 @@ public void testSelectivePolymorphism() throws IOException { // to be chosen (and we expect that first id to be the most narrow type, ChildBeanSub). Bean deserialized = mapper.readValue(serialized, Bean.class); - assertEquals(deserialized.child.getClass(), ChildBeanSub.class); + assertEquals(ChildBeanSub.class, deserialized.child.getClass()); assertEquals(((ChildBeanSub) original.child).extraField, ((ChildBeanSub) deserialized.child).extraField); // second, try deserializing with the wider type (ChildBean). We're losing data (extraField) preferredTypeId = getClass().getCanonicalName() + "$ChildBean"; deserialized = mapper.readValue(serialized, Bean.class); - assertEquals(deserialized.child.getClass(), ChildBean.class); + assertEquals(ChildBean.class, deserialized.child.getClass()); assertEquals(original.child.someField, deserialized.child.someField); // third, try deserializing into an Object. The child node should deserialize, but immediately fail mapping. preferredTypeId = "java.lang.Object"; try { deserialized = mapper.readValue(serialized, Bean.class); - Assert.fail("Expected jackson to complain about casting a (concrete) Object into a ChildBean."); + fail("Expected jackson to complain about casting a (concrete) Object into a ChildBean."); } catch (JsonMappingException e) { } } @@ -157,12 +145,12 @@ public void testWithIonDate() throws IOException { // java.util.Date can serialize properly String serialized = mapper.writeValueAsString(uDate); IonValue ionVal = ionSystem.singleValue(serialized); - Assert.assertEquals("Expected date to be serialized into an IonTimestamp", IonType.TIMESTAMP, ionVal.getType()); + assertEquals(IonType.TIMESTAMP, ionVal.getType(), "Expected date to be serialized into an IonTimestamp"); // java.sql.Date can serialize properly serialized = mapper.writeValueAsString(sDate); ionVal = ionSystem.singleValue(serialized); - Assert.assertEquals("Expected date to be serialized into an IonTimestamp", IonType.TIMESTAMP, ionVal.getType()); + assertEquals(IonType.TIMESTAMP, ionVal.getType(), "Expected date to be serialized into an IonTimestamp"); } @Test @@ -179,12 +167,12 @@ public void testWithDateAsTimestamp() throws IOException { // 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()); + assertEquals(IonType.INT, ionVal.getType(), "Expected date to be serialized into an int"); // 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()); + assertEquals(IonType.INT, ionVal.getType(), "Expected date to be serialized into an int"); } @Test @@ -204,8 +192,8 @@ public void testPolymorphicTypeWithDate() throws IOException{ String serialized = mapper.writeValueAsString(original); Bean deserialized = mapper.readValue(serialized, Bean.class); ChildBeanSub deserializedSub = (ChildBeanSub)deserialized.child; - Assert.assertEquals("Date result not the same as serialized value.", uDate, deserializedSub.uDate); - Assert.assertEquals("Date result not the same as serialized value.", sDate, deserializedSub.sDate); + assertEquals(uDate, deserializedSub.uDate, "Date result not the same as serialized value."); + assertEquals(sDate, deserializedSub.sDate, "Date result not the same as serialized value."); } @Test @@ -222,7 +210,7 @@ public void testPolymorphicTypeWithIonValue() throws IOException{ String serialized = mapper.writeValueAsString(original); Bean deserialized = mapper.readValue(serialized, Bean.class); ChildBeanSub deserializedSub = (ChildBeanSub)deserialized.child; - Assert.assertEquals("Dynamic data not the same as serialized IonValue.", dynamicData, deserializedSub.dynamicData); + assertEquals(dynamicData, deserializedSub.dynamicData, "Dynamic data not the same as serialized IonValue."); } static class Bean { diff --git a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/SimpleIonReadTest.java b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/SimpleIonReadTest.java index c73db94a2..07922c332 100644 --- a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/SimpleIonReadTest.java +++ b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/SimpleIonReadTest.java @@ -14,14 +14,16 @@ package com.fasterxml.jackson.dataformat.ion; -import java.io.*; +import java.io.IOException; -import org.junit.Test; -import static org.junit.Assert.*; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonToken; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; + public class SimpleIonReadTest { private final IonFactory ION_F = new IonFactory(); // // // Actual tests; low level diff --git a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/SimpleIonWriteTest.java b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/SimpleIonWriteTest.java index ce4e9dee3..86b6d360e 100644 --- a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/SimpleIonWriteTest.java +++ b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/SimpleIonWriteTest.java @@ -16,18 +16,15 @@ import java.io.*; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.*; +import com.amazon.ion.*; +import com.amazon.ion.system.IonSystemBuilder; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.core.JsonGenerator; -import com.amazon.ion.IonDatagram; -import com.amazon.ion.IonLoader; -import com.amazon.ion.IonStruct; -import com.amazon.ion.IonSystem; -import com.amazon.ion.IonType; -import com.amazon.ion.system.IonSystemBuilder; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; public class SimpleIonWriteTest { @@ -92,7 +89,7 @@ private void _writeSimple(JsonGenerator gen) throws IOException IonSystem ion = IonSystemBuilder.standard().build(); IonDatagram expected; - @Before + @BeforeEach public void initializeExpectedDatagram() { IonStruct struct = ion.newEmptyStruct(); struct.add("a").newString("value"); diff --git a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/dos/CyclicIonDataSerTest.java b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/dos/CyclicIonDataSerTest.java index e57e5c1ea..c56d3fc74 100644 --- a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/dos/CyclicIonDataSerTest.java +++ b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/dos/CyclicIonDataSerTest.java @@ -3,15 +3,15 @@ import java.util.ArrayList; import java.util.List; -import com.fasterxml.jackson.core.StreamWriteConstraints; -import com.fasterxml.jackson.databind.*; +import org.junit.jupiter.api.Test; +import com.fasterxml.jackson.core.StreamWriteConstraints; +import com.fasterxml.jackson.databind.DatabindException; +import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.ion.IonObjectMapper; -import org.junit.Test; - -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * Simple unit tests to verify that we fail gracefully if you attempt to serialize @@ -31,8 +31,8 @@ public void testListWithSelfReference() throws Exception { } catch (DatabindException e) { String exceptionPrefix = String.format("Document nesting depth (%d) exceeds the maximum allowed", StreamWriteConstraints.DEFAULT_MAX_DEPTH + 1); - assertTrue("DatabindException message is as expected?", - e.getMessage().startsWith(exceptionPrefix)); + assertTrue(e.getMessage().startsWith(exceptionPrefix), + "DatabindException message is as expected?"); } } } diff --git a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/failing/PrettyPrintWriteTest.java b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/failing/PrettyPrintWriteTest.java index 14bd76a86..586b0ebf0 100644 --- a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/failing/PrettyPrintWriteTest.java +++ b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/failing/PrettyPrintWriteTest.java @@ -1,11 +1,13 @@ package com.fasterxml.jackson.dataformat.ion.failing; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.dataformat.ion.IonObjectMapper; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + // For [dataformats-binary#245]: no pretty-printing for textual format public class PrettyPrintWriteTest { @@ -19,7 +21,7 @@ static class Point { public void testBasicPrettyPrintTextual() throws Exception { IonObjectMapper mapper = IonObjectMapper.builderForTextualWriters().build(); - Assert.assertEquals("{\n x:1,\n y:2\n}", + assertEquals("{\n x:1,\n y:2\n}", mapper.writerWithDefaultPrettyPrinter().writeValueAsString(new Point())); } @@ -29,6 +31,6 @@ public void testIgnorePrettyPrintForBinary() throws Exception { IonObjectMapper mapper = IonObjectMapper.builderForBinaryWriters().build(); byte[] encoded = mapper.writerWithDefaultPrettyPrinter().writeValueAsBytes(new Point()); - Assert.assertNotNull(encoded); + assertNotNull(encoded); } } diff --git a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/fuzz/Fuzz417_64721InvalidIonTest.java b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/fuzz/Fuzz417_64721InvalidIonTest.java index 724a98d81..6d63c6296 100644 --- a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/fuzz/Fuzz417_64721InvalidIonTest.java +++ b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/fuzz/Fuzz417_64721InvalidIonTest.java @@ -1,14 +1,14 @@ package com.fasterxml.jackson.dataformat.ion.fuzz; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.fail; - import org.hamcrest.Matchers; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.core.exc.StreamReadException; import com.fasterxml.jackson.dataformat.ion.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.fail; + // [dataformats-binary#417] public class Fuzz417_64721InvalidIonTest { diff --git a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/fuzz/Fuzz420_65062_65083IOOBETest.java b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/fuzz/Fuzz420_65062_65083IOOBETest.java index 45057f1b5..dd2904c20 100644 --- a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/fuzz/Fuzz420_65062_65083IOOBETest.java +++ b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/fuzz/Fuzz420_65062_65083IOOBETest.java @@ -3,13 +3,13 @@ import java.io.InputStream; import org.hamcrest.Matchers; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.core.exc.StreamReadException; import com.fasterxml.jackson.dataformat.ion.*; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; // [dataformats-binary#420] public class Fuzz420_65062_65083IOOBETest diff --git a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/fuzz/Fuzz424_65065_65126NPETest.java b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/fuzz/Fuzz424_65065_65126NPETest.java index aa15caf2e..e27fb89a2 100644 --- a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/fuzz/Fuzz424_65065_65126NPETest.java +++ b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/fuzz/Fuzz424_65065_65126NPETest.java @@ -3,13 +3,13 @@ import java.io.ByteArrayInputStream; import org.hamcrest.Matchers; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.core.exc.StreamReadException; -import com.fasterxml.jackson.dataformat.ion.*; +import com.fasterxml.jackson.dataformat.ion.IonObjectMapper; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; // [dataformats-binary#424] public class Fuzz424_65065_65126NPETest diff --git a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/fuzz/Fuzz432_65273_AssertionTest.java b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/fuzz/Fuzz432_65273_AssertionTest.java index e81e881d6..f2d3ab6da 100644 --- a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/fuzz/Fuzz432_65273_AssertionTest.java +++ b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/fuzz/Fuzz432_65273_AssertionTest.java @@ -3,14 +3,14 @@ import java.io.InputStream; import org.hamcrest.Matchers; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.exc.StreamReadException; -import com.fasterxml.jackson.dataformat.ion.*; +import com.fasterxml.jackson.dataformat.ion.IonFactory; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; // [dataformats-binary#4432] public class Fuzz432_65273_AssertionTest diff --git a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/fuzz/Fuzz434_65268_65274_NPETest.java b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/fuzz/Fuzz434_65268_65274_NPETest.java index 6552079c0..cba5d34dd 100644 --- a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/fuzz/Fuzz434_65268_65274_NPETest.java +++ b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/fuzz/Fuzz434_65268_65274_NPETest.java @@ -1,20 +1,19 @@ package com.fasterxml.jackson.dataformat.ion.fuzz; -import java.io.*; +import java.io.ByteArrayInputStream; +import java.io.InputStream; import org.hamcrest.Matchers; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonToken; import com.fasterxml.jackson.core.exc.StreamReadException; import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.dataformat.ion.*; +import com.fasterxml.jackson.dataformat.ion.IonObjectMapper; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.*; // [dataformats-binary#434] public class Fuzz434_65268_65274_NPETest diff --git a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/fuzz/Fuzz437_65452_NPETest.java b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/fuzz/Fuzz437_65452_NPETest.java index a37cfe2ba..4d5219b64 100644 --- a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/fuzz/Fuzz437_65452_NPETest.java +++ b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/fuzz/Fuzz437_65452_NPETest.java @@ -1,17 +1,18 @@ package com.fasterxml.jackson.dataformat.ion.fuzz; -import java.io.*; +import java.io.ByteArrayInputStream; +import java.io.InputStream; import org.hamcrest.Matchers; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.exc.StreamReadException; import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.dataformat.ion.*; +import com.fasterxml.jackson.dataformat.ion.IonObjectMapper; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; // [dataformats-binary#437] public class Fuzz437_65452_NPETest diff --git a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/fuzz/Fuzz_65062_VarintTest.java b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/fuzz/Fuzz_65062_VarintTest.java index 770afab37..2d85f1b28 100644 --- a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/fuzz/Fuzz_65062_VarintTest.java +++ b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/fuzz/Fuzz_65062_VarintTest.java @@ -3,16 +3,16 @@ import java.io.InputStream; import org.hamcrest.Matchers; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonToken; import com.fasterxml.jackson.core.exc.StreamReadException; -import com.fasterxml.jackson.dataformat.ion.*; +import com.fasterxml.jackson.dataformat.ion.IonObjectMapper; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; // https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=65062 public class Fuzz_65062_VarintTest diff --git a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/fuzz/IonFuzzTestUtil.java b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/fuzz/IonFuzzTestUtil.java index 2892ab00a..af5c29ea0 100644 --- a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/fuzz/IonFuzzTestUtil.java +++ b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/fuzz/IonFuzzTestUtil.java @@ -1,8 +1,6 @@ package com.fasterxml.jackson.dataformat.ion.fuzz; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; +import java.io.*; public class IonFuzzTestUtil { diff --git a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/fuzz/IonFuzz_469_66149_NegArraySizeTest.java b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/fuzz/IonFuzz_469_66149_NegArraySizeTest.java index 1f39552f9..517a28f99 100644 --- a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/fuzz/IonFuzz_469_66149_NegArraySizeTest.java +++ b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/fuzz/IonFuzz_469_66149_NegArraySizeTest.java @@ -1,14 +1,14 @@ package com.fasterxml.jackson.dataformat.ion.fuzz; import org.hamcrest.Matchers; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.core.exc.StreamReadException; import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.dataformat.ion.*; +import com.fasterxml.jackson.dataformat.ion.IonObjectMapper; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; // [dataformats-binary#469]: NegativeArraySizeException // https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=66141 diff --git a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/fuzz/IonFuzz_471_66141_AssertionErrorTest.java b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/fuzz/IonFuzz_471_66141_AssertionErrorTest.java index 4625dc45b..0610e7274 100644 --- a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/fuzz/IonFuzz_471_66141_AssertionErrorTest.java +++ b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/fuzz/IonFuzz_471_66141_AssertionErrorTest.java @@ -1,15 +1,14 @@ package com.fasterxml.jackson.dataformat.ion.fuzz; import org.hamcrest.Matchers; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.core.exc.StreamReadException; - import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.dataformat.ion.*; +import com.fasterxml.jackson.dataformat.ion.IonObjectMapper; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; // [dataformats-binary#471]: AssertionError for corrupt Timestamp // https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=66141 diff --git a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/fuzz/IonFuzz_473_66131_AIOOBE_Test.java b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/fuzz/IonFuzz_473_66131_AIOOBE_Test.java index cf750b163..80739f161 100644 --- a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/fuzz/IonFuzz_473_66131_AIOOBE_Test.java +++ b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/fuzz/IonFuzz_473_66131_AIOOBE_Test.java @@ -1,17 +1,17 @@ package com.fasterxml.jackson.dataformat.ion.fuzz; import org.hamcrest.Matchers; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonToken; import com.fasterxml.jackson.core.exc.StreamReadException; import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.dataformat.ion.*; +import com.fasterxml.jackson.dataformat.ion.IonObjectMapper; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; //[dataformats-binary#473]: ArrayIndexOutOfBoundsException //https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=66131 diff --git a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/ionvalue/IonValueDeserializerTest.java b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/ionvalue/IonValueDeserializerTest.java index 35f14897f..7c97012e6 100644 --- a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/ionvalue/IonValueDeserializerTest.java +++ b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/ionvalue/IonValueDeserializerTest.java @@ -1,24 +1,19 @@ package com.fasterxml.jackson.dataformat.ion.ionvalue; -import com.amazon.ion.IonSystem; -import com.amazon.ion.IonValue; -import com.amazon.ion.IonStruct; +import java.io.IOException; +import java.util.*; + +import com.amazon.ion.*; import com.amazon.ion.system.IonSystemBuilder; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonProperty; +import org.junit.jupiter.api.Test; + +import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.databind.util.AccessPattern; import com.fasterxml.jackson.dataformat.ion.IonObjectMapper; -import org.junit.Test; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import static org.junit.Assert.assertEquals; import static com.fasterxml.jackson.databind.PropertyNamingStrategies.SNAKE_CASE; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; public class IonValueDeserializerTest { private static class Data { diff --git a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/ionvalue/IonValueMapperTest.java b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/ionvalue/IonValueMapperTest.java index fbeba4951..3d13d7d35 100644 --- a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/ionvalue/IonValueMapperTest.java +++ b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/ionvalue/IonValueMapperTest.java @@ -14,36 +14,20 @@ package com.fasterxml.jackson.dataformat.ion.ionvalue; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertNull; - import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.junit.Test; +import java.util.*; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.amazon.ion.*; +import com.amazon.ion.system.IonSystemBuilder; +import org.junit.jupiter.api.Test; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import com.fasterxml.jackson.dataformat.ion.IonSymbolSerializer; import com.fasterxml.jackson.dataformat.ion.IonObjectMapper; +import com.fasterxml.jackson.dataformat.ion.IonSymbolSerializer; -import com.amazon.ion.IonSexp; -import com.amazon.ion.IonSystem; -import com.amazon.ion.IonValue; -import com.amazon.ion.Timestamp; -import com.amazon.ion.system.IonSystemBuilder; +import static org.junit.jupiter.api.Assertions.*; /** * Test of the {@link IonValueMapper} parser. diff --git a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/jsr310/IonTimestampInstantDeserializerTest.java b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/jsr310/IonTimestampInstantDeserializerTest.java index 31a0830a5..ef7aded4b 100644 --- a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/jsr310/IonTimestampInstantDeserializerTest.java +++ b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/jsr310/IonTimestampInstantDeserializerTest.java @@ -1,21 +1,20 @@ package com.fasterxml.jackson.dataformat.ion.jsr310; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.time.DateTimeException; -import java.time.Instant; -import java.time.ZoneOffset; +import java.time.*; import java.time.temporal.ChronoUnit; import java.time.temporal.Temporal; - -import org.junit.Test; +import java.util.concurrent.TimeUnit; import com.amazon.ion.Timestamp; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Timeout; + import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectReader; import com.fasterxml.jackson.dataformat.ion.IonObjectMapper; +import static org.junit.jupiter.api.Assertions.*; + public class IonTimestampInstantDeserializerTest { private static final IonObjectMapper MAPPER = IonObjectMapper.builder() @@ -39,21 +38,21 @@ private IonObjectMapper.Builder newMapperBuilder() { public void testDeserializationAsFloat01() throws Exception { Instant expected = Instant.ofEpochSecond(0L); Instant actual = READER.readValue("0.000000"); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test public void testDeserializationAsFloat02() throws Exception { Instant expected = Instant.ofEpochSecond(123456789L, 183917322); Instant actual = READER.readValue("123456789.183917322"); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test public void testDeserializationAsFloat03() throws Exception { Instant expected = Instant.now(); Instant actual = READER.readValue(TimestampUtils.getFractionalSeconds(expected).toString()); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } /** @@ -63,7 +62,7 @@ public void testDeserializationAsFloat03() throws Exception { public void testDeserializationAsFloatEdgeCase01() throws Exception { String input = Instant.MAX.getEpochSecond() + ".999999999"; Instant actual = READER.readValue(input); - assertEquals(actual, Instant.MAX); + assertEquals(Instant.MAX, actual); assertEquals(Instant.MAX.getEpochSecond(), actual.getEpochSecond()); assertEquals(999999999, actual.getNano()); } @@ -75,30 +74,36 @@ public void testDeserializationAsFloatEdgeCase01() throws Exception { public void testDeserializationAsFloatEdgeCase02() throws Exception { String input = Instant.MIN.getEpochSecond() + ".0"; Instant actual = READER.readValue(input); - assertEquals(actual, Instant.MIN); + assertEquals(Instant.MIN, actual); assertEquals(Instant.MIN.getEpochSecond(), actual.getEpochSecond()); assertEquals(0, actual.getNano()); } - @Test(expected = DateTimeException.class) + @Test public void testDeserializationAsFloatEdgeCase03() throws Exception { - // Instant can't go this low - String input = Instant.MIN.getEpochSecond() + ".1"; - READER.readValue(input); + assertThrows(DateTimeException.class, () -> { + // Instant can't go this low + String input = Instant.MIN.getEpochSecond() + ".1"; + READER.readValue(input); + }); } - @Test(expected = DateTimeException.class) + @Test public void testDeserializationAsFloatEdgeCase04() throws Exception { - // 1s beyond the upper-bound of Instant. - String input = (Instant.MAX.getEpochSecond() + 1) + ".0"; - READER.readValue(input); + assertThrows(DateTimeException.class, () -> { + // 1s beyond the upper-bound of Instant. + String input = (Instant.MAX.getEpochSecond() + 1) + ".0"; + READER.readValue(input); + }); } - @Test(expected = DateTimeException.class) + @Test public void testDeserializationAsFloatEdgeCase05() throws Exception { - // 1s beyond the lower-bound of Instant. - String input = (Instant.MIN.getEpochSecond() - 1) + ".0"; - READER.readValue(input); + assertThrows(DateTimeException.class, () -> { + // 1s beyond the lower-bound of Instant. + String input = (Instant.MIN.getEpochSecond() - 1) + ".0"; + READER.readValue(input); + }); } @Test @@ -119,13 +124,15 @@ public void testDeserializationAsFloatEdgeCase07() throws Exception { * Numbers with very large exponents can take a long time, but still result in zero. * https://github.com/FasterXML/jackson-databind/issues/2141 */ - @Test(timeout = 100) + @Timeout(value = 100, unit = TimeUnit.MILLISECONDS) + @Test public void testDeserializationAsFloatEdgeCase08() throws Exception { Instant actual = READER.readValue("1e308"); assertEquals(0, actual.getEpochSecond()); } - @Test(timeout = 100) + @Timeout(value = 100, unit = TimeUnit.MILLISECONDS) + @Test public void testDeserializationAsFloatEdgeCase09() throws Exception { Instant actual = READER.readValue("-1e308"); assertEquals(0, actual.getEpochSecond()); @@ -134,13 +141,15 @@ public void testDeserializationAsFloatEdgeCase09() throws Exception { /** * Same for large negative exponents. */ - @Test(timeout = 100) + @Timeout(value = 100, unit = TimeUnit.MILLISECONDS) + @Test public void testDeserializationAsFloatEdgeCase10() throws Exception { Instant actual = READER.readValue("1e-323"); assertEquals(0, actual.getEpochSecond()); } - @Test(timeout = 100) + @Timeout(value = 100, unit = TimeUnit.MILLISECONDS) + @Test public void testDeserializationAsFloatEdgeCase11() throws Exception { Instant actual = READER.readValue("-1e-323"); assertEquals(0, actual.getEpochSecond()); @@ -159,7 +168,7 @@ public void testDeserializationAsInt01Nanoseconds() throws Exception { .with(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue("0"); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -169,7 +178,7 @@ public void testDeserializationAsInt02Nanoseconds() throws Exception { .with(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue("123456789"); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -179,7 +188,7 @@ public void testDeserializationAsInt03Nanoseconds() throws Exception { .with(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue(Long.toString(expected.getEpochSecond())); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -189,7 +198,7 @@ public void testDeserializationAsInt01Milliseconds() throws Exception { .without(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue("0"); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -199,7 +208,7 @@ public void testDeserializationAsInt02Milliseconds() throws Exception { .without(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue("123456789422"); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -209,7 +218,7 @@ public void testDeserializationAsInt03Milliseconds() throws Exception { .without(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue(Long.toString(expected.toEpochMilli())); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } /* @@ -223,7 +232,7 @@ public void testDeserializationAsIonTimestamp01() throws Exception { Instant expected = Instant.ofEpochSecond(0L); Timestamp timestamp = TimestampUtils.toTimestamp(expected, ZoneOffset.UTC); Instant actual = READER.readValue(timestamp.toString()); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -231,7 +240,7 @@ public void testDeserializationAsIonTimestamp02() throws Exception { Instant expected = Instant.ofEpochSecond(123456789L, 183917322); Timestamp timestamp = TimestampUtils.toTimestamp(expected, ZoneOffset.UTC); Instant actual = READER.readValue(timestamp.toString()); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -239,7 +248,7 @@ public void testDeserializationAsIonTimestamp03() throws Exception { Instant expected = Instant.now(); Timestamp timestamp = TimestampUtils.toTimestamp(expected, ZoneOffset.UTC); Instant actual = READER.readValue(timestamp.toString()); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } /* @@ -257,8 +266,8 @@ public void testDeserializationWithTypeInfo01() throws Exception { .build(); Temporal actual = m.readValue("[\"" + Instant.class.getName() + "\",123456789.183917322]", Temporal.class); - assertTrue("The actual should be an Instant.", actual instanceof Instant); - assertEquals("The value is not correct.", expected, actual); + assertInstanceOf(Instant.class, actual, "The actual should be an Instant."); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -270,8 +279,8 @@ public void testDeserializationWithTypeInfo02() throws Exception { .build(); Temporal actual = m.readValue("[\"" + Instant.class.getName() + "\",123456789]", Temporal.class); - assertTrue("The actual should be an Instant.", actual instanceof Instant); - assertEquals("The value is not correct.", expected, actual); + assertInstanceOf(Instant.class, actual, "The actual should be an Instant."); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -283,8 +292,8 @@ public void testDeserializationWithTypeInfo03() throws Exception { .build(); Temporal actual = m.readValue("[\"" + Instant.class.getName() + "\", 123456789422]", Temporal.class); - assertTrue("The actual should be an Instant.", actual instanceof Instant); - assertEquals("The value is not correct.", expected, actual); + assertInstanceOf(Instant.class, actual, "The actual should be an Instant."); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -298,8 +307,8 @@ public void testDeserializationWithTypeInfo04() throws Exception { Temporal actual = m.readValue("[\"" + Instant.class.getName() + "\"," + timestamp.toString() + "]", Temporal.class); - assertTrue("The actual should be an Instant.", actual instanceof Instant); - assertEquals("The value is not correct.", expected, actual); + assertInstanceOf(Instant.class, actual, "The actual should be an Instant."); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -307,7 +316,7 @@ public void testDeserializationFromStringWithNonZeroOffset01() throws Exception Instant expected = Instant.now(); Timestamp timestamp = TimestampUtils.toTimestamp(expected, ZoneOffset.ofHours(8)); Instant result = READER.readValue(timestamp.toString()); - assertEquals("The value is not correct.", expected, result); + assertEquals(expected, result, "The value is not correct."); } @Test @@ -315,6 +324,6 @@ public void testDeserializationFromStringWithNonZeroOffset02() throws Exception Instant expected = Instant.now(); Timestamp timestamp = TimestampUtils.toTimestamp(expected, ZoneOffset.ofHours(-8)); Instant result = READER.readValue(timestamp.toString()); - assertEquals("The value is not correct.", expected, result); + assertEquals(expected, result, "The value is not correct."); } } diff --git a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/jsr310/IonTimestampInstantSerializerTest.java b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/jsr310/IonTimestampInstantSerializerTest.java index 15b0591e7..ebb590933 100644 --- a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/jsr310/IonTimestampInstantSerializerTest.java +++ b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/jsr310/IonTimestampInstantSerializerTest.java @@ -1,21 +1,18 @@ package com.fasterxml.jackson.dataformat.ion.jsr310; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import java.math.BigDecimal; import java.time.Instant; import java.time.ZoneOffset; -import org.junit.Test; +import com.amazon.ion.*; +import org.junit.jupiter.api.Test; -import com.amazon.ion.IonDecimal; -import com.amazon.ion.IonInt; -import com.amazon.ion.IonTimestamp; -import com.amazon.ion.Timestamp; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.dataformat.ion.IonObjectMapper; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + public class IonTimestampInstantSerializerTest { private IonObjectMapper.Builder newMapperBuilder() { @@ -32,8 +29,8 @@ public void testSerializationAsTimestamp01Nanoseconds() throws Exception { Instant date = Instant.ofEpochSecond(0L); String value = mapper.writeValueAsString(date); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.", "0.", value); + assertNotNull(value, "The value should not be null."); + assertEquals("0.", value, "The value is not correct."); } @Test @@ -45,7 +42,7 @@ public void testSerializationAsTimestamp01Milliseconds() throws Exception { Instant date = Instant.ofEpochSecond(0L); String value = mapper.writeValueAsString(date); - assertEquals("The value is not correct.", "0", value); + assertEquals("0", value, "The value is not correct."); } @Test @@ -57,7 +54,7 @@ public void testSerializationAsTimestamp02Nanoseconds() throws Exception { Instant date = Instant.ofEpochSecond(123456789L, 183917322); String value = mapper.writeValueAsString(date); - assertEquals("The value is not correct.", "123456789.183917322", value); + assertEquals("123456789.183917322", value, "The value is not correct."); } @Test @@ -69,7 +66,7 @@ public void testSerializationAsTimestamp02Milliseconds() throws Exception { Instant date = Instant.ofEpochSecond(123456789L, 183917322); String value = mapper.writeValueAsString(date); - assertEquals("The value is not correct.", "123456789183", value); + assertEquals("123456789183", value, "The value is not correct."); } @Test @@ -82,7 +79,7 @@ public void testSerializationAsTimestamp03Nanoseconds() throws Exception { Instant date = Instant.now(); String value = mapper.writeValueAsString(date); //TODO - assertEquals("The value is not correct.", TimestampUtils.getFractionalSeconds(date).toString(), value); + assertEquals(TimestampUtils.getFractionalSeconds(date).toString(), value, "The value is not correct."); } @Test @@ -94,7 +91,7 @@ public void testSerializationAsTimestamp03Milliseconds() throws Exception { Instant date = Instant.now(); String value = mapper.writeValueAsString(date); - assertEquals("The value is not correct.", Long.toString(date.toEpochMilli()), value); + assertEquals(Long.toString(date.toEpochMilli()), value, "The value is not correct."); } @Test @@ -105,7 +102,7 @@ public void testSerializationAsString01() throws Exception { Instant date = Instant.ofEpochSecond(0L); Timestamp value = ((IonTimestamp)mapper.writeValueAsIonValue(date)).timestampValue(); - assertEquals("The value is not correct.", TimestampUtils.toTimestamp(date, ZoneOffset.UTC), value); + assertEquals(TimestampUtils.toTimestamp(date, ZoneOffset.UTC), value, "The value is not correct."); } @Test @@ -116,7 +113,7 @@ public void testSerializationAsString02() throws Exception { Instant date = Instant.ofEpochSecond(123456789L, 183917322); Timestamp value = ((IonTimestamp)mapper.writeValueAsIonValue(date)).timestampValue(); - assertEquals("The value is not correct.", TimestampUtils.toTimestamp(date, ZoneOffset.UTC), value); + assertEquals(TimestampUtils.toTimestamp(date, ZoneOffset.UTC), value, "The value is not correct."); } @Test @@ -127,7 +124,7 @@ public void testSerializationAsString03() throws Exception { Instant date = Instant.now(); Timestamp value = ((IonTimestamp)mapper.writeValueAsIonValue(date)).timestampValue(); - assertEquals("The value is not correct.", TimestampUtils.toTimestamp(date, ZoneOffset.UTC), value); + assertEquals(TimestampUtils.toTimestamp(date, ZoneOffset.UTC), value, "The value is not correct."); } @Test @@ -140,9 +137,9 @@ public void testSerializationWithTypeInfo01() throws Exception { Instant date = Instant.ofEpochSecond(123456789L, 183917322); IonDecimal value = (IonDecimal) mapper.writeValueAsIonValue(date); - assertEquals("The value is not correct.", new BigDecimal("123456789.183917322"), value.bigDecimalValue()); - assertEquals("The does does not contain the expected number of annotations.", 1, value.getTypeAnnotations().length); - assertEquals("The does does not contain the expected annotation.", Instant.class.getName(), value.getTypeAnnotations()[0]); + assertEquals(new BigDecimal("123456789.183917322"), value.bigDecimalValue(), "The value is not correct."); + assertEquals(1, value.getTypeAnnotations().length, "The does does not contain the expected number of annotations."); + assertEquals(Instant.class.getName(), value.getTypeAnnotations()[0], "The does does not contain the expected annotation."); } @Test @@ -155,9 +152,9 @@ public void testSerializationWithTypeInfo02() throws Exception { Instant date = Instant.ofEpochSecond(123456789L, 183917322); IonInt value = (IonInt) mapper.writeValueAsIonValue(date); - assertEquals("The value is not correct.", 123456789183L, value.longValue()); - assertEquals("The does does not contain the expected number of annotations.", 1, value.getTypeAnnotations().length); - assertEquals("The does does not contain the expected annotation.", Instant.class.getName(), value.getTypeAnnotations()[0]); + assertEquals(123456789183L, value.longValue(), "The value is not correct."); + assertEquals(1, value.getTypeAnnotations().length, "The does does not contain the expected number of annotations."); + assertEquals(Instant.class.getName(), value.getTypeAnnotations()[0], "The does does not contain the expected annotation."); } @Test @@ -169,8 +166,8 @@ public void testSerializationWithTypeInfo03() throws Exception { Instant date = Instant.now(); IonTimestamp value = (IonTimestamp) mapper.writeValueAsIonValue(date); - assertEquals("The value is not correct.", TimestampUtils.toTimestamp(date, ZoneOffset.UTC), value.timestampValue()); - assertEquals("The does does not contain the expected number of annotations.", 1, value.getTypeAnnotations().length); - assertEquals("The does does not contain the expected annotation.", Instant.class.getName(), value.getTypeAnnotations()[0]); + assertEquals(TimestampUtils.toTimestamp(date, ZoneOffset.UTC), value.timestampValue(), "The value is not correct."); + assertEquals(1, value.getTypeAnnotations().length, "The does does not contain the expected number of annotations."); + assertEquals(Instant.class.getName(), value.getTypeAnnotations()[0], "The does does not contain the expected annotation."); } } diff --git a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/jsr310/IonTimestampOffsetDateTimeDeserializerTest.java b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/jsr310/IonTimestampOffsetDateTimeDeserializerTest.java index cee723921..db9adc2a9 100644 --- a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/jsr310/IonTimestampOffsetDateTimeDeserializerTest.java +++ b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/jsr310/IonTimestampOffsetDateTimeDeserializerTest.java @@ -1,23 +1,21 @@ package com.fasterxml.jackson.dataformat.ion.jsr310; -import static java.time.ZoneOffset.UTC; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.time.Instant; -import java.time.OffsetDateTime; -import java.time.ZoneOffset; +import java.time.*; import java.time.temporal.ChronoUnit; import java.time.temporal.Temporal; import java.util.TimeZone; -import org.junit.Test; - import com.amazon.ion.Timestamp; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectReader; import com.fasterxml.jackson.dataformat.ion.IonObjectMapper; +import static java.time.ZoneOffset.UTC; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; + public class IonTimestampOffsetDateTimeDeserializerTest { private static final ZoneOffset Z1 = ZoneOffset.ofHours(-8); @@ -47,28 +45,28 @@ private static IonObjectMapper.Builder newMapperBuilder() { public void testDeserializationAsFloat01() throws Exception { OffsetDateTime expected = OffsetDateTime.ofInstant(Instant.ofEpochSecond(0L), UTC); OffsetDateTime actual = READER_UTC_DEFAULT.readValue("0.000000"); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test public void testDeserializationAsFloat01NonUTCDefault() throws Exception { OffsetDateTime expected = OffsetDateTime.ofInstant(Instant.ofEpochSecond(0L), Z1); OffsetDateTime actual = READER_Z1_DEFAULT.readValue("0.000000"); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test public void testDeserializationAsFloat02() throws Exception { OffsetDateTime expected = OffsetDateTime.ofInstant(Instant.ofEpochSecond(123456789L, 183917322), UTC); OffsetDateTime actual = READER_UTC_DEFAULT.readValue("123456789.183917322"); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test public void testDeserializationAsFloat02NonUTCDefault() throws Exception { OffsetDateTime expected = OffsetDateTime.ofInstant(Instant.ofEpochSecond(123456789L, 183917322), Z1); OffsetDateTime actual = READER_Z1_DEFAULT.readValue("123456789.183917322"); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -76,7 +74,7 @@ public void testDeserializationAsFloat03() throws Exception { Instant now = Instant.now(); OffsetDateTime expected = OffsetDateTime.ofInstant(now, UTC); OffsetDateTime actual = READER_UTC_DEFAULT.readValue(TimestampUtils.getFractionalSeconds(now).toString()); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -84,7 +82,7 @@ public void testDeserializationAsFloat03NonUTCDefault() throws Exception { Instant now = Instant.now(); OffsetDateTime expected = OffsetDateTime.ofInstant(now, Z1); OffsetDateTime actual = READER_Z1_DEFAULT.readValue(TimestampUtils.getFractionalSeconds(now).toString()); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } /* @@ -100,7 +98,7 @@ public void testDeserializationAsInt01Nanoseconds() throws Exception { .with(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue("0"); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -110,7 +108,7 @@ public void testDeserializationAsInt01NanosecondsNonUTCDefault() throws Exceptio .with(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue("0"); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -120,7 +118,7 @@ public void testDeserializationAsInt02Nanoseconds() throws Exception { .with(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue("123456789"); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -130,7 +128,7 @@ public void testDeserializationAsInt02NanosecondsNonUTCDefault() throws Exceptio .with(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue("123456789"); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -141,7 +139,7 @@ public void testDeserializationAsInt03Nanoseconds() throws Exception { .with(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue(Long.toString(now.getEpochSecond())); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -152,7 +150,7 @@ public void testDeserializationAsInt03NanosecondsNonUTCDefault() throws Exceptio .with(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue(Long.toString(now.getEpochSecond())); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -162,7 +160,7 @@ public void testDeserializationAsInt01Milliseconds() throws Exception { .without(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue("0"); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -172,7 +170,7 @@ public void testDeserializationAsInt01MillisecondsNonUTCDefault() throws Excepti .without(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue("0"); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -182,7 +180,7 @@ public void testDeserializationAsInt02Milliseconds() throws Exception { .without(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue("123456789422"); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -192,7 +190,7 @@ public void testDeserializationAsInt02MillisecondsNonUTCDefault() throws Excepti .without(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue("123456789422"); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -203,7 +201,7 @@ public void testDeserializationAsInt03Milliseconds() throws Exception { .without(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue(Long.toString(now.toEpochMilli())); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -214,7 +212,7 @@ public void testDeserializationAsInt03MillisecondsNonUTCDefault() throws Excepti .without(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue(Long.toString(now.toEpochMilli())); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } /* @@ -228,7 +226,7 @@ public void testDeserializationAsIonTimestamp01() throws Exception { OffsetDateTime expected = OffsetDateTime.ofInstant(Instant.ofEpochSecond(0L), UTC); Timestamp timestamp = TimestampUtils.toTimestamp(expected.toInstant(), expected.getOffset()); OffsetDateTime actual = READER_UTC_DEFAULT.readValue(timestamp.toString()); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -236,7 +234,7 @@ public void testDeserializationAsIonTimestamp01NonUTCTimeOffset() throws Excepti OffsetDateTime expected = OffsetDateTime.ofInstant(Instant.ofEpochSecond(0L), Z1); Timestamp timestamp = TimestampUtils.toTimestamp(expected.toInstant(), expected.getOffset()); OffsetDateTime actual = READER_UTC_DEFAULT.readValue(timestamp.toString()); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -244,7 +242,7 @@ public void testDeserializationAsIonTimestamp02() throws Exception { OffsetDateTime expected = OffsetDateTime.ofInstant(Instant.ofEpochSecond(123456789L, 183917322), UTC); Timestamp timestamp = TimestampUtils.toTimestamp(expected.toInstant(), expected.getOffset()); OffsetDateTime actual = READER_UTC_DEFAULT.readValue(timestamp.toString()); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -252,7 +250,7 @@ public void testDeserializationAsIonTimestamp02NonUTCTimeOffset() throws Excepti OffsetDateTime expected = OffsetDateTime.ofInstant(Instant.ofEpochSecond(123456789L, 183917322), Z1); Timestamp timestamp = TimestampUtils.toTimestamp(expected.toInstant(), expected.getOffset()); OffsetDateTime actual = READER_UTC_DEFAULT.readValue(timestamp.toString()); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -260,7 +258,7 @@ public void testDeserializationAsIonTimestamp03() throws Exception { OffsetDateTime expected = OffsetDateTime.now(UTC); Timestamp timestamp = TimestampUtils.toTimestamp(expected.toInstant(), expected.getOffset()); OffsetDateTime actual = READER_UTC_DEFAULT.readValue(timestamp.toString()); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -268,7 +266,7 @@ public void testDeserializationAsIonTimestamp03NonUTCTimeOffset() throws Excepti OffsetDateTime expected = OffsetDateTime.now(Z1); Timestamp timestamp = TimestampUtils.toTimestamp(expected.toInstant(), expected.getOffset()); OffsetDateTime actual = READER_UTC_DEFAULT.readValue(timestamp.toString()); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -276,7 +274,7 @@ public void testDeserializationAsIonTimestamp04UnknownOffset() throws Exception OffsetDateTime expected = OffsetDateTime.now(UTC); Timestamp timestamp = TimestampUtils.toTimestamp(expected.toInstant(), null); OffsetDateTime actual = READER_UTC_DEFAULT.readValue(timestamp.toString()); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -284,7 +282,7 @@ public void testDeserializationAsIonTimestamp04UnknownOffsetNonUTCDefault() thro OffsetDateTime expected = OffsetDateTime.now(Z1); Timestamp timestamp = TimestampUtils.toTimestamp(expected.toInstant(), null); OffsetDateTime actual = READER_Z1_DEFAULT.readValue(timestamp.toString()); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } /* @@ -303,8 +301,8 @@ public void testDeserializationWithTypeInfo01() throws Exception { .build(); Temporal actual = m.readValue("[\"" + OffsetDateTime.class.getName() + "\",123456789.183917322]", Temporal.class); - assertTrue("The value should be an OffsetDateTime.", actual instanceof OffsetDateTime); - assertEquals("The value is not correct.", expected, actual); + assertInstanceOf(OffsetDateTime.class, actual, "The value should be an OffsetDateTime."); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -318,8 +316,8 @@ public void testDeserializationWithTypeInfo01NonUTCDefault() throws Exception { .build(); Temporal actual = m.readValue("[\"" + OffsetDateTime.class.getName() + "\",123456789.183917322]", Temporal.class); - assertTrue("The value should be an OffsetDateTime.", actual instanceof OffsetDateTime); - assertEquals("The value is not correct.", expected, actual); + assertInstanceOf(OffsetDateTime.class, actual, "The value should be an OffsetDateTime."); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -332,8 +330,8 @@ public void testDeserializationWithTypeInfo02() throws Exception { .build(); Temporal actual = m.readValue("[\"" + OffsetDateTime.class.getName() + "\",123456789]", Temporal.class); - assertTrue("The value should be an OffsetDateTime.", actual instanceof OffsetDateTime); - assertEquals("The value is not correct.", expected, actual); + assertInstanceOf(OffsetDateTime.class, actual, "The value should be an OffsetDateTime."); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -347,8 +345,8 @@ public void testDeserializationWithTypeInfo02NonUTCDefault() throws Exception { .build(); Temporal actual = m.readValue("[\"" + OffsetDateTime.class.getName() + "\",123456789]", Temporal.class); - assertTrue("The value should be an OffsetDateTime.", actual instanceof OffsetDateTime); - assertEquals("The value is not correct.", expected, actual); + assertInstanceOf(OffsetDateTime.class, actual, "The value should be an OffsetDateTime."); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -361,8 +359,8 @@ public void testDeserializationWithTypeInfo03() throws Exception { .build(); Temporal actual = m.readValue("[\"" + OffsetDateTime.class.getName() + "\", 123456789422]", Temporal.class); - assertTrue("The value should be an OffsetDateTime.", actual instanceof OffsetDateTime); - assertEquals("The value is not correct.", expected, actual); + assertInstanceOf(OffsetDateTime.class, actual, "The value should be an OffsetDateTime."); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -376,8 +374,8 @@ public void testDeserializationWithTypeInfo03NonUTCDefault() throws Exception { .build(); Temporal actual = m.readValue("[\"" + OffsetDateTime.class.getName() + "\", 123456789422]", Temporal.class); - assertTrue("The value should be an OffsetDateTime.", actual instanceof OffsetDateTime); - assertEquals("The value is not correct.", expected, actual); + assertInstanceOf(OffsetDateTime.class, actual, "The value should be an OffsetDateTime."); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -393,8 +391,8 @@ public void testDeserializationWithTypeInfo04() throws Exception { Temporal actual = m.readValue("[\"" + OffsetDateTime.class.getName() + "\"," + timestamp.toString() + "]", Temporal.class); - assertTrue("The value should be an OffsetDateTime.", actual instanceof OffsetDateTime); - assertEquals("The value is not correct.", expected, actual); + assertInstanceOf(OffsetDateTime.class, actual, "The value should be an OffsetDateTime."); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -410,7 +408,7 @@ public void testDeserializationWithTypeInfo04NonUTCOffset() throws Exception { Temporal actual = m.readValue("[\"" + OffsetDateTime.class.getName() + "\"," + timestamp.toString() + "]", Temporal.class); - assertTrue("The value should be an OffsetDateTime.", actual instanceof OffsetDateTime); - assertEquals("The value is not correct.", expected, actual); + assertInstanceOf(OffsetDateTime.class, actual, "The value should be an OffsetDateTime."); + assertEquals(expected, actual, "The value is not correct."); } } diff --git a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/jsr310/IonTimestampOffsetDateTimeSerializerTest.java b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/jsr310/IonTimestampOffsetDateTimeSerializerTest.java index 78c538401..77f0adb48 100644 --- a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/jsr310/IonTimestampOffsetDateTimeSerializerTest.java +++ b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/jsr310/IonTimestampOffsetDateTimeSerializerTest.java @@ -1,18 +1,16 @@ package com.fasterxml.jackson.dataformat.ion.jsr310; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.time.Instant; -import java.time.OffsetDateTime; -import java.time.ZoneOffset; +import java.time.*; import java.time.temporal.Temporal; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.dataformat.ion.IonObjectMapper; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + public class IonTimestampOffsetDateTimeSerializerTest { private static final ZoneOffset Z1 = ZoneOffset.ofHours(-8); @@ -33,7 +31,7 @@ public void testSerializationAsTimestamp01Nanoseconds() throws Exception { OffsetDateTime date = OffsetDateTime.ofInstant(Instant.ofEpochSecond(0L), Z1); String value = mapper.writeValueAsString(date); - assertEquals("The value is not correct.", "0.", value); + assertEquals("0.", value, "The value is not correct."); } @Test @@ -45,7 +43,7 @@ public void testSerializationAsTimestamp01Milliseconds() throws Exception { OffsetDateTime date = OffsetDateTime.ofInstant(Instant.ofEpochSecond(0L), Z1); String value = mapper.writeValueAsString(date); - assertEquals("The value is not correct.", "0", value); + assertEquals("0", value, "The value is not correct."); } @Test @@ -57,7 +55,7 @@ public void testSerializationAsTimestamp02Nanoseconds() throws Exception { OffsetDateTime date = OffsetDateTime.ofInstant(Instant.ofEpochSecond(123456789L, 183917322), Z2); String value = mapper.writeValueAsString(date); - assertEquals("The value is not correct.", "123456789.183917322", value); + assertEquals("123456789.183917322", value, "The value is not correct."); } @Test @@ -69,7 +67,7 @@ public void testSerializationAsTimestamp02Milliseconds() throws Exception { OffsetDateTime date = OffsetDateTime.ofInstant(Instant.ofEpochSecond(123456789L, 183917322), Z2); String value = mapper.writeValueAsString(date); - assertEquals("The value is not correct.", "123456789183", value); + assertEquals("123456789183", value, "The value is not correct."); } @Test @@ -81,7 +79,7 @@ public void testSerializationAsTimestamp03Nanoseconds() throws Exception { OffsetDateTime date = OffsetDateTime.now(Z3); String value = mapper.writeValueAsString(date); - assertEquals("The value is not correct.", TimestampUtils.getFractionalSeconds(date.toInstant()).toString(), value); + assertEquals(TimestampUtils.getFractionalSeconds(date.toInstant()).toString(), value, "The value is not correct."); } @Test @@ -93,7 +91,7 @@ public void testSerializationAsTimestamp03Milliseconds() throws Exception { OffsetDateTime date = OffsetDateTime.now(Z3); String value = mapper.writeValueAsString(date); - assertEquals("The value is not correct.", Long.toString(date.toInstant().toEpochMilli()), value); + assertEquals(Long.toString(date.toInstant().toEpochMilli()), value, "The value is not correct."); } @Test @@ -104,8 +102,8 @@ public void testSerializationAsString01() throws Exception { .build(); String value = mapper.writeValueAsString(date); - assertEquals("The value is not correct.", - TimestampUtils.toTimestamp(date.toInstant(), date.getOffset()).toString(), value); + assertEquals(TimestampUtils.toTimestamp(date.toInstant(), date.getOffset()).toString(), value, + "The value is not correct."); } @Test @@ -116,8 +114,8 @@ public void testSerializationAsString02() throws Exception { .build(); String value = mapper.writeValueAsString(date); - assertEquals("The value is not correct.", - TimestampUtils.toTimestamp(date.toInstant(), date.getOffset()).toString(), value); + assertEquals(TimestampUtils.toTimestamp(date.toInstant(), date.getOffset()).toString(), value, + "The value is not correct."); } @Test @@ -128,8 +126,8 @@ public void testSerializationAsString03() throws Exception { .build(); String value = mapper.writeValueAsString(date); - assertEquals("The value is not correct.", - TimestampUtils.toTimestamp(date.toInstant(), date.getOffset()).toString(), value); + assertEquals(TimestampUtils.toTimestamp(date.toInstant(), date.getOffset()).toString(), value, + "The value is not correct."); } @Test @@ -142,8 +140,8 @@ public void testSerializationWithTypeInfo01() throws Exception { .build(); String value = mapper.writeValueAsString(date); - assertEquals("The value is not correct.", - "'" + OffsetDateTime.class.getName() + "'::123456789.183917322", value); + assertEquals("'" + OffsetDateTime.class.getName() + "'::123456789.183917322", value, + "The value is not correct."); } @Test @@ -156,8 +154,8 @@ public void testSerializationWithTypeInfo02() throws Exception { .build(); String value = mapper.writeValueAsString(date); - assertEquals("The value is not correct.", - "'" + OffsetDateTime.class.getName() + "'::123456789183", value); + assertEquals("'" + OffsetDateTime.class.getName() + "'::123456789183", value, + "The value is not correct."); } @Test @@ -169,8 +167,9 @@ public void testSerializationWithTypeInfo03() throws Exception { .build(); String value = mapper.writeValueAsString(date); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.","'" + OffsetDateTime.class.getName() + "'::" - + TimestampUtils.toTimestamp(date.toInstant(), date.getOffset()).toString(), value); + assertNotNull(value, "The value should not be null."); + assertEquals("'" + OffsetDateTime.class.getName() + "'::" + + TimestampUtils.toTimestamp(date.toInstant(), date.getOffset()).toString(), value, + "The value is not correct."); } } diff --git a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/jsr310/IonTimestampZonedDateTimeDeserializerTest.java b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/jsr310/IonTimestampZonedDateTimeDeserializerTest.java index b62d0c46b..1cd4a23c8 100644 --- a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/jsr310/IonTimestampZonedDateTimeDeserializerTest.java +++ b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/jsr310/IonTimestampZonedDateTimeDeserializerTest.java @@ -1,23 +1,21 @@ package com.fasterxml.jackson.dataformat.ion.jsr310; -import static java.time.ZoneOffset.UTC; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.time.Instant; -import java.time.ZonedDateTime; -import java.time.ZoneOffset; +import java.time.*; import java.time.temporal.ChronoUnit; import java.time.temporal.Temporal; import java.util.TimeZone; -import org.junit.Test; - import com.amazon.ion.Timestamp; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectReader; import com.fasterxml.jackson.dataformat.ion.IonObjectMapper; +import static java.time.ZoneOffset.UTC; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; + public class IonTimestampZonedDateTimeDeserializerTest { private static final ZoneOffset Z1 = ZoneOffset.ofHours(-8); @@ -47,28 +45,28 @@ private static IonObjectMapper.Builder newMapperBuilder() { public void testDeserializationAsFloat01() throws Exception { ZonedDateTime expected = ZonedDateTime.ofInstant(Instant.ofEpochSecond(0L), UTC); ZonedDateTime actual = READER_UTC_DEFAULT.readValue("0.000000"); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test public void testDeserializationAsFloat01NonUTCDefault() throws Exception { ZonedDateTime expected = ZonedDateTime.ofInstant(Instant.ofEpochSecond(0L), Z1); ZonedDateTime actual = READER_Z1_DEFAULT.readValue("0.000000"); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test public void testDeserializationAsFloat02() throws Exception { ZonedDateTime expected = ZonedDateTime.ofInstant(Instant.ofEpochSecond(123456789L, 183917322), UTC); ZonedDateTime actual = READER_UTC_DEFAULT.readValue("123456789.183917322"); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test public void testDeserializationAsFloat02NonUTCDefault() throws Exception { ZonedDateTime expected = ZonedDateTime.ofInstant(Instant.ofEpochSecond(123456789L, 183917322), Z1); ZonedDateTime actual = READER_Z1_DEFAULT.readValue("123456789.183917322"); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -76,7 +74,7 @@ public void testDeserializationAsFloat03() throws Exception { Instant now = Instant.now(); ZonedDateTime expected = ZonedDateTime.ofInstant(now, UTC); ZonedDateTime actual = READER_UTC_DEFAULT.readValue(TimestampUtils.getFractionalSeconds(now).toString()); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -84,7 +82,7 @@ public void testDeserializationAsFloat03NonUTCDefault() throws Exception { Instant now = Instant.now(); ZonedDateTime expected = ZonedDateTime.ofInstant(now, Z1); ZonedDateTime actual = READER_Z1_DEFAULT.readValue(TimestampUtils.getFractionalSeconds(now).toString()); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } /* @@ -100,7 +98,7 @@ public void testDeserializationAsInt01Nanoseconds() throws Exception { .with(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue("0"); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -110,7 +108,7 @@ public void testDeserializationAsInt01NanosecondsNonUTCDefault() throws Exceptio .with(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue("0"); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -120,7 +118,7 @@ public void testDeserializationAsInt02Nanoseconds() throws Exception { .with(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue("123456789"); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -130,7 +128,7 @@ public void testDeserializationAsInt02NanosecondsNonUTCDefault() throws Exceptio .with(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue("123456789"); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -142,7 +140,7 @@ public void testDeserializationAsInt03Nanoseconds() throws Exception { .with(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue(Long.toString(now.getEpochSecond())); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -154,7 +152,7 @@ public void testDeserializationAsInt03NanosecondsNonUTCDefault() throws Exceptio .with(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue(Long.toString(now.getEpochSecond())); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -164,7 +162,7 @@ public void testDeserializationAsInt01Milliseconds() throws Exception { .without(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue("0"); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -174,7 +172,7 @@ public void testDeserializationAsInt01MillisecondsNonUTCDefault() throws Excepti .without(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue("0"); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -184,7 +182,7 @@ public void testDeserializationAsInt02Milliseconds() throws Exception { .without(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue("123456789422"); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -194,7 +192,7 @@ public void testDeserializationAsInt02MillisecondsNonUTCDefault() throws Excepti .without(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue("123456789422"); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -206,7 +204,7 @@ public void testDeserializationAsInt03Milliseconds() throws Exception { .without(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue(Long.toString(now.toEpochMilli())); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -218,7 +216,7 @@ public void testDeserializationAsInt03MillisecondsNonUTCDefault() throws Excepti .without(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS) .readValue(Long.toString(now.toEpochMilli())); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } /* @@ -232,7 +230,7 @@ public void testDeserializationAsIonTimestamp01() throws Exception { ZonedDateTime expected = ZonedDateTime.ofInstant(Instant.ofEpochSecond(0L), UTC); Timestamp timestamp = TimestampUtils.toTimestamp(expected.toInstant(), expected.getOffset()); ZonedDateTime actual = READER_UTC_DEFAULT.readValue(timestamp.toString()); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -240,7 +238,7 @@ public void testDeserializationAsIonTimestamp01NonUTCTimeOffset() throws Excepti ZonedDateTime expected = ZonedDateTime.ofInstant(Instant.ofEpochSecond(0L), Z1); Timestamp timestamp = TimestampUtils.toTimestamp(expected.toInstant(), expected.getOffset()); ZonedDateTime actual = READER_UTC_DEFAULT.readValue(timestamp.toString()); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -248,7 +246,7 @@ public void testDeserializationAsIonTimestamp02() throws Exception { ZonedDateTime expected = ZonedDateTime.ofInstant(Instant.ofEpochSecond(123456789L, 183917322), UTC); Timestamp timestamp = TimestampUtils.toTimestamp(expected.toInstant(), expected.getOffset()); ZonedDateTime actual = READER_UTC_DEFAULT.readValue(timestamp.toString()); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -256,7 +254,7 @@ public void testDeserializationAsIonTimestamp02NonUTCTimeOffset() throws Excepti ZonedDateTime expected = ZonedDateTime.ofInstant(Instant.ofEpochSecond(123456789L, 183917322), Z1); Timestamp timestamp = TimestampUtils.toTimestamp(expected.toInstant(), expected.getOffset()); ZonedDateTime actual = READER_UTC_DEFAULT.readValue(timestamp.toString()); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -264,7 +262,7 @@ public void testDeserializationAsIonTimestamp03() throws Exception { ZonedDateTime expected = ZonedDateTime.now(UTC); Timestamp timestamp = TimestampUtils.toTimestamp(expected.toInstant(), expected.getOffset()); ZonedDateTime actual = READER_UTC_DEFAULT.readValue(timestamp.toString()); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -272,7 +270,7 @@ public void testDeserializationAsIonTimestamp03NonUTCTimeOffset() throws Excepti ZonedDateTime expected = ZonedDateTime.now(Z1); Timestamp timestamp = TimestampUtils.toTimestamp(expected.toInstant(), expected.getOffset()); ZonedDateTime actual = READER_UTC_DEFAULT.readValue(timestamp.toString()); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -280,7 +278,7 @@ public void testDeserializationAsIonTimestamp04UnknownOffset() throws Exception ZonedDateTime expected = ZonedDateTime.now(UTC); Timestamp timestamp = TimestampUtils.toTimestamp(expected.toInstant(), null); ZonedDateTime actual = READER_UTC_DEFAULT.readValue(timestamp.toString()); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -288,7 +286,7 @@ public void testDeserializationAsIonTimestamp04UnknownOffsetNonUTCDefault() thro ZonedDateTime expected = ZonedDateTime.now(Z1); Timestamp timestamp = TimestampUtils.toTimestamp(expected.toInstant(), null); ZonedDateTime actual = READER_Z1_DEFAULT.readValue(timestamp.toString()); - assertEquals("The value is not correct.", expected, actual); + assertEquals(expected, actual, "The value is not correct."); } /* @@ -307,8 +305,8 @@ public void testDeserializationWithTypeInfo01() throws Exception { .build(); Temporal actual = m.readValue("[\"" + ZonedDateTime.class.getName() + "\",123456789.183917322]", Temporal.class); - assertTrue("The value should be an ZonedDateTime.", actual instanceof ZonedDateTime); - assertEquals("The value is not correct.", expected, actual); + assertInstanceOf(ZonedDateTime.class, actual, "The value should be an ZonedDateTime."); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -322,8 +320,8 @@ public void testDeserializationWithTypeInfo01NonUTCDefault() throws Exception { .build(); Temporal actual = m.readValue("[\"" + ZonedDateTime.class.getName() + "\",123456789.183917322]", Temporal.class); - assertTrue("The value should be an ZonedDateTime.", actual instanceof ZonedDateTime); - assertEquals("The value is not correct.", expected, actual); + assertInstanceOf(ZonedDateTime.class, actual, "The value should be an ZonedDateTime."); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -336,8 +334,8 @@ public void testDeserializationWithTypeInfo02() throws Exception { .build(); Temporal actual = m.readValue("[\"" + ZonedDateTime.class.getName() + "\",123456789]", Temporal.class); - assertTrue("The value should be an ZonedDateTime.", actual instanceof ZonedDateTime); - assertEquals("The value is not correct.", expected, actual); + assertInstanceOf(ZonedDateTime.class, actual, "The value should be an ZonedDateTime."); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -351,8 +349,8 @@ public void testDeserializationWithTypeInfo02NonUTCDefault() throws Exception { .build(); Temporal actual = m.readValue("[\"" + ZonedDateTime.class.getName() + "\",123456789]", Temporal.class); - assertTrue("The value should be an ZonedDateTime.", actual instanceof ZonedDateTime); - assertEquals("The value is not correct.", expected, actual); + assertInstanceOf(ZonedDateTime.class, actual, "The value should be an ZonedDateTime."); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -365,8 +363,8 @@ public void testDeserializationWithTypeInfo03() throws Exception { .build(); Temporal actual = m.readValue("[\"" + ZonedDateTime.class.getName() + "\", 123456789422]", Temporal.class); - assertTrue("The value should be an ZonedDateTime.", actual instanceof ZonedDateTime); - assertEquals("The value is not correct.", expected, actual); + assertInstanceOf(ZonedDateTime.class, actual, "The value should be an ZonedDateTime."); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -380,8 +378,8 @@ public void testDeserializationWithTypeInfo03NonUTCDefault() throws Exception { .build(); Temporal actual = m.readValue("[\"" + ZonedDateTime.class.getName() + "\", 123456789422]", Temporal.class); - assertTrue("The value should be an ZonedDateTime.", actual instanceof ZonedDateTime); - assertEquals("The value is not correct.", expected, actual); + assertInstanceOf(ZonedDateTime.class, actual, "The value should be an ZonedDateTime."); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -397,8 +395,8 @@ public void testDeserializationWithTypeInfo04() throws Exception { Temporal actual = m.readValue("[\"" + ZonedDateTime.class.getName() + "\"," + timestamp.toString() + "]", Temporal.class); - assertTrue("The value should be an ZonedDateTime.", actual instanceof ZonedDateTime); - assertEquals("The value is not correct.", expected, actual); + assertInstanceOf(ZonedDateTime.class, actual, "The value should be an ZonedDateTime."); + assertEquals(expected, actual, "The value is not correct."); } @Test @@ -414,7 +412,7 @@ public void testDeserializationWithTypeInfo04NonUTCOffset() throws Exception { Temporal actual = m.readValue("[\"" + ZonedDateTime.class.getName() + "\"," + timestamp.toString() + "]", Temporal.class); - assertTrue("The value should be an ZonedDateTime.", actual instanceof ZonedDateTime); - assertEquals("The value is not correct.", expected, actual); + assertInstanceOf(ZonedDateTime.class, actual, "The value should be an ZonedDateTime."); + assertEquals(expected, actual, "The value is not correct."); } } diff --git a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/jsr310/IonTimestampZonedDateTimeSerializerTest.java b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/jsr310/IonTimestampZonedDateTimeSerializerTest.java index bcd6ccd1a..e1561e338 100644 --- a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/jsr310/IonTimestampZonedDateTimeSerializerTest.java +++ b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/jsr310/IonTimestampZonedDateTimeSerializerTest.java @@ -1,18 +1,16 @@ package com.fasterxml.jackson.dataformat.ion.jsr310; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.time.Instant; -import java.time.ZoneId; -import java.time.ZonedDateTime; +import java.time.*; import java.time.temporal.Temporal; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.dataformat.ion.IonObjectMapper; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + public class IonTimestampZonedDateTimeSerializerTest { private static final ZoneId Z1 = ZoneId.of("America/Chicago"); @@ -33,7 +31,7 @@ public void testSerializationAsTimestamp01Nanoseconds() throws Exception { ZonedDateTime date = ZonedDateTime.ofInstant(Instant.ofEpochSecond(0L), Z1); String value = mapper.writeValueAsString(date); - assertEquals("The value is not correct.", "0.", value); + assertEquals("0.", value, "The value is not correct."); } @Test @@ -45,7 +43,7 @@ public void testSerializationAsTimestamp01Milliseconds() throws Exception { ZonedDateTime date = ZonedDateTime.ofInstant(Instant.ofEpochSecond(0L), Z1); String value = mapper.writeValueAsString(date); - assertEquals("The value is not correct.", "0", value); + assertEquals("0", value, "The value is not correct."); } @Test @@ -57,7 +55,7 @@ public void testSerializationAsTimestamp02Nanoseconds() throws Exception { ZonedDateTime date = ZonedDateTime.ofInstant(Instant.ofEpochSecond(123456789L, 183917322), Z2); String value = mapper.writeValueAsString(date); - assertEquals("The value is not correct.", "123456789.183917322", value); + assertEquals("123456789.183917322", value, "The value is not correct."); } @Test @@ -69,7 +67,7 @@ public void testSerializationAsTimestamp02Milliseconds() throws Exception { ZonedDateTime date = ZonedDateTime.ofInstant(Instant.ofEpochSecond(123456789L, 183917322), Z2); String value = mapper.writeValueAsString(date); - assertEquals("The value is not correct.", "123456789183", value); + assertEquals("123456789183", value, "The value is not correct."); } @Test @@ -81,7 +79,8 @@ public void testSerializationAsTimestamp03Nanoseconds() throws Exception { ZonedDateTime date = ZonedDateTime.now(Z3); String value = mapper.writeValueAsString(date); - assertEquals("The value is not correct.", TimestampUtils.getFractionalSeconds(date.toInstant()).toString(), value); + assertEquals(TimestampUtils.getFractionalSeconds(date.toInstant()).toString(), value, + "The value is not correct."); } @Test @@ -93,7 +92,8 @@ public void testSerializationAsTimestamp03Milliseconds() throws Exception { ZonedDateTime date = ZonedDateTime.now(Z3); String value = mapper.writeValueAsString(date); - assertEquals("The value is not correct.", Long.toString(date.toInstant().toEpochMilli()), value); + assertEquals(Long.toString(date.toInstant().toEpochMilli()), value, + "The value is not correct."); } @Test @@ -104,8 +104,8 @@ public void testSerializationAsString01() throws Exception { .build(); String value = mapper.writeValueAsString(date); - assertEquals("The value is not correct.", - TimestampUtils.toTimestamp(date.toInstant(), date.getOffset()).toString(), value); + assertEquals(TimestampUtils.toTimestamp(date.toInstant(), date.getOffset()).toString(), value, + "The value is not correct."); } @Test @@ -116,8 +116,8 @@ public void testSerializationAsString02() throws Exception { .build(); String value = mapper.writeValueAsString(date); - assertEquals("The value is not correct.", - TimestampUtils.toTimestamp(date.toInstant(), date.getOffset()).toString(), value); + assertEquals(TimestampUtils.toTimestamp(date.toInstant(), date.getOffset()).toString(), value, + "The value is not correct."); } @Test @@ -128,8 +128,8 @@ public void testSerializationAsString03() throws Exception { .build(); String value = mapper.writeValueAsString(date); - assertEquals("The value is not correct.", - TimestampUtils.toTimestamp(date.toInstant(), date.getOffset()).toString(), value); + assertEquals(TimestampUtils.toTimestamp(date.toInstant(), date.getOffset()).toString(), value, + "The value is not correct."); } @Test @@ -142,8 +142,8 @@ public void testSerializationWithTypeInfo01() throws Exception { .build(); String value = mapper.writeValueAsString(date); - assertEquals("The value is not correct.", - "'" + ZonedDateTime.class.getName() + "'::123456789.183917322", value); + assertEquals("'" + ZonedDateTime.class.getName() + "'::123456789.183917322", value, + "The value is not correct."); } @Test @@ -156,8 +156,8 @@ public void testSerializationWithTypeInfo02() throws Exception { .build(); String value = mapper.writeValueAsString(date); - assertEquals("The value is not correct.", - "'" + ZonedDateTime.class.getName() + "'::123456789183", value); + assertEquals("'" + ZonedDateTime.class.getName() + "'::123456789183", value, + "The value is not correct."); } @Test @@ -169,8 +169,10 @@ public void testSerializationWithTypeInfo03() throws Exception { .build(); String value = mapper.writeValueAsString(date); - assertNotNull("The value should not be null.", value); - assertEquals("The value is not correct.","'" + ZonedDateTime.class.getName() + "'::" - + TimestampUtils.toTimestamp(date.toInstant(), date.getOffset()).toString(), value); + assertNotNull(value, "The value should not be null."); + assertEquals("'" + ZonedDateTime.class.getName() + "'::" + + TimestampUtils.toTimestamp(date.toInstant(), date.getOffset()).toString(), value, + "The value is not correct."); } } + diff --git a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/misc/UncaughtExceptionsTest.java b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/misc/UncaughtExceptionsTest.java index 8136c7aa3..24ee16fdb 100644 --- a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/misc/UncaughtExceptionsTest.java +++ b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/misc/UncaughtExceptionsTest.java @@ -2,12 +2,12 @@ import java.net.URL; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.dataformat.ion.IonObjectMapper; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.fail; /** * A set of unit tests for reported issues where implementation does diff --git a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/polymorphism/IonAnnotationTypeDeserializerWithClassNameAnnotationTest.java b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/polymorphism/IonAnnotationTypeDeserializerWithClassNameAnnotationTest.java index 2b523c764..4ff2fdc69 100644 --- a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/polymorphism/IonAnnotationTypeDeserializerWithClassNameAnnotationTest.java +++ b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/polymorphism/IonAnnotationTypeDeserializerWithClassNameAnnotationTest.java @@ -1,6 +1,10 @@ package com.fasterxml.jackson.dataformat.ion.polymorphism; +import java.io.IOException; + import com.amazon.ion.IonValue; +import org.junit.jupiter.api.*; + import com.fasterxml.jackson.core.Version; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.JavaType; @@ -9,13 +13,8 @@ import com.fasterxml.jackson.databind.jsontype.impl.ClassNameIdResolver; import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.dataformat.ion.IonObjectMapper; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * This test checks that {@link IonAnnotationTypeDeserializer} with {@link IonAnnotationIntrospector} expecting class @@ -30,7 +29,7 @@ public class IonAnnotationTypeDeserializerWithClassNameAnnotationTest { IonObjectMapper mapperUnderTest; - @BeforeClass + @BeforeAll public static void setupClass() throws IOException { ClassA inner = new ClassA(); inner.value = 42; @@ -45,7 +44,7 @@ public static void setupClass() throws IOException { ionValueWithAnnotation = mapper.writeValueAsIonValue(outer); } - @Before + @BeforeEach public void setup() { // Important: since Jackson caches type resolving information, we need to create a separate mapper for testing. mapperUnderTest = constructIomWithClassNameIdResolver(); diff --git a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/polymorphism/PolymorphicTypeAnnotationsTest.java b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/polymorphism/PolymorphicTypeAnnotationsTest.java index 81763b483..a14b4b2ef 100644 --- a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/polymorphism/PolymorphicTypeAnnotationsTest.java +++ b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/polymorphism/PolymorphicTypeAnnotationsTest.java @@ -2,16 +2,17 @@ import java.io.IOException; +import com.amazon.ion.IonValue; +import com.amazon.ion.system.IonSystemBuilder; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonSubTypes.Type; import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.dataformat.ion.IonObjectMapper; import com.fasterxml.jackson.dataformat.ion.IonParser.Feature; -import org.junit.Assert; -import org.junit.Test; -import com.amazon.ion.IonValue; -import com.amazon.ion.system.IonSystemBuilder; +import static org.junit.jupiter.api.Assertions.*; public class PolymorphicTypeAnnotationsTest { private static final String SUBCLASS_TYPE_NAME = "subtype"; @@ -54,8 +55,8 @@ public void testNativeTypeIdsDisabledReadsTypeAnnotationsSuccessfully() throws I Container containerWithBaseClass = mapper.readValue(CONTAINER_WITH_TYPED_OBJECT, Container.class); - Assert.assertTrue(containerWithBaseClass.objectWithType instanceof Subclass); - Assert.assertEquals(SUBCLASS_TYPE_NAME, ((Subclass) containerWithBaseClass.objectWithType).base); + assertInstanceOf(Subclass.class, containerWithBaseClass.objectWithType); + assertEquals(SUBCLASS_TYPE_NAME, ((Subclass) containerWithBaseClass.objectWithType).base); } private static IonValue asIonValue(final String ionStr) { diff --git a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/polymorphism/SerializationAnnotationsTest.java b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/polymorphism/SerializationAnnotationsTest.java index c822144dc..64f5037ea 100644 --- a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/polymorphism/SerializationAnnotationsTest.java +++ b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/polymorphism/SerializationAnnotationsTest.java @@ -1,16 +1,19 @@ package com.fasterxml.jackson.dataformat.ion.polymorphism; +import java.io.IOException; + import com.amazon.ion.IonValue; import com.amazon.ion.system.IonSystemBuilder; import com.amazon.ion.util.Equivalence; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.dataformat.ion.IonGenerator; import com.fasterxml.jackson.dataformat.ion.IonObjectMapper; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import java.io.IOException; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; public class SerializationAnnotationsTest { @@ -32,7 +35,7 @@ public class SerializationAnnotationsTest { private Subclass subclass; - @Before + @BeforeEach public void setup() { this.subclass = new Subclass("some value", 42); } @@ -107,12 +110,12 @@ private static IonValue asIonValue(final String ionStr) { } private static void assertCorrectlyTypedAndFormed(final Subclass expectedSubclass, final BaseClass actualBaseclass) { - Assert.assertTrue(actualBaseclass instanceof Subclass); - assertEquals(expectedSubclass, (Subclass) actualBaseclass); + assertInstanceOf(Subclass.class, actualBaseclass); + _assertEquals(expectedSubclass, (Subclass) actualBaseclass); } - private static void assertEquals(Subclass expected, Subclass actual) { - Assert.assertEquals(expected.someString, actual.someString); - Assert.assertEquals(expected.anInt, actual.anInt); + private static void _assertEquals(Subclass expected, Subclass actual) { + assertEquals(expected.someString, actual.someString); + assertEquals(expected.anInt, actual.anInt); } private static void assertEqualIonValues(IonValue expected, IonValue actual) { diff --git a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/sequence/MappingIteratorTest.java b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/sequence/MappingIteratorTest.java index 62f6d1239..3a4d388bd 100644 --- a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/sequence/MappingIteratorTest.java +++ b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/sequence/MappingIteratorTest.java @@ -1,16 +1,14 @@ package com.fasterxml.jackson.dataformat.ion.sequence; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import com.fasterxml.jackson.databind.MappingIterator; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SequenceWriter; -import com.fasterxml.jackson.dataformat.ion.IonObjectMapper; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import org.junit.Test; + +import org.junit.jupiter.api.Test; + +import com.fasterxml.jackson.databind.*; +import com.fasterxml.jackson.dataformat.ion.IonObjectMapper; + +import static org.junit.jupiter.api.Assertions.*; public class MappingIteratorTest {