From eec399063ff00a135be54a0ad46d9cd83367a5a9 Mon Sep 17 00:00:00 2001 From: "Kim, Joo Hyuk" Date: Sun, 2 Feb 2025 10:56:22 +0900 Subject: [PATCH] [JSTEP-10] Migrate tests to JUnit 5 (#210) --- .../jackson/jaxrs/base/BaseTestBase.java | 1 - .../base/cfg/AnnotationBundleKeyTest.java | 18 ++++++++++++++---- .../jackson/jaxrs/cbor/JaxrsTestBase.java | 7 +++---- .../jackson/jaxrs/cbor/TestCBORVersions.java | 7 ++++++- .../jackson/jaxrs/cbor/TestCanDeserialize.java | 5 +++++ .../jaxrs/cbor/dw/SimpleEndpointTestBase.java | 10 ++++++++-- .../jackson/datatype/jaxrs/LinkTest.java | 7 ++++++- .../jackson/datatype/jaxrs/ModuleTestBase.java | 3 ++- .../jackson/jaxrs/json/JaxrsTestBase.java | 7 +++---- .../jackson/jaxrs/json/TestCanDeserialize.java | 9 ++++++++- .../jackson/jaxrs/json/TestCanSerialize.java | 5 +++++ .../jackson/jaxrs/json/TestJSONVersions.java | 7 ++++++- .../jaxrs/json/TestJacksonFeatures.java | 7 +++++++ .../jackson/jaxrs/json/TestJsonView.java | 6 ++++++ .../jackson/jaxrs/json/TestJsonpWrapping.java | 5 +++++ .../jackson/jaxrs/json/TestRootType.java | 7 ++++++- .../json/TestSerializeWithoutAutoflush.java | 5 +++++ .../jaxrs/json/TestStreamingOutput.java | 5 +++++ .../jackson/jaxrs/json/TestUntouchables.java | 8 +++++++- .../jaxrs/json/dw/AnnotationTestBase.java | 5 +++++ .../jaxrs/json/dw/SimpleEndpointTestBase.java | 18 ++++++++++++++++-- .../json/dw/WriteModificationsTestBase.java | 6 ++++++ .../resteasy/RestEasyProviderLoadingTest.java | 5 +++++ .../json/util/TestAnnotationBundleKey.java | 5 +++++ pom.xml | 10 +++++++--- .../jackson/jaxrs/smile/JaxrsTestBase.java | 7 +++---- .../jaxrs/smile/TestCanDeserialize.java | 5 +++++ .../jackson/jaxrs/smile/TestSmileVersions.java | 7 ++++++- .../jaxrs/smile/dw/SimpleEndpointTestBase.java | 9 +++++++-- .../jackson/jaxrs/xml/JaxrsTestBase.java | 7 +++---- .../jackson/jaxrs/xml/TestCanDeserialize.java | 8 +++++++- .../jackson/jaxrs/xml/TestCanSerialize.java | 5 +++++ .../jaxrs/xml/TestJacksonFeaturesWithXML.java | 9 ++++++++- .../jackson/jaxrs/xml/TestJsonView.java | 5 +++++ .../jackson/jaxrs/xml/TestRootType.java | 7 ++++++- .../jackson/jaxrs/xml/TestSerialize.java | 5 +++++ .../jackson/jaxrs/xml/TestUntouchables.java | 8 +++++++- .../jackson/jaxrs/xml/TestXMLVersions.java | 7 ++++++- .../jaxrs/xml/dw/SimpleEndpointTestBase.java | 9 +++++++-- .../jackson/jaxrs/yaml/JaxrsTestBase.java | 7 +++---- .../jackson/jaxrs/yaml/TestCanDeserialize.java | 8 +++++++- .../jackson/jaxrs/yaml/TestCanSerialize.java | 5 +++++ .../yaml/TestJacksonFeaturesWithYAML.java | 9 ++++++++- .../jackson/jaxrs/yaml/TestJsonView.java | 5 +++++ .../jackson/jaxrs/yaml/TestRootType.java | 7 ++++++- .../jackson/jaxrs/yaml/TestSerialize.java | 5 +++++ .../jackson/jaxrs/yaml/TestUntouchables.java | 5 +++++ .../jackson/jaxrs/yaml/TestYAMLVersions.java | 7 ++++++- .../jaxrs/yaml/dw/SimpleEndpointTestBase.java | 11 +++++++++-- 49 files changed, 290 insertions(+), 55 deletions(-) diff --git a/base/src/test/java/com/fasterxml/jackson/jaxrs/base/BaseTestBase.java b/base/src/test/java/com/fasterxml/jackson/jaxrs/base/BaseTestBase.java index 27d770f9..e42b6ba8 100644 --- a/base/src/test/java/com/fasterxml/jackson/jaxrs/base/BaseTestBase.java +++ b/base/src/test/java/com/fasterxml/jackson/jaxrs/base/BaseTestBase.java @@ -1,7 +1,6 @@ package com.fasterxml.jackson.jaxrs.base; public abstract class BaseTestBase - extends junit.framework.TestCase { // for now just placeholder } diff --git a/base/src/test/java/com/fasterxml/jackson/jaxrs/base/cfg/AnnotationBundleKeyTest.java b/base/src/test/java/com/fasterxml/jackson/jaxrs/base/cfg/AnnotationBundleKeyTest.java index dae31bd4..3a08ab3b 100644 --- a/base/src/test/java/com/fasterxml/jackson/jaxrs/base/cfg/AnnotationBundleKeyTest.java +++ b/base/src/test/java/com/fasterxml/jackson/jaxrs/base/cfg/AnnotationBundleKeyTest.java @@ -4,12 +4,16 @@ import java.util.Arrays; import java.util.HashSet; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.jaxrs.base.BaseTestBase; import com.fasterxml.jackson.jaxrs.cfg.AnnotationBundleKey; +import static org.junit.jupiter.api.Assertions.*; + // for [jaxrs-providers#111] public class AnnotationBundleKeyTest extends BaseTestBase @@ -39,6 +43,7 @@ public Helper(@JsonProperty("x") int x) { } public void setX(@JsonProperty("x") int x) { } } + @Test public void testWithClassAnnotations() throws Exception { Annotation[] annotation1 = Helper.class.getAnnotations(); @@ -48,6 +53,7 @@ public void testWithClassAnnotations() throws Exception _checkWith(annotation1, annotation2); } + @Test public void testWithMethodAnnotationEquals() throws Exception { // First, same method parameters definitely should match @@ -65,6 +71,7 @@ public void testWithMethodAnnotationEquals() throws Exception _checkWith(annotation3, annotation4); } + @Test public void testWithMethodAnnotationDifferent() throws Exception { // However: not so with actually differing annotations @@ -72,18 +79,21 @@ public void testWithMethodAnnotationDifferent() throws Exception Helper.class.getDeclaredMethod("notX").getAnnotations()); } + @Test public void testWithMethodParameterAnnotation() throws Exception { _checkWith(Helper.class.getDeclaredMethod("setX", Integer.TYPE).getParameterAnnotations()[0], Helper.class.getDeclaredMethod("setX", Integer.TYPE).getParameterAnnotations()[0]); } + @Test public void testWithConstructorAnnotation() throws Exception { _checkWith(Helper.class.getConstructor(Integer.TYPE).getAnnotations(), Helper.class.getConstructor(Integer.TYPE).getAnnotations()); } - + + @Test public void testWithConstructorParameterAnnotation() throws Exception { _checkWith(Helper.class.getConstructor(Integer.TYPE).getParameterAnnotations()[0], @@ -97,18 +107,18 @@ protected void _checkWith(Annotation[] anns1, Annotation[] anns2) { } HashSet annsSet1 = new HashSet(Arrays.asList(anns1)); HashSet annsSet2 = new HashSet(Arrays.asList(anns2)); - assertTrue("Internal error: should never differ", annsSet1.equals(annsSet2)); + assertEquals(annsSet1, annsSet2, "Internal error: should never differ"); AnnotationBundleKey b1 = new AnnotationBundleKey(anns1, Object.class); AnnotationBundleKey b2 = new AnnotationBundleKey(anns2, Object.class); - assertTrue(String.format("Implementations over %s backed annotations differ", anns1[0].getClass()), (b1.equals(b2) && b2.equals(b1))); + assertTrue((b1.equals(b2) && b2.equals(b1)), String.format("Implementations over %s backed annotations differ", anns1[0].getClass())); } protected void _checkNotEqual(Annotation[] anns1, Annotation[] anns2) { AnnotationBundleKey b1 = new AnnotationBundleKey(anns1, Object.class); AnnotationBundleKey b2 = new AnnotationBundleKey(anns2, Object.class); - assertFalse(String.format("Implementations over %s backed annotations SHOULD differ but won't", anns1[0].getClass()), (b1.equals(b2) || b2.equals(b1))); + assertFalse((b1.equals(b2) || b2.equals(b1)), String.format("Implementations over %s backed annotations SHOULD differ but won't", anns1[0].getClass())); } } diff --git a/cbor/src/test/java/com/fasterxml/jackson/jaxrs/cbor/JaxrsTestBase.java b/cbor/src/test/java/com/fasterxml/jackson/jaxrs/cbor/JaxrsTestBase.java index 86fac510..b3937562 100644 --- a/cbor/src/test/java/com/fasterxml/jackson/jaxrs/cbor/JaxrsTestBase.java +++ b/cbor/src/test/java/com/fasterxml/jackson/jaxrs/cbor/JaxrsTestBase.java @@ -5,12 +5,11 @@ import java.io.InputStream; import java.util.Arrays; -import org.junit.Assert; - import com.fasterxml.jackson.core.*; +import static org.junit.jupiter.api.Assertions.*; + public abstract class JaxrsTestBase - extends junit.framework.TestCase { /* /********************************************************** @@ -56,7 +55,7 @@ protected void verifyException(Throwable e, String... matches) protected void _verifyBytes(byte[] actBytes, byte... expBytes) { - Assert.assertArrayEquals(expBytes, actBytes); + assertArrayEquals(expBytes, actBytes); } /** diff --git a/cbor/src/test/java/com/fasterxml/jackson/jaxrs/cbor/TestCBORVersions.java b/cbor/src/test/java/com/fasterxml/jackson/jaxrs/cbor/TestCBORVersions.java index 22481d2f..2d03b868 100644 --- a/cbor/src/test/java/com/fasterxml/jackson/jaxrs/cbor/TestCBORVersions.java +++ b/cbor/src/test/java/com/fasterxml/jackson/jaxrs/cbor/TestCBORVersions.java @@ -1,10 +1,15 @@ package com.fasterxml.jackson.jaxrs.cbor; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.core.Version; import com.fasterxml.jackson.core.Versioned; +import static org.junit.jupiter.api.Assertions.*; + public class TestCBORVersions extends JaxrsTestBase { + @Test public void testMapperVersions() { assertVersion(new JacksonCBORProvider()); @@ -19,7 +24,7 @@ public void testMapperVersions() private void assertVersion(Versioned vers) { final Version v = vers.version(); - assertFalse("Should find version information (got "+v+")", v.isUnknownVersion()); + assertFalse(v.isUnknownVersion(), "Should find version information (got "+v+")"); Version exp = PackageVersion.VERSION; assertEquals(exp.toFullString(), v.toFullString()); assertEquals(exp, v); diff --git a/cbor/src/test/java/com/fasterxml/jackson/jaxrs/cbor/TestCanDeserialize.java b/cbor/src/test/java/com/fasterxml/jackson/jaxrs/cbor/TestCanDeserialize.java index 4b950ff6..9083d3f6 100644 --- a/cbor/src/test/java/com/fasterxml/jackson/jaxrs/cbor/TestCanDeserialize.java +++ b/cbor/src/test/java/com/fasterxml/jackson/jaxrs/cbor/TestCanDeserialize.java @@ -5,6 +5,10 @@ import javax.ws.rs.core.MediaType; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + /** * Unit test to check [JACKSON-540] */ @@ -15,6 +19,7 @@ static class Bean { } // [Issue#1]: exception for no content + @Test public void testCanSerializeEmpty() throws IOException { JacksonCBORProvider prov = new JacksonCBORProvider(); diff --git a/cbor/src/test/java/com/fasterxml/jackson/jaxrs/cbor/dw/SimpleEndpointTestBase.java b/cbor/src/test/java/com/fasterxml/jackson/jaxrs/cbor/dw/SimpleEndpointTestBase.java index b9caccd7..45df03f4 100644 --- a/cbor/src/test/java/com/fasterxml/jackson/jaxrs/cbor/dw/SimpleEndpointTestBase.java +++ b/cbor/src/test/java/com/fasterxml/jackson/jaxrs/cbor/dw/SimpleEndpointTestBase.java @@ -8,12 +8,15 @@ import javax.ws.rs.Produces; import org.eclipse.jetty.server.Server; -import org.junit.Assert; + +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.cbor.CBORFactory; import com.fasterxml.jackson.jaxrs.cbor.CBORMediaTypes; +import static org.junit.jupiter.api.Assertions.*; + public abstract class SimpleEndpointTestBase extends ResourceTestBase { final static int TEST_PORT = 6011; @@ -72,6 +75,7 @@ public static class SimpleRawApp extends CBORApplicationWithJackson { /********************************************************** */ + @Test public void testSimpleObject() throws Exception { final ObjectMapper mapper = new ObjectMapper(new CBORFactory()); @@ -91,6 +95,7 @@ public void testSimpleObject() throws Exception assertEquals(2, p.y); } + @Test public void testCustomMediaTypeWithCborExtension() throws Exception { final ObjectMapper mapper = new ObjectMapper(new CBORFactory()); @@ -115,12 +120,13 @@ public void testCustomMediaTypeWithCborExtension() throws Exception // [Issue#34] Verify that Untouchables act the way as they should @SuppressWarnings("resource") + @Test public void testUntouchables() throws Exception { Server server = startServer(TEST_PORT, SimpleRawApp.class); try { InputStream in = new URL("http://localhost:"+TEST_PORT+"/raw/bytes").openStream(); - Assert.assertArrayEquals(UNTOUCHABLE_RESPONSE, readAll(in)); + assertArrayEquals(UNTOUCHABLE_RESPONSE, readAll(in)); } finally { server.stop(); } diff --git a/datatypes/src/test/java/com/fasterxml/jackson/datatype/jaxrs/LinkTest.java b/datatypes/src/test/java/com/fasterxml/jackson/datatype/jaxrs/LinkTest.java index b0ed056f..f3d15f58 100644 --- a/datatypes/src/test/java/com/fasterxml/jackson/datatype/jaxrs/LinkTest.java +++ b/datatypes/src/test/java/com/fasterxml/jackson/datatype/jaxrs/LinkTest.java @@ -2,12 +2,17 @@ import javax.ws.rs.core.Link; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.ObjectMapper; +import static org.junit.jupiter.api.Assertions.*; + public class LinkTest extends ModuleTestBase { private final ObjectMapper MAPPER = mapperWithModule(); - + + @Test public void testLink() throws Exception { Link input = Link.fromUri("http://dot.com?foo=bar") diff --git a/datatypes/src/test/java/com/fasterxml/jackson/datatype/jaxrs/ModuleTestBase.java b/datatypes/src/test/java/com/fasterxml/jackson/datatype/jaxrs/ModuleTestBase.java index 36a1fcdf..f098ba13 100644 --- a/datatypes/src/test/java/com/fasterxml/jackson/datatype/jaxrs/ModuleTestBase.java +++ b/datatypes/src/test/java/com/fasterxml/jackson/datatype/jaxrs/ModuleTestBase.java @@ -5,8 +5,9 @@ import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.databind.ObjectMapper; +import static org.junit.jupiter.api.Assertions.*; + public abstract class ModuleTestBase - extends junit.framework.TestCase { protected ObjectMapper mapperWithModule() { return new ObjectMapper() diff --git a/json/src/test/java/com/fasterxml/jackson/jaxrs/json/JaxrsTestBase.java b/json/src/test/java/com/fasterxml/jackson/jaxrs/json/JaxrsTestBase.java index 8f52eb0f..331add2e 100644 --- a/json/src/test/java/com/fasterxml/jackson/jaxrs/json/JaxrsTestBase.java +++ b/json/src/test/java/com/fasterxml/jackson/jaxrs/json/JaxrsTestBase.java @@ -3,15 +3,14 @@ import java.io.IOException; import java.util.*; -import org.junit.Assert; - import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.cfg.MapperConfig; import com.fasterxml.jackson.databind.jsontype.PolymorphicTypeValidator; +import static org.junit.jupiter.api.Assertions.*; + public abstract class JaxrsTestBase - extends junit.framework.TestCase { protected static class NoCheckSubTypeValidator extends PolymorphicTypeValidator.Base @@ -68,7 +67,7 @@ protected void verifyException(Throwable e, String... matches) protected void _verifyBytes(byte[] actBytes, byte... expBytes) { - Assert.assertArrayEquals(expBytes, actBytes); + assertArrayEquals(expBytes, actBytes); } /** diff --git a/json/src/test/java/com/fasterxml/jackson/jaxrs/json/TestCanDeserialize.java b/json/src/test/java/com/fasterxml/jackson/jaxrs/json/TestCanDeserialize.java index 5da49e27..555c51c7 100644 --- a/json/src/test/java/com/fasterxml/jackson/jaxrs/json/TestCanDeserialize.java +++ b/json/src/test/java/com/fasterxml/jackson/jaxrs/json/TestCanDeserialize.java @@ -9,14 +9,19 @@ import javax.ws.rs.core.MediaType; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.jaxrs.cfg.JaxRSFeature; +import static org.junit.jupiter.api.Assertions.*; + /** * Unit test to check [JACKSON-540] */ public class TestCanDeserialize extends JaxrsTestBase { @SuppressWarnings({ "unchecked", "rawtypes" }) + @Test public void testCanDeserialize() throws IOException { Map object = new LinkedHashMap(); JacksonJsonProvider prov = new JacksonJsonProvider(); @@ -31,6 +36,7 @@ public void testCanDeserialize() throws IOException { } @SuppressWarnings({ "unchecked", "rawtypes" }) + @Test public void testCanDeserializeEmpty() throws IOException { JacksonJsonProvider prov = new JacksonJsonProvider(); @@ -46,7 +52,8 @@ public void testCanDeserializeEmpty() throws IOException { /** * Unit test for verifying functioning of {@link JaxRSFeature#ALLOW_EMPTY_INPUT}. */ - public void testFailingDeserializeEmpty() throws IOException { + @Test + public void testFailingDeserializeEmpty() throws IOException { JacksonJsonProvider prov = new JacksonJsonProvider(); prov.disable(JaxRSFeature.ALLOW_EMPTY_INPUT); diff --git a/json/src/test/java/com/fasterxml/jackson/jaxrs/json/TestCanSerialize.java b/json/src/test/java/com/fasterxml/jackson/jaxrs/json/TestCanSerialize.java index c7f108a7..1a1c6111 100644 --- a/json/src/test/java/com/fasterxml/jackson/jaxrs/json/TestCanSerialize.java +++ b/json/src/test/java/com/fasterxml/jackson/jaxrs/json/TestCanSerialize.java @@ -3,11 +3,15 @@ import java.io.*; import java.util.*; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.json.JsonMapper; +import static org.junit.jupiter.api.Assertions.*; + /** * Unit test to check [JACKSON-540] */ @@ -20,6 +24,7 @@ static class Simple { public void setList(List l) { list = l; } } + @Test public void testCanSerialize() throws IOException { ObjectMapper mapper = JsonMapper.builder() diff --git a/json/src/test/java/com/fasterxml/jackson/jaxrs/json/TestJSONVersions.java b/json/src/test/java/com/fasterxml/jackson/jaxrs/json/TestJSONVersions.java index 2b5244f7..3336eb80 100644 --- a/json/src/test/java/com/fasterxml/jackson/jaxrs/json/TestJSONVersions.java +++ b/json/src/test/java/com/fasterxml/jackson/jaxrs/json/TestJSONVersions.java @@ -1,10 +1,15 @@ package com.fasterxml.jackson.jaxrs.json; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.core.Version; import com.fasterxml.jackson.core.Versioned; +import static org.junit.jupiter.api.Assertions.*; + public class TestJSONVersions extends JaxrsTestBase { + @Test public void testMapperVersions() { assertVersion(new JacksonJsonProvider()); @@ -19,7 +24,7 @@ public void testMapperVersions() private void assertVersion(Versioned vers) { final Version v = vers.version(); - assertFalse("Should find version information (got "+v+")", v.isUnknownVersion()); + assertFalse(v.isUnknownVersion(), "Should find version information (got "+v+")"); Version exp = PackageVersion.VERSION; assertEquals(exp.toFullString(), v.toFullString()); assertEquals(exp, v); diff --git a/json/src/test/java/com/fasterxml/jackson/jaxrs/json/TestJacksonFeatures.java b/json/src/test/java/com/fasterxml/jackson/jaxrs/json/TestJacksonFeatures.java index 022a7f31..d703df14 100644 --- a/json/src/test/java/com/fasterxml/jackson/jaxrs/json/TestJacksonFeatures.java +++ b/json/src/test/java/com/fasterxml/jackson/jaxrs/json/TestJacksonFeatures.java @@ -6,6 +6,8 @@ import javax.ws.rs.core.MediaType; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JacksonAnnotationsInside; import com.fasterxml.jackson.databind.DeserializationFeature; @@ -13,6 +15,8 @@ import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.jaxrs.annotation.JacksonFeatures; +import static org.junit.jupiter.api.Assertions.*; + /** * Tests for [Issue-2], Addition of {@link JacksonFeatures}. */ @@ -45,6 +49,7 @@ public void writeConfig2() { } */ // [Issue-2], serialization + @Test public void testWriteConfigs() throws Exception { JacksonJsonProvider prov = new JacksonJsonProvider(); @@ -66,6 +71,7 @@ public void testWriteConfigs() throws Exception assertEquals("{\"a\":3}", out.toString("UTF-8")); } + @Test public void testWriteConfigsViaBundle() throws Exception { JacksonJsonProvider prov = new JacksonJsonProvider(); @@ -79,6 +85,7 @@ public void testWriteConfigsViaBundle() throws Exception } // [Issue-2], deserialization + @Test public void testReadConfigs() throws Exception { JacksonJsonProvider prov = new JacksonJsonProvider(); diff --git a/json/src/test/java/com/fasterxml/jackson/jaxrs/json/TestJsonView.java b/json/src/test/java/com/fasterxml/jackson/jaxrs/json/TestJsonView.java index bd12b26c..0f392c01 100644 --- a/json/src/test/java/com/fasterxml/jackson/jaxrs/json/TestJsonView.java +++ b/json/src/test/java/com/fasterxml/jackson/jaxrs/json/TestJsonView.java @@ -6,8 +6,12 @@ import javax.ws.rs.core.MediaType; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonView; +import static org.junit.jupiter.api.Assertions.*; + public class TestJsonView extends JaxrsTestBase { static class MyView1 { } @@ -31,6 +35,7 @@ public void bogus() { } */ // [JACKSON-578] + @Test public void testViews() throws Exception { JacksonJsonProvider prov = new JacksonJsonProvider(); @@ -45,6 +50,7 @@ public void testViews() throws Exception } // [Issue#24] + @Test public void testDefaultView() throws Exception { JacksonJsonProvider prov = new JacksonJsonProvider(); diff --git a/json/src/test/java/com/fasterxml/jackson/jaxrs/json/TestJsonpWrapping.java b/json/src/test/java/com/fasterxml/jackson/jaxrs/json/TestJsonpWrapping.java index e0ee96c6..0a81d802 100644 --- a/json/src/test/java/com/fasterxml/jackson/jaxrs/json/TestJsonpWrapping.java +++ b/json/src/test/java/com/fasterxml/jackson/jaxrs/json/TestJsonpWrapping.java @@ -5,9 +5,14 @@ import javax.ws.rs.core.MediaType; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + public class TestJsonpWrapping extends JaxrsTestBase { + @Test public void testSimple() throws Exception { JacksonJsonProvider prov = new JacksonJsonProvider(); diff --git a/json/src/test/java/com/fasterxml/jackson/jaxrs/json/TestRootType.java b/json/src/test/java/com/fasterxml/jackson/jaxrs/json/TestRootType.java index f89fdaaf..cc6af2bb 100644 --- a/json/src/test/java/com/fasterxml/jackson/jaxrs/json/TestRootType.java +++ b/json/src/test/java/com/fasterxml/jackson/jaxrs/json/TestRootType.java @@ -7,11 +7,15 @@ import javax.ws.rs.core.MediaType; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.annotation.JsonTypeInfo.As; import com.fasterxml.jackson.annotation.JsonTypeInfo.Id; import com.fasterxml.jackson.core.type.TypeReference; +import static org.junit.jupiter.api.Assertions.assertEquals; + public class TestRootType extends JaxrsTestBase { @@ -26,7 +30,8 @@ static class Bean { /* Test methods /********************************************************************** */ - + + @Test public void testRootType() throws Exception { JacksonJsonProvider prov = new JacksonJsonProvider(); diff --git a/json/src/test/java/com/fasterxml/jackson/jaxrs/json/TestSerializeWithoutAutoflush.java b/json/src/test/java/com/fasterxml/jackson/jaxrs/json/TestSerializeWithoutAutoflush.java index e868af37..43c548ea 100644 --- a/json/src/test/java/com/fasterxml/jackson/jaxrs/json/TestSerializeWithoutAutoflush.java +++ b/json/src/test/java/com/fasterxml/jackson/jaxrs/json/TestSerializeWithoutAutoflush.java @@ -8,11 +8,15 @@ import javax.ws.rs.core.MediaType; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.json.JsonMapper; +import static org.junit.jupiter.api.Assertions.*; + /** * Unit test to check that ProviderBase always writes its content, even if flush-after-write is off. */ @@ -25,6 +29,7 @@ static class Simple { public void setList(List l) { list = l; } } + @Test public void testCanSerialize() throws IOException { ObjectMapper mapper = JsonMapper.builder() diff --git a/json/src/test/java/com/fasterxml/jackson/jaxrs/json/TestStreamingOutput.java b/json/src/test/java/com/fasterxml/jackson/jaxrs/json/TestStreamingOutput.java index 4d78cf7d..e8300222 100644 --- a/json/src/test/java/com/fasterxml/jackson/jaxrs/json/TestStreamingOutput.java +++ b/json/src/test/java/com/fasterxml/jackson/jaxrs/json/TestStreamingOutput.java @@ -6,6 +6,10 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.StreamingOutput; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + public class TestStreamingOutput extends JaxrsTestBase { static class StreamingSubtype implements StreamingOutput @@ -25,6 +29,7 @@ public void write(OutputStream out) throws IOException { /********************************************************************** */ + @Test public void testSimpleSubtype() throws Exception { JacksonJsonProvider prov = new JacksonJsonProvider(); diff --git a/json/src/test/java/com/fasterxml/jackson/jaxrs/json/TestUntouchables.java b/json/src/test/java/com/fasterxml/jackson/jaxrs/json/TestUntouchables.java index 9ed8012a..47496e4a 100644 --- a/json/src/test/java/com/fasterxml/jackson/jaxrs/json/TestUntouchables.java +++ b/json/src/test/java/com/fasterxml/jackson/jaxrs/json/TestUntouchables.java @@ -7,6 +7,10 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.StreamingOutput; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + /** * Unit tests for verifying that certain JDK base types will be * ignored by default Jackson JAX-RS conversion provider. @@ -36,7 +40,8 @@ public void write(OutputStream output) { } /* Unit tests /********************************************************** */ - + + @Test public void testDefaultUntouchables() throws Exception { JacksonJsonProvider prov = new JacksonJsonProvider(); @@ -59,6 +64,7 @@ public void testDefaultUntouchables() throws Exception new Annotation[0], MediaType.APPLICATION_JSON_TYPE)); } + @Test public void testCustomUntouchables() throws Exception { JacksonJsonProvider prov = new JacksonJsonProvider(); diff --git a/json/src/test/java/com/fasterxml/jackson/jaxrs/json/dw/AnnotationTestBase.java b/json/src/test/java/com/fasterxml/jackson/jaxrs/json/dw/AnnotationTestBase.java index 4f89828f..939e79f4 100644 --- a/json/src/test/java/com/fasterxml/jackson/jaxrs/json/dw/AnnotationTestBase.java +++ b/json/src/test/java/com/fasterxml/jackson/jaxrs/json/dw/AnnotationTestBase.java @@ -8,9 +8,13 @@ import org.eclipse.jetty.server.Server; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonView; +import static org.junit.jupiter.api.Assertions.*; + public abstract class AnnotationTestBase extends ResourceTestBase { final static int TEST_PORT = 6030; @@ -68,6 +72,7 @@ public static class ResourceApp extends JsonApplicationWithJackson { * Test in which writer/generator modification is handled by * changing state from Servlet Filter. */ + @Test public void testInputOutputFiltering() throws Exception { // We need a filter to inject modifier that enables diff --git a/json/src/test/java/com/fasterxml/jackson/jaxrs/json/dw/SimpleEndpointTestBase.java b/json/src/test/java/com/fasterxml/jackson/jaxrs/json/dw/SimpleEndpointTestBase.java index 5ebc0bb1..b448cc8d 100644 --- a/json/src/test/java/com/fasterxml/jackson/jaxrs/json/dw/SimpleEndpointTestBase.java +++ b/json/src/test/java/com/fasterxml/jackson/jaxrs/json/dw/SimpleEndpointTestBase.java @@ -34,7 +34,7 @@ import javax.ws.rs.core.UriInfo; import org.eclipse.jetty.server.Server; -import org.junit.Assert; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; @@ -56,6 +56,8 @@ import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; +import static org.junit.jupiter.api.Assertions.*; + public abstract class SimpleEndpointTestBase extends ResourceTestBase { final protected static int TEST_PORT = 6011; @@ -380,6 +382,7 @@ public static class SimpleDynamicTypingApp extends JsonApplicationWithJackson { /********************************************************** */ + @Test public void testStandardJson() throws Exception { final ObjectMapper mapper = new ObjectMapper(); @@ -399,6 +402,7 @@ public void testStandardJson() throws Exception assertEquals(2, p.y); } + @Test public void testAcceptJavascriptType() throws Exception { final ObjectMapper mapper = new ObjectMapper(); @@ -476,6 +480,7 @@ public Point maxPoint(MappingIterator points) throws IOException */ // [jaxrs-providers#69] + @Test public void testMappingIterator() throws Exception { final ObjectMapper mapper = new ObjectMapper(); @@ -506,6 +511,7 @@ public void testMappingIterator() throws Exception } // [jaxrs-providers#108] + @Test public void testPointNoTrailingContent() throws Exception { final ObjectMapper mapper = new ObjectMapper(); @@ -554,6 +560,7 @@ public void testPointNoTrailingContent() throws Exception // [Issue#34] Verify that Untouchables act the way as they should @SuppressWarnings("resource") + @Test public void testUntouchables() throws Exception { Server server = startServer(TEST_PORT, SimpleRawApp.class); @@ -562,7 +569,7 @@ public void testUntouchables() throws Exception assertEquals(UNTOUCHABLE_RESPONSE, readUTF8(in)); in = new URL("http://localhost:"+TEST_PORT+"/raw/bytes").openStream(); - Assert.assertArrayEquals(UNTOUCHABLE_RESPONSE.getBytes("UTF-8"), readAll(in)); + assertArrayEquals(UNTOUCHABLE_RESPONSE.getBytes("UTF-8"), readAll(in)); } finally { server.stop(); } @@ -573,6 +580,7 @@ public void testUntouchables() throws Exception * but does not do actual data format content. Goal being to ensure that * StreamingOutput works as expected even if provider is registered. */ + @Test public void testHugeFluffyContent() throws Exception { Server server = startServer(TEST_PORT, SimpleFluffyApp.class); @@ -607,6 +615,7 @@ public void testHugeFluffyContent() throws Exception } } + @Test public void testDynamicTypingSingle() throws Exception { final ObjectMapper mapper = new ObjectMapper(); @@ -628,6 +637,7 @@ public void testDynamicTypingSingle() throws Exception } // for [#60], problems with non-polymorphic Lists + @Test public void testDynamicTypingList() throws Exception { final ObjectMapper mapper = new ObjectMapper(); @@ -654,11 +664,13 @@ public void testDynamicTypingList() throws Exception } // for [#87], problems with GenericEntity where type != rawType + @Test public void testDynamicTypingGenericPageEntity() throws Exception { testDynamicTypingPage(URI.create("http://localhost:" + TEST_PORT + "/dynamic/genericPageEntity")); } // for [#87], problems with GenericEntity where type != rawType + @Test public void testDynamicTypingGenericPageImplEntity() throws Exception { testDynamicTypingPage(URI.create("http://localhost:" + TEST_PORT + "/dynamic/genericPageImplEntity")); } @@ -687,11 +699,13 @@ private void testDynamicTypingPage(URI uri) throws Exception { } // for [#87], problems with GenericEntity where type != rawType + @Test public void testDynamicTypingGenericCollectionEntity() throws Exception { testDynamicTypingCollection(URI.create("http://localhost:" + TEST_PORT + "/dynamic/genericCollectionEntity")); } // for [#87], problems with GenericEntity where type != rawType + @Test public void testDynamicTypingGenericCollectionImplEntity() throws Exception { testDynamicTypingCollection(URI .create("http://localhost:" + TEST_PORT + "/dynamic/genericCollectionImplEntity")); diff --git a/json/src/test/java/com/fasterxml/jackson/jaxrs/json/dw/WriteModificationsTestBase.java b/json/src/test/java/com/fasterxml/jackson/jaxrs/json/dw/WriteModificationsTestBase.java index ed24c3ab..a7b262b1 100644 --- a/json/src/test/java/com/fasterxml/jackson/jaxrs/json/dw/WriteModificationsTestBase.java +++ b/json/src/test/java/com/fasterxml/jackson/jaxrs/json/dw/WriteModificationsTestBase.java @@ -13,12 +13,16 @@ import org.eclipse.jetty.server.Server; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.ObjectWriter; import com.fasterxml.jackson.jaxrs.cfg.EndpointConfigBase; import com.fasterxml.jackson.jaxrs.cfg.ObjectWriterInjector; import com.fasterxml.jackson.jaxrs.cfg.ObjectWriterModifier; +import static org.junit.jupiter.api.Assertions.*; + public abstract class WriteModificationsTestBase extends ResourceTestBase { final static int TEST_PORT = 6021; @@ -128,6 +132,7 @@ public void destroy() { } * Test in which writer/generator modification is handled by * changing state from Servlet Filter. */ + @Test public void testIndentationWithFilter() throws Exception { // We need a filter to inject modifier that enables @@ -154,6 +159,7 @@ public void testIndentationWithFilter() throws Exception * Test in which output writer/generator is modified by assignment from * resource method itself. */ + @Test public void testIndentationWithResource() throws Exception { // We need a filter to inject modifier that enables diff --git a/json/src/test/java/com/fasterxml/jackson/jaxrs/json/resteasy/RestEasyProviderLoadingTest.java b/json/src/test/java/com/fasterxml/jackson/jaxrs/json/resteasy/RestEasyProviderLoadingTest.java index 3c5e5c48..207f2b1b 100644 --- a/json/src/test/java/com/fasterxml/jackson/jaxrs/json/resteasy/RestEasyProviderLoadingTest.java +++ b/json/src/test/java/com/fasterxml/jackson/jaxrs/json/resteasy/RestEasyProviderLoadingTest.java @@ -2,10 +2,15 @@ import org.jboss.resteasy.plugins.providers.jackson.ResteasyJackson2Provider; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.jaxrs.json.JaxrsTestBase; +import static org.junit.jupiter.api.Assertions.assertNotNull; + public class RestEasyProviderLoadingTest extends JaxrsTestBase { + @Test public void testLoading() throws Exception { ResteasyJackson2Provider provider = new ResteasyJackson2Provider(); diff --git a/json/src/test/java/com/fasterxml/jackson/jaxrs/json/util/TestAnnotationBundleKey.java b/json/src/test/java/com/fasterxml/jackson/jaxrs/json/util/TestAnnotationBundleKey.java index 4ed730b3..81cb8e43 100644 --- a/json/src/test/java/com/fasterxml/jackson/jaxrs/json/util/TestAnnotationBundleKey.java +++ b/json/src/test/java/com/fasterxml/jackson/jaxrs/json/util/TestAnnotationBundleKey.java @@ -3,11 +3,15 @@ import java.lang.annotation.Annotation; import java.lang.reflect.Method; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.jaxrs.cfg.AnnotationBundleKey; import com.fasterxml.jackson.jaxrs.json.JaxrsTestBase; import com.fasterxml.jackson.jaxrs.json.annotation.JSONP; +import static org.junit.jupiter.api.Assertions.*; + public class TestAnnotationBundleKey extends JaxrsTestBase { @JSONP("foo") @@ -22,6 +26,7 @@ public void annotated2() { } /********************************************************** */ + @Test public void testKeys() throws Exception { Method m1 = getClass().getDeclaredMethod("annotated1"); diff --git a/pom.xml b/pom.xml index 946356ce..525d4107 100644 --- a/pom.xml +++ b/pom.xml @@ -123,10 +123,14 @@ https://stackoverflow.com/questions/44088493/jersey-stopped-working-with-injecti ${version.jersey} test - - junit - junit + org.junit.jupiter + junit-jupiter + test + + + org.junit.jupiter + junit-jupiter-api test diff --git a/smile/src/test/java/com/fasterxml/jackson/jaxrs/smile/JaxrsTestBase.java b/smile/src/test/java/com/fasterxml/jackson/jaxrs/smile/JaxrsTestBase.java index 8762b680..8db6834a 100644 --- a/smile/src/test/java/com/fasterxml/jackson/jaxrs/smile/JaxrsTestBase.java +++ b/smile/src/test/java/com/fasterxml/jackson/jaxrs/smile/JaxrsTestBase.java @@ -5,12 +5,11 @@ import java.io.InputStream; import java.util.Arrays; -import org.junit.Assert; - import com.fasterxml.jackson.core.*; +import static org.junit.jupiter.api.Assertions.*; + public abstract class JaxrsTestBase - extends junit.framework.TestCase { /* /********************************************************** @@ -56,7 +55,7 @@ protected void verifyException(Throwable e, String... matches) protected void _verifyBytes(byte[] actBytes, byte... expBytes) { - Assert.assertArrayEquals(expBytes, actBytes); + assertArrayEquals(expBytes, actBytes); } /** diff --git a/smile/src/test/java/com/fasterxml/jackson/jaxrs/smile/TestCanDeserialize.java b/smile/src/test/java/com/fasterxml/jackson/jaxrs/smile/TestCanDeserialize.java index f9d3a33b..3da52ae9 100644 --- a/smile/src/test/java/com/fasterxml/jackson/jaxrs/smile/TestCanDeserialize.java +++ b/smile/src/test/java/com/fasterxml/jackson/jaxrs/smile/TestCanDeserialize.java @@ -5,6 +5,10 @@ import javax.ws.rs.core.MediaType; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + /** * Unit test to check [JACKSON-540] */ @@ -28,6 +32,7 @@ public void testCanSerialize() throws IOException */ // [Issue#1]: exception for no content + @Test public void testCanSerializeEmpty() throws IOException { JacksonSmileProvider prov = new JacksonSmileProvider(); diff --git a/smile/src/test/java/com/fasterxml/jackson/jaxrs/smile/TestSmileVersions.java b/smile/src/test/java/com/fasterxml/jackson/jaxrs/smile/TestSmileVersions.java index c5ee6f55..8dd70e4f 100644 --- a/smile/src/test/java/com/fasterxml/jackson/jaxrs/smile/TestSmileVersions.java +++ b/smile/src/test/java/com/fasterxml/jackson/jaxrs/smile/TestSmileVersions.java @@ -1,10 +1,15 @@ package com.fasterxml.jackson.jaxrs.smile; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.core.Version; import com.fasterxml.jackson.core.Versioned; +import static org.junit.jupiter.api.Assertions.*; + public class TestSmileVersions extends JaxrsTestBase { + @Test public void testMapperVersions() { assertVersion(new JacksonSmileProvider()); @@ -19,7 +24,7 @@ public void testMapperVersions() private void assertVersion(Versioned vers) { final Version v = vers.version(); - assertFalse("Should find version information (got "+v+")", v.isUnknownVersion()); + assertFalse(v.isUnknownVersion(), "Should find version information (got "+v+")"); Version exp = PackageVersion.VERSION; assertEquals(exp.toFullString(), v.toFullString()); assertEquals(exp, v); diff --git a/smile/src/test/java/com/fasterxml/jackson/jaxrs/smile/dw/SimpleEndpointTestBase.java b/smile/src/test/java/com/fasterxml/jackson/jaxrs/smile/dw/SimpleEndpointTestBase.java index 2e35ec46..8126f9d0 100644 --- a/smile/src/test/java/com/fasterxml/jackson/jaxrs/smile/dw/SimpleEndpointTestBase.java +++ b/smile/src/test/java/com/fasterxml/jackson/jaxrs/smile/dw/SimpleEndpointTestBase.java @@ -6,12 +6,14 @@ import javax.ws.rs.*; import org.eclipse.jetty.server.Server; -import org.junit.Assert; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.smile.SmileFactory; import com.fasterxml.jackson.jaxrs.smile.SmileMediaTypes; +import static org.junit.jupiter.api.Assertions.*; + public abstract class SimpleEndpointTestBase extends ResourceTestBase { final static int TEST_PORT = 6011; @@ -70,6 +72,7 @@ public static class SimpleRawApp extends SmileApplicationWithJackson { /********************************************************** */ + @Test public void testStandardSmile() throws Exception { final ObjectMapper mapper = new ObjectMapper(new SmileFactory()); @@ -89,6 +92,7 @@ public void testStandardSmile() throws Exception assertEquals(2, p.y); } + @Test public void testCustomMediaTypeWithSmileExtension() throws Exception { final ObjectMapper mapper = new ObjectMapper(new SmileFactory()); @@ -113,12 +117,13 @@ public void testCustomMediaTypeWithSmileExtension() throws Exception // [Issue#34] Verify that Untouchables act the way as they should @SuppressWarnings("resource") + @Test public void testUntouchables() throws Exception { Server server = startServer(TEST_PORT, SimpleRawApp.class); try { InputStream in = new URL("http://localhost:"+TEST_PORT+"/raw/bytes").openStream(); - Assert.assertArrayEquals(UNTOUCHABLE_RESPONSE, readAll(in)); + assertArrayEquals(UNTOUCHABLE_RESPONSE, readAll(in)); } finally { server.stop(); } diff --git a/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/JaxrsTestBase.java b/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/JaxrsTestBase.java index 25d3c59c..77dc742f 100644 --- a/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/JaxrsTestBase.java +++ b/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/JaxrsTestBase.java @@ -5,12 +5,11 @@ import java.io.InputStream; import java.util.Arrays; -import org.junit.Assert; - import com.fasterxml.jackson.core.*; +import static org.junit.jupiter.api.Assertions.*; + public abstract class JaxrsTestBase - extends junit.framework.TestCase { /* /********************************************************** @@ -56,7 +55,7 @@ protected void verifyException(Throwable e, String... matches) protected void _verifyBytes(byte[] actBytes, byte... expBytes) { - Assert.assertArrayEquals(expBytes, actBytes); + assertArrayEquals(expBytes, actBytes); } /** diff --git a/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/TestCanDeserialize.java b/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/TestCanDeserialize.java index 8303c060..5cecb5a7 100644 --- a/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/TestCanDeserialize.java +++ b/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/TestCanDeserialize.java @@ -5,6 +5,10 @@ import javax.ws.rs.core.MediaType; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + /** * Unit test to check [JACKSON-540] */ @@ -13,7 +17,8 @@ public class TestCanDeserialize extends JaxrsTestBase static class Bean { public int x; } - + + @Test public void testCanSerialize() throws IOException { JacksonXMLProvider prov = new JacksonXMLProvider(); @@ -26,6 +31,7 @@ public void testCanSerialize() throws IOException } // [Issue#4]: exception for no content + @Test public void testCanSerializeEmpty() throws IOException { JacksonXMLProvider prov = new JacksonXMLProvider(); diff --git a/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/TestCanSerialize.java b/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/TestCanSerialize.java index 88b05221..2806a97c 100644 --- a/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/TestCanSerialize.java +++ b/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/TestCanSerialize.java @@ -3,9 +3,13 @@ import java.io.*; import java.util.*; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.json.JsonMapper; +import static org.junit.jupiter.api.Assertions.*; + /** * Unit test to check [JACKSON-540] */ @@ -18,6 +22,7 @@ static class Simple { public void setList(List l) { list = l; } } + @Test public void testCanSerialize() throws IOException { ObjectMapper mapper = new JsonMapper(); diff --git a/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/TestJacksonFeaturesWithXML.java b/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/TestJacksonFeaturesWithXML.java index 4d77cae5..a510f670 100644 --- a/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/TestJacksonFeaturesWithXML.java +++ b/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/TestJacksonFeaturesWithXML.java @@ -6,6 +6,8 @@ import javax.ws.rs.core.MediaType; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JacksonAnnotationsInside; import com.fasterxml.jackson.databind.DeserializationFeature; @@ -14,6 +16,8 @@ import com.fasterxml.jackson.jaxrs.annotation.JacksonFeatures; +import static org.junit.jupiter.api.Assertions.*; + /** * Tests for [Issue-2], Addition of {@link JacksonFeatures}. */ @@ -46,6 +50,7 @@ public void writeConfig2() { } */ // [Issue-2], serialization + @Test public void testWriteConfigs() throws Exception { JacksonXMLProvider prov = new JacksonXMLProvider(); @@ -75,7 +80,8 @@ public void testWriteConfigs() throws Exception MediaType.APPLICATION_JSON_TYPE, null, out); assertEquals("3", out.toString("UTF-8")); } - + + @Test public void testWriteConfigsViaBundle() throws Exception { JacksonXMLProvider prov = new JacksonXMLProvider(); @@ -90,6 +96,7 @@ public void testWriteConfigsViaBundle() throws Exception } // [Issue-2], deserialization + @Test public void testReadConfigs() throws Exception { JacksonXMLProvider prov = new JacksonXMLProvider(); diff --git a/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/TestJsonView.java b/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/TestJsonView.java index 79f9d508..58594254 100644 --- a/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/TestJsonView.java +++ b/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/TestJsonView.java @@ -6,8 +6,12 @@ import javax.ws.rs.core.MediaType; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonView; +import static org.junit.jupiter.api.Assertions.*; + public class TestJsonView extends JaxrsTestBase { static class MyView1 { } @@ -31,6 +35,7 @@ public void bogus() { } */ // [JACKSON-578] + @Test public void testViews() throws Exception { JacksonXMLProvider prov = new JacksonXMLProvider(); diff --git a/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/TestRootType.java b/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/TestRootType.java index cfef4a59..534db630 100644 --- a/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/TestRootType.java +++ b/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/TestRootType.java @@ -7,11 +7,15 @@ import javax.ws.rs.core.MediaType; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.annotation.JsonTypeInfo.As; import com.fasterxml.jackson.annotation.JsonTypeInfo.Id; import com.fasterxml.jackson.core.type.TypeReference; +import static org.junit.jupiter.api.Assertions.assertEquals; + public class TestRootType extends JaxrsTestBase { @@ -20,7 +24,8 @@ public class TestRootType static class Bean { public int a = 3; } - + + @Test public void testRootType() throws Exception { JacksonXMLProvider prov = new JacksonXMLProvider(); diff --git a/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/TestSerialize.java b/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/TestSerialize.java index ff26f2a1..c67a63c9 100644 --- a/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/TestSerialize.java +++ b/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/TestSerialize.java @@ -6,9 +6,13 @@ import javax.ws.rs.core.MediaType; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonRootName; +import static org.junit.jupiter.api.Assertions.assertEquals; + public class TestSerialize extends JaxrsTestBase { // for [Issue-1] @@ -48,6 +52,7 @@ public int getPageNumber() { */ // [Issue-1] + @Test public void testSimpleWriteTo() throws Exception { Messages msgs = new Messages(); diff --git a/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/TestUntouchables.java b/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/TestUntouchables.java index d3078955..be606f0f 100644 --- a/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/TestUntouchables.java +++ b/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/TestUntouchables.java @@ -6,6 +6,10 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.StreamingOutput; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + /** * Unit tests for verifying that certain JDK base types will be * ignored by default Jackson JAX-RS conversion provider. @@ -30,7 +34,8 @@ public static class MyJacksonProvider extends JacksonXMLProvider { /* Unit tests /********************************************************** */ - + + @Test public void testDefaultUntouchables() throws Exception { JacksonXMLProvider prov = new JacksonXMLProvider(); @@ -51,6 +56,7 @@ public void testDefaultUntouchables() throws Exception new Annotation[0], MediaType.APPLICATION_XML_TYPE)); } + @Test public void testCustomUntouchables() throws Exception { JacksonXMLProvider prov = new JacksonXMLProvider(); diff --git a/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/TestXMLVersions.java b/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/TestXMLVersions.java index 73a2ad54..11fa774c 100644 --- a/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/TestXMLVersions.java +++ b/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/TestXMLVersions.java @@ -1,10 +1,15 @@ package com.fasterxml.jackson.jaxrs.xml; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.core.Version; import com.fasterxml.jackson.core.Versioned; +import static org.junit.jupiter.api.Assertions.*; + public class TestXMLVersions extends JaxrsTestBase { + @Test public void testMapperVersions() { assertVersion(new JacksonXMLProvider()); @@ -19,7 +24,7 @@ public void testMapperVersions() private void assertVersion(Versioned vers) { final Version v = vers.version(); - assertFalse("Should find version information (got "+v+")", v.isUnknownVersion()); + assertFalse(v.isUnknownVersion(), "Should find version information (got "+v+")"); Version exp = PackageVersion.VERSION; assertEquals(exp.toFullString(), v.toFullString()); assertEquals(exp, v); diff --git a/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/dw/SimpleEndpointTestBase.java b/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/dw/SimpleEndpointTestBase.java index 7c0f7a4e..e6ce9c41 100644 --- a/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/dw/SimpleEndpointTestBase.java +++ b/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/dw/SimpleEndpointTestBase.java @@ -9,11 +9,13 @@ import javax.ws.rs.core.MediaType; import org.eclipse.jetty.server.Server; -import org.junit.Assert; +import org.junit.jupiter.api.Test; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.xml.XmlMapper; +import static org.junit.jupiter.api.Assertions.*; + public abstract class SimpleEndpointTestBase extends ResourceTestBase { final static int TEST_PORT = 6011; @@ -72,6 +74,7 @@ public static class SimpleRawApp extends XMLApplicationWithJackson { /********************************************************** */ + @Test public void testSimplePoint() throws Exception { final ObjectMapper mapper = new XmlMapper(); @@ -99,6 +102,7 @@ public void testSimplePoint() throws Exception } } + @Test public void testCustomMediaTypeWithXmlExtension() throws Exception { final ObjectMapper mapper = new XmlMapper(); @@ -123,12 +127,13 @@ public void testCustomMediaTypeWithXmlExtension() throws Exception // [Issue#34] Verify that Untouchables act the way as they should @SuppressWarnings("resource") + @Test public void testUntouchables() throws Exception { Server server = startServer(TEST_PORT, SimpleRawApp.class); try { InputStream in = new URL("http://localhost:"+TEST_PORT+"/raw/bytes").openStream(); - Assert.assertArrayEquals(UNTOUCHABLE_RESPONSE, readAll(in)); + assertArrayEquals(UNTOUCHABLE_RESPONSE, readAll(in)); } finally { server.stop(); } diff --git a/yaml/src/test/java/com/fasterxml/jackson/jaxrs/yaml/JaxrsTestBase.java b/yaml/src/test/java/com/fasterxml/jackson/jaxrs/yaml/JaxrsTestBase.java index 78788814..f4509822 100644 --- a/yaml/src/test/java/com/fasterxml/jackson/jaxrs/yaml/JaxrsTestBase.java +++ b/yaml/src/test/java/com/fasterxml/jackson/jaxrs/yaml/JaxrsTestBase.java @@ -4,8 +4,6 @@ import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonToken; -import org.junit.Assert; - import javax.ws.rs.core.MediaType; import java.io.ByteArrayOutputStream; @@ -13,8 +11,9 @@ import java.io.InputStream; import java.util.Arrays; +import static org.junit.jupiter.api.Assertions.*; + public abstract class JaxrsTestBase - extends junit.framework.TestCase { public static final MediaType YAML_MEDIA_TYPE = YAMLMediaTypes.APPLICATION_JACKSON_YAML_TYPE; @@ -62,7 +61,7 @@ protected void verifyException(Throwable e, String... matches) protected void _verifyBytes(byte[] actBytes, byte... expBytes) { - Assert.assertArrayEquals(expBytes, actBytes); + assertArrayEquals(expBytes, actBytes); } /** diff --git a/yaml/src/test/java/com/fasterxml/jackson/jaxrs/yaml/TestCanDeserialize.java b/yaml/src/test/java/com/fasterxml/jackson/jaxrs/yaml/TestCanDeserialize.java index 092eabda..b4826b0a 100644 --- a/yaml/src/test/java/com/fasterxml/jackson/jaxrs/yaml/TestCanDeserialize.java +++ b/yaml/src/test/java/com/fasterxml/jackson/jaxrs/yaml/TestCanDeserialize.java @@ -5,6 +5,10 @@ import java.io.InputStream; import java.lang.annotation.Annotation; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + /** * Unit test to check [JACKSON-540] */ @@ -14,7 +18,8 @@ public class TestCanDeserialize extends JaxrsTestBase static class Bean { public int x; } - + + @Test public void testCanSerialize() throws IOException { JacksonYAMLProvider prov = new JacksonYAMLProvider(); @@ -27,6 +32,7 @@ public void testCanSerialize() throws IOException } // [Issue#4]: exception for no content + @Test public void testCanSerializeEmpty() throws IOException { JacksonYAMLProvider prov = new JacksonYAMLProvider(); diff --git a/yaml/src/test/java/com/fasterxml/jackson/jaxrs/yaml/TestCanSerialize.java b/yaml/src/test/java/com/fasterxml/jackson/jaxrs/yaml/TestCanSerialize.java index 2fd68b5d..aeb53571 100644 --- a/yaml/src/test/java/com/fasterxml/jackson/jaxrs/yaml/TestCanSerialize.java +++ b/yaml/src/test/java/com/fasterxml/jackson/jaxrs/yaml/TestCanSerialize.java @@ -7,6 +7,10 @@ import java.util.ArrayList; import java.util.List; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + public class TestCanSerialize extends JaxrsTestBase { static class Simple { @@ -16,6 +20,7 @@ static class Simple { public void setList(List l) { list = l; } } + @Test public void testCanSerialize() throws IOException { ObjectMapper mapper = new YAMLMapper(); diff --git a/yaml/src/test/java/com/fasterxml/jackson/jaxrs/yaml/TestJacksonFeaturesWithYAML.java b/yaml/src/test/java/com/fasterxml/jackson/jaxrs/yaml/TestJacksonFeaturesWithYAML.java index 457d38ae..fbc765c5 100644 --- a/yaml/src/test/java/com/fasterxml/jackson/jaxrs/yaml/TestJacksonFeaturesWithYAML.java +++ b/yaml/src/test/java/com/fasterxml/jackson/jaxrs/yaml/TestJacksonFeaturesWithYAML.java @@ -12,6 +12,10 @@ import java.lang.annotation.*; import java.lang.reflect.Method; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + /** * Tests for [Issue-2], Addition of {@link JacksonFeatures}. */ @@ -44,6 +48,7 @@ public void writeConfig2() { } */ // [Issue-2], serialization + @Test public void testWriteConfigs() throws Exception { JacksonYAMLProvider prov = new JacksonYAMLProvider(); @@ -67,7 +72,8 @@ public void testWriteConfigs() throws Exception MediaType.APPLICATION_JSON_TYPE, null, out); assertEquals("---\na: 3\n", out.toString("UTF-8")); } - + + @Test public void testWriteConfigsViaBundle() throws Exception { JacksonYAMLProvider prov = new JacksonYAMLProvider(); @@ -82,6 +88,7 @@ public void testWriteConfigsViaBundle() throws Exception } // [Issue-2], deserialization + @Test public void testReadConfigs() throws Exception { JacksonYAMLProvider prov = new JacksonYAMLProvider(); diff --git a/yaml/src/test/java/com/fasterxml/jackson/jaxrs/yaml/TestJsonView.java b/yaml/src/test/java/com/fasterxml/jackson/jaxrs/yaml/TestJsonView.java index c5a25a2b..30e8b547 100644 --- a/yaml/src/test/java/com/fasterxml/jackson/jaxrs/yaml/TestJsonView.java +++ b/yaml/src/test/java/com/fasterxml/jackson/jaxrs/yaml/TestJsonView.java @@ -7,6 +7,10 @@ import java.lang.annotation.Annotation; import java.lang.reflect.Method; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + public class TestJsonView extends JaxrsTestBase { static class MyView1 { } @@ -33,6 +37,7 @@ public void bogus() { */ // [JACKSON-578] + @Test public void testViews() throws Exception { JacksonYAMLProvider prov = new JacksonYAMLProvider(); ByteArrayOutputStream out = new ByteArrayOutputStream(); diff --git a/yaml/src/test/java/com/fasterxml/jackson/jaxrs/yaml/TestRootType.java b/yaml/src/test/java/com/fasterxml/jackson/jaxrs/yaml/TestRootType.java index 36cc1bb0..4a144b21 100644 --- a/yaml/src/test/java/com/fasterxml/jackson/jaxrs/yaml/TestRootType.java +++ b/yaml/src/test/java/com/fasterxml/jackson/jaxrs/yaml/TestRootType.java @@ -12,6 +12,10 @@ import java.util.ArrayList; import java.util.List; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + public class TestRootType extends JaxrsTestBase { @@ -20,7 +24,8 @@ public class TestRootType static class Bean { public int a = 3; } - + + @Test public void testRootType() throws Exception { JacksonYAMLProvider prov = new JacksonYAMLProvider(); diff --git a/yaml/src/test/java/com/fasterxml/jackson/jaxrs/yaml/TestSerialize.java b/yaml/src/test/java/com/fasterxml/jackson/jaxrs/yaml/TestSerialize.java index e9551986..03d7c6ac 100644 --- a/yaml/src/test/java/com/fasterxml/jackson/jaxrs/yaml/TestSerialize.java +++ b/yaml/src/test/java/com/fasterxml/jackson/jaxrs/yaml/TestSerialize.java @@ -9,6 +9,10 @@ import java.util.ArrayList; import java.util.List; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + public class TestSerialize extends JaxrsTestBase { // for [Issue-1] @@ -48,6 +52,7 @@ public int getPageNumber() { */ // [Issue-1] + @Test public void testSimpleWriteTo() throws Exception { Messages msgs = new Messages(); diff --git a/yaml/src/test/java/com/fasterxml/jackson/jaxrs/yaml/TestUntouchables.java b/yaml/src/test/java/com/fasterxml/jackson/jaxrs/yaml/TestUntouchables.java index a8739513..d9889249 100644 --- a/yaml/src/test/java/com/fasterxml/jackson/jaxrs/yaml/TestUntouchables.java +++ b/yaml/src/test/java/com/fasterxml/jackson/jaxrs/yaml/TestUntouchables.java @@ -8,6 +8,9 @@ import java.util.Collection; import java.util.HashSet; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; /** * Unit tests for verifying that certain JDK base types will be @@ -34,6 +37,7 @@ public static class MyJacksonProvider extends JacksonYAMLProvider { /********************************************************** */ + @Test public void testDefaultUntouchables() throws Exception { JacksonYAMLProvider prov = new JacksonYAMLProvider(); @@ -54,6 +58,7 @@ public void testDefaultUntouchables() throws Exception new Annotation[0], YAMLMediaTypes.APPLICATION_JACKSON_YAML_TYPE)); } + @Test public void testCustomUntouchables() throws Exception { JacksonYAMLProvider prov = new JacksonYAMLProvider(); diff --git a/yaml/src/test/java/com/fasterxml/jackson/jaxrs/yaml/TestYAMLVersions.java b/yaml/src/test/java/com/fasterxml/jackson/jaxrs/yaml/TestYAMLVersions.java index 35290fa0..9c1c9949 100644 --- a/yaml/src/test/java/com/fasterxml/jackson/jaxrs/yaml/TestYAMLVersions.java +++ b/yaml/src/test/java/com/fasterxml/jackson/jaxrs/yaml/TestYAMLVersions.java @@ -1,10 +1,15 @@ package com.fasterxml.jackson.jaxrs.yaml; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.core.Version; import com.fasterxml.jackson.core.Versioned; +import static org.junit.jupiter.api.Assertions.*; + public class TestYAMLVersions extends JaxrsTestBase { + @Test public void testMapperVersions() { assertVersion(new JacksonYAMLProvider()); @@ -19,7 +24,7 @@ public void testMapperVersions() private void assertVersion(Versioned vers) { final Version v = vers.version(); - assertFalse("Should find version information (got "+v+")", v.isUnknownVersion()); + assertFalse(v.isUnknownVersion(), "Should find version information (got "+v+")"); Version exp = PackageVersion.VERSION; assertEquals(exp.toFullString(), v.toFullString()); assertEquals(exp, v); diff --git a/yaml/src/test/java/com/fasterxml/jackson/jaxrs/yaml/dw/SimpleEndpointTestBase.java b/yaml/src/test/java/com/fasterxml/jackson/jaxrs/yaml/dw/SimpleEndpointTestBase.java index d5e2d751..955bb640 100644 --- a/yaml/src/test/java/com/fasterxml/jackson/jaxrs/yaml/dw/SimpleEndpointTestBase.java +++ b/yaml/src/test/java/com/fasterxml/jackson/jaxrs/yaml/dw/SimpleEndpointTestBase.java @@ -10,7 +10,8 @@ import com.fasterxml.jackson.jaxrs.yaml.YAMLMediaTypes; import org.eclipse.jetty.server.Server; -import org.junit.Assert; + +import org.junit.jupiter.api.Test; import javax.ws.rs.GET; import javax.ws.rs.Path; @@ -22,6 +23,8 @@ import java.net.HttpURLConnection; import java.net.URL; +import static org.junit.jupiter.api.Assertions.*; + public abstract class SimpleEndpointTestBase extends ResourceTestBase { final static int TEST_PORT = 6011; @@ -103,6 +106,7 @@ public static class SimpleRawApp extends YAMLApplicationWithJackson { /********************************************************** */ + @Test public void testSimplePoint() throws Exception { final ObjectMapper mapper = new YAMLMapper(); @@ -132,6 +136,7 @@ public void testSimplePoint() throws Exception } } + @Test public void testCustomMediaTypeWithYamlExtension() throws Exception { final ObjectMapper mapper = new YAMLMapper(); @@ -156,6 +161,7 @@ public void testCustomMediaTypeWithYamlExtension() throws Exception // Tests that if multiple providers are registered, content negotiation works properly across regular and irregular // mime types + @Test public void testMultipleMediaTypes() throws Exception { Server server = startServer(TEST_PORT, MultiMediaTypeResourceApp.class); @@ -253,12 +259,13 @@ public void testMultipleMediaTypes() throws Exception // [Issue#34] Verify that Untouchables act the way as they should @SuppressWarnings("resource") + @Test public void testUntouchables() throws Exception { Server server = startServer(TEST_PORT, SimpleRawApp.class); try { InputStream in = new URL("http://localhost:"+TEST_PORT+"/raw/bytes").openStream(); - Assert.assertArrayEquals(UNTOUCHABLE_RESPONSE, readAll(in)); + assertArrayEquals(UNTOUCHABLE_RESPONSE, readAll(in)); } finally { server.stop(); }