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 * } * }