From fef36bb8a02c7d773b80e25ef5d80d8911d6a323 Mon Sep 17 00:00:00 2001 From: "Kim, Joo Hyuk" Date: Sun, 19 Jan 2025 09:04:00 +0900 Subject: [PATCH] Migrate `paranamer` module to JUnit 5 (#275) --- paranamer/pom.xml | 10 ++++++++-- .../jackson/module/paranamer/ModuleTestBase.java | 3 +-- .../fasterxml/jackson/module/paranamer/SimpleTest.java | 6 ++++++ .../paranamer/TestCreatorWithNamingStrategy.java | 5 +++++ .../module/paranamer/TestJDKSerializability.java | 5 +++++ .../failing/TestCreatorWithNamingStrategy.java | 5 +++++ 6 files changed, 30 insertions(+), 4 deletions(-) diff --git a/paranamer/pom.xml b/paranamer/pom.xml index 90e58fb29..4998a1e51 100644 --- a/paranamer/pom.xml +++ b/paranamer/pom.xml @@ -52,9 +52,15 @@ to introspect names of constructor (and factory method) parameters. 2.8 + - junit - junit + org.junit.jupiter + junit-jupiter + test + + + org.junit.jupiter + junit-jupiter-api test diff --git a/paranamer/src/test/java/com/fasterxml/jackson/module/paranamer/ModuleTestBase.java b/paranamer/src/test/java/com/fasterxml/jackson/module/paranamer/ModuleTestBase.java index 51ed61ff7..a2f54bd1e 100644 --- a/paranamer/src/test/java/com/fasterxml/jackson/module/paranamer/ModuleTestBase.java +++ b/paranamer/src/test/java/com/fasterxml/jackson/module/paranamer/ModuleTestBase.java @@ -2,10 +2,9 @@ import java.util.Arrays; -import junit.framework.TestCase; +import static org.junit.jupiter.api.Assertions.*; public abstract class ModuleTestBase - extends TestCase { protected void verifyException(Throwable e, String... matches) { diff --git a/paranamer/src/test/java/com/fasterxml/jackson/module/paranamer/SimpleTest.java b/paranamer/src/test/java/com/fasterxml/jackson/module/paranamer/SimpleTest.java index 09ef08464..05696ddc3 100644 --- a/paranamer/src/test/java/com/fasterxml/jackson/module/paranamer/SimpleTest.java +++ b/paranamer/src/test/java/com/fasterxml/jackson/module/paranamer/SimpleTest.java @@ -1,11 +1,15 @@ package com.fasterxml.jackson.module.paranamer; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.exc.InvalidDefinitionException; import com.fasterxml.jackson.databind.json.JsonMapper; +import static org.junit.jupiter.api.Assertions.*; + public class SimpleTest extends ModuleTestBase { static class CreatorBean @@ -27,6 +31,7 @@ public CreatorBean(int age, String name) /********************************************************** */ + @Test public void testSimple() throws Exception { final String JSON = "{\"name\":\"Bob\", \"age\":40}"; @@ -60,6 +65,7 @@ public void testSimple() throws Exception // Let's test handling of case where parameter names are not found; for example when // trying to access things for JDK types + @Test public void testWrapper() throws Exception { ObjectMapper mapper = JsonMapper.builder() diff --git a/paranamer/src/test/java/com/fasterxml/jackson/module/paranamer/TestCreatorWithNamingStrategy.java b/paranamer/src/test/java/com/fasterxml/jackson/module/paranamer/TestCreatorWithNamingStrategy.java index 0d9d0f71d..7b041389d 100644 --- a/paranamer/src/test/java/com/fasterxml/jackson/module/paranamer/TestCreatorWithNamingStrategy.java +++ b/paranamer/src/test/java/com/fasterxml/jackson/module/paranamer/TestCreatorWithNamingStrategy.java @@ -1,9 +1,13 @@ package com.fasterxml.jackson.module.paranamer; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import static org.junit.jupiter.api.Assertions.*; + public class TestCreatorWithNamingStrategy extends ModuleTestBase { @@ -24,6 +28,7 @@ public CreatorBean(int myAge, String myName) .registerModule(new ParanamerModule()) .setPropertyNamingStrategy(PropertyNamingStrategies.UPPER_CAMEL_CASE); + @Test public void testSimpleConstructor() throws Exception { CreatorBean bean = MAPPER.readValue("{ \"MyAge\" : 42, \"MyName\" : \"NotMyRealName\" }", CreatorBean.class); diff --git a/paranamer/src/test/java/com/fasterxml/jackson/module/paranamer/TestJDKSerializability.java b/paranamer/src/test/java/com/fasterxml/jackson/module/paranamer/TestJDKSerializability.java index 2fdd9ea29..e5126262a 100644 --- a/paranamer/src/test/java/com/fasterxml/jackson/module/paranamer/TestJDKSerializability.java +++ b/paranamer/src/test/java/com/fasterxml/jackson/module/paranamer/TestJDKSerializability.java @@ -6,14 +6,19 @@ import java.io.ObjectInputStream; import java.io.ObjectOutputStream; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.ObjectMapper; +import static org.junit.jupiter.api.Assertions.*; + public class TestJDKSerializability extends ModuleTestBase { static class Point { public int x, y; } + @Test public void testMapper() throws Exception { ObjectMapper mapper = new ObjectMapper().registerModule(new ParanamerModule()); diff --git a/paranamer/src/test/java/com/fasterxml/jackson/module/paranamer/failing/TestCreatorWithNamingStrategy.java b/paranamer/src/test/java/com/fasterxml/jackson/module/paranamer/failing/TestCreatorWithNamingStrategy.java index 97c6902a5..8584b9a8d 100644 --- a/paranamer/src/test/java/com/fasterxml/jackson/module/paranamer/failing/TestCreatorWithNamingStrategy.java +++ b/paranamer/src/test/java/com/fasterxml/jackson/module/paranamer/failing/TestCreatorWithNamingStrategy.java @@ -1,11 +1,15 @@ package com.fasterxml.jackson.module.paranamer.failing; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.PropertyNamingStrategies; import com.fasterxml.jackson.module.paranamer.ParanamerModule; import com.fasterxml.jackson.module.paranamer.ModuleTestBase; +import static org.junit.jupiter.api.Assertions.*; + public class TestCreatorWithNamingStrategy extends ModuleTestBase { @@ -36,6 +40,7 @@ public static StaticStringCreatorBean parse(String delimited) .registerModule(new ParanamerModule()) .setPropertyNamingStrategy(PropertyNamingStrategies.UPPER_CAMEL_CASE); + @Test public void testStaticStringCreator() throws Exception { StaticStringCreatorBean bean = MAPPER.readValue("\"42|NotMyRealName\"", StaticStringCreatorBean.class);