diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/AvroAnnotationIntrospector.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/AvroAnnotationIntrospector.java index 6415a25f3..209007c01 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/AvroAnnotationIntrospector.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/AvroAnnotationIntrospector.java @@ -1,22 +1,15 @@ package com.fasterxml.jackson.dataformat.avro; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; +import java.util.*; import org.apache.avro.reflect.*; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.core.Version; -import com.fasterxml.jackson.databind.AnnotationIntrospector; -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.PropertyName; +import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.cfg.MapperConfig; -import com.fasterxml.jackson.databind.introspect.Annotated; -import com.fasterxml.jackson.databind.introspect.AnnotatedClass; -import com.fasterxml.jackson.databind.introspect.AnnotatedConstructor; -import com.fasterxml.jackson.databind.introspect.AnnotatedMember; +import com.fasterxml.jackson.databind.introspect.*; import com.fasterxml.jackson.databind.jsontype.NamedType; import com.fasterxml.jackson.databind.jsontype.TypeResolverBuilder; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/AvroFactory.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/AvroFactory.java index 3fd43ffa7..1cdb32fd6 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/AvroFactory.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/AvroFactory.java @@ -10,7 +10,7 @@ import com.fasterxml.jackson.core.util.RecyclerPool; import com.fasterxml.jackson.dataformat.avro.apacheimpl.ApacheCodecRecycler; import com.fasterxml.jackson.dataformat.avro.apacheimpl.AvroRecyclerPools; -import com.fasterxml.jackson.dataformat.avro.deser.*; +import com.fasterxml.jackson.dataformat.avro.deser.JacksonAvroParserImpl; /** * Default {@link JsonFactory} implementation for encoding/decoding Avro diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/AvroFactoryBuilder.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/AvroFactoryBuilder.java index 4b9b7bb45..ec7fb3181 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/AvroFactoryBuilder.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/AvroFactoryBuilder.java @@ -2,7 +2,6 @@ import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.TSFBuilder; -import com.fasterxml.jackson.dataformat.avro.AvroFactoryBuilder; /** * {@link com.fasterxml.jackson.core.TSFBuilder} diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/AvroMapper.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/AvroMapper.java index d3fd08b71..ea16d85bb 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/AvroMapper.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/AvroMapper.java @@ -1,18 +1,13 @@ package com.fasterxml.jackson.dataformat.avro; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; +import java.io.*; import org.apache.avro.Schema; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.Version; - -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.Module; -import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.cfg.MapperBuilder; import com.fasterxml.jackson.databind.exc.InvalidDefinitionException; import com.fasterxml.jackson.databind.util.ClassUtil; diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/AvroModule.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/AvroModule.java index 13f1fb70e..e546ecaa7 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/AvroModule.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/AvroModule.java @@ -7,10 +7,8 @@ import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.Version; - -import com.fasterxml.jackson.databind.AnnotationIntrospector; import com.fasterxml.jackson.databind.Module; -import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.module.SimpleDeserializers; import com.fasterxml.jackson.databind.module.SimpleSerializers; import com.fasterxml.jackson.databind.ser.std.StdSerializer; diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/AvroSerializerModifier.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/AvroSerializerModifier.java index 05c26b495..c5012d486 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/AvroSerializerModifier.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/AvroSerializerModifier.java @@ -1,6 +1,7 @@ package com.fasterxml.jackson.dataformat.avro; -import java.util.*; +import java.util.Iterator; +import java.util.List; import org.apache.avro.specific.SpecificRecordBase; diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/AvroTypeIdResolver.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/AvroTypeIdResolver.java index 1f2b6f081..7ee82c7fe 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/AvroTypeIdResolver.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/AvroTypeIdResolver.java @@ -1,9 +1,7 @@ package com.fasterxml.jackson.dataformat.avro; import java.io.IOException; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; +import java.util.*; import com.fasterxml.jackson.databind.DatabindContext; import com.fasterxml.jackson.databind.JavaType; diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/AvroTypeResolverBuilder.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/AvroTypeResolverBuilder.java index 6cd13e1b1..fb52e8404 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/AvroTypeResolverBuilder.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/AvroTypeResolverBuilder.java @@ -3,15 +3,9 @@ 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.*; import com.fasterxml.jackson.databind.cfg.MapperConfig; -import com.fasterxml.jackson.databind.jsontype.NamedType; -import com.fasterxml.jackson.databind.jsontype.PolymorphicTypeValidator; -import com.fasterxml.jackson.databind.jsontype.TypeDeserializer; -import com.fasterxml.jackson.databind.jsontype.TypeIdResolver; -import com.fasterxml.jackson.databind.jsontype.TypeSerializer; +import com.fasterxml.jackson.databind.jsontype.*; import com.fasterxml.jackson.databind.jsontype.impl.StdTypeResolverBuilder; /** diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/annotation/AvroDecimal.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/annotation/AvroDecimal.java index 5205db285..8534e6051 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/annotation/AvroDecimal.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/annotation/AvroDecimal.java @@ -1,9 +1,6 @@ package com.fasterxml.jackson.dataformat.avro.annotation; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; +import java.lang.annotation.*; /** * When generate logical types is enabled, annotation instructs the diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/annotation/AvroNamespace.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/annotation/AvroNamespace.java index 708bb8355..b5dca33da 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/annotation/AvroNamespace.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/annotation/AvroNamespace.java @@ -1,9 +1,6 @@ package com.fasterxml.jackson.dataformat.avro.annotation; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; +import java.lang.annotation.*; /** * Annotation allows to override default Avro type namespace value. diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/apacheimpl/ApacheAvroParserImpl.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/apacheimpl/ApacheAvroParserImpl.java index ab59a3979..a82fd707d 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/apacheimpl/ApacheAvroParserImpl.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/apacheimpl/ApacheAvroParserImpl.java @@ -1,13 +1,12 @@ package com.fasterxml.jackson.dataformat.avro.apacheimpl; -import java.io.IOException; -import java.io.InputStream; -import java.io.Writer; +import java.io.*; import org.apache.avro.io.BinaryDecoder; import org.apache.avro.io.DecoderFactory; -import com.fasterxml.jackson.core.*; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.core.ObjectCodec; import com.fasterxml.jackson.core.io.IOContext; import com.fasterxml.jackson.dataformat.avro.deser.AvroParserImpl; import com.fasterxml.jackson.dataformat.avro.deser.AvroReadContext; diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/apacheimpl/ApacheCodecRecycler.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/apacheimpl/ApacheCodecRecycler.java index de14ba122..655c2888b 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/apacheimpl/ApacheCodecRecycler.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/apacheimpl/ApacheCodecRecycler.java @@ -3,11 +3,12 @@ import java.util.Objects; import java.util.concurrent.atomic.AtomicReference; +import org.apache.avro.io.BinaryDecoder; +import org.apache.avro.io.BinaryEncoder; + import com.fasterxml.jackson.core.util.RecyclerPool; import com.fasterxml.jackson.core.util.RecyclerPool.WithPool; -import org.apache.avro.io.*; - /** * Simple helper class that contains extracted functionality for * simple encoder/decoder recycling. diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/deser/AvroParserImpl.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/deser/AvroParserImpl.java index a0c3393dc..35c9ec553 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/deser/AvroParserImpl.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/deser/AvroParserImpl.java @@ -1,12 +1,11 @@ package com.fasterxml.jackson.dataformat.avro.deser; -import java.io.*; +import java.io.IOException; import java.math.BigDecimal; import java.math.BigInteger; import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.core.io.IOContext; - import com.fasterxml.jackson.dataformat.avro.AvroParser; import com.fasterxml.jackson.dataformat.avro.AvroSchema; diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/deser/AvroUntypedDeserializer.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/deser/AvroUntypedDeserializer.java index d95b715bc..8c7fa00d4 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/deser/AvroUntypedDeserializer.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/deser/AvroUntypedDeserializer.java @@ -5,10 +5,7 @@ import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.KeyDeserializer; +import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.deser.ResolvableDeserializer; import com.fasterxml.jackson.databind.deser.std.UntypedObjectDeserializer; import com.fasterxml.jackson.databind.jsontype.TypeDeserializer; diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/deser/JacksonAvroParserImpl.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/deser/JacksonAvroParserImpl.java index e2afa4ee2..bcc6c882e 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/deser/JacksonAvroParserImpl.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/deser/JacksonAvroParserImpl.java @@ -1,9 +1,6 @@ package com.fasterxml.jackson.dataformat.avro.deser; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.Writer; +import java.io.*; import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.core.io.IOContext; diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/jsr310/AvroJavaTimeModule.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/jsr310/AvroJavaTimeModule.java index a380f1681..1fffc085c 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/jsr310/AvroJavaTimeModule.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/jsr310/AvroJavaTimeModule.java @@ -1,22 +1,11 @@ package com.fasterxml.jackson.dataformat.avro.jsr310; +import java.time.*; + import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.dataformat.avro.PackageVersion; -import com.fasterxml.jackson.dataformat.avro.jsr310.deser.AvroInstantDeserializer; -import com.fasterxml.jackson.dataformat.avro.jsr310.deser.AvroLocalDateDeserializer; -import com.fasterxml.jackson.dataformat.avro.jsr310.deser.AvroLocalDateTimeDeserializer; -import com.fasterxml.jackson.dataformat.avro.jsr310.deser.AvroLocalTimeDeserializer; -import com.fasterxml.jackson.dataformat.avro.jsr310.ser.AvroInstantSerializer; -import com.fasterxml.jackson.dataformat.avro.jsr310.ser.AvroLocalDateSerializer; -import com.fasterxml.jackson.dataformat.avro.jsr310.ser.AvroLocalDateTimeSerializer; -import com.fasterxml.jackson.dataformat.avro.jsr310.ser.AvroLocalTimeSerializer; - -import java.time.Instant; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.LocalTime; -import java.time.OffsetDateTime; -import java.time.ZonedDateTime; +import com.fasterxml.jackson.dataformat.avro.jsr310.deser.*; +import com.fasterxml.jackson.dataformat.avro.jsr310.ser.*; /** * A module that installs a collection of serializers and deserializers for java.time classes. diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/jsr310/deser/AvroInstantDeserializer.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/jsr310/deser/AvroInstantDeserializer.java index 9a2d6e986..49e1bdc0f 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/jsr310/deser/AvroInstantDeserializer.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/jsr310/deser/AvroInstantDeserializer.java @@ -1,9 +1,6 @@ package com.fasterxml.jackson.dataformat.avro.jsr310.deser; -import java.time.Instant; -import java.time.OffsetDateTime; -import java.time.ZoneId; -import java.time.ZonedDateTime; +import java.time.*; import java.time.temporal.Temporal; import java.util.function.BiFunction; diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/jsr310/deser/AvroJavaTimeDeserializerBase.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/jsr310/deser/AvroJavaTimeDeserializerBase.java index 0ee178e0b..d37ca0961 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/jsr310/deser/AvroJavaTimeDeserializerBase.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/jsr310/deser/AvroJavaTimeDeserializerBase.java @@ -1,13 +1,13 @@ package com.fasterxml.jackson.dataformat.avro.jsr310.deser; +import java.io.IOException; +import java.time.ZoneId; + import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.deser.std.StdScalarDeserializer; import com.fasterxml.jackson.databind.type.LogicalType; -import java.io.IOException; -import java.time.ZoneId; - import static com.fasterxml.jackson.core.JsonToken.VALUE_NUMBER_INT; public abstract class AvroJavaTimeDeserializerBase extends StdScalarDeserializer diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/jsr310/deser/AvroLocalDateTimeDeserializer.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/jsr310/deser/AvroLocalDateTimeDeserializer.java index e2318fae2..59f748762 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/jsr310/deser/AvroLocalDateTimeDeserializer.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/jsr310/deser/AvroLocalDateTimeDeserializer.java @@ -1,9 +1,6 @@ package com.fasterxml.jackson.dataformat.avro.jsr310.deser; -import java.time.Instant; -import java.time.LocalDateTime; -import java.time.ZoneId; -import java.time.ZoneOffset; +import java.time.*; /** * Deserializer for {@link LocalDateTime} from an integer value. diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/jsr310/ser/AvroInstantSerializer.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/jsr310/ser/AvroInstantSerializer.java index b362c447e..dbb1eda85 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/jsr310/ser/AvroInstantSerializer.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/jsr310/ser/AvroInstantSerializer.java @@ -1,21 +1,17 @@ package com.fasterxml.jackson.dataformat.avro.jsr310.ser; +import java.io.IOException; +import java.time.*; +import java.time.temporal.Temporal; +import java.util.function.Function; + import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonIntegerFormatVisitor; import com.fasterxml.jackson.databind.ser.std.StdScalarSerializer; -import java.io.IOException; -import java.time.Instant; -import java.time.OffsetDateTime; -import java.time.ZonedDateTime; -import java.time.temporal.Temporal; -import java.util.function.Function; - /** * Serializer for variants of java.time classes (Instant, OffsetDateTime, ZonedDateTime) into long value. * diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/jsr310/ser/AvroLocalDateSerializer.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/jsr310/ser/AvroLocalDateSerializer.java index 1278e7148..8f8cf66f8 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/jsr310/ser/AvroLocalDateSerializer.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/jsr310/ser/AvroLocalDateSerializer.java @@ -1,17 +1,15 @@ package com.fasterxml.jackson.dataformat.avro.jsr310.ser; +import java.io.IOException; +import java.time.LocalDate; + import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonIntegerFormatVisitor; import com.fasterxml.jackson.databind.ser.std.StdScalarSerializer; -import java.io.IOException; -import java.time.LocalDate; - /** * Serializer for {@link LocalDate} into int value. * diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/jsr310/ser/AvroLocalDateTimeSerializer.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/jsr310/ser/AvroLocalDateTimeSerializer.java index d1c0f7f09..dc3f21b60 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/jsr310/ser/AvroLocalDateTimeSerializer.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/jsr310/ser/AvroLocalDateTimeSerializer.java @@ -1,19 +1,15 @@ package com.fasterxml.jackson.dataformat.avro.jsr310.ser; +import java.io.IOException; +import java.time.*; + import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonIntegerFormatVisitor; import com.fasterxml.jackson.databind.ser.std.StdScalarSerializer; -import java.io.IOException; -import java.time.Instant; -import java.time.LocalDateTime; -import java.time.ZoneOffset; - /** * Serializer for {@link LocalDateTime} into long value * diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/jsr310/ser/AvroLocalTimeSerializer.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/jsr310/ser/AvroLocalTimeSerializer.java index 3476b0b54..3e2dc2f3f 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/jsr310/ser/AvroLocalTimeSerializer.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/jsr310/ser/AvroLocalTimeSerializer.java @@ -1,17 +1,15 @@ package com.fasterxml.jackson.dataformat.avro.jsr310.ser; +import java.io.IOException; +import java.time.LocalTime; + import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonIntegerFormatVisitor; import com.fasterxml.jackson.databind.ser.std.StdScalarSerializer; -import java.io.IOException; -import java.time.LocalTime; - /** * Serializer for {@link LocalTime} into int value. * diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/ArrayVisitor.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/ArrayVisitor.java index b70c6c7d7..9c2299bd6 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/ArrayVisitor.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/ArrayVisitor.java @@ -5,12 +5,8 @@ import org.apache.avro.Schema; import org.apache.avro.Schema.Type; -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonArrayFormatVisitor; -import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatTypes; -import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitable; +import com.fasterxml.jackson.databind.*; +import com.fasterxml.jackson.databind.jsonFormatVisitors.*; import static com.fasterxml.jackson.dataformat.avro.schema.AvroSchemaHelper.AVRO_SCHEMA_PROP_CLASS; diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/AvroSchemaHelper.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/AvroSchemaHelper.java index 2916e8671..f923f0220 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/AvroSchemaHelper.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/AvroSchemaHelper.java @@ -7,10 +7,8 @@ import java.net.URL; import java.util.*; -import org.apache.avro.JsonProperties; -import org.apache.avro.Schema; +import org.apache.avro.*; import org.apache.avro.Schema.Parser; -import org.apache.avro.SchemaParseException; import org.apache.avro.reflect.AvroAlias; import org.apache.avro.reflect.Stringable; import org.apache.avro.specific.SpecificData; diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/DateTimeVisitor.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/DateTimeVisitor.java index 059ef3338..f93651c93 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/DateTimeVisitor.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/DateTimeVisitor.java @@ -1,17 +1,13 @@ package com.fasterxml.jackson.dataformat.avro.schema; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonIntegerFormatVisitor; +import java.time.*; + import org.apache.avro.LogicalType; import org.apache.avro.Schema; -import java.time.Instant; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.LocalTime; -import java.time.OffsetDateTime; -import java.time.ZonedDateTime; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.JavaType; +import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonIntegerFormatVisitor; public class DateTimeVisitor extends JsonIntegerFormatVisitor.Base implements SchemaBuilder { diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/DefinedSchemas.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/DefinedSchemas.java index 696b2e08f..62b4fb4ec 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/DefinedSchemas.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/DefinedSchemas.java @@ -1,6 +1,7 @@ package com.fasterxml.jackson.dataformat.avro.schema; -import java.util.*; +import java.util.LinkedHashMap; +import java.util.Map; import org.apache.avro.Schema; diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/EnumVisitor.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/EnumVisitor.java index 438fab57d..e4a519028 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/EnumVisitor.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/EnumVisitor.java @@ -3,13 +3,11 @@ import java.util.ArrayList; import java.util.Set; -import com.fasterxml.jackson.databind.BeanDescription; -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonStringFormatVisitor; - import org.apache.avro.Schema; +import com.fasterxml.jackson.databind.*; +import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonStringFormatVisitor; + /** * Specific visitor for Java Enum types that are to be exposed as * Avro Enums. Used unless Java Enums are to be mapped to Avro Strings. diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/MapVisitor.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/MapVisitor.java index a99348a15..1ae5db36b 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/MapVisitor.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/MapVisitor.java @@ -2,9 +2,7 @@ import org.apache.avro.Schema; -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.introspect.AnnotatedClass; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitable; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonMapFormatVisitor; diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/RecordVisitor.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/RecordVisitor.java index 8aa8f9b32..30a00dea2 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/RecordVisitor.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/RecordVisitor.java @@ -1,8 +1,6 @@ package com.fasterxml.jackson.dataformat.avro.schema; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; +import java.util.*; import org.apache.avro.LogicalTypes; import org.apache.avro.Schema; diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/StringVisitor.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/StringVisitor.java index 4aabb9dca..d3a8f984a 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/StringVisitor.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/StringVisitor.java @@ -5,9 +5,7 @@ import org.apache.avro.Schema; import com.fasterxml.jackson.core.JsonParser.NumberType; -import com.fasterxml.jackson.databind.BeanDescription; -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonStringFormatVisitor; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonValueFormat; diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/UUIDVisitor.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/UUIDVisitor.java index 914fb954e..113f6e74a 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/UUIDVisitor.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/UUIDVisitor.java @@ -2,12 +2,12 @@ import java.util.Set; -import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonStringFormatVisitor; -import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonValueFormat; - import org.apache.avro.LogicalTypes; import org.apache.avro.Schema; +import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonStringFormatVisitor; +import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonValueFormat; + /** * Visitor for {@link java.util.UUID} type. When it is created with logicalTypesEnabled enabled, * Avro schema is created with logical type uuid. diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/VisitorFormatWrapperImpl.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/VisitorFormatWrapperImpl.java index ce4802b39..f2dc4808c 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/VisitorFormatWrapperImpl.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/VisitorFormatWrapperImpl.java @@ -2,18 +2,14 @@ import java.time.temporal.Temporal; -import com.fasterxml.jackson.core.JsonGenerator; +import org.apache.avro.Schema; -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.exc.InvalidDefinitionException; import com.fasterxml.jackson.databind.jsonFormatVisitors.*; - import com.fasterxml.jackson.dataformat.avro.AvroSchema; -import org.apache.avro.Schema; - public class VisitorFormatWrapperImpl implements JsonFormatVisitorWrapper { diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/ser/AvroWriteContext.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/ser/AvroWriteContext.java index 15d216183..3c05e6def 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/ser/AvroWriteContext.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/ser/AvroWriteContext.java @@ -2,16 +2,12 @@ import java.io.IOException; import java.math.BigDecimal; -import java.util.Arrays; -import java.util.List; -import java.util.Map; +import java.util.*; import org.apache.avro.Schema; import org.apache.avro.Schema.Type; import org.apache.avro.UnresolvedUnionException; -import org.apache.avro.generic.GenericArray; -import org.apache.avro.generic.GenericData; -import org.apache.avro.generic.GenericRecord; +import org.apache.avro.generic.*; import org.apache.avro.io.BinaryEncoder; import org.apache.avro.reflect.ReflectData; diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/ser/CustomEncodingSerializer.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/ser/CustomEncodingSerializer.java index 1c405db28..719211926 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/ser/CustomEncodingSerializer.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/ser/CustomEncodingSerializer.java @@ -6,10 +6,7 @@ import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper; import com.fasterxml.jackson.dataformat.avro.AvroSchema; import com.fasterxml.jackson.dataformat.avro.CustomEncodingWrapper; diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/ser/RootContext.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/ser/RootContext.java index 5a049f9a7..1d9166d64 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/ser/RootContext.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/ser/RootContext.java @@ -5,15 +5,15 @@ import org.apache.avro.Schema; import org.apache.avro.file.DataFileWriter; -import org.apache.avro.generic.*; +import org.apache.avro.generic.GenericArray; +import org.apache.avro.generic.GenericRecord; import org.apache.avro.io.BinaryEncoder; +import org.apache.avro.io.DatumWriter; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.dataformat.avro.AvroGenerator; import com.fasterxml.jackson.dataformat.avro.AvroGenerator.Feature; -import org.apache.avro.io.DatumWriter; - class RootContext extends AvroWriteContext { diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/AmbiguousUnionWriteTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/AmbiguousUnionWriteTest.java index 45d5e1e27..1aaf15262 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/AmbiguousUnionWriteTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/AmbiguousUnionWriteTest.java @@ -1,5 +1,9 @@ package com.fasterxml.jackson.dataformat.avro; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + // 23-Aug-2017, tatu: There was some confusion on whether potential ambiguity // might be problematic (compared to actual one) -- this test verifies // it should not be. @@ -34,6 +38,7 @@ protected StringWrapper() { } private final AvroMapper MAPPER = newMapper(); + @Test public void testWriteNoAmbiguity() throws Exception { AvroSchema schema = MAPPER.schemaFrom(SCHEMA_WITH_AMBIGUITY); diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/AnyProperties75Test.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/AnyProperties75Test.java index dfbfd8677..34a47c8de 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/AnyProperties75Test.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/AnyProperties75Test.java @@ -3,9 +3,14 @@ import java.util.HashMap; import java.util.Map; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + // for [dataformats-binary#75] -- not legit, probably, // but included for now to see if there's something we // could do @@ -30,6 +35,7 @@ public Object get(String name) { private final AvroMapper MAPPER = getMapper(); + @Test public void testReadWriteIntSequence() throws Exception { final String SCHEMA_JSON = aposToQuotes("{\n" diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/ArrayTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/ArrayTest.java index f97c4b724..be2be600f 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/ArrayTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/ArrayTest.java @@ -2,20 +2,23 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; +import java.util.*; -import com.fasterxml.jackson.core.*; +import org.junit.jupiter.api.Test; -import com.fasterxml.jackson.databind.*; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.SequenceWriter; import com.fasterxml.jackson.dataformat.avro.testsupport.LimitingInputStream; +import static org.junit.jupiter.api.Assertions.*; + public class ArrayTest extends AvroTestBase { private final AvroMapper MAPPER = getMapper(); // Simple test for a single array + @Test public void testRootStringArray() throws Exception { AvroSchema schema = getStringArraySchema(); @@ -43,6 +46,7 @@ public void testRootStringArray() throws Exception } // And more complex: sequence of (String) arrays + @Test public void testStringArraySequence() throws Exception { AvroSchema schema = getStringArraySchema(); @@ -95,6 +99,7 @@ public void testStringArraySequence() throws Exception } // And the ultimate case of sequence of arrays of records + @Test public void testEmployeeArraySequence() throws Exception { AvroSchema schema = MAPPER.schemaFrom(EMPLOYEE_ARRAY_SCHEMA_JSON); diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/AvroNumberTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/AvroNumberTest.java index 7c8728742..98de4c7c0 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/AvroNumberTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/AvroNumberTest.java @@ -3,14 +3,18 @@ import java.math.BigDecimal; import java.math.BigInteger; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonToken; import com.fasterxml.jackson.core.JsonParser.NumberType; import com.fasterxml.jackson.core.JsonParser.NumberTypeFP; +import com.fasterxml.jackson.core.JsonToken; import com.fasterxml.jackson.core.io.SerializedString; import com.fasterxml.jackson.dataformat.avro.testsupport.LimitingInputStream; +import static org.junit.jupiter.api.Assertions.*; + public class AvroNumberTest extends AvroTestBase { static class NumberWrapper { @@ -41,6 +45,7 @@ public Numbers(int i0, long l0, private final AvroMapper MAPPER = newMapper(); // for [dataformat-avro#41] + @Test public void testNumberType() throws Exception { AvroSchema schema = MAPPER.schemaFor(NumberWrapper.class); @@ -54,6 +59,7 @@ public void testNumberType() throws Exception assertEquals(Integer.valueOf(17), result.value); } + @Test public void testNumberCoercions() throws Exception { AvroSchema schema = MAPPER.schemaFor(Numbers.class); diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/AvroTestBase.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/AvroTestBase.java index c579f3c96..9da6c427e 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/AvroTestBase.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/AvroTestBase.java @@ -1,19 +1,16 @@ package com.fasterxml.jackson.dataformat.avro; import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Random; - -import junit.framework.TestCase; +import java.util.*; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonToken; import com.fasterxml.jackson.databind.ObjectMapper; -public abstract class AvroTestBase extends TestCase +import static org.junit.jupiter.api.Assertions.fail; + +public abstract class AvroTestBase { /* /********************************************************** diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/BigDecimal_schemaCreationTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/BigDecimal_schemaCreationTest.java index 48d8722e3..ce331198a 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/BigDecimal_schemaCreationTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/BigDecimal_schemaCreationTest.java @@ -1,17 +1,19 @@ package com.fasterxml.jackson.dataformat.avro; +import java.math.BigDecimal; + +import org.apache.avro.LogicalTypes; +import org.apache.avro.Schema; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.dataformat.avro.annotation.AvroDecimal; import com.fasterxml.jackson.dataformat.avro.schema.AvroSchemaGenerator; -import org.apache.avro.LogicalTypes; -import org.apache.avro.Schema; -import org.junit.Test; - -import java.math.BigDecimal; import static org.assertj.core.api.Assertions.assertThat; + public class BigDecimal_schemaCreationTest extends AvroTestBase { private static final AvroMapper MAPPER = new AvroMapper(); diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/BigDecimal_serialization_and_deserializationTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/BigDecimal_serialization_and_deserializationTest.java index 97e534314..89c418c98 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/BigDecimal_serialization_and_deserializationTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/BigDecimal_serialization_and_deserializationTest.java @@ -1,10 +1,12 @@ package com.fasterxml.jackson.dataformat.avro; +import java.math.BigDecimal; + +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; -import java.math.BigDecimal; - import static org.assertj.core.api.Assertions.assertThat; public class BigDecimal_serialization_and_deserializationTest extends AvroTestBase { @@ -24,6 +26,7 @@ public BigDecimalAndName( } // By default, BigDecimal is serialized to string + @Test public void testSerialization_toString() throws Exception { // GIVEN String schemaString = "{" + @@ -68,6 +71,7 @@ public void testSerialization_toString() throws Exception { assertThat(result.name).isEqualTo("peter"); } + @Test public void testSerialization_toBytesWithLogicalTypeDecimal() throws Exception { // GIVEN String schemaString = "{" + @@ -118,6 +122,7 @@ public void testSerialization_toBytesWithLogicalTypeDecimal() throws Exception { assertThat(result.name).isEqualTo("peter"); } + @Test public void testSerialization_toFixedWithLogicalTypeDecimal() throws Exception { // GIVEN String schemaString = "{" + diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/BinaryDataTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/BinaryDataTest.java index 4478da07e..36a8a6d33 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/BinaryDataTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/BinaryDataTest.java @@ -4,6 +4,8 @@ import java.math.BigInteger; import java.nio.charset.StandardCharsets; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonToken; @@ -11,6 +13,8 @@ import com.fasterxml.jackson.dataformat.avro.schema.AvroSchemaGenerator; import com.fasterxml.jackson.dataformat.avro.testsupport.ThrottledInputStream; +import static org.junit.jupiter.api.Assertions.*; + public class BinaryDataTest extends AvroTestBase { @JsonPropertyOrder({ "filename", "data", "size" }) @@ -29,6 +33,7 @@ public FilePojo(String text) { private final AvroMapper AVRO_JACKSON_MAPPER = AvroMapper.builder(new AvroFactory()).build(); private final AvroMapper AVRO_APACHE_MAPPER = AvroMapper.builder(new ApacheAvroFactory()).build(); + @Test public void testAvroSchemaGenerationWithJackson() throws Exception { _testAvroSchemaGenerationWithJackson(AVRO_JACKSON_MAPPER); diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/ConcurrencyTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/ConcurrencyTest.java index 8103065d7..e37f16a39 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/ConcurrencyTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/ConcurrencyTest.java @@ -2,9 +2,13 @@ import java.io.*; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.MappingIterator; import com.fasterxml.jackson.databind.SequenceWriter; +import static org.junit.jupiter.api.Assertions.*; + /** * Simple tests for some testable aspects of concurrent usage. * Specifically tries to ensure that usage of multiple parsers, @@ -23,6 +27,7 @@ public ConcurrencyTest() throws IOException { // Simple test that creates 2 encoders and uses them in interleaved manner. // This should tease out simplest problems with possible encoder reuse. + @Test public void testMultipleEncoders() throws Exception { ByteArrayOutputStream b1 = new ByteArrayOutputStream(); @@ -43,10 +48,12 @@ public void testMultipleEncoders() throws Exception assertEquals(6926, b1.size()); } + @Test public void testMultipleDecodersBlock() throws Exception { _testMultipleDecoders(false); } + @Test public void testMultipleDecodersStreaming() throws Exception { _testMultipleDecoders(true); } diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/EnumTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/EnumTest.java index 26f4ba379..edd592191 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/EnumTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/EnumTest.java @@ -1,5 +1,10 @@ package com.fasterxml.jackson.dataformat.avro; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + public class EnumTest extends AvroTestBase { // gender as Avro enum @@ -32,6 +37,7 @@ protected static class EmployeeStr { private final AvroMapper MAPPER = newMapper(); + @Test public void test_avroSchemaWithEnum_fromEnumValueToEnumValue() throws Exception { AvroSchema schema = MAPPER.schemaFrom(ENUM_SCHEMA_JSON); @@ -51,6 +57,7 @@ public void test_avroSchemaWithEnum_fromEnumValueToEnumValue() throws Exception assertEquals(Gender.F, output.gender); } + @Test public void test_avroSchemaWithEnum_fromStringValueToEnumValue() throws Exception { AvroSchema schema = MAPPER.schemaFrom(ENUM_SCHEMA_JSON); @@ -68,6 +75,7 @@ public void test_avroSchemaWithEnum_fromStringValueToEnumValue() throws Exceptio assertEquals(Gender.F, output.gender); } + @Test public void test_avroSchemaWithString_fromEnumValueToEnumValue() throws Exception { AvroSchema schema = MAPPER.schemaFrom(STRING_SCHEMA_JSON); @@ -101,6 +109,7 @@ public void test_avroSchemaWithString_fromEnumValueToEnumValue() throws Exceptio } // Not sure this test makes sense + @Test public void test_avroSchemaWithString_fromStringValueToEnumValue() throws Exception { AvroSchema schema = MAPPER.schemaFrom(STRING_SCHEMA_JSON); diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/FileFormatTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/FileFormatTest.java index 17e890307..2cdbc2b0f 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/FileFormatTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/FileFormatTest.java @@ -5,12 +5,17 @@ import org.apache.avro.generic.GenericDatumReader; import org.apache.avro.generic.GenericRecord; import org.apache.avro.io.DatumReader; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.databind.ObjectMapper; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + // for [dataformats-binary#15] public class FileFormatTest extends AvroTestBase { + @Test public void testFileFormatOutput() throws Exception { _testFileFormatOutput(true); diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/FixedFieldTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/FixedFieldTest.java index 35efa688c..691491d1d 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/FixedFieldTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/FixedFieldTest.java @@ -1,10 +1,12 @@ package com.fasterxml.jackson.dataformat.avro; -import org.junit.Assert; - import java.io.IOException; import java.util.Random; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertArrayEquals; + public class FixedFieldTest extends AvroTestBase { private static final String FIXED_SCHEMA_JSON = "{\n" @@ -15,6 +17,7 @@ public class FixedFieldTest extends AvroTestBase + " ]\n" + "}"; + @Test public void testFixedField() throws IOException { AvroMapper mapper = getMapper(); AvroSchema schema = mapper.schemaFrom(FIXED_SCHEMA_JSON); @@ -24,7 +27,7 @@ public void testFixedField() throws IOException { in.fixedField = bytes; byte[] serialized = mapper.writer(schema).writeValueAsBytes(in); WithFixedField deser = mapper.readerFor(WithFixedField.class).with(schema).readValue(serialized); - Assert.assertArrayEquals(bytes, deser.fixedField); + assertArrayEquals(bytes, deser.fixedField); } static class WithFixedField { diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/Issue19Test.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/Issue19Test.java index 76efea690..98381b810 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/Issue19Test.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/Issue19Test.java @@ -4,13 +4,16 @@ import java.util.ArrayList; import java.util.List; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; import com.fasterxml.jackson.annotation.PropertyAccessor; - import com.fasterxml.jackson.core.JsonGenerator; - import com.fasterxml.jackson.databind.DeserializationFeature; +import static org.junit.jupiter.api.Assertions.assertNotNull; + + public class Issue19Test extends AvroTestBase { static class EventID { @@ -61,6 +64,7 @@ public EventLog(Integer version, Byte eventCount, List events, List sampleEvents = new ArrayList<>(); diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/MapTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/MapTest.java index 789bb0dad..f6f602d1e 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/MapTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/MapTest.java @@ -1,14 +1,17 @@ package com.fasterxml.jackson.dataformat.avro; import java.io.ByteArrayOutputStream; -import java.util.*; +import java.util.LinkedHashMap; +import java.util.Map; -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonToken; +import org.junit.jupiter.api.Test; + +import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.databind.MappingIterator; import com.fasterxml.jackson.databind.SequenceWriter; +import static org.junit.jupiter.api.Assertions.*; + public class MapTest extends AvroTestBase { private final static String MAP_SCHEMA_JSON = "{\n" @@ -40,6 +43,7 @@ public void setStuff(Map arg) { private final AvroMapper MAPPER = getMapper(); + @Test public void testRecordWithMap() throws Exception { AvroSchema schema = MAPPER.schemaFrom(MAP_SCHEMA_JSON); @@ -110,6 +114,7 @@ public void testRecordWithMap() throws Exception assertEquals(1, bytes.length); // measured to be current exp size } + @Test public void testMapOrNull() throws Exception { AvroSchema schema = MAPPER.schemaFrom(MAP_OR_NULL_SCHEMA_JSON); @@ -147,6 +152,7 @@ public void testMapOrNull() throws Exception // since Records and Arrays work, but looks like there are some issues // regarding them so can't yet test + @Test public void testRootStringMap() throws Exception { AvroSchema schema = getStringMapSchema(); @@ -160,6 +166,7 @@ public void testRootStringMap() throws Exception assertEquals("1", result.get("a")); assertEquals("2", result.get("b")); } + @Test public void testRootMapSequence() throws Exception { ByteArrayOutputStream b = new ByteArrayOutputStream(1000); diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/MapWithUnionTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/MapWithUnionTest.java index b9f3e041a..36ec7e2d1 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/MapWithUnionTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/MapWithUnionTest.java @@ -2,11 +2,16 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.util.*; +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.databind.MappingIterator; import com.fasterxml.jackson.databind.SequenceWriter; +import static org.junit.jupiter.api.Assertions.*; + public class MapWithUnionTest extends AvroTestBase { protected final String MAP_WITH_UNION_SCHEMA_JSON = aposToQuotes( @@ -50,6 +55,7 @@ public MapContainer(Map p) { private final AvroMapper MAPPER = getMapper(); + @Test public void testRootMapWithUnion() throws Exception { AvroSchema schema = MAPPER.schemaFrom(MAP_WITH_UNION_SCHEMA_JSON); @@ -67,6 +73,7 @@ public void testRootMapWithUnion() throws Exception assertEquals("foobar", result.get("xy")); } + @Test public void testRootMapWithUnionSequence() throws Exception { AvroSchema schema = MAPPER.schemaFrom(MAP_WITH_UNION_SCHEMA_JSON); @@ -97,6 +104,7 @@ public void testRootMapWithUnionSequence() throws Exception it.close(); } + @Test public void testMapContainerWithNested() throws IOException { Map map = new LinkedHashMap<>(); diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/MapperConfigTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/MapperConfigTest.java index b70937b8f..93481cc8e 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/MapperConfigTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/MapperConfigTest.java @@ -2,10 +2,14 @@ import java.io.ByteArrayOutputStream; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.core.FormatSchema; import com.fasterxml.jackson.core.StreamReadCapability; import com.fasterxml.jackson.databind.*; +import static org.junit.jupiter.api.Assertions.*; + public class MapperConfigTest extends AvroTestBase { private final AvroFactory AVRO_F = new AvroFactory(); @@ -18,6 +22,7 @@ public class MapperConfigTest extends AvroTestBase /********************************************************** */ + @Test public void testFactoryDefaults() throws Exception { assertTrue(AVRO_F.isEnabled(AvroParser.Feature.AVRO_BUFFERING)); @@ -25,6 +30,7 @@ public void testFactoryDefaults() throws Exception assertFalse(AVRO_F.canUseSchema(BOGUS_SCHEMA)); } + @Test public void testParserDefaults() throws Exception { AvroParser p = AVRO_F.createParser(new byte[0]); @@ -50,6 +56,7 @@ public void testParserDefaults() throws Exception p.close(); } + @Test public void testGeneratorDefaults() throws Exception { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); @@ -79,6 +86,7 @@ public void testGeneratorDefaults() throws Exception */ // Test to verify that data format affects default state of order-props-alphabetically + @Test public void testDefaultSettingsWithObjectMapper() { ObjectMapper mapper = AvroMapper.builder(AVRO_F).build(); @@ -95,6 +103,7 @@ public void testDefaultSettingsWithObjectMapper() assertTrue(r.isEnabled(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY)); } + @Test public void testDefaultSettingsWithAvroMapper() { AvroMapper mapper = AvroMapper.builder().build(); diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/NestedMapTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/NestedMapTest.java index aaf90d69e..0be04ff8a 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/NestedMapTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/NestedMapTest.java @@ -1,14 +1,16 @@ package com.fasterxml.jackson.dataformat.avro; import java.io.IOException; -import java.util.*; +import java.util.Map; -import com.fasterxml.jackson.annotation.JsonProperty; +import org.junit.jupiter.api.Test; +import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.ObjectMapper; - import com.fasterxml.jackson.dataformat.avro.schema.AvroSchemaGenerator; +import static org.junit.jupiter.api.Assertions.assertEquals; + public class NestedMapTest extends AvroTestBase { public static class Nester { @@ -24,6 +26,7 @@ public static class Nester { private final AvroMapper MAPPER = getMapper(); + @Test public void testSerialization() throws IOException { Nester fromJson = new ObjectMapper().readValue( diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/OptionalEnumTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/OptionalEnumTest.java index ca94e0483..35a0966be 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/OptionalEnumTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/OptionalEnumTest.java @@ -1,5 +1,10 @@ package com.fasterxml.jackson.dataformat.avro; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + public class OptionalEnumTest extends AvroTestBase { protected enum Gender { M, F; } @@ -11,6 +16,7 @@ protected static class Employee { private final AvroMapper MAPPER = newMapper(); // [dataformat-avro#12] + @Test public void testEnumViaGeneratedSchema() throws Exception { final AvroSchema schema = MAPPER.schemaFor(Employee.class); diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/POJOComplexReadTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/POJOComplexReadTest.java index 8c3b48bce..99d5c4c6e 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/POJOComplexReadTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/POJOComplexReadTest.java @@ -3,11 +3,15 @@ import java.io.ByteArrayInputStream; import java.io.InputStream; -import com.fasterxml.jackson.core.JsonProcessingException; +import org.junit.jupiter.api.Test; +import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.dataformat.avro.testsupport.ThrottledInputStream; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + public class POJOComplexReadTest extends AvroTestBase { protected final static Image IMAGE1 = new Image("http://javaone.com/keynote_large.jpg", @@ -30,6 +34,7 @@ public POJOComplexReadTest() throws JsonMappingException { /********************************************************** */ + @Test public void testRoundtrip() throws Exception { byte[] avro = getStdItemBytes(); diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/POJOSimpleReadTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/POJOSimpleReadTest.java index 8ededee38..09821b3ca 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/POJOSimpleReadTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/POJOSimpleReadTest.java @@ -1,21 +1,21 @@ package com.fasterxml.jackson.dataformat.avro; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.InputStream; -import java.io.StringWriter; +import java.io.*; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; +import org.junit.jupiter.api.Test; + +import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.core.JsonParser.NumberType; -import com.fasterxml.jackson.core.JsonToken; import com.fasterxml.jackson.core.io.SerializedString; import com.fasterxml.jackson.dataformat.avro.testsupport.ThrottledInputStream; +import static org.junit.jupiter.api.Assertions.*; + public class POJOSimpleReadTest extends AvroTestBase { private final AvroMapper MAPPER = new AvroMapper(); + @Test public void testSimplePojoViaMapper() throws Exception { Employee empl = _simpleEmployee(); @@ -34,6 +34,7 @@ public void testSimplePojoViaMapper() throws Exception assertNull(empl.boss.boss); } + @Test public void testSimplePojoViaParser() throws Exception { Employee empl = _simpleEmployee(); @@ -133,6 +134,7 @@ private void _testSimplePojoViaParser(Employee empl, byte[] avro, p.close(); } + @Test public void testMissingSchema() throws Exception { Employee empl = _simpleEmployee(); diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/RootEmptyRecord177Test.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/RootEmptyRecord177Test.java index efaab0977..2562a6e23 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/RootEmptyRecord177Test.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/RootEmptyRecord177Test.java @@ -1,7 +1,11 @@ package com.fasterxml.jackson.dataformat.avro; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonAutoDetect; +import static org.junit.jupiter.api.Assertions.assertEquals; + public class RootEmptyRecord177Test extends AvroTestBase { private final AvroMapper MAPPER = getMapper(); @@ -17,6 +21,7 @@ public boolean equals(Object o) { } } + @Test public void testEmptyRecord() throws Exception { final Empty empty = new Empty(); diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/RootSequenceTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/RootSequenceTest.java index 808c8d620..f11856c76 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/RootSequenceTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/RootSequenceTest.java @@ -2,11 +2,13 @@ import java.io.ByteArrayOutputStream; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.MappingIterator; import com.fasterxml.jackson.databind.SequenceWriter; import com.fasterxml.jackson.dataformat.avro.testsupport.ThrottledInputStream; -import static org.junit.Assert.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.*; /** * Tests to ensure that it is possible to read a sequence of root-level @@ -16,6 +18,7 @@ public class RootSequenceTest extends AvroTestBase { private final AvroMapper MAPPER = getMapper(); + @Test public void testReadWriteIntSequence() throws Exception { AvroSchema schema = MAPPER.schemaFrom(quote("int")); @@ -43,6 +46,7 @@ public void testReadWriteIntSequence() throws Exception it.close(); } + @Test public void testReadWriteStringSequence() throws Exception { AvroSchema schema = MAPPER.schemaFrom(quote("string")); @@ -72,6 +76,7 @@ public void testReadWriteStringSequence() throws Exception it.close(); } + @Test public void testReadWriteEmployeeSequence() throws Exception { // Just for fun, use throttled input to force boundary reads... diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/RoundtripTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/RoundtripTest.java index de2777211..ef886a794 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/RoundtripTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/RoundtripTest.java @@ -1,10 +1,14 @@ package com.fasterxml.jackson.dataformat.avro; -import com.fasterxml.jackson.core.JsonGenerator; +import org.junit.jupiter.api.Test; +import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.StreamReadConstraints; import com.fasterxml.jackson.core.exc.StreamConstraintsException; -import com.fasterxml.jackson.databind.*; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.ObjectWriter; + +import static org.junit.jupiter.api.Assertions.*; public class RoundtripTest extends MapTest { @@ -49,6 +53,7 @@ public org.apache.avro.Schema getSchema() { /********************************************************** */ + @Test public void testIssue9() throws Exception { AvroSchema jsch = getEmployeeSchema(); @@ -61,6 +66,7 @@ public void testIssue9() throws Exception assertNotNull(avroData); } + @Test public void testCharSequences() throws Exception { ObjectMapper mapper = AvroMapper.builder() @@ -83,6 +89,7 @@ public void testCharSequences() throws Exception assertEquals(input.name, output.name); } + @Test public void testCharSequencesLowStringLimit() throws Exception { AvroFactory factory = AvroFactory.builder() @@ -105,8 +112,8 @@ public void testCharSequencesLowStringLimit() throws Exception .forType(CharSeqBean.class).readValue(avroData); fail("expected StreamConstraintsException"); } catch (StreamConstraintsException ise) { - assertTrue("unexpected exception message: " + ise.getMessage(), - ise.getMessage().startsWith("String value length (3) exceeds the maximum allowed")); + assertTrue(ise.getMessage().startsWith("String value length (3) exceeds the maximum allowed"), + "unexpected exception message: " + ise.getMessage()); } } } diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/ScalarTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/ScalarTest.java index 1aac137f5..59313ca57 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/ScalarTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/ScalarTest.java @@ -1,12 +1,18 @@ package com.fasterxml.jackson.dataformat.avro; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.ObjectReader; import com.fasterxml.jackson.dataformat.avro.testsupport.ThrottledInputStream; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; + public class ScalarTest extends AvroTestBase { private final AvroMapper MAPPER = getMapper(); + @Test public void testRootString() throws Exception { final String INPUT = "Something or other"; @@ -30,6 +36,7 @@ public void _testRootString(int chunkSize, ObjectReader r, byte[] encoded, in.close(); } + @Test public void testRootInt() throws Exception { Integer inputValue = Integer.valueOf(0xE134567); @@ -52,6 +59,7 @@ public void _testRootInt(int chunkSize, ObjectReader r, byte[] encoded, in.close(); } + @Test public void testRootLong() throws Exception { for (long l : new long[] { @@ -86,6 +94,7 @@ public void _testRootLong(int chunkSize, ObjectReader r, byte[] encoded, } } + @Test public void testRootDouble() throws Exception { for (double d : new double[] { @@ -118,6 +127,7 @@ public void _testRootDouble(int chunkSize, ObjectReader r, byte[] encoded, } } + @Test public void testRootFloat() throws Exception { for (float f : new float[] { @@ -150,6 +160,7 @@ public void _testRootFloat(int chunkSize, ObjectReader r, byte[] encoded, } } + @Test public void testRootBoolean() throws Exception { AvroSchema schema = MAPPER.schemaFrom(quote("boolean")); diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/SerializeGeneratedTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/SerializeGeneratedTest.java index 63c3eeadc..5e41a4c01 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/SerializeGeneratedTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/SerializeGeneratedTest.java @@ -1,13 +1,17 @@ package com.fasterxml.jackson.dataformat.avro; -import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.jupiter.api.Test; +import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.avro.gen.Event35; import com.fasterxml.jackson.dataformat.avro.gen.Event35Id; +import static org.junit.jupiter.api.Assertions.assertNotNull; + // Test(s) for [dataformat-avro#35] public class SerializeGeneratedTest extends AvroTestBase { + @Test public void testWriteGeneratedEvent() throws Exception { Event35 event = new Event35(); diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/SimpleGenerationTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/SimpleGenerationTest.java index 8f4f09079..6e2049523 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/SimpleGenerationTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/SimpleGenerationTest.java @@ -3,13 +3,15 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; -import org.junit.Assert; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; +import static org.junit.jupiter.api.Assertions.*; + public class SimpleGenerationTest extends AvroTestBase { protected final String SCHEMA_WITH_BINARY_JSON_SRC = "{\n" @@ -70,6 +72,7 @@ public SimpleGenerationTest() throws IOException /********************************************************** */ + @Test public void testSimplest() throws Exception { Employee empl = new Employee(); @@ -94,6 +97,7 @@ public void testSimplest() throws Exception assertEquals(output.age, empl.age); } + @Test public void testBinaryOk() throws Exception { ObjectMapper mapper = new ObjectMapper(new AvroFactory()); @@ -105,10 +109,11 @@ public void testBinaryOk() throws Exception assertNotNull(output); assertEquals("Foo", output.name); assertNotNull(output.value); - Assert.assertArrayEquals(bin.value, output.value); + assertArrayEquals(bin.value, output.value); } @SuppressWarnings("resource") + @Test public void testIgnoringOfUnknownScalar() throws Exception { AvroFactory af = new AvroFactory(); @@ -137,6 +142,7 @@ public void testIgnoringOfUnknownScalar() throws Exception assertEquals("Bob", output.name); } + @Test public void testIgnoringOfUnknownObject() throws Exception { AvroFactory af = new AvroFactory(); diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/UUIDTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/UUIDTest.java index b9b859e13..f5dc8a5ac 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/UUIDTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/UUIDTest.java @@ -3,6 +3,11 @@ import java.nio.charset.StandardCharsets; import java.util.UUID; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + + // @since 2.10 public class UUIDTest extends AvroTestBase { @@ -18,6 +23,7 @@ protected UUIDWrapper() { } // 10-Sep-2019, tatu: as per [dataformats-binary#179], should really serialize // UUID as binary, but due to various complications can not make it work // safely and reliably with 2.10; can only add some foundational support. + @Test public void testUUIDRoundtrip() throws Exception { final AvroSchema schema = MAPPER.schemaFor(UUIDWrapper.class); diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/annotation/AvroNamespaceTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/annotation/AvroNamespaceTest.java index ce3160ccb..da3eba092 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/annotation/AvroNamespaceTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/annotation/AvroNamespaceTest.java @@ -1,11 +1,10 @@ package com.fasterxml.jackson.dataformat.avro.annotation; -import com.fasterxml.jackson.dataformat.avro.AvroMapper; -import com.fasterxml.jackson.dataformat.avro.schema.AvroSchemaGenerator; - import org.apache.avro.Schema; +import org.junit.jupiter.api.Test; -import org.junit.Test; +import com.fasterxml.jackson.dataformat.avro.AvroMapper; +import com.fasterxml.jackson.dataformat.avro.schema.AvroSchemaGenerator; import static org.assertj.core.api.Assertions.assertThat; diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/dos/CyclicAvroDataSerTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/dos/CyclicAvroDataSerTest.java index 52f063a81..2a77e92c0 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/dos/CyclicAvroDataSerTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/dos/CyclicAvroDataSerTest.java @@ -1,11 +1,14 @@ package com.fasterxml.jackson.dataformat.avro.dos; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.core.StreamReadConstraints; import com.fasterxml.jackson.databind.exc.InvalidDefinitionException; -import com.fasterxml.jackson.dataformat.avro.AvroFactory; -import com.fasterxml.jackson.dataformat.avro.AvroMapper; -import com.fasterxml.jackson.dataformat.avro.AvroSchema; -import com.fasterxml.jackson.dataformat.avro.AvroTestBase; +import com.fasterxml.jackson.dataformat.avro.*; + +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 @@ -43,6 +46,7 @@ public Bean(Bean next, String name) { MAPPER_400 = new AvroMapper(f); } + @Test public void testDirectCyclic() throws Exception { Bean bean = new Bean(null, "123"); bean.assignNext(bean); @@ -51,12 +55,13 @@ public void testDirectCyclic() throws Exception { MAPPER.writer(schema).writeValueAsBytes(bean); fail("expected InvalidDefinitionException"); } catch (InvalidDefinitionException idex) { - assertTrue("InvalidDefinitionException message is as expected?", - idex.getMessage().startsWith("Direct self-reference leading to cycle")); + assertTrue(idex.getMessage().startsWith("Direct self-reference leading to cycle"), + "InvalidDefinitionException message is as expected?"); } } // With 2.16 also test looser loops, wrt new limits + @Test public void testLooserCyclic() throws Exception { Bean beanRoot = new Bean(null, "123"); @@ -72,8 +77,8 @@ public void testLooserCyclic() throws Exception MAPPER_400.writer(schema).writeValueAsBytes(beanRoot); fail("expected InvalidDefinitionException"); } catch (InvalidDefinitionException idex) { - assertTrue("InvalidDefinitionException message is as expected?", - idex.getMessage().startsWith("Direct self-reference leading to cycle")); + assertTrue(idex.getMessage().startsWith("Direct self-reference leading to cycle"), + "InvalidDefinitionException message is as expected?"); } } } diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/dos/DeepNestingAvroParserTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/dos/DeepNestingAvroParserTest.java index 3b28d1f27..72ea02319 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/dos/DeepNestingAvroParserTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/dos/DeepNestingAvroParserTest.java @@ -2,16 +2,16 @@ import java.io.IOException; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.StreamReadConstraints; import com.fasterxml.jackson.core.exc.StreamConstraintsException; - import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.dataformat.avro.*; -import com.fasterxml.jackson.dataformat.avro.AvroFactory; -import com.fasterxml.jackson.dataformat.avro.AvroMapper; -import com.fasterxml.jackson.dataformat.avro.AvroSchema; -import com.fasterxml.jackson.dataformat.avro.AvroTestBase; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * Unit tests for deeply nested Documents @@ -59,7 +59,7 @@ public Node(int id, Node next) { } } - + @Test public void testDeeplyNestedObjectsHighLimits() throws Exception { byte[] doc = genDeepDoc(410); @@ -68,6 +68,7 @@ public void testDeeplyNestedObjectsHighLimits() throws Exception } } + @Test public void testDeeplyNestedObjectsLowLimits() throws Exception { byte[] doc = genDeepDoc(410); @@ -75,8 +76,8 @@ public void testDeeplyNestedObjectsLowLimits() throws Exception while (jp.nextToken() != null) { } fail("expected StreamConstraintsException"); } catch (StreamConstraintsException e) { - assertTrue("unexpected message: " + e.getMessage(), - e.getMessage().startsWith("Document nesting depth (401) exceeds the maximum allowed")); + assertTrue(e.getMessage().startsWith("Document nesting depth (401) exceeds the maximum allowed"), + "unexpected message: " + e.getMessage()); } } diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/failing/FileSerialization319Test.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/failing/FileSerialization319Test.java index 7523c5d2e..5d9dd7e8d 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/failing/FileSerialization319Test.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/failing/FileSerialization319Test.java @@ -1,27 +1,27 @@ package com.fasterxml.jackson.dataformat.avro.failing; -import com.fasterxml.jackson.databind.SequenceWriter; -import com.fasterxml.jackson.dataformat.avro.AvroFactory; -import com.fasterxml.jackson.dataformat.avro.AvroGenerator; -import com.fasterxml.jackson.dataformat.avro.AvroMapper; -import com.fasterxml.jackson.dataformat.avro.AvroSchema; -import com.fasterxml.jackson.dataformat.avro.AvroTestBase; -import com.fasterxml.jackson.dataformat.avro.schema.AvroSchemaGenerator; +import java.io.*; +import java.nio.file.Files; + import org.apache.avro.file.DataFileReader; import org.apache.avro.generic.GenericDatumReader; import org.apache.avro.generic.GenericRecord; import org.apache.avro.io.DatumReader; +import org.junit.jupiter.api.Test; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.nio.file.Files; +import com.fasterxml.jackson.databind.SequenceWriter; +import com.fasterxml.jackson.dataformat.avro.*; +import com.fasterxml.jackson.dataformat.avro.schema.AvroSchemaGenerator; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; // For [dataformats-binary#319]: not 100% certain test is valid, // but there is need for work wrt File-backed Avro content public class FileSerialization319Test extends AvroTestBase { // [dataformats-binary#319] + @Test public void testFileSerialization() throws Exception { final Employee employee = new Employee(); diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/failing/POJOEvolution164Test.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/failing/POJOEvolution164Test.java index 8fbd5f8c8..03b8ed8a4 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/failing/POJOEvolution164Test.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/failing/POJOEvolution164Test.java @@ -1,8 +1,10 @@ package com.fasterxml.jackson.dataformat.avro.failing; -import com.fasterxml.jackson.dataformat.avro.AvroMapper; -import com.fasterxml.jackson.dataformat.avro.AvroSchema; -import com.fasterxml.jackson.dataformat.avro.AvroTestBase; +import org.junit.jupiter.api.Test; + +import com.fasterxml.jackson.dataformat.avro.*; + +import static org.junit.jupiter.api.Assertions.assertEquals; public class POJOEvolution164Test extends AvroTestBase { @@ -13,6 +15,7 @@ static class MyClass { private final AvroMapper MAPPER = getMapper(); + @Test public void testSimpleFieldRemove() throws Exception { final String WRITER_SCHEMA_SRC = "{\n" + diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/fuzz/AvroFuzz449_65618_65649_IOOBETest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/fuzz/AvroFuzz449_65618_65649_IOOBETest.java index c9fa0f5e0..9307f49ac 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/fuzz/AvroFuzz449_65618_65649_IOOBETest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/fuzz/AvroFuzz449_65618_65649_IOOBETest.java @@ -1,15 +1,13 @@ package com.fasterxml.jackson.dataformat.avro.fuzz; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.core.JsonToken; import com.fasterxml.jackson.core.exc.StreamReadException; -import com.fasterxml.jackson.dataformat.avro.AvroFactory; -import com.fasterxml.jackson.dataformat.avro.AvroMapper; -import com.fasterxml.jackson.dataformat.avro.AvroParser; -import com.fasterxml.jackson.dataformat.avro.AvroSchema; -import com.fasterxml.jackson.dataformat.avro.AvroTestBase; +import com.fasterxml.jackson.dataformat.avro.*; + +import static org.junit.jupiter.api.Assertions.fail; // [dataformats-binary#449] public class AvroFuzz449_65618_65649_IOOBETest extends AvroTestBase diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/fuzz/AvroFuzzTestUtil.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/fuzz/AvroFuzzTestUtil.java index e7e6b30d4..c7857afb8 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/fuzz/AvroFuzzTestUtil.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/fuzz/AvroFuzzTestUtil.java @@ -1,8 +1,6 @@ package com.fasterxml.jackson.dataformat.avro.fuzz; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; +import java.io.*; public class AvroFuzzTestUtil { diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/ApacheAvroInteropUtil.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/ApacheAvroInteropUtil.java index b32c421e3..3262a6742 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/ApacheAvroInteropUtil.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/ApacheAvroInteropUtil.java @@ -2,26 +2,19 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; -import java.lang.reflect.TypeVariable; +import java.lang.reflect.*; import java.util.HashMap; import java.util.Map; import org.apache.avro.AvroRuntimeException; import org.apache.avro.Schema; -import org.apache.avro.io.Decoder; -import org.apache.avro.io.DecoderFactory; -import org.apache.avro.io.Encoder; -import org.apache.avro.io.EncoderFactory; +import org.apache.avro.io.*; import org.apache.avro.reflect.ReflectData; import com.fasterxml.jackson.core.JacksonException; import com.fasterxml.jackson.core.JsonGenerator; - import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.exc.InvalidDefinitionException; - import com.fasterxml.jackson.dataformat.avro.AvroMapper; import com.fasterxml.jackson.dataformat.avro.AvroSchema; import com.fasterxml.jackson.dataformat.avro.testsupport.BiFunction; diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/annotations/AvroDefaultTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/annotations/AvroDefaultTest.java index 926bd4c2a..db3ddc64a 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/annotations/AvroDefaultTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/annotations/AvroDefaultTest.java @@ -2,7 +2,7 @@ import org.apache.avro.Schema; import org.apache.avro.reflect.AvroDefault; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.dataformat.avro.interop.ApacheAvroInteropUtil; diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/annotations/CustomSerializationTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/annotations/CustomSerializationTest.java index 1ab552891..f862c6ce9 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/annotations/CustomSerializationTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/annotations/CustomSerializationTest.java @@ -2,17 +2,16 @@ import java.io.IOException; import java.util.Objects; + +import org.apache.avro.Schema; +import org.apache.avro.SchemaBuilder; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import org.apache.avro.Schema; -import org.apache.avro.SchemaBuilder; -import org.junit.Test; import static com.fasterxml.jackson.dataformat.avro.interop.ApacheAvroInteropUtil.jacksonDeserialize; import static com.fasterxml.jackson.dataformat.avro.interop.ApacheAvroInteropUtil.jacksonSerialize; diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/annotations/UnionResolvingTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/annotations/UnionResolvingTest.java index 5e92d5582..d6a081e90 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/annotations/UnionResolvingTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/annotations/UnionResolvingTest.java @@ -1,14 +1,12 @@ package com.fasterxml.jackson.dataformat.avro.interop.annotations; import java.io.IOException; -import java.util.Collections; -import java.util.HashSet; -import java.util.Objects; -import java.util.Set; +import java.util.*; + import org.apache.avro.Schema; import org.apache.avro.SchemaBuilder; import org.apache.avro.reflect.Union; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static com.fasterxml.jackson.dataformat.avro.interop.ApacheAvroInteropUtil.jacksonDeserialize; import static com.fasterxml.jackson.dataformat.avro.interop.ApacheAvroInteropUtil.jacksonSerialize; diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/records/RecordWithMissingType.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/records/RecordWithMissingType.java index 1b8c0d0d3..8ccbe8e93 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/records/RecordWithMissingType.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/records/RecordWithMissingType.java @@ -4,15 +4,12 @@ import java.util.Map; import org.apache.avro.Schema; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.annotation.JsonProperty; -import static com.fasterxml.jackson.dataformat.avro.interop.ApacheAvroInteropUtil.getJacksonSchema; -import static com.fasterxml.jackson.dataformat.avro.interop.ApacheAvroInteropUtil.jacksonDeserialize; -import static com.fasterxml.jackson.dataformat.avro.interop.ApacheAvroInteropUtil.jacksonSerialize; +import static com.fasterxml.jackson.dataformat.avro.interop.ApacheAvroInteropUtil.*; import static com.fasterxml.jackson.dataformat.avro.interop.InteropTestBase.type; - import static org.assertj.core.api.Assertions.assertThat; public class RecordWithMissingType { diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/jsr310/AvroJavaTimeModule_schemaCreationTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/jsr310/AvroJavaTimeModule_schemaCreationTest.java index 60d59707c..5d6a17cb0 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/jsr310/AvroJavaTimeModule_schemaCreationTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/jsr310/AvroJavaTimeModule_schemaCreationTest.java @@ -1,42 +1,24 @@ package com.fasterxml.jackson.dataformat.avro.jsr310; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.dataformat.avro.AvroMapper; -import com.fasterxml.jackson.dataformat.avro.schema.AvroSchemaGenerator; +import java.time.*; +import java.util.Arrays; +import java.util.Collection; + import org.apache.avro.LogicalType; import org.apache.avro.Schema; import org.apache.avro.specific.SpecificData; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; -import java.time.Instant; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.LocalTime; -import java.time.OffsetDateTime; -import java.time.ZonedDateTime; -import java.util.Arrays; -import java.util.Collection; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.dataformat.avro.AvroMapper; +import com.fasterxml.jackson.dataformat.avro.schema.AvroSchemaGenerator; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class AvroJavaTimeModule_schemaCreationTest { - @Parameter(0) - public Class testClass; - - @Parameter(1) - public Schema.Type expectedType; - - @Parameter(2) - public String expectedLogicalType; - - @Parameters(name = "With {0}") - public static Collection testData() { + public static Collection testData() { return Arrays.asList(new Object[][]{ // Java type | expected Avro type | expected logicalType {Instant.class, Schema.Type.LONG, "timestamp-millis"}, @@ -48,8 +30,12 @@ public static Collection testData() { }); } - @Test - public void testSchemaCreation() throws JsonMappingException { + @ParameterizedTest(name = "With {0}") + @MethodSource("testData") + public void testSchemaCreation(Class testClass, + Schema.Type expectedType, String expectedLogicalType) + throws JsonMappingException + { // GIVEN AvroMapper mapper = AvroMapper.builder() .addModule(new AvroJavaTimeModule()) diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/jsr310/AvroJavaTimeModule_serialization_and_deserializationTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/jsr310/AvroJavaTimeModule_serialization_and_deserializationTest.java index 1e67bcdc2..4955f24ad 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/jsr310/AvroJavaTimeModule_serialization_and_deserializationTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/jsr310/AvroJavaTimeModule_serialization_and_deserializationTest.java @@ -1,17 +1,12 @@ package com.fasterxml.jackson.dataformat.avro.jsr310; +import java.io.IOException; +import java.time.*; + +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.dataformat.avro.AvroMapper; import com.fasterxml.jackson.dataformat.avro.AvroSchema; -import org.junit.Test; - -import java.io.IOException; -import java.time.Instant; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.LocalTime; -import java.time.OffsetDateTime; -import java.time.ZoneOffset; -import java.time.ZonedDateTime; import static org.assertj.core.api.Assertions.assertThat; diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schema/AvroSchemaGenerationTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schema/AvroSchemaGenerationTest.java index 3c70389ca..2a7d401d6 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schema/AvroSchemaGenerationTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schema/AvroSchemaGenerationTest.java @@ -3,14 +3,14 @@ import java.nio.ByteBuffer; import java.util.*; -import com.fasterxml.jackson.annotation.JsonAlias; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; +import org.apache.avro.Schema; +import org.junit.jupiter.api.Test; +import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.databind.exc.InvalidDefinitionException; import com.fasterxml.jackson.dataformat.avro.*; -import org.apache.avro.Schema; +import static org.junit.jupiter.api.Assertions.*; public class AvroSchemaGenerationTest extends AvroTestBase { @@ -60,6 +60,7 @@ public ByteBuffer getBytes() { private final AvroMapper MAPPER = newMapper(); + @Test public void testBasic() throws Exception { AvroSchemaGenerator gen = new AvroSchemaGenerator(); @@ -87,6 +88,7 @@ public void testBasic() throws Exception assertEquals(new HashSet(Arrays.asList("nm", "Name")), f.aliases()); } + @Test public void testEmployee() throws Exception { AvroSchemaGenerator gen = new AvroSchemaGenerator(); @@ -118,6 +120,7 @@ public void testEmployee() throws Exception assertEquals("Bobbee", e2.name); } + @Test public void testMap() throws Exception { AvroSchemaGenerator gen = new AvroSchemaGenerator(); @@ -136,6 +139,7 @@ public void testMap() throws Exception } // [Issue#8] + @Test public void testWithDate() throws Exception { AvroSchemaGenerator gen = new AvroSchemaGenerator(); @@ -144,6 +148,7 @@ public void testWithDate() throws Exception assertNotNull(schema); } + @Test public void testFixed() throws Exception { AvroSchemaGenerator gen = new AvroSchemaGenerator(); @@ -160,6 +165,7 @@ public void testFixed() throws Exception // as per [dataformats-binary#98], no can do (unless we start supporting polymorphic // handling or something...) + @Test public void testSchemaForUntypedMap() throws Exception { try { diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schema/AvroSchemaHelperTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schema/AvroSchemaHelperTest.java index bde4b8be9..95732bec3 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schema/AvroSchemaHelperTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schema/AvroSchemaHelperTest.java @@ -1,15 +1,22 @@ package com.fasterxml.jackson.dataformat.avro.schema; +import org.apache.avro.JsonProperties; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.JsonNodeFactory; + import static com.fasterxml.jackson.dataformat.avro.schema.AvroSchemaHelper.jsonNodeToObject; import static com.fasterxml.jackson.dataformat.avro.schema.AvroSchemaHelper.objectToJsonNode; -import junit.framework.TestCase; -import org.apache.avro.JsonProperties; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; + +public class AvroSchemaHelperTest +{ -public class AvroSchemaHelperTest extends TestCase { private static final JsonNodeFactory NODE_FACTORY = new ObjectMapper().getNodeFactory(); + @Test public void testObjectToJsonNode() { assertEquals(NODE_FACTORY.nullNode(), objectToJsonNode(null)); assertEquals(NODE_FACTORY.nullNode(), objectToJsonNode(JsonProperties.NULL_VALUE)); @@ -18,6 +25,7 @@ public void testObjectToJsonNode() { assertEquals(NODE_FACTORY.textNode("foo"), objectToJsonNode("foo")); } + @Test public void testJsonNodeToObject() { assertNull(jsonNodeToObject(null)); assertEquals(JsonProperties.NULL_VALUE, jsonNodeToObject(NODE_FACTORY.nullNode())); diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schema/DateTimeVisitor_builtAvroSchemaTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schema/DateTimeVisitor_builtAvroSchemaTest.java index 90261f1cb..058b1b4dc 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schema/DateTimeVisitor_builtAvroSchemaTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schema/DateTimeVisitor_builtAvroSchemaTest.java @@ -1,44 +1,23 @@ package com.fasterxml.jackson.dataformat.avro.schema; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.type.TypeFactory; +import java.time.*; +import java.util.Arrays; +import java.util.Collection; + import org.apache.avro.LogicalType; import org.apache.avro.Schema; import org.apache.avro.specific.SpecificData; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; -import java.time.Instant; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.LocalTime; -import java.time.OffsetDateTime; -import java.time.ZonedDateTime; -import java.util.Arrays; -import java.util.Collection; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.type.TypeFactory; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class DateTimeVisitor_builtAvroSchemaTest { - @Parameter(0) - public Class testClass; - - @Parameter(1) - public JsonParser.NumberType givenNumberType; - - @Parameter(2) - public Schema.Type expectedAvroType; - - @Parameter(3) - public String expectedLogicalType; - - @Parameters(name = "With {0} and number type {1}") - public static Collection testData() { + public static Collection testData() { return Arrays.asList(new Object[][]{ // Java type | given number type, | expected Avro type | expected logicalType { @@ -75,8 +54,12 @@ public static Collection testData() { }); } - @Test - public void builtAvroSchemaTest() { + @ParameterizedTest(name = "With {0} and number type {1}") + @MethodSource("testData") + public void builtAvroSchemaTest(Class testClass, + JsonParser.NumberType givenNumberType, Schema.Type expectedAvroType, + String expectedLogicalType) + { // GIVEN final TypeFactory tf = TypeFactory.createDefaultInstance(); DateTimeVisitor dateTimeVisitor = new DateTimeVisitor(tf.constructSimpleType(testClass, null)); diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schema/EnumSchema422Test.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schema/EnumSchema422Test.java index 819fe0e28..e3b2438c7 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schema/EnumSchema422Test.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schema/EnumSchema422Test.java @@ -1,12 +1,14 @@ package com.fasterxml.jackson.dataformat.avro.schema; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.annotation.JsonValue; - import com.fasterxml.jackson.dataformat.avro.AvroMapper; import com.fasterxml.jackson.dataformat.avro.AvroTestBase; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.fail; + // For [dataformats-binary#422] public class EnumSchema422Test extends AvroTestBase { diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schema/Enum_schemaCreationTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schema/Enum_schemaCreationTest.java index 7f23bf319..83550dba2 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schema/Enum_schemaCreationTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schema/Enum_schemaCreationTest.java @@ -1,14 +1,14 @@ package com.fasterxml.jackson.dataformat.avro.schema; -import static org.assertj.core.api.Assertions.assertThat; +import org.apache.avro.Schema; +import org.apache.avro.specific.SpecificData; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.dataformat.avro.AvroMapper; import com.fasterxml.jackson.dataformat.avro.AvroTestBase; -import org.apache.avro.Schema; -import org.apache.avro.specific.SpecificData; -import org.junit.Test; +import static org.assertj.core.api.Assertions.assertThat; public class Enum_schemaCreationTest extends AvroTestBase { diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schema/UUIDVisitor_builtAvroSchemaTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schema/UUIDVisitor_builtAvroSchemaTest.java index 847fb399a..6c271d7a9 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schema/UUIDVisitor_builtAvroSchemaTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schema/UUIDVisitor_builtAvroSchemaTest.java @@ -1,9 +1,8 @@ package com.fasterxml.jackson.dataformat.avro.schema; -import org.junit.Test; - import org.apache.avro.LogicalType; import org.apache.avro.Schema; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schema/VisitorFormatWrapperImpl_createChildWrapperTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schema/VisitorFormatWrapperImpl_createChildWrapperTest.java index f8ace325b..fdb6a8c42 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schema/VisitorFormatWrapperImpl_createChildWrapperTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schema/VisitorFormatWrapperImpl_createChildWrapperTest.java @@ -1,9 +1,10 @@ package com.fasterxml.jackson.dataformat.avro.schema; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.ser.DefaultSerializerProvider; -import org.assertj.core.api.Assertions; -import org.junit.Test; public class VisitorFormatWrapperImpl_createChildWrapperTest { diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schemaev/ArrayEvolutionTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schemaev/ArrayEvolutionTest.java index e0cb969f0..0e3bf8b10 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schemaev/ArrayEvolutionTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schemaev/ArrayEvolutionTest.java @@ -1,9 +1,13 @@ package com.fasterxml.jackson.dataformat.avro.schemaev; -import com.fasterxml.jackson.databind.JsonMappingException; +import org.junit.jupiter.api.Test; +import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.dataformat.avro.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; + public class ArrayEvolutionTest extends AvroTestBase { // NOTE! Avro requires names of record types to match; this is why type names @@ -92,6 +96,7 @@ public String toString() { /********************************************************************** */ + @Test public void testAddField() throws Exception { final AvroSchema srcSchema = MAPPER.schemaFrom(SCHEMA_XY_ARRAY_JSON); @@ -110,6 +115,7 @@ public void testAddField() throws Exception assertEquals(result[2], new PointXYZ(123456, 6, 99)); } + @Test public void testRemoveField() throws Exception { final AvroSchema srcSchema = MAPPER.schemaFrom(SCHEMA_XYZ_ARRAY_JSON); @@ -134,6 +140,7 @@ public void testRemoveField() throws Exception /********************************************************************** */ + @Test public void testFailNewFieldNoDefault() throws Exception { final AvroSchema srcSchema = MAPPER.schemaFrom(SCHEMA_X_ARRAY_JSON); diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schemaev/ComplexDefaultsTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schemaev/ComplexDefaultsTest.java index 0eb5b782b..ed04fae20 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schemaev/ComplexDefaultsTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schemaev/ComplexDefaultsTest.java @@ -1,10 +1,15 @@ package com.fasterxml.jackson.dataformat.avro.schemaev; -import java.util.*; +import java.util.List; +import java.util.Map; + +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.dataformat.avro.*; +import static org.junit.jupiter.api.Assertions.*; + public class ComplexDefaultsTest extends AvroTestBase { static String SCHEMA_V1_JSON = aposToQuotes("{\n"+ @@ -118,6 +123,7 @@ static class Metadata { /********************************************************************** */ + @Test public void testRecordDefaults() throws Exception { final AvroSchema srcSchema = MAPPER.schemaFrom(SCHEMA_V1_JSON); @@ -146,6 +152,7 @@ public void testRecordDefaults() throws Exception assertEquals("foobar", result.data.value); } + @Test public void testMapDefaults() throws Exception { final AvroSchema srcSchema = MAPPER.schemaFrom(SCHEMA_V1_JSON); @@ -166,6 +173,7 @@ public void testMapDefaults() throws Exception assertEquals("oobar", result.data.get("b")); } + @Test public void testListDefaults() throws Exception { final AvroSchema srcSchema = MAPPER.schemaFrom(SCHEMA_V1_JSON); diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schemaev/EnumEvolutionTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schemaev/EnumEvolutionTest.java index 23b886fe3..eacab4797 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schemaev/EnumEvolutionTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schemaev/EnumEvolutionTest.java @@ -1,7 +1,12 @@ package com.fasterxml.jackson.dataformat.avro.schemaev; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.dataformat.avro.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + public class EnumEvolutionTest extends AvroTestBase { protected final static String ENUM_SCHEMA1_JSON = "{\n" @@ -30,6 +35,7 @@ protected static class Employee { private final AvroMapper MAPPER = new AvroMapper(); + @Test public void testSimple() throws Exception { AvroSchema src = MAPPER.schemaFrom(ENUM_SCHEMA1_JSON); diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schemaev/RecordEvolutionTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schemaev/RecordEvolutionTest.java index afd572859..606e4f1c1 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schemaev/RecordEvolutionTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schemaev/RecordEvolutionTest.java @@ -1,13 +1,14 @@ package com.fasterxml.jackson.dataformat.avro.schemaev; +import java.util.*; + +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.dataformat.avro.*; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; + +import static org.junit.jupiter.api.Assertions.assertEquals; public class RecordEvolutionTest extends AvroTestBase { @@ -139,6 +140,7 @@ public String toString() { private final AvroMapper MAPPER = getMapper(); + @Test public void testEvolutionInvolvingComplexRecords() throws Exception { final AvroSchema schemaV1 = MAPPER.schemaFrom(SCHEMA_V1); diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schemaev/SimpleEvolutionTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schemaev/SimpleEvolutionTest.java index 9a79058ff..3e803c645 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schemaev/SimpleEvolutionTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schemaev/SimpleEvolutionTest.java @@ -3,14 +3,15 @@ import java.io.ByteArrayOutputStream; import java.util.Arrays; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.MappingIterator; -import com.fasterxml.jackson.databind.SequenceWriter; +import org.junit.jupiter.api.Test; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.dataformat.avro.*; import com.fasterxml.jackson.dataformat.avro.testsupport.LimitingInputStream; +import static org.junit.jupiter.api.Assertions.*; + public class SimpleEvolutionTest extends AvroTestBase { // NOTE! Avro requires named types to match; this is why type names @@ -176,6 +177,7 @@ public PointXBinaryY(int x0, int y0, byte[] b0) { /********************************************************************** */ + @Test public void testAddField() throws Exception { final AvroSchema srcSchema = MAPPER.schemaFrom(SCHEMA_XY_JSON); @@ -212,6 +214,7 @@ public void testAddField() throws Exception it.close(); } + @Test public void testRemoveField() throws Exception { final AvroSchema srcSchema = MAPPER.schemaFrom(SCHEMA_XYZ_JSON); @@ -246,6 +249,7 @@ public void testRemoveField() throws Exception it.close(); } + @Test public void testRemoveArrayField() throws Exception { final AvroSchema srcSchema = MAPPER.schemaFrom(SCHEMA_XAY_JSON); @@ -290,6 +294,7 @@ public void testRemoveArrayField() throws Exception it.close(); } + @Test public void testRemoveBinaryField() throws Exception { final AvroSchema srcSchema = MAPPER.schemaFrom(SCHEMA_XBY_JSON); @@ -313,6 +318,7 @@ public void testRemoveBinaryField() throws Exception /********************************************************************** */ + @Test public void testFailNewFieldNoDefault() throws Exception { final AvroSchema srcSchema = MAPPER.schemaFrom(SCHEMA_X_JSON); @@ -333,6 +339,7 @@ public void testFailNewFieldNoDefault() throws Exception assertNotNull(risky); } + @Test public void testFailNameChangeNoAlias() throws Exception { final AvroSchema srcSchema = MAPPER.schemaFrom(SCHEMA_XYZ_JSON); diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schemaev/UnionArrayEvolutionTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schemaev/UnionArrayEvolutionTest.java index a638225c1..59a6c6932 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schemaev/UnionArrayEvolutionTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schemaev/UnionArrayEvolutionTest.java @@ -1,11 +1,13 @@ package com.fasterxml.jackson.dataformat.avro.schemaev; -import com.fasterxml.jackson.dataformat.avro.AvroMapper; -import com.fasterxml.jackson.dataformat.avro.AvroSchema; -import com.fasterxml.jackson.dataformat.avro.AvroTestBase; - import java.util.List; +import org.junit.jupiter.api.Test; + +import com.fasterxml.jackson.dataformat.avro.*; + +import static org.junit.jupiter.api.Assertions.assertEquals; + public class UnionArrayEvolutionTest extends AvroTestBase { static String SCHEMA_V1_ARRAY_JSON = aposToQuotes("{\n"+ @@ -65,6 +67,7 @@ public V2(String id, List names) { /********************************************************** */ + @Test public void testRoundtripToOlderCompatibleSchema() throws Exception { final AvroSchema srcSchema = MAPPER.schemaFrom(SCHEMA_V2_ARRAY_JSON); diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schemaev/UnionMapEvolutionTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schemaev/UnionMapEvolutionTest.java index 858bc0704..240202ec7 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schemaev/UnionMapEvolutionTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schemaev/UnionMapEvolutionTest.java @@ -1,11 +1,13 @@ package com.fasterxml.jackson.dataformat.avro.schemaev; -import com.fasterxml.jackson.dataformat.avro.AvroMapper; -import com.fasterxml.jackson.dataformat.avro.AvroSchema; -import com.fasterxml.jackson.dataformat.avro.AvroTestBase; - import java.util.Map; +import org.junit.jupiter.api.Test; + +import com.fasterxml.jackson.dataformat.avro.*; + +import static org.junit.jupiter.api.Assertions.assertEquals; + public class UnionMapEvolutionTest extends AvroTestBase { static String SCHEMA_V1_ARRAY_JSON = aposToQuotes("{\n"+ @@ -65,6 +67,7 @@ public V2(String id, Map names) { /********************************************************** */ + @Test public void testRoundtripToOlderCompatibleSchema() throws Exception { final AvroSchema srcSchema = MAPPER.schemaFrom(SCHEMA_V2_ARRAY_JSON); diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schemaev/UnionRecordEvolutionTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schemaev/UnionRecordEvolutionTest.java index 15fc6a3d9..6f46d912d 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schemaev/UnionRecordEvolutionTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/schemaev/UnionRecordEvolutionTest.java @@ -1,8 +1,10 @@ package com.fasterxml.jackson.dataformat.avro.schemaev; -import com.fasterxml.jackson.dataformat.avro.AvroMapper; -import com.fasterxml.jackson.dataformat.avro.AvroSchema; -import com.fasterxml.jackson.dataformat.avro.AvroTestBase; +import org.junit.jupiter.api.Test; + +import com.fasterxml.jackson.dataformat.avro.*; + +import static org.junit.jupiter.api.Assertions.assertEquals; public class UnionRecordEvolutionTest extends AvroTestBase { @@ -84,6 +86,7 @@ public Names(String firstName) { /********************************************************** */ + @Test public void testRoundtripToOlderCompatibleSchema() throws Exception { final AvroSchema srcSchema = MAPPER.schemaFrom(SCHEMA_V2_ARRAY_JSON); final AvroSchema dstSchema = MAPPER.schemaFrom(SCHEMA_V1_ARRAY_JSON); diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/testsupport/ThrottledInputStream.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/testsupport/ThrottledInputStream.java index 429af25af..c6628101b 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/testsupport/ThrottledInputStream.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/testsupport/ThrottledInputStream.java @@ -1,9 +1,6 @@ package com.fasterxml.jackson.dataformat.avro.testsupport; -import java.io.ByteArrayInputStream; -import java.io.FilterInputStream; -import java.io.IOException; -import java.io.InputStream; +import java.io.*; public class ThrottledInputStream extends FilterInputStream { diff --git a/avro/src/test/java/perf/PerfBase.java b/avro/src/test/java/perf/PerfBase.java index ed95f65ba..04b194918 100644 --- a/avro/src/test/java/perf/PerfBase.java +++ b/avro/src/test/java/perf/PerfBase.java @@ -1,6 +1,7 @@ package perf; -import java.io.*; +import java.io.ByteArrayInputStream; +import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -10,10 +11,7 @@ import org.apache.avro.io.DecoderFactory; import org.apache.avro.io.EncoderFactory; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.ObjectReader; -import com.fasterxml.jackson.databind.ObjectWriter; -import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.dataformat.avro.AvroFactory; import com.fasterxml.jackson.dataformat.avro.AvroSchema; diff --git a/avro/src/test/java/perf/SerPerf.java b/avro/src/test/java/perf/SerPerf.java index a4f621e58..8bc59eb0a 100644 --- a/avro/src/test/java/perf/SerPerf.java +++ b/avro/src/test/java/perf/SerPerf.java @@ -1,6 +1,6 @@ package perf; -import java.io.*; +import java.io.ByteArrayOutputStream; import org.apache.avro.generic.GenericDatumWriter; import org.apache.avro.generic.GenericRecord; diff --git a/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/ByteAccumulator.java b/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/ByteAccumulator.java index 0f0bafcd5..00cfb57c9 100644 --- a/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/ByteAccumulator.java +++ b/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/ByteAccumulator.java @@ -1,6 +1,7 @@ package com.fasterxml.jackson.dataformat.protobuf; -import java.io.*; +import java.io.IOException; +import java.io.OutputStream; /** * Helper object used for buffering content for cases where we need (byte-)length prefixes diff --git a/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/ProtobufFactory.java b/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/ProtobufFactory.java index c6b7fbe71..a780ec78e 100644 --- a/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/ProtobufFactory.java +++ b/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/ProtobufFactory.java @@ -6,8 +6,8 @@ import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.core.format.InputAccessor; import com.fasterxml.jackson.core.format.MatchStrength; -import com.fasterxml.jackson.core.io.IOContext; import com.fasterxml.jackson.core.io.ContentReference; +import com.fasterxml.jackson.core.io.IOContext; import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchema; public class ProtobufFactory extends JsonFactory diff --git a/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/ProtobufGenerator.java b/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/ProtobufGenerator.java index d738ff404..2806cc812 100644 --- a/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/ProtobufGenerator.java +++ b/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/ProtobufGenerator.java @@ -1,6 +1,7 @@ package com.fasterxml.jackson.dataformat.protobuf; -import java.io.*; +import java.io.IOException; +import java.io.OutputStream; import java.math.BigDecimal; import java.math.BigInteger; import java.nio.charset.Charset; @@ -10,11 +11,7 @@ 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.protobuf.schema.FieldType; -import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufField; -import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufMessage; -import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchema; -import com.fasterxml.jackson.dataformat.protobuf.schema.WireType; +import com.fasterxml.jackson.dataformat.protobuf.schema.*; public class ProtobufGenerator extends GeneratorBase { diff --git a/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/ProtobufMapper.java b/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/ProtobufMapper.java index c78a3f7b1..4226a961b 100644 --- a/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/ProtobufMapper.java +++ b/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/ProtobufMapper.java @@ -1,21 +1,14 @@ package com.fasterxml.jackson.dataformat.protobuf; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; +import java.io.*; import java.net.URL; import java.util.concurrent.locks.ReentrantLock; import com.fasterxml.jackson.core.Version; import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.cfg.MapperBuilder; -import com.fasterxml.jackson.dataformat.protobuf.schema.DescriptorLoader; -import com.fasterxml.jackson.dataformat.protobuf.schema.FileDescriptorSet; -import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchema; -import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchemaLoader; +import com.fasterxml.jackson.dataformat.protobuf.schema.*; import com.fasterxml.jackson.dataformat.protobuf.schemagen.ProtobufSchemaGenerator; public class ProtobufMapper extends ObjectMapper diff --git a/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/ProtobufParser.java b/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/ProtobufParser.java index 6f673bd1b..8551ea819 100644 --- a/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/ProtobufParser.java +++ b/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/ProtobufParser.java @@ -8,11 +8,7 @@ import com.fasterxml.jackson.core.base.ParserMinimalBase; import com.fasterxml.jackson.core.io.IOContext; import com.fasterxml.jackson.core.io.NumberInput; -import com.fasterxml.jackson.core.util.ByteArrayBuilder; -import com.fasterxml.jackson.core.util.JacksonFeatureSet; -import com.fasterxml.jackson.core.util.TextBuffer; -import com.fasterxml.jackson.core.util.VersionUtil; - +import com.fasterxml.jackson.core.util.*; import com.fasterxml.jackson.dataformat.protobuf.schema.*; public class ProtobufParser extends ParserMinimalBase diff --git a/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/ProtobufReadContext.java b/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/ProtobufReadContext.java index 0a9b41ee5..8fa1b849c 100644 --- a/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/ProtobufReadContext.java +++ b/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/ProtobufReadContext.java @@ -1,6 +1,7 @@ package com.fasterxml.jackson.dataformat.protobuf; -import com.fasterxml.jackson.core.*; +import com.fasterxml.jackson.core.JsonLocation; +import com.fasterxml.jackson.core.JsonStreamContext; import com.fasterxml.jackson.core.io.CharTypes; import com.fasterxml.jackson.core.io.ContentReference; import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufField; diff --git a/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schema/DescriptorLoader.java b/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schema/DescriptorLoader.java index 30fe0c739..3f5e2c66a 100644 --- a/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schema/DescriptorLoader.java +++ b/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schema/DescriptorLoader.java @@ -1,9 +1,6 @@ package com.fasterxml.jackson.dataformat.protobuf.schema; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.Reader; +import java.io.*; import java.net.URL; import com.fasterxml.jackson.databind.ObjectMapper; diff --git a/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schema/FieldLookup.java b/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schema/FieldLookup.java index 3965cd575..31e0f4a57 100644 --- a/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schema/FieldLookup.java +++ b/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schema/FieldLookup.java @@ -1,6 +1,6 @@ package com.fasterxml.jackson.dataformat.protobuf.schema; -import java.util.*; +import java.util.Arrays; /** * Helper class used for cases where {@link ProtobufField} instances diff --git a/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schema/FieldTypes.java b/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schema/FieldTypes.java index 9ef45e7ca..7a3e8862a 100644 --- a/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schema/FieldTypes.java +++ b/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schema/FieldTypes.java @@ -1,6 +1,6 @@ package com.fasterxml.jackson.dataformat.protobuf.schema; -import java.util.*; +import java.util.EnumMap; import com.squareup.protoparser.DataType; diff --git a/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schema/FileDescriptorSet.java b/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schema/FileDescriptorSet.java index 1d04e3031..50834f1be 100644 --- a/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schema/FileDescriptorSet.java +++ b/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schema/FileDescriptorSet.java @@ -3,13 +3,7 @@ import java.util.EnumMap; import java.util.Map; -import com.squareup.protoparser.DataType; -import com.squareup.protoparser.EnumConstantElement; -import com.squareup.protoparser.EnumElement; -import com.squareup.protoparser.FieldElement; -import com.squareup.protoparser.MessageElement; -import com.squareup.protoparser.OptionElement; -import com.squareup.protoparser.ProtoFile; +import com.squareup.protoparser.*; /** * @since 2.9 diff --git a/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schema/ProtobufField.java b/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schema/ProtobufField.java index 75e5767a4..619b5ac1a 100644 --- a/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schema/ProtobufField.java +++ b/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schema/ProtobufField.java @@ -1,11 +1,12 @@ package com.fasterxml.jackson.dataformat.protobuf.schema; -import java.util.*; +import java.util.Collection; -import com.fasterxml.jackson.core.SerializableString; import com.squareup.protoparser.FieldElement; import com.squareup.protoparser.OptionElement; +import com.fasterxml.jackson.core.SerializableString; + public class ProtobufField // sorted in increasing order implements Comparable diff --git a/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schema/ProtobufMessage.java b/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schema/ProtobufMessage.java index 5033ea181..318cb9d14 100644 --- a/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schema/ProtobufMessage.java +++ b/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schema/ProtobufMessage.java @@ -1,6 +1,6 @@ package com.fasterxml.jackson.dataformat.protobuf.schema; -import java.util.*; +import java.util.Arrays; import com.fasterxml.jackson.core.SerializableString; diff --git a/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schema/TypeResolver.java b/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schema/TypeResolver.java index 1ad5f735f..ca0099ced 100644 --- a/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schema/TypeResolver.java +++ b/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schema/TypeResolver.java @@ -2,9 +2,10 @@ import java.util.*; -import com.fasterxml.jackson.core.util.InternCache; import com.squareup.protoparser.*; +import com.fasterxml.jackson.core.util.InternCache; + /** * Stateful class needed to properly resolve type definitions of * protobuf message (and related types); some complexity coming diff --git a/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schemagen/DefinedTypeElementBuilders.java b/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schemagen/DefinedTypeElementBuilders.java index 8eaaa3af9..204b121d9 100644 --- a/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schemagen/DefinedTypeElementBuilders.java +++ b/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schemagen/DefinedTypeElementBuilders.java @@ -1,10 +1,6 @@ package com.fasterxml.jackson.dataformat.protobuf.schemagen; -import java.util.Collection; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Set; +import java.util.*; import com.fasterxml.jackson.databind.JavaType; diff --git a/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schemagen/EnumElementVisitor.java b/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schemagen/EnumElementVisitor.java index 34f17b22b..9c39a7908 100644 --- a/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schemagen/EnumElementVisitor.java +++ b/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schemagen/EnumElementVisitor.java @@ -2,12 +2,11 @@ import java.util.Set; +import com.squareup.protoparser.*; + import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonStringFormatVisitor.Base; -import com.squareup.protoparser.EnumConstantElement; -import com.squareup.protoparser.EnumElement; -import com.squareup.protoparser.TypeElement; public class EnumElementVisitor extends Base implements TypeElementBuilder { diff --git a/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schemagen/MessageElementVisitor.java b/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schemagen/MessageElementVisitor.java index 27f6567a8..b2cbf6e82 100644 --- a/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schemagen/MessageElementVisitor.java +++ b/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schemagen/MessageElementVisitor.java @@ -3,17 +3,14 @@ import java.util.HashSet; import java.util.Set; -import com.fasterxml.jackson.databind.*; -import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitable; -import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonObjectFormatVisitor; - -import com.squareup.protoparser.DataType; +import com.squareup.protoparser.*; import com.squareup.protoparser.DataType.NamedType; import com.squareup.protoparser.DataType.ScalarType; -import com.squareup.protoparser.FieldElement; import com.squareup.protoparser.FieldElement.Label; -import com.squareup.protoparser.MessageElement; -import com.squareup.protoparser.TypeElement; + +import com.fasterxml.jackson.databind.*; +import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitable; +import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonObjectFormatVisitor; public class MessageElementVisitor extends JsonObjectFormatVisitor.Base implements TypeElementBuilder diff --git a/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schemagen/ProtoBufSchemaVisitor.java b/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schemagen/ProtoBufSchemaVisitor.java index 1dddec866..9e78e0b66 100644 --- a/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schemagen/ProtoBufSchemaVisitor.java +++ b/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schemagen/ProtoBufSchemaVisitor.java @@ -3,15 +3,15 @@ import java.util.LinkedHashSet; import java.util.Set; +import com.squareup.protoparser.DataType; +import com.squareup.protoparser.DataType.ScalarType; +import com.squareup.protoparser.TypeElement; + import com.fasterxml.jackson.core.JsonParser.NumberType; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.jsonFormatVisitors.*; -import com.squareup.protoparser.DataType; -import com.squareup.protoparser.TypeElement; -import com.squareup.protoparser.DataType.ScalarType; - public class ProtoBufSchemaVisitor extends JsonFormatVisitorWrapper.Base implements TypeElementBuilder { diff --git a/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schemagen/ProtobufSchemaGenerator.java b/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schemagen/ProtobufSchemaGenerator.java index cfc374b5d..6bfb2e4fd 100644 --- a/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schemagen/ProtobufSchemaGenerator.java +++ b/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schemagen/ProtobufSchemaGenerator.java @@ -7,7 +7,6 @@ import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.jsonFormatVisitors.*; - import com.fasterxml.jackson.dataformat.protobuf.schema.NativeProtobufSchema; import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchema; diff --git a/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schemagen/ProtobufSchemaHelper.java b/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schemagen/ProtobufSchemaHelper.java index 7a43f0c60..942503e8e 100644 --- a/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schemagen/ProtobufSchemaHelper.java +++ b/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schemagen/ProtobufSchemaHelper.java @@ -3,7 +3,8 @@ import java.nio.ByteBuffer; import java.util.UUID; -import com.fasterxml.jackson.databind.*; +import com.fasterxml.jackson.databind.BeanProperty; +import com.fasterxml.jackson.databind.JavaType; public class ProtobufSchemaHelper { diff --git a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/EnumHandlingTest.java b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/EnumHandlingTest.java index 3349933b7..a18d22192 100644 --- a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/EnumHandlingTest.java +++ b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/EnumHandlingTest.java @@ -1,10 +1,15 @@ package com.fasterxml.jackson.dataformat.protobuf; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectReader; import com.fasterxml.jackson.databind.ObjectWriter; import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchema; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + public class EnumHandlingTest extends ProtobufTestBase { enum TinyEnum { @@ -38,6 +43,7 @@ static class BigEnumWrapper { final ProtobufMapper MAPPER = newObjectMapper(); + @Test public void testBigEnum() throws Exception { ProtobufSchema schema = MAPPER.generateSchemaFor(BigEnumWrapper.class); @@ -55,6 +61,7 @@ public void testBigEnum() throws Exception assertEquals(input.value, result.value); } + @Test public void testTinyEnum() throws Exception { ProtobufSchema schema = MAPPER.generateSchemaFor(TinyEnumWrapper.class); diff --git a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/FactoryPropertiesTest.java b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/FactoryPropertiesTest.java index 492e9793e..64e608eb5 100644 --- a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/FactoryPropertiesTest.java +++ b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/FactoryPropertiesTest.java @@ -2,14 +2,15 @@ import java.io.*; -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.StreamReadCapability; -import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.jupiter.api.Test; +import com.fasterxml.jackson.core.*; +import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchema; import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchemaLoader; +import static org.junit.jupiter.api.Assertions.*; + public class FactoryPropertiesTest extends ProtobufTestBase { final ProtobufSchema POINT_SCHEMA; @@ -22,6 +23,7 @@ public FactoryPropertiesTest() throws IOException { POINT_SCHEMA = ProtobufSchemaLoader.std.parse(PROTOC_BOX, "Point"); } + @Test public void testProtoFactorySerializable() throws Exception { ProtobufFactory f = new ProtobufFactory(); @@ -34,6 +36,7 @@ public void testProtoFactorySerializable() throws Exception assertNotNull(f2); } + @Test public void testProtoFactoryCopy() throws Exception { ProtobufFactory f2 = PROTO_F.copy(); @@ -43,6 +46,7 @@ public void testProtoFactoryCopy() throws Exception assertNotNull(doc); } + @Test public void testVersions() throws Exception { ProtobufFactory f = PROTO_F; @@ -60,6 +64,7 @@ public void testVersions() throws Exception p.close(); } + @Test public void testCapabilities() throws Exception { assertTrue(PROTO_F.canHandleBinaryNatively()); @@ -68,6 +73,7 @@ public void testCapabilities() throws Exception assertNull(PROTO_F.getFormatWriteFeatureType()); } + @Test public void testInabilityToReadChars() throws Exception { final String EXP = "non-byte-based source"; @@ -91,6 +97,7 @@ public void testInabilityToReadChars() throws Exception } } + @Test public void testInabilityToWriteChars() throws Exception { try { @@ -102,6 +109,7 @@ public void testInabilityToWriteChars() throws Exception } // @since 2.14 + @Test public void testStreamReadCapabilities() throws Exception { byte[] doc = _writeDoc(PROTO_F); diff --git a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/NestedWrite67Test.java b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/NestedWrite67Test.java index feffbc185..c868da54d 100644 --- a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/NestedWrite67Test.java +++ b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/NestedWrite67Test.java @@ -1,10 +1,13 @@ package com.fasterxml.jackson.dataformat.protobuf; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; - import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchema; +import static org.junit.jupiter.api.Assertions.assertEquals; + public class NestedWrite67Test extends ProtobufTestBase { @JsonPropertyOrder({ "value1", "level2" }) @@ -36,6 +39,7 @@ public static class Level3 { /********************************************************** */ + @Test public void testIssue67() throws Exception { ProtobufSchema schema = MAPPER.generateSchemaFor(Level1.class); diff --git a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/NextXxxParsingTest.java b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/NextXxxParsingTest.java index 1b45fc4a8..1d70a3291 100644 --- a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/NextXxxParsingTest.java +++ b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/NextXxxParsingTest.java @@ -1,5 +1,7 @@ package com.fasterxml.jackson.dataformat.protobuf; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonToken; import com.fasterxml.jackson.core.io.SerializedString; @@ -8,6 +10,8 @@ import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchema; import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchemaLoader; +import static org.junit.jupiter.api.Assertions.*; + public class NextXxxParsingTest extends ProtobufTestBase { final private static String PROTOC_STRINGS = @@ -25,6 +29,7 @@ public Strings() { } final ObjectMapper MAPPER = new ObjectMapper(new ProtobufFactory()); + @Test public void testNextFieldAndText() throws Exception { ProtobufSchema schema = ProtobufSchemaLoader.std.parse(PROTOC_STRINGS); @@ -63,6 +68,7 @@ public void testNextFieldAndText() throws Exception p.close(); } + @Test public void testNextInt() throws Exception { ProtobufSchema point3Schema = ProtobufSchemaLoader.std.parse(PROTOC_POINT3); diff --git a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/ProtobufTestBase.java b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/ProtobufTestBase.java index 56551cdc4..bdfc10309 100644 --- a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/ProtobufTestBase.java +++ b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/ProtobufTestBase.java @@ -1,18 +1,16 @@ package com.fasterxml.jackson.dataformat.protobuf; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; +import java.util.*; -import com.fasterxml.jackson.core.*; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufField; import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufMessage; -import junit.framework.TestCase; - -import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import static org.junit.jupiter.api.Assertions.fail; -public abstract class ProtobufTestBase extends TestCase +public abstract class ProtobufTestBase { /* /********************************************************** diff --git a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/ReadComplexPojoTest.java b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/ReadComplexPojoTest.java index d09190f53..d49767a41 100644 --- a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/ReadComplexPojoTest.java +++ b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/ReadComplexPojoTest.java @@ -3,14 +3,17 @@ import java.io.ByteArrayInputStream; import java.io.InputStream; -import org.junit.Assert; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import com.fasterxml.jackson.databind.*; +import com.fasterxml.jackson.databind.ObjectReader; +import com.fasterxml.jackson.databind.ObjectWriter; import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchema; import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchemaLoader; import com.fasterxml.jackson.dataformat.protobuf.testutil.LimitingInputStream; +import static org.junit.jupiter.api.Assertions.*; + public class ReadComplexPojoTest extends ProtobufTestBase { @JsonPropertyOrder({ "b", "i", "l", "d" }) @@ -42,11 +45,13 @@ public PojoWithArrays(boolean[] b, final ProtobufMapper MAPPER = new ProtobufMapper(); + @Test public void testMediaItemSimple() throws Exception { _testMediaItem(false); } + @Test public void testMediaItemWithSmallReads() throws Exception { _testMediaItem(true); @@ -76,11 +81,12 @@ private void _testMediaItem(boolean smallReads) throws Exception byte[] b2 = w.writeValueAsBytes(result); assertEquals(bytes.length, b2.length); - Assert.assertArrayEquals(bytes, b2); + assertArrayEquals(bytes, b2); assertEquals(input, result); } + @Test public void testPojoWithArrays() throws Exception { _testPojoWithArrays(false); @@ -114,9 +120,9 @@ private void _testPojoWithArrays(boolean smallReads) throws Exception PojoWithArrays result = r.readValue(in); assertNotNull(result); - Assert.assertArrayEquals(input.i, result.i); - Assert.assertArrayEquals(input.l, result.l); - Assert.assertArrayEquals(input.b, result.b); + assertArrayEquals(input.i, result.i); + assertArrayEquals(input.l, result.l); + assertArrayEquals(input.b, result.b); assertEquals(input.d.length, result.d.length); for (int ix = 0; ix < input.d.length; ++ix) { assertEquals(input.d[ix], result.d[ix]); @@ -126,7 +132,7 @@ private void _testPojoWithArrays(boolean smallReads) throws Exception byte[] b2 = w.writeValueAsBytes(result); assertEquals(bytes.length, b2.length); - Assert.assertArrayEquals(bytes, b2); + assertArrayEquals(bytes, b2); // and then see what happens if empty arrays are passed; expecting empty // (all fields missing, since zero-length arrays can not be represented) diff --git a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/ReadNestedUnknownFieldsTest.java b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/ReadNestedUnknownFieldsTest.java index 6babc763f..a97ef19b6 100644 --- a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/ReadNestedUnknownFieldsTest.java +++ b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/ReadNestedUnknownFieldsTest.java @@ -3,11 +3,15 @@ import java.util.Arrays; import java.util.List; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchema; +import static org.junit.jupiter.api.Assertions.assertEquals; + public class ReadNestedUnknownFieldsTest extends ProtobufTestBase { // [dataformats-binary#108] @@ -125,6 +129,7 @@ public static class Embed { private final ProtobufMapper MAPPER = new ProtobufMapper(); // [dataformats-binary#108] + @Test public void testMultipleUnknown() throws Exception { MoreNestedField moreNestedField = new MoreNestedField(); @@ -147,6 +152,7 @@ public void testMultipleUnknown() throws Exception } // [dataformats-binary#126] + @Test public void testCheckEndAfterSkip() throws Exception { ProtobufMapper mapper = new ProtobufMapper(); diff --git a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/ReadPackedRepeatedTest.java b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/ReadPackedRepeatedTest.java index c1e834c7a..a59f8315c 100644 --- a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/ReadPackedRepeatedTest.java +++ b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/ReadPackedRepeatedTest.java @@ -1,12 +1,17 @@ package com.fasterxml.jackson.dataformat.protobuf; +import java.io.StringReader; + +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchema; -import java.io.StringReader; +import static org.junit.jupiter.api.Assertions.assertEquals; public class ReadPackedRepeatedTest extends ProtobufTestBase { + @Test public void testPacked() throws Exception { final ProtobufMapper mapper = newObjectMapper(); diff --git a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/ReadSimpleTest.java b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/ReadSimpleTest.java index cfef5430b..bfec52d69 100644 --- a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/ReadSimpleTest.java +++ b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/ReadSimpleTest.java @@ -3,18 +3,17 @@ import java.io.ByteArrayOutputStream; import java.io.StringWriter; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonToken; +import org.junit.jupiter.api.Test; -import com.fasterxml.jackson.core.StreamReadConstraints; +import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.core.JsonParser.NumberType; import com.fasterxml.jackson.core.JsonParser.NumberTypeFP; -import com.fasterxml.jackson.databind.DatabindException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.ObjectWriter; +import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchema; import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchemaLoader; +import static org.junit.jupiter.api.Assertions.*; + public class ReadSimpleTest extends ProtobufTestBase { final protected static String PROTOC_STRINGS = @@ -62,6 +61,7 @@ public NamedStrings(String n, String... v) { private final ObjectMapper MAPPER = newObjectMapper(); + @Test public void testReadPointIntAsPOJO() throws Exception { ProtobufSchema schema = ProtobufSchemaLoader.std.parse(PROTOC_BOX, "Point"); @@ -80,6 +80,7 @@ public void testReadPointIntAsPOJO() throws Exception assertEquals(input.y, result.y); } + @Test public void testReadPointIntStreaming() throws Exception { ProtobufSchema schema = ProtobufSchemaLoader.std.parse(PROTOC_BOX, "Point"); @@ -112,6 +113,7 @@ public void testReadPointIntStreaming() throws Exception assertNull(p.currentName()); } + @Test public void testReadPointLong() throws Exception { ProtobufSchema schema = ProtobufSchemaLoader.std.parse(PROTOC_POINT_L); @@ -156,6 +158,7 @@ public void testReadPointLong() throws Exception } } + @Test public void testReadName() throws Exception { ProtobufSchema schema = ProtobufSchemaLoader.std.parse(PROTOC_NAME); @@ -175,6 +178,7 @@ public void testReadName() throws Exception assertEquals(input.last, result.last); } + @Test public void testReadBox() throws Exception { final ProtobufSchema schema = ProtobufSchemaLoader.std.parse(PROTOC_BOX); @@ -243,6 +247,7 @@ public void testReadBox() throws Exception } } + @Test public void testStringArraySimple() throws Exception { ProtobufSchema schema = ProtobufSchemaLoader.std.parse(PROTOC_STRINGS); @@ -310,6 +315,7 @@ public void testStringArraySimple() throws Exception assertNull(p.nextToken()); } + @Test public void testStringArrayPacked() throws Exception { ProtobufSchema schema = ProtobufSchemaLoader.std.parse(PROTOC_STRINGS_PACKED); @@ -330,6 +336,7 @@ public void testStringArrayPacked() throws Exception } } + @Test public void testStringArrayWithName() throws Exception { ProtobufSchema schema = ProtobufSchemaLoader.std.parse(PROTOC_NAMED_STRINGS); @@ -392,6 +399,7 @@ public void testStringArrayWithName() throws Exception p.close(); } + @Test public void testSearchMessage() throws Exception { ProtobufSchema schema = ProtobufSchemaLoader.std.parse(PROTOC_SEARCH_REQUEST); @@ -416,6 +424,7 @@ public void testSearchMessage() throws Exception assertEquals(input.corpus, result.corpus); } + @Test public void testSkipUnknown() throws Exception { ProtobufSchema pointSchema = ProtobufSchemaLoader.std.parse(PROTOC_POINT); @@ -436,6 +445,7 @@ public void testSkipUnknown() throws Exception assertEquals(input.y, result.y); } + @Test public void testStringArraySimpleLowLimit() throws Exception { ProtobufSchema schema = ProtobufSchemaLoader.std.parse(PROTOC_STRINGS); @@ -455,8 +465,8 @@ public void testStringArraySimpleLowLimit() throws Exception fail("Expected DatabindException"); } catch (DatabindException jme) { String message = jme.getMessage(); - assertTrue("unexpected message: " + message, - message.startsWith("String value length (4) exceeds the maximum allowed")); + assertTrue(message.startsWith("String value length (4) exceeds the maximum allowed"), + "unexpected message: " + message); } } } diff --git a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/ReadUnknownFields202Test.java b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/ReadUnknownFields202Test.java index c70fef12f..d30aecd80 100644 --- a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/ReadUnknownFields202Test.java +++ b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/ReadUnknownFields202Test.java @@ -1,15 +1,15 @@ package com.fasterxml.jackson.dataformat.protobuf; -import com.fasterxml.jackson.annotation.JsonProperty; +import org.junit.jupiter.api.Test; +import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.core.JsonParser; - import com.fasterxml.jackson.databind.MapperFeature; - import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchema; import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchemaLoader; -// [dataformats-binary#202] +import static org.junit.jupiter.api.Assertions.assertEquals; + public class ReadUnknownFields202Test extends ProtobufTestBase { // [dataformats-binary#202] @@ -108,6 +108,7 @@ public String getSource() { */ // [dataformats-binary#202] + @Test public void testV1toV0() throws Exception { final ProtobufMapper MAPPER = newMapperBuilder() .enable(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY) diff --git a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/ReadUnkownFieldsTest.java b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/ReadUnkownFieldsTest.java index 756d5fb89..ea4a29243 100644 --- a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/ReadUnkownFieldsTest.java +++ b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/ReadUnkownFieldsTest.java @@ -1,11 +1,13 @@ package com.fasterxml.jackson.dataformat.protobuf; -import com.fasterxml.jackson.annotation.*; - -import com.fasterxml.jackson.core.*; +import org.junit.jupiter.api.Test; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchema; +import static org.junit.jupiter.api.Assertions.assertEquals; + public class ReadUnkownFieldsTest extends ProtobufTestBase { static class OneField { @@ -64,6 +66,7 @@ public void setF3(int f3) { /********************************************************** */ + @Test public void testMultipleUnknown() throws Exception { final ProtobufMapper mapper = newObjectMapper(); diff --git a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/RoundtripNestedMessageTest.java b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/RoundtripNestedMessageTest.java index b03a13fea..21133a2ae 100644 --- a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/RoundtripNestedMessageTest.java +++ b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/RoundtripNestedMessageTest.java @@ -2,14 +2,17 @@ import java.io.IOException; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import org.junit.jupiter.api.Test; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonToken; - import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchema; import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchemaLoader; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; + public class RoundtripNestedMessageTest extends ProtobufTestBase { private static final String VALUE_A = "value"; @@ -112,6 +115,7 @@ static class Employee135 { private final ProtobufMapper MAPPER = new ProtobufMapper(); + @Test public void testNestedRoundtrip() throws IOException { TestObject testClass = new TestObject(); @@ -136,6 +140,7 @@ public void testNestedRoundtrip() throws IOException } // [dataformats-binary#135]: endless END_OBJECT at end of doc + @Test public void testIssue135() throws Exception { String protobuf_str = "message Employee {\n" diff --git a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/SerDeserLongTest.java b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/SerDeserLongTest.java index ca37d56e6..9d307ff61 100644 --- a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/SerDeserLongTest.java +++ b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/SerDeserLongTest.java @@ -1,11 +1,12 @@ package com.fasterxml.jackson.dataformat.protobuf; +import java.io.IOException; + +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchema; import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchemaLoader; -import org.junit.Test; - -import java.io.IOException; /** * Created by miz on 8/10/16. diff --git a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/WriteArrayTest.java b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/WriteArrayTest.java index 256c7c3bb..c6c92e5d8 100644 --- a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/WriteArrayTest.java +++ b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/WriteArrayTest.java @@ -1,12 +1,15 @@ package com.fasterxml.jackson.dataformat.protobuf; -import org.junit.Assert; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectWriter; import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchema; import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchemaLoader; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; + public class WriteArrayTest extends ProtobufTestBase { final protected static String PROTOC_STRING_ARRAY_SPARSE = "message Strings {\n" @@ -63,23 +66,25 @@ public WriteArrayTest() throws Exception { /********************************************************** */ + @Test public void testStringArraySparse() throws Exception { final ObjectWriter w = MAPPER.writer(SPARSE_STRING_SCHEMA); byte[] bytes = w.writeValueAsBytes(new StringArray("Foo", "Bar")); assertEquals(10, bytes.length); - Assert.assertArrayEquals(new byte[] { + assertArrayEquals(new byte[] { 0xA, 3, 'F', 'o', 'o', 0xA, 3, 'B', 'a', 'r', }, bytes); } + @Test public void testStringArrayPacked() throws Exception { final ObjectWriter w = MAPPER.writer(PACKED_STRING_SCHEMA); byte[] bytes = w.writeValueAsBytes(new StringArray("A", "B", "C")); assertEquals(8, bytes.length); - Assert.assertArrayEquals(new byte[] { + assertArrayEquals(new byte[] { 0xA, 6, 1, 'A', 1, 'B', @@ -93,6 +98,7 @@ public void testStringArrayPacked() throws Exception /********************************************************** */ + @Test public void testPointArraySparse() throws Exception { final ObjectWriter w = MAPPER.writer(ProtobufSchemaLoader.std.parse(PROTOC_POINT_ARRAY_SPARSE)); @@ -116,6 +122,7 @@ public void testPointArraySparse() throws Exception assertEquals(8, bytes[11]); // Point (, 4) } + @Test public void testPointArrayPacked() throws Exception { final ObjectWriter w = MAPPER.writer(ProtobufSchemaLoader.std.parse(PROTOC_POINT_ARRAY_PACKED)); diff --git a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/WriteAsMapTest.java b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/WriteAsMapTest.java index 4206772e4..6e02a2b12 100644 --- a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/WriteAsMapTest.java +++ b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/WriteAsMapTest.java @@ -2,9 +2,13 @@ import java.util.*; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.dataformat.protobuf.schema.*; +import static org.junit.jupiter.api.Assertions.assertEquals; + public class WriteAsMapTest extends ProtobufTestBase { final static String PROTOC = @@ -30,6 +34,7 @@ public class WriteAsMapTest extends ProtobufTestBase ; + @Test public void testWriteAsMap() throws Exception { ObjectMapper mapper = newObjectMapper(); diff --git a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/WriteBigArrayTest.java b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/WriteBigArrayTest.java index 46d04f668..7f95899d9 100644 --- a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/WriteBigArrayTest.java +++ b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/WriteBigArrayTest.java @@ -3,11 +3,16 @@ import java.util.ArrayList; import java.util.List; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectWriter; import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchema; import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchemaLoader; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; + public class WriteBigArrayTest extends ProtobufTestBase { final protected static String PROTOC_STRING_ARRAY_SPARSE = "message Strings {\n" @@ -61,6 +66,7 @@ public StringArrayWrapper(List v) { /********************************************************** */ + @Test public void testStringArraySparseWithLongValues() throws Exception { final ObjectMapper mapper = new ObjectMapper(new ProtobufFactory()); @@ -98,6 +104,7 @@ public void testStringArraySparseWithLongValues() throws Exception } // and then do something bit more sizable + @Test public void testStringArraySparseLong() throws Exception { final int COUNT = 35000; @@ -125,6 +132,7 @@ public void testStringArraySparseLong() throws Exception assertEquals(bytes.length, ptr); } + @Test public void testStringArrayPackedLong() throws Exception { final int COUNT = 39600; @@ -158,6 +166,7 @@ public void testStringArrayPackedLong() throws Exception assertEquals(bytes.length, ptr); } + @Test public void testWrappedStringArray() throws Exception { final int COUNT = 39600; diff --git a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/WriteBinaryTest.java b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/WriteBinaryTest.java index f58e5f806..b690a6441 100644 --- a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/WriteBinaryTest.java +++ b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/WriteBinaryTest.java @@ -1,11 +1,16 @@ package com.fasterxml.jackson.dataformat.protobuf; +import org.junit.jupiter.api.Test; + +import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.*; -import com.fasterxml.jackson.dataformat.protobuf.schema.*; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.ObjectWriter; +import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchema; +import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchemaLoader; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import static org.junit.jupiter.api.Assertions.*; public class WriteBinaryTest extends ProtobufTestBase { @@ -38,6 +43,7 @@ public Binary(int id, byte[] data, int trailer) { private final ObjectMapper MAPPER = newObjectMapper(); + @Test public void testSimpleBinary() throws Exception { ProtobufSchema schema = ProtobufSchemaLoader.std.parse(PROTOC_BINARY); diff --git a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/WriteComplexPojoTest.java b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/WriteComplexPojoTest.java index 0d46ca7e4..e3d99beb0 100644 --- a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/WriteComplexPojoTest.java +++ b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/WriteComplexPojoTest.java @@ -1,11 +1,15 @@ package com.fasterxml.jackson.dataformat.protobuf; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectWriter; - import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchema; import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchemaLoader; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + public class WriteComplexPojoTest extends ProtobufTestBase { final ObjectMapper MAPPER = new ObjectMapper(new ProtobufFactory()); @@ -16,6 +20,7 @@ public class WriteComplexPojoTest extends ProtobufTestBase /********************************************************** */ + @Test public void testMediaItemSimple() throws Exception { ProtobufSchema schema = ProtobufSchemaLoader.std.parse(PROTOC_MEDIA_ITEM); diff --git a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/WriteErrorsTest.java b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/WriteErrorsTest.java index 0209628b9..95a9b88a0 100644 --- a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/WriteErrorsTest.java +++ b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/WriteErrorsTest.java @@ -2,6 +2,8 @@ import java.io.ByteArrayOutputStream; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; @@ -9,6 +11,8 @@ import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchema; import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchemaLoader; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Unit tests for generation that trigger exceptions (or would * without suppression). @@ -27,6 +31,7 @@ public Point3D(int x, int y, int z) { private final ObjectMapper MAPPER = new ObjectMapper(new ProtobufFactory()); + @Test public void testUnknownProperties() throws Exception { ProtobufSchema schema = ProtobufSchemaLoader.std.parse(PROTOC_BOX, "Point"); diff --git a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/WriteLongString94Test.java b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/WriteLongString94Test.java index 888653d98..48f640a23 100644 --- a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/WriteLongString94Test.java +++ b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/WriteLongString94Test.java @@ -1,9 +1,12 @@ package com.fasterxml.jackson.dataformat.protobuf; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import org.junit.jupiter.api.Test; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchema; +import static org.junit.jupiter.api.Assertions.assertEquals; + public class WriteLongString94Test extends ProtobufTestBase { @JsonPropertyOrder({ "a", "b" }) @@ -21,6 +24,7 @@ public static class TwoStrings { final ProtobufMapper MAPPER = newObjectMapper(); // [dataformats-binary#94] + @Test public void testLongerStrings() throws Exception { TwoStrings p = new TwoStrings(); // near 8000, so index out of bounds at 8000 diff --git a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/WritePrimitiveArrayTest.java b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/WritePrimitiveArrayTest.java index 5c0db4513..0541cb9a2 100644 --- a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/WritePrimitiveArrayTest.java +++ b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/WritePrimitiveArrayTest.java @@ -3,17 +3,19 @@ import java.math.BigDecimal; import java.math.BigInteger; -import org.junit.Assert; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonToken; import com.fasterxml.jackson.core.JsonParser.NumberType; import com.fasterxml.jackson.core.JsonParser.NumberTypeFP; +import com.fasterxml.jackson.core.JsonToken; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectWriter; import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchema; import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchemaLoader; +import static org.junit.jupiter.api.Assertions.*; + public class WritePrimitiveArrayTest extends ProtobufTestBase { final protected static String PROTOC_INT_ARRAY_SPARSE = "message Ints {\n" @@ -125,6 +127,7 @@ public StringArray(String... v) { final ObjectMapper MAPPER = newObjectMapper(); + @Test public void testVIntArraySparse() throws Exception { final ObjectWriter w = MAPPER.writer(ProtobufSchemaLoader.std.parse(PROTOC_INT_ARRAY_SPARSE)); @@ -139,6 +142,7 @@ public void testVIntArraySparse() throws Exception assertEquals(0x4, bytes[5]); // zig-zagged value for 2 } + @Test public void testVIntArrayPacked() throws Exception { final ObjectWriter w = MAPPER.writer(ProtobufSchemaLoader.std.parse(PROTOC_INT_ARRAY_PACKED)); @@ -152,6 +156,7 @@ public void testVIntArrayPacked() throws Exception assertEquals(0x4, bytes[4]); // zig-zagged value for 2 } + @Test public void testInt32ArraySparse() throws Exception { final ObjectWriter w = MAPPER.writer(ProtobufSchemaLoader.std.parse @@ -161,6 +166,7 @@ public void testInt32ArraySparse() throws Exception assertEquals(15, bytes.length); } + @Test public void testInt32ArrayPacked() throws Exception { final ObjectWriter w = MAPPER.writer(ProtobufSchemaLoader.std.parse @@ -178,6 +184,7 @@ public void testInt32ArrayPacked() throws Exception // // // First as ints: + @Test public void testIntAsLongArraySparse() throws Exception { ProtobufSchema schema = ProtobufSchemaLoader.std.parse(PROTOC_INT64_ARRAY_SPARSE); @@ -188,9 +195,10 @@ public void testIntAsLongArraySparse() throws Exception IntArray result = MAPPER.readerFor(IntArray.class).with(schema) .readValue(bytes); - Assert.assertArrayEquals(input.values, result.values); + assertArrayEquals(input.values, result.values); } + @Test public void testIntAsLongArrayPacked() throws Exception { ProtobufSchema schema = ProtobufSchemaLoader.std.parse(PROTOC_INT64_ARRAY_PACKED); @@ -202,11 +210,12 @@ public void testIntAsLongArrayPacked() throws Exception IntArray result = MAPPER.readerFor(IntArray.class).with(schema) .readValue(bytes); - Assert.assertArrayEquals(input.values, result.values); + assertArrayEquals(input.values, result.values); } // // // But then as regular longs + @Test public void testLongArraySparse() throws Exception { ProtobufSchema schema = ProtobufSchemaLoader.std.parse(PROTOC_INT64_ARRAY_SPARSE); @@ -217,11 +226,12 @@ public void testLongArraySparse() throws Exception LongArray result = MAPPER.readerFor(LongArray.class).with(schema) .readValue(bytes); - Assert.assertArrayEquals(input.values, result.values); + assertArrayEquals(input.values, result.values); _verifyLongArray(bytes, schema, input.values); } + @Test public void testLongArrayPacked() throws Exception { ProtobufSchema schema = ProtobufSchemaLoader.std.parse(PROTOC_INT64_ARRAY_PACKED); @@ -232,7 +242,7 @@ public void testLongArrayPacked() throws Exception LongArray result = MAPPER.readerFor(LongArray.class).with(schema) .readValue(bytes); - Assert.assertArrayEquals(input.values, result.values); + assertArrayEquals(input.values, result.values); _verifyLongArray(bytes, schema, input.values); } @@ -278,6 +288,7 @@ private void _verifyLongArray(byte[] doc, ProtobufSchema schema, /********************************************************** */ + @Test public void testDoubleArraySparse() throws Exception { ProtobufSchema schema = ProtobufSchemaLoader.std.parse(PROTOC_DOUBLE_ARRAY_SPARSE); @@ -293,6 +304,7 @@ public void testDoubleArraySparse() throws Exception _verifyDoubleArray(bytes, schema, input.values); } + @Test public void testDoubleArrayPacked() throws Exception { ProtobufSchema schema = ProtobufSchemaLoader.std.parse(PROTOC_DOUBLE_ARRAY_PACKED); @@ -352,6 +364,7 @@ private void _verifyDoubleArray(byte[] doc, ProtobufSchema schema, p.close(); } + @Test public void testFloatArraySparse() throws Exception { ProtobufSchema schema = ProtobufSchemaLoader.std.parse(PROTOC_FLOAT_ARRAY_SPARSE); @@ -367,6 +380,7 @@ public void testFloatArraySparse() throws Exception _verifyFloatArray(bytes, schema, input.values); } + @Test public void testFloatArrayPacked() throws Exception { ProtobufSchema schema = ProtobufSchemaLoader.std.parse(PROTOC_FLOAT_ARRAY_PACKED); @@ -430,6 +444,7 @@ private void _assertEquals(float[] exp, float[] act) /********************************************************** */ + @Test public void testStringArraySparse() throws Exception { ProtobufSchema schema = ProtobufSchemaLoader.std.parse(PROTOC_STRING_ARRAY_SPARSE); @@ -440,9 +455,10 @@ public void testStringArraySparse() throws Exception StringArray result = MAPPER.readerFor(StringArray.class).with(schema) .readValue(bytes); - Assert.assertArrayEquals(input.values, result.values); + assertArrayEquals(input.values, result.values); } + @Test public void testStringArrayPacked() throws Exception { ProtobufSchema schema = ProtobufSchemaLoader.std.parse(PROTOC_STRING_ARRAY_PACKED); @@ -453,6 +469,6 @@ public void testStringArrayPacked() throws Exception StringArray result = MAPPER.readerFor(StringArray.class).with(schema) .readValue(bytes); - Assert.assertArrayEquals(input.values, result.values); + assertArrayEquals(input.values, result.values); } } diff --git a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/WriteSimpleTest.java b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/WriteSimpleTest.java index 4f090c3af..84543efcc 100644 --- a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/WriteSimpleTest.java +++ b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/WriteSimpleTest.java @@ -4,13 +4,19 @@ import java.util.Arrays; import java.util.List; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.io.SerializedString; -import com.fasterxml.jackson.databind.*; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.ObjectWriter; import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchema; import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchemaLoader; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + public class WriteSimpleTest extends ProtobufTestBase { static class Point3D extends Point { @@ -64,6 +70,7 @@ public boolean equals(Object o) { /********************************************************** */ + @Test public void testWritePointInt() throws Exception { ProtobufSchema schema = ProtobufSchemaLoader.std.parse(PROTOC_BOX, "Point"); @@ -87,6 +94,7 @@ public void testWritePointInt() throws Exception assertEquals(input, result); } + @Test public void testWritePointLongFixed() throws Exception { ProtobufSchema schema = ProtobufSchemaLoader.std.parse(PROTOC_POINT_FL); @@ -105,6 +113,7 @@ public void testWritePointLongFixed() throws Exception assertEquals(input, result); } + @Test public void testWritePointDouble() throws Exception { ProtobufSchema schema = ProtobufSchemaLoader.std.parse(PROTOC_POINT_D); @@ -121,6 +130,7 @@ public void testWritePointDouble() throws Exception assertEquals(input, result); } + @Test public void testWriteNameManual() throws Exception { ProtobufSchema schema = ProtobufSchemaLoader.std.parse(PROTOC_NAME); @@ -147,6 +157,7 @@ public void testWriteNameManual() throws Exception assertEquals(11, b.length); } + @Test public void testWritePointWithLongsManual() throws Exception { ProtobufSchema schema = ProtobufSchemaLoader.std.parse(PROTOC_POINT_L); @@ -195,6 +206,7 @@ public void testWritePointWithLongsManual() throws Exception assertEquals(0x01, b[20] & 0x01); } + @Test public void testBooleanAndNull() throws Exception { ProtobufSchema schema = ProtobufSchemaLoader.std.parse(PROTOC_OPTIONAL_VALUE); @@ -217,6 +229,7 @@ public void testBooleanAndNull() throws Exception assertEquals(input, result); } + @Test public void testIdPoint() throws Exception { ProtobufSchema schema = ProtobufSchemaLoader.std.parse(PROTOC_ID_POINTS); @@ -231,6 +244,7 @@ public void testIdPoint() throws Exception assertEquals(input, result); } + @Test public void testWriteCoord() throws Exception { ProtobufSchema schema = ProtobufSchemaLoader.std.parse(PROTOC_BOX, "Box"); diff --git a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/WriteStringsTest.java b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/WriteStringsTest.java index 8e5a19f74..210ed4979 100644 --- a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/WriteStringsTest.java +++ b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/WriteStringsTest.java @@ -2,12 +2,16 @@ import java.io.*; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectWriter; import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchema; import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchemaLoader; +import static org.junit.jupiter.api.Assertions.assertEquals; + public class WriteStringsTest extends ProtobufTestBase { @@ -28,6 +32,7 @@ public class WriteStringsTest extends ProtobufTestBase } } + @Test public void testSimpleShort() throws Exception { final ObjectWriter w = MAPPER.writer(NAME_SCHEMA); @@ -53,6 +58,7 @@ public void testSimpleShort() throws Exception assertEquals((byte) 'r', bytes[12]); } + @Test public void testSimpleLongAscii() throws Exception { _testSimpleLong(129, "Bob"); @@ -60,6 +66,7 @@ public void testSimpleLongAscii() throws Exception _testSimpleLong(9000, "Emily"); } + @Test public void testSimpleLongTwoByteUTF8() throws Exception { _testSimpleLong(90, "\u00A8a\u00F3"); @@ -68,6 +75,7 @@ public void testSimpleLongTwoByteUTF8() throws Exception _testSimpleLong(7000, "\u00A8xy"); } + @Test public void testSimpleLongThreeByteUTF8() throws Exception { _testSimpleLong(90, "\u2009\u3333"); diff --git a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/dos/DeepNestingProtobufParserTest.java b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/dos/DeepNestingProtobufParserTest.java index be709eaa5..a4fcc346e 100644 --- a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/dos/DeepNestingProtobufParserTest.java +++ b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/dos/DeepNestingProtobufParserTest.java @@ -2,15 +2,17 @@ import java.io.IOException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.StreamReadConstraints; -import com.fasterxml.jackson.core.StreamWriteConstraints; -import com.fasterxml.jackson.core.exc.StreamConstraintsException; +import org.junit.jupiter.api.Test; +import com.fasterxml.jackson.core.*; +import com.fasterxml.jackson.core.exc.StreamConstraintsException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.protobuf.*; import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchema; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + /** * Unit tests for deeply nested Documents */ @@ -47,6 +49,7 @@ public Node(int id, Node next) { } + @Test public void testDeeplyNestedObjectsHighLimits() throws Exception { byte[] doc = genDeepDoc(1200); @@ -55,6 +58,7 @@ public void testDeeplyNestedObjectsHighLimits() throws Exception } } + @Test public void testDeeplyNestedObjectsLowLimits() throws Exception { byte[] doc = genDeepDoc(1200); @@ -64,8 +68,8 @@ public void testDeeplyNestedObjectsLowLimits() throws Exception } catch (StreamConstraintsException e) { String exceptionPrefix = String.format("Document nesting depth (%d) exceeds the maximum allowed", StreamReadConstraints.DEFAULT_MAX_DEPTH + 1); - assertTrue("StreamConstraintsException message is as expected?", - e.getMessage().startsWith(exceptionPrefix)); + assertTrue(e.getMessage().startsWith(exceptionPrefix), + "StreamConstraintsException message is as expected?"); } } diff --git a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/failing/GenerateNestedType73Test.java b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/failing/GenerateNestedType73Test.java index 78f2b9b2b..65892e57e 100644 --- a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/failing/GenerateNestedType73Test.java +++ b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/failing/GenerateNestedType73Test.java @@ -2,10 +2,14 @@ import java.io.StringReader; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.dataformat.protobuf.ProtobufMapper; import com.fasterxml.jackson.dataformat.protobuf.ProtobufTestBase; import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchema; +import static org.junit.jupiter.api.Assertions.assertNotNull; + public class GenerateNestedType73Test extends ProtobufTestBase { /* @@ -17,6 +21,7 @@ public class GenerateNestedType73Test extends ProtobufTestBase final ProtobufMapper MAPPER = new ProtobufMapper(); // [dataformats-binary#68] + @Test public void testNestedTypes() throws Exception { final String SCHEMA_STR = diff --git a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/fuzz/ProtobufFuzz_65674_NPETest.java b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/fuzz/ProtobufFuzz_65674_NPETest.java index 0b04b0f27..771c4c0d1 100644 --- a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/fuzz/ProtobufFuzz_65674_NPETest.java +++ b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/fuzz/ProtobufFuzz_65674_NPETest.java @@ -1,13 +1,13 @@ package com.fasterxml.jackson.dataformat.protobuf.fuzz; -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.dataformat.protobuf.*; +import com.fasterxml.jackson.dataformat.protobuf.ProtobufMapper; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; public class ProtobufFuzz_65674_NPETest { diff --git a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/schema/DescriptorLoaderTest.java b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/schema/DescriptorLoaderTest.java index 2e97324ac..c80490f5e 100644 --- a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/schema/DescriptorLoaderTest.java +++ b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/schema/DescriptorLoaderTest.java @@ -2,10 +2,15 @@ import java.io.InputStream; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.ObjectWriter; import com.fasterxml.jackson.dataformat.protobuf.ProtobufMapper; import com.fasterxml.jackson.dataformat.protobuf.ProtobufTestBase; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + public class DescriptorLoaderTest extends ProtobufTestBase { private final ProtobufMapper MAPPER = new ProtobufMapper(); @@ -47,6 +52,7 @@ public Other(int f) + " required int32 f = 1;\n" + "}\n"; + @Test public void testParsing() throws Exception { // create PB binary from known .proto schema diff --git a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/schema/ReadCyclicSchema140Test.java b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/schema/ReadCyclicSchema140Test.java index 931b0087c..8526b1d12 100644 --- a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/schema/ReadCyclicSchema140Test.java +++ b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/schema/ReadCyclicSchema140Test.java @@ -2,8 +2,13 @@ import java.util.List; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.dataformat.protobuf.ProtobufTestBase; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + public class ReadCyclicSchema140Test extends ProtobufTestBase { final protected static String PROTOC_CYCLIC = @@ -18,6 +23,7 @@ public class ReadCyclicSchema140Test extends ProtobufTestBase +"}\n" ; + @Test public void testCyclicDefinition() throws Exception { ProtobufSchema schema = ProtobufSchemaLoader.std.parse(PROTOC_CYCLIC); diff --git a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/schema/SchemGenForSelfRef140Test.java b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/schema/SchemGenForSelfRef140Test.java index 9edbc6d5a..fc9633660 100644 --- a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/schema/SchemGenForSelfRef140Test.java +++ b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/schema/SchemGenForSelfRef140Test.java @@ -1,6 +1,11 @@ package com.fasterxml.jackson.dataformat.protobuf.schema; -import com.fasterxml.jackson.dataformat.protobuf.*; +import org.junit.jupiter.api.Test; + +import com.fasterxml.jackson.dataformat.protobuf.ProtobufMapper; +import com.fasterxml.jackson.dataformat.protobuf.ProtobufTestBase; + +import static org.junit.jupiter.api.Assertions.assertNotNull; // for [dataformats-binary#140] public class SchemGenForSelfRef140Test extends ProtobufTestBase @@ -23,7 +28,8 @@ public static class BackRefType { private final ProtobufMapper MAPPER = newObjectMapper(); - public void testWithNestedClass() throws Exception + @Test + public void testWithNestedClass() throws Exception { ProtobufSchema schemaWrapper = MAPPER.generateSchemaFor(ForwardRefType.class); assertNotNull(schemaWrapper); diff --git a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/schema/SchemaGenTest.java b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/schema/SchemaGenTest.java index 948d56731..8bad352a9 100644 --- a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/schema/SchemaGenTest.java +++ b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/schema/SchemaGenTest.java @@ -1,17 +1,18 @@ package com.fasterxml.jackson.dataformat.protobuf.schema; -import static org.junit.Assert.assertArrayEquals; - import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.List; -import com.fasterxml.jackson.annotation.JsonProperty; +import org.junit.jupiter.api.Test; +import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.dataformat.protobuf.ProtobufMapper; import com.fasterxml.jackson.dataformat.protobuf.ProtobufTestBase; import com.fasterxml.jackson.dataformat.protobuf.schemagen.ProtobufSchemaGenerator; +import static org.junit.jupiter.api.Assertions.*; + public class SchemaGenTest extends ProtobufTestBase { public static class WithNestedClass { @@ -71,6 +72,7 @@ public static class Employee { private final ProtobufMapper MAPPER = newObjectMapper(); + @Test public void testWithNestedClass() throws Exception { ProtobufSchema schemaWrapper = MAPPER.generateSchemaFor(WithNestedClass.class); @@ -80,6 +82,7 @@ public void testWithNestedClass() throws Exception // System.out.println(schemaWrapper.getSource().toString()); } + @Test public void testWithIndexAnnotation() throws Exception { ProtobufSchema schemaWrapper = MAPPER.generateSchemaFor(WithIndexAnnotation.class); @@ -95,6 +98,7 @@ public void testWithIndexAnnotation() throws Exception assertEquals("b", pMessage.field(4).name); } + @Test public void testSelfRefPojoGenProtobufSchema() throws Exception { ProtobufSchemaGenerator gen = new ProtobufSchemaGenerator(); MAPPER.acceptJsonFormatVisitor(Employee.class, gen); @@ -123,6 +127,7 @@ public void testSelfRefPojoGenProtobufSchema() throws Exception { assertEquals(empl.boss, newEmpl.boss); } + @Test public void testComplexPojoGenProtobufSchema() throws Exception { ProtobufSchemaGenerator gen = new ProtobufSchemaGenerator(); MAPPER.acceptJsonFormatVisitor(MediaItem.class, gen); @@ -143,6 +148,7 @@ public void testComplexPojoGenProtobufSchema() throws Exception { assertEquals(mediaItem, deserMediaItem); } + @Test public void testSimplePojoGenProtobufSchema() throws Exception { ProtobufSchemaGenerator gen = new ProtobufSchemaGenerator(); MAPPER.acceptJsonFormatVisitor(RootType.class, gen); diff --git a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/schema/SchemaParsingTest.java b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/schema/SchemaParsingTest.java index b85b1173b..4c2067b26 100644 --- a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/schema/SchemaParsingTest.java +++ b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/schema/SchemaParsingTest.java @@ -2,8 +2,12 @@ import java.util.List; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.dataformat.protobuf.ProtobufTestBase; +import static org.junit.jupiter.api.Assertions.*; + public class SchemaParsingTest extends ProtobufTestBase { final protected static String PROTOC_ENUMS = @@ -29,6 +33,7 @@ public class SchemaParsingTest extends ProtobufTestBase +"}\n" ; + @Test public void testSimpleSearchRequest() throws Exception { // First: with implicit first type: @@ -50,6 +55,7 @@ public void testSimpleSearchRequest() throws Exception _verifyMessageFieldLinking(msg); } + @Test public void testBoxAndPoint() throws Exception { ProtobufSchema schema = ProtobufSchemaLoader.std.parse(PROTOC_BOX); @@ -61,6 +67,7 @@ public void testBoxAndPoint() throws Exception _verifyMessageFieldLinking(schema.getRootType()); } + @Test public void testRecursive() throws Exception { ProtobufSchema schema = ProtobufSchemaLoader.std.parse(PROTOC_NODE); @@ -77,6 +84,7 @@ public void testRecursive() throws Exception _verifyMessageFieldLinking(schema.getRootType()); } + @Test public void testEnum() throws Exception { ProtobufSchema schema = ProtobufSchemaLoader.std.parse(PROTOC_ENUMS); @@ -101,6 +109,7 @@ public void testEnum() throws Exception assertFalse(f.isStdEnum); } + @Test public void testEmpty() throws Exception { ProtobufSchema schema = ProtobufSchemaLoader.std.parse(PROTOC_EMPTY); @@ -109,6 +118,7 @@ public void testEmpty() throws Exception assertEquals(1, all.size()); } + @Test public void testPacked() throws Exception { ProtobufSchema schema = ProtobufSchemaLoader.std.parse(PROTOC_STRINGS_PACKED); diff --git a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/schema/SchemaWithIntArray483Test.java b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/schema/SchemaWithIntArray483Test.java index 1ec050920..2a18b8fbf 100644 --- a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/schema/SchemaWithIntArray483Test.java +++ b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/schema/SchemaWithIntArray483Test.java @@ -1,12 +1,14 @@ package com.fasterxml.jackson.dataformat.protobuf.schema; -import static org.junit.Assert.assertArrayEquals; - -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.dataformat.protobuf.ProtobufMapper; import com.fasterxml.jackson.dataformat.protobuf.ProtobufTestBase; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + public class SchemaWithIntArray483Test extends ProtobufTestBase { static class IntArrayBean @@ -24,6 +26,7 @@ static class IntArrayBean private final ProtobufMapper MAPPER = new ProtobufMapper(); // [dataformats-binary#483]: int arrays supported as nested (property) values + @Test public void testWithWrappedIntArray() throws Exception { ProtobufSchema schema = MAPPER.generateSchemaFor(IntArrayBean.class); @@ -42,7 +45,7 @@ public void testWithWrappedIntArray() throws Exception } // [dataformats-binary#483]: cannot support root-level arrays, unfortunately - @Ignore("Can't be supported with Protobuf") + @Disabled("Can't be supported with Protobuf") public void dontTestWithRootIntArray() throws Exception { ProtobufSchema schema = MAPPER.generateSchemaFor(int[].class); diff --git a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/schema/SchemaWithUUIDTest.java b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/schema/SchemaWithUUIDTest.java index 1741eed9d..0421b48db 100644 --- a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/schema/SchemaWithUUIDTest.java +++ b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/schema/SchemaWithUUIDTest.java @@ -4,12 +4,14 @@ import java.nio.charset.StandardCharsets; import java.util.UUID; -import org.junit.Assert; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.dataformat.protobuf.ProtobufMapper; import com.fasterxml.jackson.dataformat.protobuf.ProtobufTestBase; +import static org.junit.jupiter.api.Assertions.*; + public class SchemaWithUUIDTest extends ProtobufTestBase { static class UUIDBean @@ -42,6 +44,7 @@ static class BinaryBean private final ProtobufMapper MAPPER = new ProtobufMapper(); // [dataformats-binary#68] + @Test public void testWithUUID() throws Exception { ProtobufSchema schema = MAPPER.generateSchemaFor(UUIDBean.class); @@ -60,12 +63,14 @@ public void testWithUUID() throws Exception } // [dataformats-binary#68] + @Test public void testWithShort() throws Exception { ProtobufSchema schema = MAPPER.generateSchemaFor(ShortBean.class); assertNotNull(schema); } + @Test public void testWithBinary() throws Exception { ProtobufSchema schema = MAPPER.generateSchemaFor(BinaryBean.class); @@ -81,6 +86,6 @@ public void testWithBinary() throws Exception .with(schema) .readValue(proto); assertNotNull(result.data); - Assert.assertArrayEquals(input.data, result.data); + assertArrayEquals(input.data, result.data); } } diff --git a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/testutil/failure/JacksonTestFailureExpected.java b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/testutil/failure/JacksonTestFailureExpected.java index 84d102e5f..38b27de3b 100644 --- a/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/testutil/failure/JacksonTestFailureExpected.java +++ b/protobuf/src/test/java/com/fasterxml/jackson/dataformat/protobuf/testutil/failure/JacksonTestFailureExpected.java @@ -21,8 +21,7 @@ * * @Test * @JacksonTestFailureExpected - * @Test - public void testFeatureNotYetImplemented() { + * public void testFeatureNotYetImplemented() { * // Test code that is expected to fail * } * }