Skip to content

Commit fef36bb

Browse files
authored
Migrate paranamer module to JUnit 5 (#275)
1 parent f587964 commit fef36bb

File tree

6 files changed

+30
-4
lines changed

6 files changed

+30
-4
lines changed

paranamer/pom.xml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,15 @@ to introspect names of constructor (and factory method) parameters.
5252
<version>2.8</version>
5353
</dependency>
5454

55+
<!-- Test dependencies: -->
5556
<dependency>
56-
<groupId>junit</groupId>
57-
<artifactId>junit</artifactId>
57+
<groupId>org.junit.jupiter</groupId>
58+
<artifactId>junit-jupiter</artifactId>
59+
<scope>test</scope>
60+
</dependency>
61+
<dependency>
62+
<groupId>org.junit.jupiter</groupId>
63+
<artifactId>junit-jupiter-api</artifactId>
5864
<scope>test</scope>
5965
</dependency>
6066
</dependencies>

paranamer/src/test/java/com/fasterxml/jackson/module/paranamer/ModuleTestBase.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22

33
import java.util.Arrays;
44

5-
import junit.framework.TestCase;
5+
import static org.junit.jupiter.api.Assertions.*;
66

77
public abstract class ModuleTestBase
8-
extends TestCase
98
{
109
protected void verifyException(Throwable e, String... matches)
1110
{

paranamer/src/test/java/com/fasterxml/jackson/module/paranamer/SimpleTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
package com.fasterxml.jackson.module.paranamer;
22

3+
import org.junit.jupiter.api.Test;
4+
35
import com.fasterxml.jackson.annotation.JsonCreator;
46

57
import com.fasterxml.jackson.databind.ObjectMapper;
68
import com.fasterxml.jackson.databind.exc.InvalidDefinitionException;
79
import com.fasterxml.jackson.databind.json.JsonMapper;
810

11+
import static org.junit.jupiter.api.Assertions.*;
12+
913
public class SimpleTest extends ModuleTestBase
1014
{
1115
static class CreatorBean
@@ -27,6 +31,7 @@ public CreatorBean(int age, String name)
2731
/**********************************************************
2832
*/
2933

34+
@Test
3035
public void testSimple() throws Exception
3136
{
3237
final String JSON = "{\"name\":\"Bob\", \"age\":40}";
@@ -60,6 +65,7 @@ public void testSimple() throws Exception
6065

6166
// Let's test handling of case where parameter names are not found; for example when
6267
// trying to access things for JDK types
68+
@Test
6369
public void testWrapper() throws Exception
6470
{
6571
ObjectMapper mapper = JsonMapper.builder()

paranamer/src/test/java/com/fasterxml/jackson/module/paranamer/TestCreatorWithNamingStrategy.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
package com.fasterxml.jackson.module.paranamer;
22

3+
import org.junit.jupiter.api.Test;
4+
35
import com.fasterxml.jackson.annotation.JsonCreator;
46
import com.fasterxml.jackson.databind.ObjectMapper;
57
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
68

9+
import static org.junit.jupiter.api.Assertions.*;
10+
711
public class TestCreatorWithNamingStrategy
812
extends ModuleTestBase
913
{
@@ -24,6 +28,7 @@ public CreatorBean(int myAge, String myName)
2428
.registerModule(new ParanamerModule())
2529
.setPropertyNamingStrategy(PropertyNamingStrategies.UPPER_CAMEL_CASE);
2630

31+
@Test
2732
public void testSimpleConstructor() throws Exception
2833
{
2934
CreatorBean bean = MAPPER.readValue("{ \"MyAge\" : 42, \"MyName\" : \"NotMyRealName\" }", CreatorBean.class);

paranamer/src/test/java/com/fasterxml/jackson/module/paranamer/TestJDKSerializability.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,19 @@
66
import java.io.ObjectInputStream;
77
import java.io.ObjectOutputStream;
88

9+
import org.junit.jupiter.api.Test;
10+
911
import com.fasterxml.jackson.databind.ObjectMapper;
1012

13+
import static org.junit.jupiter.api.Assertions.*;
14+
1115
public class TestJDKSerializability extends ModuleTestBase
1216
{
1317
static class Point {
1418
public int x, y;
1519
}
1620

21+
@Test
1722
public void testMapper() throws Exception
1823
{
1924
ObjectMapper mapper = new ObjectMapper().registerModule(new ParanamerModule());

paranamer/src/test/java/com/fasterxml/jackson/module/paranamer/failing/TestCreatorWithNamingStrategy.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
package com.fasterxml.jackson.module.paranamer.failing;
22

3+
import org.junit.jupiter.api.Test;
4+
35
import com.fasterxml.jackson.annotation.JsonCreator;
46
import com.fasterxml.jackson.databind.ObjectMapper;
57
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
68
import com.fasterxml.jackson.module.paranamer.ParanamerModule;
79
import com.fasterxml.jackson.module.paranamer.ModuleTestBase;
810

11+
import static org.junit.jupiter.api.Assertions.*;
12+
913
public class TestCreatorWithNamingStrategy
1014
extends ModuleTestBase
1115
{
@@ -36,6 +40,7 @@ public static StaticStringCreatorBean parse(String delimited)
3640
.registerModule(new ParanamerModule())
3741
.setPropertyNamingStrategy(PropertyNamingStrategies.UPPER_CAMEL_CASE);
3842

43+
@Test
3944
public void testStaticStringCreator() throws Exception
4045
{
4146
StaticStringCreatorBean bean = MAPPER.readValue("\"42|NotMyRealName\"", StaticStringCreatorBean.class);

0 commit comments

Comments
 (0)