diff --git a/UserGuide.md b/UserGuide.md
index 331ef27663..429dc23ca7 100644
--- a/UserGuide.md
+++ b/UserGuide.md
@@ -53,13 +53,13 @@ Gson can work with arbitrary Java objects including pre-existing objects that yo
Here are some metrics that we obtained on a desktop (dual opteron, 8GB RAM, 64-bit Ubuntu) running lots of other things along-with the tests. You can rerun these tests by using the class [`PerformanceTest`](gson/src/test/java/com/google/gson/metrics/PerformanceTest.java).
-* Strings: Deserialized strings of over 25MB without any problems (see `disabled_testStringDeserializationPerformance` method in `PerformanceTest`)
+* Strings: Deserialized strings of over 25MB without any problems (see `testStringDeserialization` method in `PerformanceTest`)
* Large collections:
- * Serialized a collection of 1.4 million objects (see `disabled_testLargeCollectionSerialization` method in `PerformanceTest`)
- * Deserialized a collection of 87,000 objects (see `disabled_testLargeCollectionDeserialization` in `PerformanceTest`)
+ * Serialized a collection of 1.4 million objects (see `testLargeCollectionSerialization` method in `PerformanceTest`)
+ * Deserialized a collection of 87,000 objects (see `testLargeCollectionDeserialization` in `PerformanceTest`)
* Gson 1.4 raised the deserialization limit for byte arrays and collection to over 11MB from 80KB.
-Note: Delete the `disabled_` prefix to run these tests. We use this prefix to prevent running these tests every time we run JUnit tests.
+Note: Remove the `@Disabled` annotations to run these tests. They are disabled by default to not run them every time we run JUnit tests.
## Gson Users
diff --git a/codegen/pom.xml b/codegen/pom.xml
index 4d232e3a92..8178ad9695 100644
--- a/codegen/pom.xml
+++ b/codegen/pom.xml
@@ -25,8 +25,8 @@
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter
test
diff --git a/codegen/src/test/java/com/google/gson/codegen/functional/CodeGenFunctionalTest.java b/codegen/src/test/java/com/google/gson/codegen/functional/CodeGenFunctionalTest.java
index 855ee3faf5..1f66c50a27 100644
--- a/codegen/src/test/java/com/google/gson/codegen/functional/CodeGenFunctionalTest.java
+++ b/codegen/src/test/java/com/google/gson/codegen/functional/CodeGenFunctionalTest.java
@@ -15,11 +15,12 @@
*/
package com.google.gson.codegen.functional;
-import junit.framework.TestCase;
+import org.junit.jupiter.api.Test;
-public class CodeGenFunctionalTest extends TestCase {
+class CodeGenFunctionalTest {
- public void testGeneratedJson() {
+ @Test
+ void testGeneratedJson() {
Order order = new Order("toy", 10);
// TODO: figure out how to access the generated type adapter
}
diff --git a/extras/pom.xml b/extras/pom.xml
index 0f83b14230..066c79511e 100644
--- a/extras/pom.xml
+++ b/extras/pom.xml
@@ -35,8 +35,8 @@
1.0
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter
test
diff --git a/extras/src/test/java/com/google/gson/graph/GraphAdapterBuilderTest.java b/extras/src/test/java/com/google/gson/graph/GraphAdapterBuilderTest.java
index 43fc6b6991..fa424dc943 100644
--- a/extras/src/test/java/com/google/gson/graph/GraphAdapterBuilderTest.java
+++ b/extras/src/test/java/com/google/gson/graph/GraphAdapterBuilderTest.java
@@ -16,23 +16,21 @@
package com.google.gson.graph;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import org.junit.jupiter.api.Test;
-import org.junit.Test;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.reflect.TypeToken;
-
-public final class GraphAdapterBuilderTest {
+class GraphAdapterBuilderTest {
@Test
- public void testSerialization() {
+ void testSerialization() {
Roshambo rock = new Roshambo("ROCK");
Roshambo scissors = new Roshambo("SCISSORS");
Roshambo paper = new Roshambo("PAPER");
@@ -53,7 +51,7 @@ public void testSerialization() {
}
@Test
- public void testDeserialization() {
+ void testDeserialization() {
String json = "{'0x1':{'name':'ROCK','beats':'0x2'}," +
"'0x2':{'name':'SCISSORS','beats':'0x3'}," +
"'0x3':{'name':'PAPER','beats':'0x1'}}";
@@ -74,7 +72,7 @@ public void testDeserialization() {
}
@Test
- public void testDeserializationDirectSelfReference() {
+ void testDeserializationDirectSelfReference() {
String json = "{'0x1':{'name':'SUICIDE','beats':'0x1'}}";
GsonBuilder gsonBuilder = new GsonBuilder();
@@ -89,7 +87,7 @@ public void testDeserializationDirectSelfReference() {
}
@Test
- public void testSerializeListOfLists() {
+ void testSerializeListOfLists() {
Type listOfListsType = new TypeToken>>() {}.getType();
Type listOfAnyType = new TypeToken>() {}.getType();
@@ -109,7 +107,7 @@ public void testSerializeListOfLists() {
}
@Test
- public void testDeserializeListOfLists() {
+ void testDeserializeListOfLists() {
Type listOfAnyType = new TypeToken>() {}.getType();
Type listOfListsType = new TypeToken>>() {}.getType();
@@ -127,7 +125,7 @@ public void testDeserializeListOfLists() {
}
@Test
- public void testSerializationWithMultipleTypes() {
+ void testSerializationWithMultipleTypes() {
Company google = new Company("Google");
new Employee("Jesse", google);
new Employee("Joel", google);
@@ -146,7 +144,7 @@ public void testSerializationWithMultipleTypes() {
}
@Test
- public void testDeserializationWithMultipleTypes() {
+ void testDeserializationWithMultipleTypes() {
GsonBuilder gsonBuilder = new GsonBuilder();
new GraphAdapterBuilder()
.addType(Company.class)
diff --git a/extras/src/test/java/com/google/gson/interceptors/InterceptorTest.java b/extras/src/test/java/com/google/gson/interceptors/InterceptorTest.java
index 0aab6598c3..1bf6958812 100644
--- a/extras/src/test/java/com/google/gson/interceptors/InterceptorTest.java
+++ b/extras/src/test/java/com/google/gson/interceptors/InterceptorTest.java
@@ -15,6 +15,9 @@
*/
package com.google.gson.interceptors;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
+
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonParseException;
@@ -29,51 +32,56 @@
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
-import junit.framework.TestCase;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Unit tests for {@link Intercept} and {@link JsonPostDeserializer}.
*
* @author Inderjeet Singh
*/
-public final class InterceptorTest extends TestCase {
+class InterceptorTest {
private Gson gson;
- @Override
- public void setUp() throws Exception {
- super.setUp();
+ @BeforeEach
+ void setUp() throws Exception {
this.gson = new GsonBuilder()
.registerTypeAdapterFactory(new InterceptorFactory())
.enableComplexMapKeySerialization()
.create();
}
- public void testExceptionsPropagated() {
+ @Test
+ void testExceptionsPropagated() {
try {
gson.fromJson("{}", User.class);
fail();
} catch (JsonParseException expected) {}
}
- public void testTopLevelClass() {
+ @Test
+ void testTopLevelClass() {
User user = gson.fromJson("{name:'bob',password:'pwd'}", User.class);
assertEquals(User.DEFAULT_EMAIL, user.email);
}
- public void testList() {
+ @Test
+ void testList() {
List list = gson.fromJson("[{name:'bob',password:'pwd'}]", new TypeToken>(){}.getType());
User user = list.get(0);
assertEquals(User.DEFAULT_EMAIL, user.email);
}
- public void testCollection() {
+ @Test
+ void testCollection() {
Collection list = gson.fromJson("[{name:'bob',password:'pwd'}]", new TypeToken>(){}.getType());
User user = list.iterator().next();
assertEquals(User.DEFAULT_EMAIL, user.email);
}
- public void testMapKeyAndValues() {
+ @Test
+ void testMapKeyAndValues() {
Type mapType = new TypeToken