diff --git a/.github/workflows/dep_build_v2.yml b/.github/workflows/dep_build_v2.yml index ff16f728..8064da99 100644 --- a/.github/workflows/dep_build_v2.yml +++ b/.github/workflows/dep_build_v2.yml @@ -20,7 +20,7 @@ jobs: steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Set up JDK - uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4.6.0 + uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0 with: distribution: 'temurin' java-version: ${{ matrix.java_version }} diff --git a/.github/workflows/dep_build_v3.yml b/.github/workflows/dep_build_v3.yml index 59d9d025..acdec2a5 100644 --- a/.github/workflows/dep_build_v3.yml +++ b/.github/workflows/dep_build_v3.yml @@ -22,7 +22,7 @@ jobs: with: ref: master - name: Set up JDK - uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4.6.0 + uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0 with: distribution: 'temurin' java-version: ${{ matrix.java_version }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 15668f5a..4810bf5a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -29,7 +29,7 @@ jobs: steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Set up JDK - uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4.6.0 + uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0 with: distribution: 'temurin' java-version: ${{ matrix.java_version }} diff --git a/base/src/test/java/module-info.java b/base/src/test/java/module-info.java index a5c7fcd0..afcb57a0 100644 --- a/base/src/test/java/module-info.java +++ b/base/src/test/java/module-info.java @@ -9,7 +9,8 @@ requires transitive tools.jackson.databind; // Additional test lib/framework dependencies - requires junit; // JUnit 4 + requires org.junit.jupiter.api; + requires org.junit.jupiter.params; // Further, need to open up test packages for JUnit et al diff --git a/base/src/test/java/tools/jackson/jaxrs/base/BaseTestBase.java b/base/src/test/java/tools/jackson/jaxrs/base/BaseTestBase.java index 3ed100a9..eb2b81b5 100644 --- a/base/src/test/java/tools/jackson/jaxrs/base/BaseTestBase.java +++ b/base/src/test/java/tools/jackson/jaxrs/base/BaseTestBase.java @@ -1,7 +1,6 @@ package tools.jackson.jaxrs.base; public abstract class BaseTestBase - extends junit.framework.TestCase { // for now just placeholder } diff --git a/base/src/test/java/tools/jackson/jaxrs/base/cfg/AnnotationBundleKeyTest.java b/base/src/test/java/tools/jackson/jaxrs/base/cfg/AnnotationBundleKeyTest.java index 27e55075..5ae4cbdd 100644 --- a/base/src/test/java/tools/jackson/jaxrs/base/cfg/AnnotationBundleKeyTest.java +++ b/base/src/test/java/tools/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 tools.jackson.databind.annotation.JsonDeserialize; import tools.jackson.databind.annotation.JsonSerialize; import tools.jackson.jaxrs.base.BaseTestBase; import tools.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/module-info.java b/cbor/src/test/java/module-info.java index e7b3339b..bb817f74 100644 --- a/cbor/src/test/java/module-info.java +++ b/cbor/src/test/java/module-info.java @@ -14,7 +14,8 @@ requires java.ws.rs; // Additional test lib/framework dependencies - requires junit; // JUnit 4 + requires org.junit.jupiter.api; + requires org.junit.jupiter.params; // Further, need to open up test packages for JUnit et al diff --git a/cbor/src/test/java/tools/jackson/jaxrs/cbor/JaxrsTestBase.java b/cbor/src/test/java/tools/jackson/jaxrs/cbor/JaxrsTestBase.java index 50aade57..9db698b0 100644 --- a/cbor/src/test/java/tools/jackson/jaxrs/cbor/JaxrsTestBase.java +++ b/cbor/src/test/java/tools/jackson/jaxrs/cbor/JaxrsTestBase.java @@ -5,12 +5,11 @@ import java.io.InputStream; import java.util.Arrays; -import org.junit.Assert; - import tools.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/tools/jackson/jaxrs/cbor/TestCBORVersions.java b/cbor/src/test/java/tools/jackson/jaxrs/cbor/TestCBORVersions.java index 59c871d9..9824446a 100644 --- a/cbor/src/test/java/tools/jackson/jaxrs/cbor/TestCBORVersions.java +++ b/cbor/src/test/java/tools/jackson/jaxrs/cbor/TestCBORVersions.java @@ -1,10 +1,15 @@ package tools.jackson.jaxrs.cbor; +import org.junit.jupiter.api.Test; + import tools.jackson.core.Version; import tools.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/tools/jackson/jaxrs/cbor/TestCanDeserialize.java b/cbor/src/test/java/tools/jackson/jaxrs/cbor/TestCanDeserialize.java index b9c813bb..23157e83 100644 --- a/cbor/src/test/java/tools/jackson/jaxrs/cbor/TestCanDeserialize.java +++ b/cbor/src/test/java/tools/jackson/jaxrs/cbor/TestCanDeserialize.java @@ -3,10 +3,14 @@ import java.io.*; import java.lang.annotation.Annotation; +import org.junit.jupiter.api.Test; + import javax.ws.rs.core.MediaType; import tools.jackson.jaxrs.cbor.JacksonCBORProvider; +import static org.junit.jupiter.api.Assertions.*; + /** * Unit test to check [JACKSON-540] */ @@ -17,6 +21,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/tools/jackson/jaxrs/cbor/dw/SimpleEndpointTestBase.java b/cbor/src/test/java/tools/jackson/jaxrs/cbor/dw/SimpleEndpointTestBase.java index 49796ec4..a6fb9071 100644 --- a/cbor/src/test/java/tools/jackson/jaxrs/cbor/dw/SimpleEndpointTestBase.java +++ b/cbor/src/test/java/tools/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 tools.jackson.databind.ObjectMapper; import tools.jackson.dataformat.cbor.CBORFactory; import tools.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/module-info.java b/datatypes/src/test/java/module-info.java index 76b06610..8256d6dd 100644 --- a/datatypes/src/test/java/module-info.java +++ b/datatypes/src/test/java/module-info.java @@ -9,7 +9,8 @@ requires java.ws.rs; // Additional test lib/framework dependencies - requires junit; // JUnit 4 + requires org.junit.jupiter.api; + requires org.junit.jupiter.params; // Further, need to open up test packages for JUnit et al diff --git a/datatypes/src/test/java/tools/jackson/datatype/jaxrs/LinkTest.java b/datatypes/src/test/java/tools/jackson/datatype/jaxrs/LinkTest.java index 700773d2..a492b3c0 100644 --- a/datatypes/src/test/java/tools/jackson/datatype/jaxrs/LinkTest.java +++ b/datatypes/src/test/java/tools/jackson/datatype/jaxrs/LinkTest.java @@ -2,12 +2,17 @@ import javax.ws.rs.core.Link; +import org.junit.jupiter.api.Test; + import tools.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/tools/jackson/datatype/jaxrs/ModuleTestBase.java b/datatypes/src/test/java/tools/jackson/datatype/jaxrs/ModuleTestBase.java index e777b9d7..510659ce 100644 --- a/datatypes/src/test/java/tools/jackson/datatype/jaxrs/ModuleTestBase.java +++ b/datatypes/src/test/java/tools/jackson/datatype/jaxrs/ModuleTestBase.java @@ -5,10 +5,10 @@ import tools.jackson.core.*; import tools.jackson.databind.ObjectMapper; import tools.jackson.databind.json.JsonMapper; -import tools.jackson.datatype.jaxrs.Jaxrs2TypesModule; + +import static org.junit.jupiter.api.Assertions.*; public abstract class ModuleTestBase - extends junit.framework.TestCase { protected ObjectMapper mapperWithModule() { return JsonMapper.builder() diff --git a/json/src/test/java/module-info.java b/json/src/test/java/module-info.java index 4d64df51..89c7886a 100644 --- a/json/src/test/java/module-info.java +++ b/json/src/test/java/module-info.java @@ -13,7 +13,8 @@ requires java.ws.rs; // Additional test lib/framework dependencies - requires junit; // JUnit 4 + requires org.junit.jupiter.api; + requires org.junit.jupiter.params; // Further, need to open up test packages for JUnit et al diff --git a/json/src/test/java/tools/jackson/jaxrs/json/JaxrsTestBase.java b/json/src/test/java/tools/jackson/jaxrs/json/JaxrsTestBase.java index a2bf295e..0d733750 100644 --- a/json/src/test/java/tools/jackson/jaxrs/json/JaxrsTestBase.java +++ b/json/src/test/java/tools/jackson/jaxrs/json/JaxrsTestBase.java @@ -2,10 +2,9 @@ import java.util.*; -import org.junit.Assert; +import static org.junit.jupiter.api.Assertions.*; public abstract class JaxrsTestBase - extends junit.framework.TestCase { /* /********************************************************************** @@ -39,7 +38,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/tools/jackson/jaxrs/json/TestCanDeserialize.java b/json/src/test/java/tools/jackson/jaxrs/json/TestCanDeserialize.java index ca030751..18f6b39c 100644 --- a/json/src/test/java/tools/jackson/jaxrs/json/TestCanDeserialize.java +++ b/json/src/test/java/tools/jackson/jaxrs/json/TestCanDeserialize.java @@ -7,19 +7,21 @@ import java.util.LinkedHashMap; import java.util.Map; +import org.junit.jupiter.api.Test; + import javax.ws.rs.core.MediaType; import javax.ws.rs.core.NoContentException; import tools.jackson.jaxrs.cfg.JaxRSFeature; import tools.jackson.jaxrs.json.JacksonJsonProvider; -/** - * Unit test to check [JACKSON-540] - */ -public class TestCanDeserialize extends JaxrsTestBase { +import static org.junit.jupiter.api.Assertions.*; - @SuppressWarnings({ "unchecked", "rawtypes" }) - public void testCanDeserialize() throws IOException { +public class TestCanDeserialize extends JaxrsTestBase +{ + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Test + public void testCanDeserialize() throws IOException { Map object = new LinkedHashMap(); JacksonJsonProvider prov = new JacksonJsonProvider(); @@ -33,6 +35,7 @@ public void testCanDeserialize() throws IOException { } @SuppressWarnings({ "unchecked", "rawtypes" }) + @Test public void testCanDeserializeEmpty() throws IOException { JacksonJsonProvider prov = new JacksonJsonProvider(); @@ -48,7 +51,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/tools/jackson/jaxrs/json/TestCanSerialize.java b/json/src/test/java/tools/jackson/jaxrs/json/TestCanSerialize.java index a62f8fd4..a718329b 100644 --- a/json/src/test/java/tools/jackson/jaxrs/json/TestCanSerialize.java +++ b/json/src/test/java/tools/jackson/jaxrs/json/TestCanSerialize.java @@ -3,12 +3,16 @@ import java.io.*; import java.util.*; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonTypeInfo; import tools.jackson.databind.DefaultTyping; import tools.jackson.databind.ObjectMapper; import tools.jackson.databind.json.JsonMapper; import tools.jackson.jaxrs.json.testutil.NoCheckSubTypeValidator; +import static org.junit.jupiter.api.Assertions.*; + public class TestCanSerialize extends JaxrsTestBase { static class Simple { @@ -18,6 +22,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/tools/jackson/jaxrs/json/TestJSONVersions.java b/json/src/test/java/tools/jackson/jaxrs/json/TestJSONVersions.java index a59321f1..5d5adf76 100644 --- a/json/src/test/java/tools/jackson/jaxrs/json/TestJSONVersions.java +++ b/json/src/test/java/tools/jackson/jaxrs/json/TestJSONVersions.java @@ -1,10 +1,15 @@ package tools.jackson.jaxrs.json; +import org.junit.jupiter.api.Test; + import tools.jackson.core.Version; import tools.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/tools/jackson/jaxrs/json/TestJacksonFeatures.java b/json/src/test/java/tools/jackson/jaxrs/json/TestJacksonFeatures.java index f7815653..442b77c6 100644 --- a/json/src/test/java/tools/jackson/jaxrs/json/TestJacksonFeatures.java +++ b/json/src/test/java/tools/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 tools.jackson.databind.DeserializationFeature; @@ -13,6 +15,8 @@ import tools.jackson.databind.exc.UnrecognizedPropertyException; import tools.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 { JacksonJsonProvider prov = new JacksonJsonProvider(); @@ -67,6 +72,7 @@ public void testWriteConfigs() throws Exception assertEquals("{\"a\":3}", out.toString("UTF-8")); } + @Test public void testWriteConfigsViaBundle() throws Exception { JacksonJsonProvider prov = new JacksonJsonProvider(); @@ -80,6 +86,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/tools/jackson/jaxrs/json/TestJsonView.java b/json/src/test/java/tools/jackson/jaxrs/json/TestJsonView.java index 9ea744d6..98259be7 100644 --- a/json/src/test/java/tools/jackson/jaxrs/json/TestJsonView.java +++ b/json/src/test/java/tools/jackson/jaxrs/json/TestJsonView.java @@ -4,12 +4,16 @@ import java.lang.annotation.Annotation; import java.lang.reflect.Method; +import org.junit.jupiter.api.Test; + import javax.ws.rs.core.MediaType; import com.fasterxml.jackson.annotation.JsonView; import tools.jackson.jaxrs.json.JacksonJsonProvider; +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 { JacksonJsonProvider prov = new JacksonJsonProvider(); @@ -47,6 +52,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/tools/jackson/jaxrs/json/TestJsonpWrapping.java b/json/src/test/java/tools/jackson/jaxrs/json/TestJsonpWrapping.java index 5d3a02b3..108e8957 100644 --- a/json/src/test/java/tools/jackson/jaxrs/json/TestJsonpWrapping.java +++ b/json/src/test/java/tools/jackson/jaxrs/json/TestJsonpWrapping.java @@ -3,13 +3,18 @@ import java.io.*; import java.lang.annotation.Annotation; +import org.junit.jupiter.api.Test; + import javax.ws.rs.core.MediaType; import tools.jackson.jaxrs.json.JacksonJsonProvider; +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/tools/jackson/jaxrs/json/TestRootType.java b/json/src/test/java/tools/jackson/jaxrs/json/TestRootType.java index 723b895f..96935728 100644 --- a/json/src/test/java/tools/jackson/jaxrs/json/TestRootType.java +++ b/json/src/test/java/tools/jackson/jaxrs/json/TestRootType.java @@ -7,12 +7,16 @@ 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 tools.jackson.core.type.TypeReference; import tools.jackson.jaxrs.json.JacksonJsonProvider; +import static org.junit.jupiter.api.Assertions.assertEquals; + public class TestRootType extends JaxrsTestBase { @@ -27,7 +31,8 @@ static class Bean { /* Test methods /********************************************************************** */ - + + @Test public void testRootType() throws Exception { JacksonJsonProvider prov = new JacksonJsonProvider(); diff --git a/json/src/test/java/tools/jackson/jaxrs/json/TestSerializeWithoutAutoflush.java b/json/src/test/java/tools/jackson/jaxrs/json/TestSerializeWithoutAutoflush.java index e1c39bdd..32060f59 100644 --- a/json/src/test/java/tools/jackson/jaxrs/json/TestSerializeWithoutAutoflush.java +++ b/json/src/test/java/tools/jackson/jaxrs/json/TestSerializeWithoutAutoflush.java @@ -8,6 +8,8 @@ import javax.ws.rs.core.MediaType; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonTypeInfo; import tools.jackson.databind.DefaultTyping; @@ -15,6 +17,8 @@ import tools.jackson.databind.json.JsonMapper; import tools.jackson.jaxrs.json.testutil.NoCheckSubTypeValidator; +import static org.junit.jupiter.api.Assertions.*; + /** * Unit test to check that ProviderBase always writes its content, even if flush-after-write is off. */ @@ -27,6 +31,7 @@ static class Simple { public void setList(List l) { list = l; } } + @Test public void testCanSerialize() throws IOException { JsonMapper mapper = JsonMapper.builder() diff --git a/json/src/test/java/tools/jackson/jaxrs/json/TestStreamingOutput.java b/json/src/test/java/tools/jackson/jaxrs/json/TestStreamingOutput.java index fc59b71b..d805e514 100644 --- a/json/src/test/java/tools/jackson/jaxrs/json/TestStreamingOutput.java +++ b/json/src/test/java/tools/jackson/jaxrs/json/TestStreamingOutput.java @@ -3,11 +3,15 @@ import java.io.*; import java.lang.annotation.Annotation; +import org.junit.jupiter.api.Test; + import javax.ws.rs.core.MediaType; import javax.ws.rs.core.StreamingOutput; import tools.jackson.jaxrs.json.JacksonJsonProvider; +import static org.junit.jupiter.api.Assertions.*; + public class TestStreamingOutput extends JaxrsTestBase { static class StreamingSubtype implements StreamingOutput @@ -27,6 +31,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/tools/jackson/jaxrs/json/TestUntouchables.java b/json/src/test/java/tools/jackson/jaxrs/json/TestUntouchables.java index 711b6816..14c54d80 100644 --- a/json/src/test/java/tools/jackson/jaxrs/json/TestUntouchables.java +++ b/json/src/test/java/tools/jackson/jaxrs/json/TestUntouchables.java @@ -4,11 +4,15 @@ import java.lang.annotation.Annotation; import java.util.*; +import org.junit.jupiter.api.Test; + import javax.ws.rs.core.MediaType; import javax.ws.rs.core.StreamingOutput; import tools.jackson.jaxrs.json.JacksonJsonProvider; +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. @@ -38,7 +42,8 @@ public void write(OutputStream output) { } /* Unit tests /********************************************************** */ - + + @Test public void testDefaultUntouchables() throws Exception { JacksonJsonProvider prov = new JacksonJsonProvider(); @@ -61,6 +66,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/tools/jackson/jaxrs/json/dw/AnnotationTestBase.java b/json/src/test/java/tools/jackson/jaxrs/json/dw/AnnotationTestBase.java index bd443d12..cc65597c 100644 --- a/json/src/test/java/tools/jackson/jaxrs/json/dw/AnnotationTestBase.java +++ b/json/src/test/java/tools/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/tools/jackson/jaxrs/json/dw/SimpleEndpointTestBase.java b/json/src/test/java/tools/jackson/jaxrs/json/dw/SimpleEndpointTestBase.java index 429df09d..269646f7 100644 --- a/json/src/test/java/tools/jackson/jaxrs/json/dw/SimpleEndpointTestBase.java +++ b/json/src/test/java/tools/jackson/jaxrs/json/dw/SimpleEndpointTestBase.java @@ -29,7 +29,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; @@ -50,6 +50,8 @@ import tools.jackson.databind.annotation.JsonSerialize; import tools.jackson.jaxrs.json.JacksonJsonProvider; +import static org.junit.jupiter.api.Assertions.*; + public abstract class SimpleEndpointTestBase extends ResourceTestBase { final protected static int TEST_PORT = 6011; @@ -369,6 +371,7 @@ public static class SimpleDynamicTypingApp extends JsonApplicationWithJackson { /********************************************************** */ + @Test public void testStandardJson() throws Exception { final ObjectMapper mapper = new ObjectMapper(); @@ -388,6 +391,7 @@ public void testStandardJson() throws Exception assertEquals(2, p.y); } + @Test public void testAcceptJavascriptType() throws Exception { final ObjectMapper mapper = new ObjectMapper(); @@ -465,6 +469,7 @@ public Point maxPoint(MappingIterator points) throws JacksonException */ // [jaxrs-providers#69] + @Test public void testMappingIterator() throws Exception { final ObjectMapper mapper = new ObjectMapper(); @@ -495,6 +500,7 @@ public void testMappingIterator() throws Exception } // [jaxrs-providers#108] + @Test public void testPointNoTrailingContent() throws Exception { final ObjectMapper mapper = new ObjectMapper(); @@ -543,6 +549,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); @@ -551,7 +558,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(); } @@ -562,6 +569,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); @@ -596,6 +604,7 @@ public void testHugeFluffyContent() throws Exception } } + @Test public void testDynamicTypingSingle() throws Exception { final ObjectMapper mapper = new ObjectMapper(); @@ -617,6 +626,7 @@ public void testDynamicTypingSingle() throws Exception } // for [#60], problems with non-polymorphic Lists + @Test public void testDynamicTypingList() throws Exception { final ObjectMapper mapper = new ObjectMapper(); @@ -643,11 +653,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")); } @@ -676,11 +688,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/tools/jackson/jaxrs/json/dw/WriteModificationsTestBase.java b/json/src/test/java/tools/jackson/jaxrs/json/dw/WriteModificationsTestBase.java index 12972bca..370fcdbb 100644 --- a/json/src/test/java/tools/jackson/jaxrs/json/dw/WriteModificationsTestBase.java +++ b/json/src/test/java/tools/jackson/jaxrs/json/dw/WriteModificationsTestBase.java @@ -3,6 +3,8 @@ import java.io.IOException; import java.net.*; +import org.junit.jupiter.api.Test; + import javax.servlet.*; import javax.ws.rs.GET; import javax.ws.rs.Path; @@ -18,6 +20,8 @@ import tools.jackson.jaxrs.cfg.ObjectWriterInjector; import tools.jackson.jaxrs.cfg.ObjectWriterModifier; +import static org.junit.jupiter.api.Assertions.*; + public abstract class WriteModificationsTestBase extends ResourceTestBase { final static int TEST_PORT = 6021; @@ -162,6 +166,7 @@ public void testNoIndentWithResource() throws Exception * 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 @@ -182,6 +187,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/tools/jackson/jaxrs/json/util/TestAnnotationBundleKey.java b/json/src/test/java/tools/jackson/jaxrs/json/util/TestAnnotationBundleKey.java index 192a782e..1cf80efa 100644 --- a/json/src/test/java/tools/jackson/jaxrs/json/util/TestAnnotationBundleKey.java +++ b/json/src/test/java/tools/jackson/jaxrs/json/util/TestAnnotationBundleKey.java @@ -3,10 +3,14 @@ import java.lang.annotation.Annotation; import java.lang.reflect.Method; +import org.junit.jupiter.api.Test; + import tools.jackson.jaxrs.cfg.AnnotationBundleKey; import tools.jackson.jaxrs.json.JaxrsTestBase; import tools.jackson.jaxrs.json.annotation.JSONP; +import static org.junit.jupiter.api.Assertions.*; + public class TestAnnotationBundleKey extends JaxrsTestBase { @JSONP("foo") @@ -21,6 +25,7 @@ public void annotated2() { } /********************************************************** */ + @Test public void testKeys() throws Exception { Method m1 = getClass().getDeclaredMethod("annotated1"); diff --git a/pom.xml b/pom.xml index ae8a7bd9..ba250399 100644 --- a/pom.xml +++ b/pom.xml @@ -118,10 +118,16 @@ https://stackoverflow.com/questions/44088493/jersey-stopped-working-with-injecti ${version.jersey} test - + + + + org.junit.jupiter + junit-jupiter + test + - junit - junit + org.junit.jupiter + junit-jupiter-api test diff --git a/smile/src/test/java/module-info.java b/smile/src/test/java/module-info.java index 817ebfe6..5d4912d8 100644 --- a/smile/src/test/java/module-info.java +++ b/smile/src/test/java/module-info.java @@ -14,7 +14,8 @@ requires java.ws.rs; // Additional test lib/framework dependencies - requires junit; // JUnit 4 + requires org.junit.jupiter.api; + requires org.junit.jupiter.params; // Further, need to open up test packages for JUnit et al diff --git a/smile/src/test/java/tools/jackson/jaxrs/smile/JaxrsTestBase.java b/smile/src/test/java/tools/jackson/jaxrs/smile/JaxrsTestBase.java index baa65011..588dde27 100644 --- a/smile/src/test/java/tools/jackson/jaxrs/smile/JaxrsTestBase.java +++ b/smile/src/test/java/tools/jackson/jaxrs/smile/JaxrsTestBase.java @@ -5,12 +5,11 @@ import java.io.InputStream; import java.util.Arrays; -import org.junit.Assert; - import tools.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/tools/jackson/jaxrs/smile/TestCanDeserialize.java b/smile/src/test/java/tools/jackson/jaxrs/smile/TestCanDeserialize.java index e5215839..c0c50f1b 100644 --- a/smile/src/test/java/tools/jackson/jaxrs/smile/TestCanDeserialize.java +++ b/smile/src/test/java/tools/jackson/jaxrs/smile/TestCanDeserialize.java @@ -3,13 +3,14 @@ import java.io.*; import java.lang.annotation.Annotation; +import org.junit.jupiter.api.Test; + import javax.ws.rs.core.MediaType; import tools.jackson.jaxrs.smile.JacksonSmileProvider; -/** - * Unit test to check [JACKSON-540] - */ +import static org.junit.jupiter.api.Assertions.*; + public class TestCanDeserialize extends JaxrsTestBase { static class Bean { @@ -30,6 +31,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/tools/jackson/jaxrs/smile/TestSmileVersions.java b/smile/src/test/java/tools/jackson/jaxrs/smile/TestSmileVersions.java index 4e691e6f..f265fb86 100644 --- a/smile/src/test/java/tools/jackson/jaxrs/smile/TestSmileVersions.java +++ b/smile/src/test/java/tools/jackson/jaxrs/smile/TestSmileVersions.java @@ -1,10 +1,15 @@ package tools.jackson.jaxrs.smile; +import org.junit.jupiter.api.Test; + import tools.jackson.core.Version; import tools.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/tools/jackson/jaxrs/smile/dw/SimpleEndpointTestBase.java b/smile/src/test/java/tools/jackson/jaxrs/smile/dw/SimpleEndpointTestBase.java index 37935ec9..7d63527b 100644 --- a/smile/src/test/java/tools/jackson/jaxrs/smile/dw/SimpleEndpointTestBase.java +++ b/smile/src/test/java/tools/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 tools.jackson.databind.ObjectMapper; import tools.jackson.dataformat.smile.SmileFactory; import tools.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/module-info.java b/xml/src/test/java/module-info.java index 6bddc335..a89cb3f5 100644 --- a/xml/src/test/java/module-info.java +++ b/xml/src/test/java/module-info.java @@ -14,7 +14,8 @@ requires java.ws.rs; // Additional test lib/framework dependencies - requires junit; // JUnit 4 + requires org.junit.jupiter.api; + requires org.junit.jupiter.params; // Further, need to open up test packages for JUnit et al diff --git a/xml/src/test/java/tools/jackson/jaxrs/xml/JaxrsTestBase.java b/xml/src/test/java/tools/jackson/jaxrs/xml/JaxrsTestBase.java index d81d4ee9..5c2c1ab7 100644 --- a/xml/src/test/java/tools/jackson/jaxrs/xml/JaxrsTestBase.java +++ b/xml/src/test/java/tools/jackson/jaxrs/xml/JaxrsTestBase.java @@ -5,10 +5,12 @@ import java.io.InputStream; import java.util.Arrays; -import org.junit.Assert; +import javax.ws.rs.core.MediaType; + +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.fail; public abstract class JaxrsTestBase - extends junit.framework.TestCase { /* /********************************************************** @@ -42,7 +44,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/tools/jackson/jaxrs/xml/TestCanDeserialize.java b/xml/src/test/java/tools/jackson/jaxrs/xml/TestCanDeserialize.java index 8d554a71..31f420a0 100644 --- a/xml/src/test/java/tools/jackson/jaxrs/xml/TestCanDeserialize.java +++ b/xml/src/test/java/tools/jackson/jaxrs/xml/TestCanDeserialize.java @@ -3,16 +3,21 @@ import java.io.*; import java.lang.annotation.Annotation; +import org.junit.jupiter.api.Test; + import javax.ws.rs.core.MediaType; import tools.jackson.jaxrs.xml.JacksonXMLProvider; +import static org.junit.jupiter.api.Assertions.*; + public class TestCanDeserialize extends JaxrsTestBase { static class Bean { public int x; } + @Test public void testCanDeserialize() throws IOException { JacksonXMLProvider prov = new JacksonXMLProvider(); @@ -25,6 +30,7 @@ public void testCanDeserialize() throws IOException } // [Issue#4]: exception for no content + @Test public void testCanDeserializeEmpty() throws IOException { JacksonXMLProvider prov = new JacksonXMLProvider(); diff --git a/xml/src/test/java/tools/jackson/jaxrs/xml/TestJacksonFeaturesWithXML.java b/xml/src/test/java/tools/jackson/jaxrs/xml/TestJacksonFeaturesWithXML.java index 2b8d8281..5386318f 100644 --- a/xml/src/test/java/tools/jackson/jaxrs/xml/TestJacksonFeaturesWithXML.java +++ b/xml/src/test/java/tools/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 tools.jackson.databind.DeserializationFeature; @@ -13,6 +15,8 @@ import tools.jackson.databind.exc.UnrecognizedPropertyException; import tools.jackson.jaxrs.annotation.JacksonFeatures; +import static org.junit.jupiter.api.Assertions.*; + /** * Tests for addition of {@link JacksonFeatures}. */ @@ -45,6 +49,7 @@ public void writeConfig2() { } /********************************************************************** */ + @Test public void testWriteConfigs() throws Exception { JacksonXMLProvider prov = new JacksonXMLProvider(); @@ -71,7 +76,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(); @@ -85,6 +91,7 @@ public void testWriteConfigsViaBundle() throws Exception assertEquals("3", out.toString("UTF-8")); } + @Test public void testReadConfigs() throws Exception { JacksonXMLProvider prov = new JacksonXMLProvider(); diff --git a/xml/src/test/java/tools/jackson/jaxrs/xml/TestJsonView.java b/xml/src/test/java/tools/jackson/jaxrs/xml/TestJsonView.java index 6e332611..d67f32d8 100644 --- a/xml/src/test/java/tools/jackson/jaxrs/xml/TestJsonView.java +++ b/xml/src/test/java/tools/jackson/jaxrs/xml/TestJsonView.java @@ -4,12 +4,16 @@ import java.lang.annotation.Annotation; import java.lang.reflect.Method; +import org.junit.jupiter.api.Test; + import javax.ws.rs.core.MediaType; import com.fasterxml.jackson.annotation.JsonView; import tools.jackson.jaxrs.xml.JacksonXMLProvider; +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 { JacksonXMLProvider prov = new JacksonXMLProvider(); diff --git a/xml/src/test/java/tools/jackson/jaxrs/xml/TestRootType.java b/xml/src/test/java/tools/jackson/jaxrs/xml/TestRootType.java index 1e7734c2..c7e07f52 100644 --- a/xml/src/test/java/tools/jackson/jaxrs/xml/TestRootType.java +++ b/xml/src/test/java/tools/jackson/jaxrs/xml/TestRootType.java @@ -7,6 +7,8 @@ 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; @@ -14,6 +16,8 @@ import tools.jackson.core.type.TypeReference; import tools.jackson.jaxrs.xml.JacksonXMLProvider; +import static org.junit.jupiter.api.Assertions.assertEquals; + public class TestRootType extends JaxrsTestBase { @@ -22,7 +26,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/tools/jackson/jaxrs/xml/TestSerialize.java b/xml/src/test/java/tools/jackson/jaxrs/xml/TestSerialize.java index bd1850e1..fc777993 100644 --- a/xml/src/test/java/tools/jackson/jaxrs/xml/TestSerialize.java +++ b/xml/src/test/java/tools/jackson/jaxrs/xml/TestSerialize.java @@ -6,11 +6,15 @@ 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 tools.jackson.jaxrs.xml.JacksonXMLProvider; +import static org.junit.jupiter.api.Assertions.assertEquals; + public class TestSerialize extends JaxrsTestBase { // for [Issue-1] @@ -50,6 +54,7 @@ public int getPageNumber() { */ // [Issue-1] + @Test public void testSimpleWriteTo() throws Exception { Messages msgs = new Messages(); diff --git a/xml/src/test/java/tools/jackson/jaxrs/xml/TestUntouchables.java b/xml/src/test/java/tools/jackson/jaxrs/xml/TestUntouchables.java index 9c798254..5fedec94 100644 --- a/xml/src/test/java/tools/jackson/jaxrs/xml/TestUntouchables.java +++ b/xml/src/test/java/tools/jackson/jaxrs/xml/TestUntouchables.java @@ -3,11 +3,15 @@ import java.lang.annotation.Annotation; import java.util.*; +import org.junit.jupiter.api.Test; + import javax.ws.rs.core.MediaType; import javax.ws.rs.core.StreamingOutput; import tools.jackson.jaxrs.xml.JacksonXMLProvider; +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. @@ -20,7 +24,7 @@ public class TestUntouchables * remains overridable. */ public static class MyJacksonProvider extends JacksonXMLProvider { - // ensure isJsonType remains "protected" � this is a compile-time check. + // ensure isJsonType remains "protected" - this is a compile-time check. // Some users of JacksonJsonProvider override this method; // changing to "private" would regress them. @Override @@ -32,7 +36,8 @@ public static class MyJacksonProvider extends JacksonXMLProvider { /* Unit tests /********************************************************** */ - + + @Test public void testDefaultUntouchables() throws Exception { JacksonXMLProvider prov = new JacksonXMLProvider(); @@ -53,6 +58,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/tools/jackson/jaxrs/xml/TestXMLVersions.java b/xml/src/test/java/tools/jackson/jaxrs/xml/TestXMLVersions.java index 55624a6f..3a1e6b71 100644 --- a/xml/src/test/java/tools/jackson/jaxrs/xml/TestXMLVersions.java +++ b/xml/src/test/java/tools/jackson/jaxrs/xml/TestXMLVersions.java @@ -1,10 +1,15 @@ package tools.jackson.jaxrs.xml; +import org.junit.jupiter.api.Test; + import tools.jackson.core.Version; import tools.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/tools/jackson/jaxrs/xml/dw/SimpleEndpointTestBase.java b/xml/src/test/java/tools/jackson/jaxrs/xml/dw/SimpleEndpointTestBase.java index c3a7e43e..0a8f3f1b 100644 --- a/xml/src/test/java/tools/jackson/jaxrs/xml/dw/SimpleEndpointTestBase.java +++ b/xml/src/test/java/tools/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 tools.jackson.databind.ObjectMapper; import tools.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/main/java/tools/jackson/jaxrs/yaml/JacksonJaxbYAMLProvider.java b/yaml/src/main/java/tools/jackson/jaxrs/yaml/JacksonJaxbYAMLProvider.java index 099645d6..4f5693cb 100644 --- a/yaml/src/main/java/tools/jackson/jaxrs/yaml/JacksonJaxbYAMLProvider.java +++ b/yaml/src/main/java/tools/jackson/jaxrs/yaml/JacksonJaxbYAMLProvider.java @@ -1,14 +1,14 @@ package tools.jackson.jaxrs.yaml; -import tools.jackson.databind.AnnotationIntrospector; -import tools.jackson.dataformat.yaml.YAMLMapper; -import tools.jackson.module.jaxb.JaxbAnnotationIntrospector; - import javax.ws.rs.Consumes; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.ext.Provider; +import tools.jackson.databind.AnnotationIntrospector; +import tools.jackson.dataformat.yaml.YAMLMapper; +import tools.jackson.module.jaxb.JaxbAnnotationIntrospector; + /** * JSON content type provider automatically configured to use both Jackson * and JAXB annotations (in that order of priority). Otherwise functionally diff --git a/yaml/src/test/java/module-info.java b/yaml/src/test/java/module-info.java index 0541665f..7f7ae211 100644 --- a/yaml/src/test/java/module-info.java +++ b/yaml/src/test/java/module-info.java @@ -14,7 +14,8 @@ requires java.ws.rs; // Additional test lib/framework dependencies - requires junit; // JUnit 4 + requires org.junit.jupiter.api; + requires org.junit.jupiter.params; // Other test deps: we test format-negotiation so need JSON and Smile providers diff --git a/yaml/src/test/java/tools/jackson/jaxrs/yaml/JaxrsTestBase.java b/yaml/src/test/java/tools/jackson/jaxrs/yaml/JaxrsTestBase.java index 4f3633a6..681d9657 100644 --- a/yaml/src/test/java/tools/jackson/jaxrs/yaml/JaxrsTestBase.java +++ b/yaml/src/test/java/tools/jackson/jaxrs/yaml/JaxrsTestBase.java @@ -8,12 +8,11 @@ import tools.jackson.core.JsonParser; import tools.jackson.core.JsonToken; -import org.junit.Assert; - import javax.ws.rs.core.MediaType; +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; @@ -61,7 +60,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/tools/jackson/jaxrs/yaml/TestCanDeserialize.java b/yaml/src/test/java/tools/jackson/jaxrs/yaml/TestCanDeserialize.java index 0f1af03b..3bb526fc 100644 --- a/yaml/src/test/java/tools/jackson/jaxrs/yaml/TestCanDeserialize.java +++ b/yaml/src/test/java/tools/jackson/jaxrs/yaml/TestCanDeserialize.java @@ -5,8 +5,12 @@ import java.io.InputStream; import java.lang.annotation.Annotation; +import org.junit.jupiter.api.Test; + import tools.jackson.jaxrs.yaml.JacksonYAMLProvider; +import static org.junit.jupiter.api.Assertions.*; + public class TestCanDeserialize extends JaxrsTestBase { @@ -14,6 +18,7 @@ static class Bean { public int x; } + @Test public void testCanDeserialize() throws IOException { JacksonYAMLProvider prov = new JacksonYAMLProvider(); @@ -25,7 +30,7 @@ public void testCanDeserialize() throws IOException assertEquals(3, b.x); } - // [Issue#4]: exception for no content + @Test public void testCanDeserializeEmpty() throws IOException { JacksonYAMLProvider prov = new JacksonYAMLProvider(); diff --git a/yaml/src/test/java/tools/jackson/jaxrs/yaml/TestJacksonFeaturesWithYAML.java b/yaml/src/test/java/tools/jackson/jaxrs/yaml/TestJacksonFeaturesWithYAML.java index 643c4e2b..670a3b56 100644 --- a/yaml/src/test/java/tools/jackson/jaxrs/yaml/TestJacksonFeaturesWithYAML.java +++ b/yaml/src/test/java/tools/jackson/jaxrs/yaml/TestJacksonFeaturesWithYAML.java @@ -5,6 +5,8 @@ import java.lang.annotation.*; import java.lang.reflect.Method; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JacksonAnnotationsInside; import tools.jackson.databind.DeserializationFeature; @@ -14,6 +16,8 @@ import javax.ws.rs.core.MediaType; +import static org.junit.jupiter.api.Assertions.*; + /** * Tests for addition of {@link JacksonFeatures}. */ @@ -46,6 +50,7 @@ public void writeConfig2() { } /********************************************************************** */ + @Test public void testWriteConfigs() throws Exception { JacksonYAMLProvider prov = new JacksonYAMLProvider(); @@ -69,7 +74,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(); @@ -83,6 +89,7 @@ public void testWriteConfigsViaBundle() throws Exception assertEquals("---\nBean:\n a: 3\n", out.toString("UTF-8")); } + @Test public void testReadConfigs() throws Exception { JacksonYAMLProvider prov = new JacksonYAMLProvider(); diff --git a/yaml/src/test/java/tools/jackson/jaxrs/yaml/TestJsonView.java b/yaml/src/test/java/tools/jackson/jaxrs/yaml/TestJsonView.java index eae8f411..f86a6acc 100644 --- a/yaml/src/test/java/tools/jackson/jaxrs/yaml/TestJsonView.java +++ b/yaml/src/test/java/tools/jackson/jaxrs/yaml/TestJsonView.java @@ -9,6 +9,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 { } @@ -35,6 +39,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/tools/jackson/jaxrs/yaml/TestRootType.java b/yaml/src/test/java/tools/jackson/jaxrs/yaml/TestRootType.java index a3f868e6..94c2c130 100644 --- a/yaml/src/test/java/tools/jackson/jaxrs/yaml/TestRootType.java +++ b/yaml/src/test/java/tools/jackson/jaxrs/yaml/TestRootType.java @@ -1,5 +1,14 @@ package tools.jackson.jaxrs.yaml; +import java.io.ByteArrayOutputStream; +import java.lang.annotation.Annotation; +import java.util.ArrayList; +import java.util.List; + +import org.junit.jupiter.api.Test; + +import javax.ws.rs.core.MediaType; + import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeInfo.As; import com.fasterxml.jackson.annotation.JsonTypeInfo.Id; @@ -7,11 +16,7 @@ import tools.jackson.core.type.TypeReference; import tools.jackson.jaxrs.yaml.JacksonYAMLProvider; -import javax.ws.rs.core.MediaType; -import java.io.ByteArrayOutputStream; -import java.lang.annotation.Annotation; -import java.util.ArrayList; -import java.util.List; +import static org.junit.jupiter.api.Assertions.assertEquals; public class TestRootType extends JaxrsTestBase @@ -21,7 +26,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/tools/jackson/jaxrs/yaml/TestSerialize.java b/yaml/src/test/java/tools/jackson/jaxrs/yaml/TestSerialize.java index 94838726..f91eb891 100644 --- a/yaml/src/test/java/tools/jackson/jaxrs/yaml/TestSerialize.java +++ b/yaml/src/test/java/tools/jackson/jaxrs/yaml/TestSerialize.java @@ -1,15 +1,20 @@ package tools.jackson.jaxrs.yaml; +import java.io.ByteArrayOutputStream; +import java.lang.annotation.Annotation; +import java.util.ArrayList; +import java.util.List; + +import org.junit.jupiter.api.Test; + +import javax.ws.rs.core.MediaType; + import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonRootName; import tools.jackson.jaxrs.yaml.JacksonYAMLProvider; -import javax.ws.rs.core.MediaType; -import java.io.ByteArrayOutputStream; -import java.lang.annotation.Annotation; -import java.util.ArrayList; -import java.util.List; +import static org.junit.jupiter.api.Assertions.assertEquals; public class TestSerialize extends JaxrsTestBase { @@ -50,6 +55,7 @@ public int getPageNumber() { */ // [Issue-1] + @Test public void testSimpleWriteTo() throws Exception { Messages msgs = new Messages(); diff --git a/yaml/src/test/java/tools/jackson/jaxrs/yaml/TestUntouchables.java b/yaml/src/test/java/tools/jackson/jaxrs/yaml/TestUntouchables.java index 247bec06..0122179f 100644 --- a/yaml/src/test/java/tools/jackson/jaxrs/yaml/TestUntouchables.java +++ b/yaml/src/test/java/tools/jackson/jaxrs/yaml/TestUntouchables.java @@ -5,11 +5,15 @@ import java.util.Collection; import java.util.HashSet; +import org.junit.jupiter.api.Test; + import javax.ws.rs.core.MediaType; import javax.ws.rs.core.StreamingOutput; import tools.jackson.jaxrs.yaml.JacksonYAMLProvider; +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. @@ -35,6 +39,7 @@ public static class MyJacksonProvider extends JacksonYAMLProvider { /********************************************************** */ + @Test public void testDefaultUntouchables() throws Exception { JacksonYAMLProvider prov = new JacksonYAMLProvider(); @@ -55,6 +60,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/tools/jackson/jaxrs/yaml/TestYAMLVersions.java b/yaml/src/test/java/tools/jackson/jaxrs/yaml/TestYAMLVersions.java index cad18939..6efd198c 100644 --- a/yaml/src/test/java/tools/jackson/jaxrs/yaml/TestYAMLVersions.java +++ b/yaml/src/test/java/tools/jackson/jaxrs/yaml/TestYAMLVersions.java @@ -1,11 +1,16 @@ package tools.jackson.jaxrs.yaml; +import org.junit.jupiter.api.Test; + import tools.jackson.core.Version; import tools.jackson.core.Versioned; import tools.jackson.jaxrs.yaml.JacksonYAMLProvider; +import static org.junit.jupiter.api.Assertions.*; + public class TestYAMLVersions extends JaxrsTestBase { + @Test public void testMapperVersions() { assertVersion(new JacksonYAMLProvider()); @@ -20,7 +25,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/tools/jackson/jaxrs/yaml/dw/SimpleEndpointTestBase.java b/yaml/src/test/java/tools/jackson/jaxrs/yaml/dw/SimpleEndpointTestBase.java index 558ec5bf..ca789809 100644 --- a/yaml/src/test/java/tools/jackson/jaxrs/yaml/dw/SimpleEndpointTestBase.java +++ b/yaml/src/test/java/tools/jackson/jaxrs/yaml/dw/SimpleEndpointTestBase.java @@ -5,11 +5,15 @@ import java.net.HttpURLConnection; import java.net.URL; +import org.junit.jupiter.api.Test; + import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; +import org.eclipse.jetty.server.Server; + import tools.jackson.databind.ObjectMapper; import tools.jackson.databind.json.JsonMapper; @@ -23,8 +27,7 @@ import tools.jackson.jaxrs.yaml.JacksonYAMLProvider; import tools.jackson.jaxrs.yaml.YAMLMediaTypes; -import org.eclipse.jetty.server.Server; -import org.junit.Assert; +import static org.junit.jupiter.api.Assertions.*; public abstract class SimpleEndpointTestBase extends ResourceTestBase { @@ -107,6 +110,7 @@ public static class SimpleRawApp extends YAMLApplicationWithJackson { /********************************************************** */ + @Test public void testSimplePoint() throws Exception { final ObjectMapper mapper = new YAMLMapper(); @@ -136,6 +140,7 @@ public void testSimplePoint() throws Exception } } + @Test public void testCustomMediaTypeWithYamlExtension() throws Exception { final ObjectMapper mapper = new YAMLMapper(); @@ -160,6 +165,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); @@ -257,12 +263,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(); }