diff --git a/README.md b/README.md
index fc90176584..c27460e89d 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,11 @@
# Gson
+## Migrate to JUnit 5 with Symflower
+
+* Symflower version: 44511
+* Execution time: 13.5s
+* Diff: 136 files changed, 398 insertions(+), 362 deletions(-)
+
Gson is a Java library that can be used to convert Java Objects into their JSON representation. It can also be used to convert a JSON string to an equivalent Java object.
Gson can work with arbitrary Java objects including pre-existing objects that you do not have source-code of.
diff --git a/extras/pom.xml b/extras/pom.xml
index 5fb9df63ac..6d8994b6f7 100644
--- a/extras/pom.xml
+++ b/extras/pom.xml
@@ -61,8 +61,8 @@
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
test
@@ -70,6 +70,12 @@
truth
test
+
+ org.junit.vintage
+ junit-vintage-engine
+ 5.11.3
+ 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 9c79130d0d..8161b483b8 100644
--- a/extras/src/test/java/com/google/gson/graph/GraphAdapterBuilderTest.java
+++ b/extras/src/test/java/com/google/gson/graph/GraphAdapterBuilderTest.java
@@ -24,7 +24,7 @@
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public final class GraphAdapterBuilderTest {
@Test
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 6c5cc91fa6..a26ebd2698 100644
--- a/extras/src/test/java/com/google/gson/interceptors/InterceptorTest.java
+++ b/extras/src/test/java/com/google/gson/interceptors/InterceptorTest.java
@@ -16,7 +16,7 @@
package com.google.gson.interceptors;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@@ -32,8 +32,8 @@
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Unit tests for {@link Intercept} and {@link JsonPostDeserializer}.
@@ -44,7 +44,7 @@ public final class InterceptorTest {
private Gson gson;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
this.gson =
new GsonBuilder()
diff --git a/extras/src/test/java/com/google/gson/typeadapters/PostConstructAdapterFactoryTest.java b/extras/src/test/java/com/google/gson/typeadapters/PostConstructAdapterFactoryTest.java
index a46fa3089b..2d5473f843 100644
--- a/extras/src/test/java/com/google/gson/typeadapters/PostConstructAdapterFactoryTest.java
+++ b/extras/src/test/java/com/google/gson/typeadapters/PostConstructAdapterFactoryTest.java
@@ -17,7 +17,7 @@
package com.google.gson.typeadapters;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@@ -25,7 +25,7 @@
import java.util.List;
import java.util.Objects;
import javax.annotation.PostConstruct;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class PostConstructAdapterFactoryTest {
@Test
diff --git a/extras/src/test/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactoryTest.java b/extras/src/test/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactoryTest.java
index dc8bd495fb..500ae7f9d6 100644
--- a/extras/src/test/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactoryTest.java
+++ b/extras/src/test/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactoryTest.java
@@ -17,13 +17,13 @@
package com.google.gson.typeadapters;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonParseException;
import com.google.gson.TypeAdapterFactory;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public final class RuntimeTypeAdapterFactoryTest {
diff --git a/extras/src/test/java/com/google/gson/typeadapters/UtcDateTypeAdapterTest.java b/extras/src/test/java/com/google/gson/typeadapters/UtcDateTypeAdapterTest.java
index 40240cebe9..4b228e2a52 100644
--- a/extras/src/test/java/com/google/gson/typeadapters/UtcDateTypeAdapterTest.java
+++ b/extras/src/test/java/com/google/gson/typeadapters/UtcDateTypeAdapterTest.java
@@ -17,7 +17,7 @@
package com.google.gson.typeadapters;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@@ -27,7 +27,7 @@
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
@SuppressWarnings("JavaUtilDate")
public final class UtcDateTypeAdapterTest {
diff --git a/gson/pom.xml b/gson/pom.xml
index 02f9db85a9..1b9fc085c2 100644
--- a/gson/pom.xml
+++ b/gson/pom.xml
@@ -54,8 +54,8 @@
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
test
@@ -243,6 +243,12 @@
proguard-core
9.1.6
+
+ org.junit.vintage
+ junit-vintage-engine
+ 5.11.3
+ test
+
true
diff --git a/gson/src/test/java/com/google/gson/CommentsTest.java b/gson/src/test/java/com/google/gson/CommentsTest.java
index a08bc67371..7b83a65547 100644
--- a/gson/src/test/java/com/google/gson/CommentsTest.java
+++ b/gson/src/test/java/com/google/gson/CommentsTest.java
@@ -20,7 +20,7 @@
import com.google.gson.reflect.TypeToken;
import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Tests that by default Gson accepts several forms of comments.
diff --git a/gson/src/test/java/com/google/gson/DefaultInetAddressTypeAdapterTest.java b/gson/src/test/java/com/google/gson/DefaultInetAddressTypeAdapterTest.java
index f05c557638..11eb9b4a3b 100644
--- a/gson/src/test/java/com/google/gson/DefaultInetAddressTypeAdapterTest.java
+++ b/gson/src/test/java/com/google/gson/DefaultInetAddressTypeAdapterTest.java
@@ -19,8 +19,8 @@
import static com.google.common.truth.Truth.assertThat;
import java.net.InetAddress;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Unit tests for the default serializer/deserializer for the {@code InetAddress} type.
@@ -30,7 +30,7 @@
public class DefaultInetAddressTypeAdapterTest {
private Gson gson;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
gson = new Gson();
}
diff --git a/gson/src/test/java/com/google/gson/DefaultMapJsonSerializerTest.java b/gson/src/test/java/com/google/gson/DefaultMapJsonSerializerTest.java
index 1fd2102234..e771710804 100644
--- a/gson/src/test/java/com/google/gson/DefaultMapJsonSerializerTest.java
+++ b/gson/src/test/java/com/google/gson/DefaultMapJsonSerializerTest.java
@@ -22,7 +22,7 @@
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Unit test for the default JSON map serialization object located in the {@link
diff --git a/gson/src/test/java/com/google/gson/ExposeAnnotationExclusionStrategyTest.java b/gson/src/test/java/com/google/gson/ExposeAnnotationExclusionStrategyTest.java
index 8738e5b98c..f594d77be0 100644
--- a/gson/src/test/java/com/google/gson/ExposeAnnotationExclusionStrategyTest.java
+++ b/gson/src/test/java/com/google/gson/ExposeAnnotationExclusionStrategyTest.java
@@ -21,7 +21,7 @@
import com.google.gson.annotations.Expose;
import com.google.gson.internal.Excluder;
import java.lang.reflect.Field;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Unit tests for GsonBuilder.REQUIRE_EXPOSE_DESERIALIZE.
diff --git a/gson/src/test/java/com/google/gson/FieldAttributesTest.java b/gson/src/test/java/com/google/gson/FieldAttributesTest.java
index 672fb3fdbc..46751de46e 100644
--- a/gson/src/test/java/com/google/gson/FieldAttributesTest.java
+++ b/gson/src/test/java/com/google/gson/FieldAttributesTest.java
@@ -17,14 +17,14 @@
package com.google.gson;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Modifier;
import java.lang.reflect.Type;
import java.util.List;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Unit tests for the {@link FieldAttributes} class.
@@ -35,7 +35,7 @@
public class FieldAttributesTest {
private FieldAttributes fieldAttributes;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
fieldAttributes = new FieldAttributes(Foo.class.getField("bar"));
}
diff --git a/gson/src/test/java/com/google/gson/FieldNamingPolicyTest.java b/gson/src/test/java/com/google/gson/FieldNamingPolicyTest.java
index 0d085269f8..ff29eff82f 100644
--- a/gson/src/test/java/com/google/gson/FieldNamingPolicyTest.java
+++ b/gson/src/test/java/com/google/gson/FieldNamingPolicyTest.java
@@ -22,7 +22,7 @@
import com.google.gson.functional.FieldNamingTest;
import java.lang.reflect.Field;
import java.util.Locale;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Performs tests directly against {@link FieldNamingPolicy}; for integration tests see {@link
diff --git a/gson/src/test/java/com/google/gson/GenericArrayTypeTest.java b/gson/src/test/java/com/google/gson/GenericArrayTypeTest.java
index f17f29c721..dcc2cc18b8 100644
--- a/gson/src/test/java/com/google/gson/GenericArrayTypeTest.java
+++ b/gson/src/test/java/com/google/gson/GenericArrayTypeTest.java
@@ -23,8 +23,8 @@
import java.lang.reflect.GenericArrayType;
import java.lang.reflect.Type;
import java.util.List;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Unit tests for the {@code GenericArrayType}s created by the {@link $Gson$Types} class.
@@ -35,7 +35,7 @@
public class GenericArrayTypeTest {
private GenericArrayType ourType;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
ourType =
$Gson$Types.arrayOf(
diff --git a/gson/src/test/java/com/google/gson/GsonBuilderTest.java b/gson/src/test/java/com/google/gson/GsonBuilderTest.java
index 757183fec0..0c4cf7b894 100644
--- a/gson/src/test/java/com/google/gson/GsonBuilderTest.java
+++ b/gson/src/test/java/com/google/gson/GsonBuilderTest.java
@@ -17,7 +17,7 @@
package com.google.gson;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
@@ -28,7 +28,7 @@
import java.lang.reflect.Type;
import java.text.DateFormat;
import java.util.Date;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Unit tests for {@link GsonBuilder}.
diff --git a/gson/src/test/java/com/google/gson/GsonTest.java b/gson/src/test/java/com/google/gson/GsonTest.java
index 45cd1d4479..33b4729432 100644
--- a/gson/src/test/java/com/google/gson/GsonTest.java
+++ b/gson/src/test/java/com/google/gson/GsonTest.java
@@ -17,7 +17,7 @@
package com.google.gson;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.gson.Gson.FutureTypeAdapter;
import com.google.gson.internal.Excluder;
@@ -35,7 +35,7 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Unit tests for {@link Gson}.
diff --git a/gson/src/test/java/com/google/gson/GsonTypeAdapterTest.java b/gson/src/test/java/com/google/gson/GsonTypeAdapterTest.java
index 969405eb0f..1986752910 100644
--- a/gson/src/test/java/com/google/gson/GsonTypeAdapterTest.java
+++ b/gson/src/test/java/com/google/gson/GsonTypeAdapterTest.java
@@ -17,14 +17,14 @@
package com.google.gson;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import java.lang.reflect.Type;
import java.math.BigInteger;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Contains numerous tests involving registered type converters with a Gson instance.
@@ -35,7 +35,7 @@
public class GsonTypeAdapterTest {
private Gson gson;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
gson =
new GsonBuilder()
diff --git a/gson/src/test/java/com/google/gson/InnerClassExclusionStrategyTest.java b/gson/src/test/java/com/google/gson/InnerClassExclusionStrategyTest.java
index f768c5012c..5bbcda4825 100644
--- a/gson/src/test/java/com/google/gson/InnerClassExclusionStrategyTest.java
+++ b/gson/src/test/java/com/google/gson/InnerClassExclusionStrategyTest.java
@@ -20,7 +20,7 @@
import com.google.gson.internal.Excluder;
import java.lang.reflect.Field;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Unit test for GsonBuilder.EXCLUDE_INNER_CLASSES.
diff --git a/gson/src/test/java/com/google/gson/JavaSerializationTest.java b/gson/src/test/java/com/google/gson/JavaSerializationTest.java
index 219e16bb56..17d2253347 100644
--- a/gson/src/test/java/com/google/gson/JavaSerializationTest.java
+++ b/gson/src/test/java/com/google/gson/JavaSerializationTest.java
@@ -27,7 +27,7 @@
import java.lang.reflect.Type;
import java.util.List;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Check that Gson doesn't return non-serializable data types.
diff --git a/gson/src/test/java/com/google/gson/JsonArrayAsListTest.java b/gson/src/test/java/com/google/gson/JsonArrayAsListTest.java
index 50e101c6b6..796fa2efa9 100644
--- a/gson/src/test/java/com/google/gson/JsonArrayAsListTest.java
+++ b/gson/src/test/java/com/google/gson/JsonArrayAsListTest.java
@@ -17,7 +17,7 @@
package com.google.gson;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.gson.common.MoreAsserts;
import java.util.Arrays;
@@ -27,7 +27,7 @@
import java.util.Spliterator;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/** Tests for {@link JsonArray#asList()}. */
public class JsonArrayAsListTest {
diff --git a/gson/src/test/java/com/google/gson/JsonArrayTest.java b/gson/src/test/java/com/google/gson/JsonArrayTest.java
index e6e60070af..33bf25ca54 100644
--- a/gson/src/test/java/com/google/gson/JsonArrayTest.java
+++ b/gson/src/test/java/com/google/gson/JsonArrayTest.java
@@ -17,12 +17,12 @@
package com.google.gson;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.common.testing.EqualsTester;
import com.google.gson.common.MoreAsserts;
import java.math.BigInteger;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Tests handling of JSON arrays.
diff --git a/gson/src/test/java/com/google/gson/JsonNullTest.java b/gson/src/test/java/com/google/gson/JsonNullTest.java
index d3c5b98cd6..aac3ae9f98 100644
--- a/gson/src/test/java/com/google/gson/JsonNullTest.java
+++ b/gson/src/test/java/com/google/gson/JsonNullTest.java
@@ -19,7 +19,7 @@
import static com.google.common.truth.Truth.assertThat;
import com.google.gson.common.MoreAsserts;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Tests handling of JSON nulls.
diff --git a/gson/src/test/java/com/google/gson/JsonObjectAsMapTest.java b/gson/src/test/java/com/google/gson/JsonObjectAsMapTest.java
index 55d045cbe2..3c873228af 100644
--- a/gson/src/test/java/com/google/gson/JsonObjectAsMapTest.java
+++ b/gson/src/test/java/com/google/gson/JsonObjectAsMapTest.java
@@ -17,7 +17,7 @@
package com.google.gson;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.gson.common.MoreAsserts;
import java.util.AbstractMap.SimpleEntry;
@@ -30,7 +30,7 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/** Tests for {@link JsonObject#asMap()}. */
public class JsonObjectAsMapTest {
diff --git a/gson/src/test/java/com/google/gson/JsonObjectTest.java b/gson/src/test/java/com/google/gson/JsonObjectTest.java
index a728fda3be..2826981abc 100644
--- a/gson/src/test/java/com/google/gson/JsonObjectTest.java
+++ b/gson/src/test/java/com/google/gson/JsonObjectTest.java
@@ -17,7 +17,7 @@
package com.google.gson;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.common.testing.EqualsTester;
import com.google.gson.common.MoreAsserts;
@@ -31,7 +31,7 @@
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Unit test for the {@link JsonObject} class.
diff --git a/gson/src/test/java/com/google/gson/JsonParserParameterizedTest.java b/gson/src/test/java/com/google/gson/JsonParserParameterizedTest.java
index 3ec42b258b..64bf953c30 100644
--- a/gson/src/test/java/com/google/gson/JsonParserParameterizedTest.java
+++ b/gson/src/test/java/com/google/gson/JsonParserParameterizedTest.java
@@ -19,7 +19,7 @@
import static com.google.common.truth.Truth.assertThat;
import java.util.Arrays;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameter;
diff --git a/gson/src/test/java/com/google/gson/JsonParserTest.java b/gson/src/test/java/com/google/gson/JsonParserTest.java
index 47192c797b..7f83659960 100644
--- a/gson/src/test/java/com/google/gson/JsonParserTest.java
+++ b/gson/src/test/java/com/google/gson/JsonParserTest.java
@@ -17,7 +17,7 @@
package com.google.gson;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.gson.common.TestTypes.BagOfPrimitives;
import com.google.gson.internal.Streams;
@@ -26,7 +26,7 @@
import java.io.CharArrayWriter;
import java.io.IOException;
import java.io.StringReader;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Unit test for {@link JsonParser}
diff --git a/gson/src/test/java/com/google/gson/JsonPrimitiveTest.java b/gson/src/test/java/com/google/gson/JsonPrimitiveTest.java
index be73c315ad..4201140fb3 100644
--- a/gson/src/test/java/com/google/gson/JsonPrimitiveTest.java
+++ b/gson/src/test/java/com/google/gson/JsonPrimitiveTest.java
@@ -18,12 +18,12 @@
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.gson.common.MoreAsserts;
import java.math.BigDecimal;
import java.math.BigInteger;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Unit test for the {@link JsonPrimitive} class.
diff --git a/gson/src/test/java/com/google/gson/JsonStreamParserTest.java b/gson/src/test/java/com/google/gson/JsonStreamParserTest.java
index 807b93f89d..23fdb13134 100644
--- a/gson/src/test/java/com/google/gson/JsonStreamParserTest.java
+++ b/gson/src/test/java/com/google/gson/JsonStreamParserTest.java
@@ -16,12 +16,12 @@
package com.google.gson;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import java.io.EOFException;
import java.util.NoSuchElementException;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Unit tests for {@link JsonStreamParser}
@@ -31,7 +31,7 @@
public class JsonStreamParserTest {
private JsonStreamParser parser;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
parser = new JsonStreamParser("'one' 'two'");
}
diff --git a/gson/src/test/java/com/google/gson/LongSerializationPolicyTest.java b/gson/src/test/java/com/google/gson/LongSerializationPolicyTest.java
index 39a57feae4..0dc522da34 100644
--- a/gson/src/test/java/com/google/gson/LongSerializationPolicyTest.java
+++ b/gson/src/test/java/com/google/gson/LongSerializationPolicyTest.java
@@ -18,7 +18,7 @@
import static com.google.common.truth.Truth.assertThat;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Unit test for the {@link LongSerializationPolicy} class.
diff --git a/gson/src/test/java/com/google/gson/MixedStreamTest.java b/gson/src/test/java/com/google/gson/MixedStreamTest.java
index d65b36bb61..2e7ab34b44 100644
--- a/gson/src/test/java/com/google/gson/MixedStreamTest.java
+++ b/gson/src/test/java/com/google/gson/MixedStreamTest.java
@@ -17,7 +17,7 @@
package com.google.gson;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
@@ -28,7 +28,7 @@
import java.lang.reflect.Type;
import java.util.Arrays;
import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public final class MixedStreamTest {
diff --git a/gson/src/test/java/com/google/gson/ObjectTypeAdapterParameterizedTest.java b/gson/src/test/java/com/google/gson/ObjectTypeAdapterParameterizedTest.java
index 612c628b16..45ba6533d6 100644
--- a/gson/src/test/java/com/google/gson/ObjectTypeAdapterParameterizedTest.java
+++ b/gson/src/test/java/com/google/gson/ObjectTypeAdapterParameterizedTest.java
@@ -20,7 +20,7 @@
import java.io.IOException;
import java.util.Arrays;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameter;
diff --git a/gson/src/test/java/com/google/gson/ObjectTypeAdapterTest.java b/gson/src/test/java/com/google/gson/ObjectTypeAdapterTest.java
index 840a83d71b..d840491458 100644
--- a/gson/src/test/java/com/google/gson/ObjectTypeAdapterTest.java
+++ b/gson/src/test/java/com/google/gson/ObjectTypeAdapterTest.java
@@ -26,7 +26,7 @@
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public final class ObjectTypeAdapterTest {
private final Gson gson = new GsonBuilder().create();
diff --git a/gson/src/test/java/com/google/gson/OverrideCoreTypeAdaptersTest.java b/gson/src/test/java/com/google/gson/OverrideCoreTypeAdaptersTest.java
index 134abe1571..14011af295 100644
--- a/gson/src/test/java/com/google/gson/OverrideCoreTypeAdaptersTest.java
+++ b/gson/src/test/java/com/google/gson/OverrideCoreTypeAdaptersTest.java
@@ -22,7 +22,7 @@
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.util.Locale;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Tests handling of Core Type Adapters
diff --git a/gson/src/test/java/com/google/gson/ParameterizedTypeTest.java b/gson/src/test/java/com/google/gson/ParameterizedTypeTest.java
index ca837c540e..1ef1fbd3f7 100644
--- a/gson/src/test/java/com/google/gson/ParameterizedTypeTest.java
+++ b/gson/src/test/java/com/google/gson/ParameterizedTypeTest.java
@@ -23,8 +23,8 @@
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.List;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Unit tests for {@code ParameterizedType}s created by the {@link $Gson$Types} class.
@@ -35,7 +35,7 @@
public class ParameterizedTypeTest {
private ParameterizedType ourType;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
ourType = $Gson$Types.newParameterizedTypeWithOwner(null, List.class, String.class);
}
diff --git a/gson/src/test/java/com/google/gson/ToNumberPolicyTest.java b/gson/src/test/java/com/google/gson/ToNumberPolicyTest.java
index d6ce1f7888..3055f30ac6 100644
--- a/gson/src/test/java/com/google/gson/ToNumberPolicyTest.java
+++ b/gson/src/test/java/com/google/gson/ToNumberPolicyTest.java
@@ -17,7 +17,7 @@
package com.google.gson;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.gson.internal.LazilyParsedNumber;
import com.google.gson.stream.JsonReader;
@@ -25,7 +25,7 @@
import java.io.IOException;
import java.io.StringReader;
import java.math.BigDecimal;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class ToNumberPolicyTest {
@Test
diff --git a/gson/src/test/java/com/google/gson/TypeAdapterTest.java b/gson/src/test/java/com/google/gson/TypeAdapterTest.java
index 8f4806f821..05d16c81fc 100644
--- a/gson/src/test/java/com/google/gson/TypeAdapterTest.java
+++ b/gson/src/test/java/com/google/gson/TypeAdapterTest.java
@@ -17,13 +17,13 @@
package com.google.gson;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.io.StringReader;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class TypeAdapterTest {
@Test
diff --git a/gson/src/test/java/com/google/gson/VersionExclusionStrategyTest.java b/gson/src/test/java/com/google/gson/VersionExclusionStrategyTest.java
index 5c2b22ca6c..1518695d72 100644
--- a/gson/src/test/java/com/google/gson/VersionExclusionStrategyTest.java
+++ b/gson/src/test/java/com/google/gson/VersionExclusionStrategyTest.java
@@ -23,7 +23,7 @@
import com.google.gson.annotations.Until;
import com.google.gson.internal.Excluder;
import java.lang.reflect.Field;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Unit tests for the {@link Excluder} class.
diff --git a/gson/src/test/java/com/google/gson/common/MoreAsserts.java b/gson/src/test/java/com/google/gson/common/MoreAsserts.java
index 3b74056dcc..ac7cc23449 100644
--- a/gson/src/test/java/com/google/gson/common/MoreAsserts.java
+++ b/gson/src/test/java/com/google/gson/common/MoreAsserts.java
@@ -22,7 +22,7 @@
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
-import org.junit.Assert;
+import org.junit.jupiter.api.Assertions;
/**
* Handy asserts that we wish were present in {@link Assert} so that we didn't have to write them.
@@ -44,15 +44,15 @@ public static void assertContains(Collection collection, T value) {
return;
}
}
- Assert.fail(value + " not present in " + collection);
+ Assertions.fail(value + " not present in " + collection);
}
public static void assertEqualsAndHashCode(Object a, Object b) {
- Assert.assertTrue(a.equals(b));
- Assert.assertTrue(b.equals(a));
- Assert.assertEquals(a.hashCode(), b.hashCode());
- Assert.assertFalse(a.equals(null));
- Assert.assertFalse(a.equals(new Object()));
+ Assertions.assertTrue(a.equals(b));
+ Assertions.assertTrue(b.equals(a));
+ Assertions.assertEquals(a.hashCode(), b.hashCode());
+ Assertions.assertFalse(a.equals(null));
+ Assertions.assertFalse(a.equals(new Object()));
}
private static boolean isProtectedOrPublic(Method method) {
@@ -102,7 +102,7 @@ public static void assertOverridesMethods(
}
if (!requiredOverriddenMethods.isEmpty()) {
- Assert.fail(
+ Assertions.fail(
subClass.getSimpleName() + " must override these methods: " + requiredOverriddenMethods);
}
}
diff --git a/gson/src/test/java/com/google/gson/functional/ArrayTest.java b/gson/src/test/java/com/google/gson/functional/ArrayTest.java
index b8a4e3a069..bbe23f0159 100644
--- a/gson/src/test/java/com/google/gson/functional/ArrayTest.java
+++ b/gson/src/test/java/com/google/gson/functional/ArrayTest.java
@@ -17,7 +17,7 @@
package com.google.gson.functional;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@@ -29,8 +29,8 @@
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collection;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Functional tests for Json serialization and deserialization of arrays.
@@ -41,7 +41,7 @@
public class ArrayTest {
private Gson gson;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
gson = new Gson();
}
diff --git a/gson/src/test/java/com/google/gson/functional/CircularReferenceTest.java b/gson/src/test/java/com/google/gson/functional/CircularReferenceTest.java
index 847284f6b1..ab6c0c7c19 100644
--- a/gson/src/test/java/com/google/gson/functional/CircularReferenceTest.java
+++ b/gson/src/test/java/com/google/gson/functional/CircularReferenceTest.java
@@ -16,7 +16,7 @@
package com.google.gson.functional;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@@ -28,8 +28,8 @@
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Collection;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Functional tests related to circular reference detection and error reporting.
@@ -40,7 +40,7 @@
public class CircularReferenceTest {
private Gson gson;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
gson = new Gson();
}
diff --git a/gson/src/test/java/com/google/gson/functional/CollectionTest.java b/gson/src/test/java/com/google/gson/functional/CollectionTest.java
index 54bf68c2ef..cec678450b 100644
--- a/gson/src/test/java/com/google/gson/functional/CollectionTest.java
+++ b/gson/src/test/java/com/google/gson/functional/CollectionTest.java
@@ -40,8 +40,8 @@
import java.util.Set;
import java.util.Stack;
import java.util.Vector;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Functional tests for Json serialization and deserialization of collections.
@@ -52,7 +52,7 @@
public class CollectionTest {
private Gson gson;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
gson = new Gson();
}
diff --git a/gson/src/test/java/com/google/gson/functional/ConcurrencyTest.java b/gson/src/test/java/com/google/gson/functional/ConcurrencyTest.java
index b4af36128a..56d9ed2188 100644
--- a/gson/src/test/java/com/google/gson/functional/ConcurrencyTest.java
+++ b/gson/src/test/java/com/google/gson/functional/ConcurrencyTest.java
@@ -22,8 +22,8 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicReference;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Tests for ensuring Gson thread-safety.
@@ -34,7 +34,7 @@
public class ConcurrencyTest {
private Gson gson;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
gson = new Gson();
}
diff --git a/gson/src/test/java/com/google/gson/functional/CustomDeserializerTest.java b/gson/src/test/java/com/google/gson/functional/CustomDeserializerTest.java
index 075399a864..658b462230 100644
--- a/gson/src/test/java/com/google/gson/functional/CustomDeserializerTest.java
+++ b/gson/src/test/java/com/google/gson/functional/CustomDeserializerTest.java
@@ -28,8 +28,8 @@
import com.google.gson.common.TestTypes.Base;
import com.google.gson.common.TestTypes.ClassWithBaseField;
import java.lang.reflect.Type;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Functional Test exercising custom deserialization only. When test applies to both serialization
@@ -43,7 +43,7 @@ public class CustomDeserializerTest {
private Gson gson;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
gson =
new GsonBuilder()
diff --git a/gson/src/test/java/com/google/gson/functional/CustomSerializerTest.java b/gson/src/test/java/com/google/gson/functional/CustomSerializerTest.java
index de6d57f194..b315cad136 100644
--- a/gson/src/test/java/com/google/gson/functional/CustomSerializerTest.java
+++ b/gson/src/test/java/com/google/gson/functional/CustomSerializerTest.java
@@ -30,7 +30,7 @@
import com.google.gson.common.TestTypes.ClassWithBaseField;
import com.google.gson.common.TestTypes.Sub;
import com.google.gson.common.TestTypes.SubSerializer;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Functional Test exercising custom serialization only. When test applies to both serialization and
diff --git a/gson/src/test/java/com/google/gson/functional/CustomTypeAdaptersTest.java b/gson/src/test/java/com/google/gson/functional/CustomTypeAdaptersTest.java
index 5a4371813a..e73351b52c 100644
--- a/gson/src/test/java/com/google/gson/functional/CustomTypeAdaptersTest.java
+++ b/gson/src/test/java/com/google/gson/functional/CustomTypeAdaptersTest.java
@@ -39,9 +39,9 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
/**
* Functional tests for the support of custom serializer and deserializers.
@@ -52,7 +52,7 @@
public class CustomTypeAdaptersTest {
private GsonBuilder builder;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
builder = new GsonBuilder();
}
@@ -95,7 +95,7 @@ public void testCustomDeserializers() {
}
@Test
- @Ignore
+ @Disabled
public void disable_testCustomSerializersOfSelf() {
Gson gson = createGsonObjectWithFooTypeAdapter();
Gson basicGson = new Gson();
@@ -107,7 +107,7 @@ public void disable_testCustomSerializersOfSelf() {
}
@Test
- @Ignore
+ @Disabled
public void disable_testCustomDeserializersOfSelf() {
Gson gson = createGsonObjectWithFooTypeAdapter();
Gson basicGson = new Gson();
diff --git a/gson/src/test/java/com/google/gson/functional/DefaultTypeAdaptersTest.java b/gson/src/test/java/com/google/gson/functional/DefaultTypeAdaptersTest.java
index c3892188be..bb6b9daf03 100644
--- a/gson/src/test/java/com/google/gson/functional/DefaultTypeAdaptersTest.java
+++ b/gson/src/test/java/com/google/gson/functional/DefaultTypeAdaptersTest.java
@@ -17,7 +17,7 @@
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@@ -56,9 +56,9 @@
import java.util.TimeZone;
import java.util.TreeSet;
import java.util.UUID;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Functional test for Json serialization and deserialization for common classes for which default
@@ -73,7 +73,7 @@ public class DefaultTypeAdaptersTest {
private TimeZone oldTimeZone;
private Locale oldLocale;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
this.oldTimeZone = TimeZone.getDefault();
TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles"));
@@ -82,7 +82,7 @@ public void setUp() throws Exception {
gson = new Gson();
}
- @After
+ @AfterEach
public void tearDown() {
TimeZone.setDefault(oldTimeZone);
Locale.setDefault(oldLocale);
diff --git a/gson/src/test/java/com/google/gson/functional/DelegateTypeAdapterTest.java b/gson/src/test/java/com/google/gson/functional/DelegateTypeAdapterTest.java
index d10ab42dcb..205270a24e 100644
--- a/gson/src/test/java/com/google/gson/functional/DelegateTypeAdapterTest.java
+++ b/gson/src/test/java/com/google/gson/functional/DelegateTypeAdapterTest.java
@@ -28,8 +28,8 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Functional tests for {@link Gson#getDelegateAdapter(TypeAdapterFactory, TypeToken)} method.
@@ -41,7 +41,7 @@ public class DelegateTypeAdapterTest {
private StatsTypeAdapterFactory stats;
private Gson gson;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
stats = new StatsTypeAdapterFactory();
gson = new GsonBuilder().registerTypeAdapterFactory(stats).create();
diff --git a/gson/src/test/java/com/google/gson/functional/EnumTest.java b/gson/src/test/java/com/google/gson/functional/EnumTest.java
index 990a6463e8..877ada6de8 100644
--- a/gson/src/test/java/com/google/gson/functional/EnumTest.java
+++ b/gson/src/test/java/com/google/gson/functional/EnumTest.java
@@ -38,8 +38,8 @@
import java.util.EnumSet;
import java.util.Map;
import java.util.Set;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Functional tests for Java 5.0 enums.
@@ -51,7 +51,7 @@ public class EnumTest {
private Gson gson;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
gson = new Gson();
}
diff --git a/gson/src/test/java/com/google/gson/functional/EnumWithObfuscatedTest.java b/gson/src/test/java/com/google/gson/functional/EnumWithObfuscatedTest.java
index a17b6c28c9..69fe965364 100644
--- a/gson/src/test/java/com/google/gson/functional/EnumWithObfuscatedTest.java
+++ b/gson/src/test/java/com/google/gson/functional/EnumWithObfuscatedTest.java
@@ -17,12 +17,12 @@
package com.google.gson.functional;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Functional tests for enums with Proguard.
@@ -32,7 +32,7 @@
public class EnumWithObfuscatedTest {
private Gson gson;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
gson = new Gson();
}
@@ -49,9 +49,9 @@ public enum Gender {
public void testEnumClassWithObfuscated() {
for (Gender enumConstant : Gender.class.getEnumConstants()) {
assertThrows(
- "Enum is not obfuscated",
NoSuchFieldException.class,
- () -> Gender.class.getField(enumConstant.name()));
+ () -> Gender.class.getField(enumConstant.name()),
+ "Enum is not obfuscated");
}
assertThat(gson.fromJson("\"MAIL\"", Gender.class)).isEqualTo(Gender.MALE);
diff --git a/gson/src/test/java/com/google/gson/functional/EscapingTest.java b/gson/src/test/java/com/google/gson/functional/EscapingTest.java
index 1eeeb1768d..13ec083145 100644
--- a/gson/src/test/java/com/google/gson/functional/EscapingTest.java
+++ b/gson/src/test/java/com/google/gson/functional/EscapingTest.java
@@ -23,8 +23,8 @@
import com.google.gson.common.TestTypes.BagOfPrimitives;
import java.util.ArrayList;
import java.util.List;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Performs some functional test involving JSON output escaping.
@@ -35,7 +35,7 @@
public class EscapingTest {
private Gson gson;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
gson = new Gson();
}
diff --git a/gson/src/test/java/com/google/gson/functional/ExclusionStrategyFunctionalTest.java b/gson/src/test/java/com/google/gson/functional/ExclusionStrategyFunctionalTest.java
index 43ffc0eb80..59f18fe6a3 100644
--- a/gson/src/test/java/com/google/gson/functional/ExclusionStrategyFunctionalTest.java
+++ b/gson/src/test/java/com/google/gson/functional/ExclusionStrategyFunctionalTest.java
@@ -28,8 +28,8 @@
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Performs some functional tests when Gson is instantiated with some common user defined {@link
@@ -54,7 +54,7 @@ public boolean shouldSkipClass(Class> clazz) {
private SampleObjectForTest src;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
src = new SampleObjectForTest();
}
diff --git a/gson/src/test/java/com/google/gson/functional/ExposeFieldsTest.java b/gson/src/test/java/com/google/gson/functional/ExposeFieldsTest.java
index 678b1bcad8..f82e30fa61 100644
--- a/gson/src/test/java/com/google/gson/functional/ExposeFieldsTest.java
+++ b/gson/src/test/java/com/google/gson/functional/ExposeFieldsTest.java
@@ -24,8 +24,8 @@
import com.google.gson.InstanceCreator;
import com.google.gson.annotations.Expose;
import java.lang.reflect.Type;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Unit tests for the regarding functional "@Expose" type tests.
@@ -36,7 +36,7 @@ public class ExposeFieldsTest {
private Gson gson;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
gson =
new GsonBuilder()
diff --git a/gson/src/test/java/com/google/gson/functional/FieldExclusionTest.java b/gson/src/test/java/com/google/gson/functional/FieldExclusionTest.java
index 591cb2fd9d..780d19a1d8 100644
--- a/gson/src/test/java/com/google/gson/functional/FieldExclusionTest.java
+++ b/gson/src/test/java/com/google/gson/functional/FieldExclusionTest.java
@@ -20,8 +20,8 @@
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Performs some functional testing to ensure GSON infrastructure properly serializes/deserializes
@@ -35,7 +35,7 @@ public class FieldExclusionTest {
private Outer outer;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
outer = new Outer();
}
diff --git a/gson/src/test/java/com/google/gson/functional/FieldNamingTest.java b/gson/src/test/java/com/google/gson/functional/FieldNamingTest.java
index 36f03f2889..7b5673516c 100644
--- a/gson/src/test/java/com/google/gson/functional/FieldNamingTest.java
+++ b/gson/src/test/java/com/google/gson/functional/FieldNamingTest.java
@@ -28,7 +28,7 @@
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.annotations.SerializedName;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public final class FieldNamingTest {
@Test
diff --git a/gson/src/test/java/com/google/gson/functional/FormattingStyleTest.java b/gson/src/test/java/com/google/gson/functional/FormattingStyleTest.java
index 581b23e55b..5e30ed78c9 100644
--- a/gson/src/test/java/com/google/gson/functional/FormattingStyleTest.java
+++ b/gson/src/test/java/com/google/gson/functional/FormattingStyleTest.java
@@ -16,7 +16,7 @@
package com.google.gson.functional;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.gson.FormattingStyle;
import com.google.gson.Gson;
@@ -26,7 +26,7 @@
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
diff --git a/gson/src/test/java/com/google/gson/functional/GsonVersionDiagnosticsTest.java b/gson/src/test/java/com/google/gson/functional/GsonVersionDiagnosticsTest.java
index 1cbeb4156e..820b5937d7 100644
--- a/gson/src/test/java/com/google/gson/functional/GsonVersionDiagnosticsTest.java
+++ b/gson/src/test/java/com/google/gson/functional/GsonVersionDiagnosticsTest.java
@@ -16,7 +16,7 @@
package com.google.gson.functional;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@@ -24,8 +24,8 @@
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.util.regex.Pattern;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Functional tests to validate printing of Gson version on AssertionErrors
@@ -39,7 +39,7 @@ public class GsonVersionDiagnosticsTest {
private Gson gson;
- @Before
+ @BeforeEach
public void setUp() {
gson =
new GsonBuilder()
diff --git a/gson/src/test/java/com/google/gson/functional/InheritanceTest.java b/gson/src/test/java/com/google/gson/functional/InheritanceTest.java
index f41b133fb3..22b2e67707 100644
--- a/gson/src/test/java/com/google/gson/functional/InheritanceTest.java
+++ b/gson/src/test/java/com/google/gson/functional/InheritanceTest.java
@@ -37,8 +37,8 @@
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Functional tests for Json serialization and deserialization of classes with inheritance
@@ -50,7 +50,7 @@
public class InheritanceTest {
private Gson gson;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
gson = new Gson();
}
diff --git a/gson/src/test/java/com/google/gson/functional/InstanceCreatorTest.java b/gson/src/test/java/com/google/gson/functional/InstanceCreatorTest.java
index 91eb54e35e..dc003b3ea3 100644
--- a/gson/src/test/java/com/google/gson/functional/InstanceCreatorTest.java
+++ b/gson/src/test/java/com/google/gson/functional/InstanceCreatorTest.java
@@ -30,7 +30,7 @@
import java.util.List;
import java.util.SortedSet;
import java.util.TreeSet;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Functional Test exercising custom deserialization only. When test applies to both serialization
diff --git a/gson/src/test/java/com/google/gson/functional/InterfaceTest.java b/gson/src/test/java/com/google/gson/functional/InterfaceTest.java
index 4da40419aa..b69cc2ce63 100644
--- a/gson/src/test/java/com/google/gson/functional/InterfaceTest.java
+++ b/gson/src/test/java/com/google/gson/functional/InterfaceTest.java
@@ -19,8 +19,8 @@
import static com.google.common.truth.Truth.assertThat;
import com.google.gson.Gson;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Functional tests involving interfaces.
@@ -34,7 +34,7 @@ public class InterfaceTest {
private Gson gson;
private TestObject obj;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
gson = new Gson();
obj = new TestObject("StringValue");
diff --git a/gson/src/test/java/com/google/gson/functional/InternationalizationTest.java b/gson/src/test/java/com/google/gson/functional/InternationalizationTest.java
index 775c6ffd86..83eb976c12 100644
--- a/gson/src/test/java/com/google/gson/functional/InternationalizationTest.java
+++ b/gson/src/test/java/com/google/gson/functional/InternationalizationTest.java
@@ -19,8 +19,8 @@
import static com.google.common.truth.Truth.assertThat;
import com.google.gson.Gson;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Functional tests for internationalized strings.
@@ -30,7 +30,7 @@
public class InternationalizationTest {
private Gson gson;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
gson = new Gson();
}
diff --git a/gson/src/test/java/com/google/gson/functional/Java17RecordTest.java b/gson/src/test/java/com/google/gson/functional/Java17RecordTest.java
index 2a067471ad..b1599caa3b 100644
--- a/gson/src/test/java/com/google/gson/functional/Java17RecordTest.java
+++ b/gson/src/test/java/com/google/gson/functional/Java17RecordTest.java
@@ -16,7 +16,7 @@
package com.google.gson.functional;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.gson.ExclusionStrategy;
import com.google.gson.FieldAttributes;
@@ -39,7 +39,7 @@
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.lang.reflect.Type;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
diff --git a/gson/src/test/java/com/google/gson/functional/JavaUtilConcurrentAtomicTest.java b/gson/src/test/java/com/google/gson/functional/JavaUtilConcurrentAtomicTest.java
index 4b6f639a9e..191aa8b53c 100644
--- a/gson/src/test/java/com/google/gson/functional/JavaUtilConcurrentAtomicTest.java
+++ b/gson/src/test/java/com/google/gson/functional/JavaUtilConcurrentAtomicTest.java
@@ -26,8 +26,8 @@
import java.util.concurrent.atomic.AtomicIntegerArray;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicLongArray;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Functional test for Json serialization and deserialization for classes in
@@ -36,7 +36,7 @@
public class JavaUtilConcurrentAtomicTest {
private Gson gson;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
gson = new Gson();
}
diff --git a/gson/src/test/java/com/google/gson/functional/JavaUtilTest.java b/gson/src/test/java/com/google/gson/functional/JavaUtilTest.java
index 6936dd90ae..d6fd7f57e4 100644
--- a/gson/src/test/java/com/google/gson/functional/JavaUtilTest.java
+++ b/gson/src/test/java/com/google/gson/functional/JavaUtilTest.java
@@ -21,14 +21,14 @@
import com.google.gson.Gson;
import java.util.Currency;
import java.util.Properties;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/** Functional test for Json serialization and deserialization for classes in java.util */
public class JavaUtilTest {
private Gson gson;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
gson = new Gson();
}
diff --git a/gson/src/test/java/com/google/gson/functional/JsonAdapterAnnotationOnClassesTest.java b/gson/src/test/java/com/google/gson/functional/JsonAdapterAnnotationOnClassesTest.java
index a4e694112b..7dc6719a50 100644
--- a/gson/src/test/java/com/google/gson/functional/JsonAdapterAnnotationOnClassesTest.java
+++ b/gson/src/test/java/com/google/gson/functional/JsonAdapterAnnotationOnClassesTest.java
@@ -17,7 +17,7 @@
package com.google.gson.functional;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.common.base.Splitter;
import com.google.gson.Gson;
@@ -40,7 +40,7 @@
import java.lang.reflect.Type;
import java.util.List;
import java.util.Locale;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/** Functional tests for the {@link JsonAdapter} annotation on classes. */
@SuppressWarnings("ClassNamedLikeTypeParameter") // for dummy classes A, B, ...
diff --git a/gson/src/test/java/com/google/gson/functional/JsonAdapterAnnotationOnFieldsTest.java b/gson/src/test/java/com/google/gson/functional/JsonAdapterAnnotationOnFieldsTest.java
index 0c8422952b..a8f9188032 100644
--- a/gson/src/test/java/com/google/gson/functional/JsonAdapterAnnotationOnFieldsTest.java
+++ b/gson/src/test/java/com/google/gson/functional/JsonAdapterAnnotationOnFieldsTest.java
@@ -40,7 +40,7 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/** Functional tests for the {@link JsonAdapter} annotation on fields. */
public final class JsonAdapterAnnotationOnFieldsTest {
diff --git a/gson/src/test/java/com/google/gson/functional/JsonAdapterSerializerDeserializerTest.java b/gson/src/test/java/com/google/gson/functional/JsonAdapterSerializerDeserializerTest.java
index 393aebe4a6..0d7f2c74ea 100644
--- a/gson/src/test/java/com/google/gson/functional/JsonAdapterSerializerDeserializerTest.java
+++ b/gson/src/test/java/com/google/gson/functional/JsonAdapterSerializerDeserializerTest.java
@@ -34,7 +34,7 @@
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.lang.reflect.Type;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Functional tests for the {@link JsonAdapter} annotation on fields where the value is of type
diff --git a/gson/src/test/java/com/google/gson/functional/JsonParserTest.java b/gson/src/test/java/com/google/gson/functional/JsonParserTest.java
index 57f6a887ed..d09fe5d284 100644
--- a/gson/src/test/java/com/google/gson/functional/JsonParserTest.java
+++ b/gson/src/test/java/com/google/gson/functional/JsonParserTest.java
@@ -17,7 +17,7 @@
package com.google.gson.functional;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
@@ -35,8 +35,8 @@
import java.util.Arrays;
import java.util.List;
import java.util.Map;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Functional tests for that use JsonParser and related Gson methods
@@ -47,7 +47,7 @@
public class JsonParserTest {
private Gson gson;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
gson = new Gson();
}
diff --git a/gson/src/test/java/com/google/gson/functional/JsonTreeTest.java b/gson/src/test/java/com/google/gson/functional/JsonTreeTest.java
index 82f8aae88c..7b3d59fae4 100644
--- a/gson/src/test/java/com/google/gson/functional/JsonTreeTest.java
+++ b/gson/src/test/java/com/google/gson/functional/JsonTreeTest.java
@@ -26,8 +26,8 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Functional tests for {@link Gson#toJsonTree(Object)} and {@link Gson#toJsonTree(Object,
@@ -39,7 +39,7 @@
public class JsonTreeTest {
private Gson gson;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
gson = new Gson();
}
diff --git a/gson/src/test/java/com/google/gson/functional/LeniencyTest.java b/gson/src/test/java/com/google/gson/functional/LeniencyTest.java
index 40197ae75e..1038d15293 100644
--- a/gson/src/test/java/com/google/gson/functional/LeniencyTest.java
+++ b/gson/src/test/java/com/google/gson/functional/LeniencyTest.java
@@ -22,8 +22,8 @@
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import java.util.List;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/** Functional tests for leniency option. */
public class LeniencyTest {
@@ -31,7 +31,7 @@ public class LeniencyTest {
private Gson gson;
@SuppressWarnings({"deprecation", "InlineMeInliner"}) // for GsonBuilder.setLenient
- @Before
+ @BeforeEach
public void setUp() throws Exception {
gson = new GsonBuilder().setLenient().create();
}
diff --git a/gson/src/test/java/com/google/gson/functional/MapAsArrayTypeAdapterTest.java b/gson/src/test/java/com/google/gson/functional/MapAsArrayTypeAdapterTest.java
index 20155bc6b9..385468f4e3 100644
--- a/gson/src/test/java/com/google/gson/functional/MapAsArrayTypeAdapterTest.java
+++ b/gson/src/test/java/com/google/gson/functional/MapAsArrayTypeAdapterTest.java
@@ -17,7 +17,7 @@
package com.google.gson.functional;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@@ -27,8 +27,8 @@
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
public class MapAsArrayTypeAdapterTest {
@@ -58,7 +58,7 @@ public void testSerializeComplexMapWithTypeAdapter() {
}
@Test
- @Ignore("we no longer hash keys at serialization time")
+ @Disabled("we no longer hash keys at serialization time")
public void testTwoTypesCollapseToOneSerialize() {
Gson gson = new GsonBuilder().enableComplexMapKeySerialization().create();
diff --git a/gson/src/test/java/com/google/gson/functional/MapTest.java b/gson/src/test/java/com/google/gson/functional/MapTest.java
index 9ab43d325c..919da72ab0 100644
--- a/gson/src/test/java/com/google/gson/functional/MapTest.java
+++ b/gson/src/test/java/com/google/gson/functional/MapTest.java
@@ -17,7 +17,7 @@
package com.google.gson.functional;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@@ -43,8 +43,8 @@
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ConcurrentNavigableMap;
import java.util.concurrent.ConcurrentSkipListMap;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Functional test for Json serialization and deserialization for Maps
@@ -55,7 +55,7 @@
public class MapTest {
private Gson gson;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
gson = new Gson();
}
diff --git a/gson/src/test/java/com/google/gson/functional/MoreSpecificTypeSerializationTest.java b/gson/src/test/java/com/google/gson/functional/MoreSpecificTypeSerializationTest.java
index 0702884143..4700336a00 100644
--- a/gson/src/test/java/com/google/gson/functional/MoreSpecificTypeSerializationTest.java
+++ b/gson/src/test/java/com/google/gson/functional/MoreSpecificTypeSerializationTest.java
@@ -25,8 +25,8 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Tests for Gson serialization of a sub-class object while encountering a base-class type
@@ -37,7 +37,7 @@
public class MoreSpecificTypeSerializationTest {
private Gson gson;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
gson = new Gson();
}
diff --git a/gson/src/test/java/com/google/gson/functional/NamingPolicyTest.java b/gson/src/test/java/com/google/gson/functional/NamingPolicyTest.java
index c419f6155d..994e571bac 100644
--- a/gson/src/test/java/com/google/gson/functional/NamingPolicyTest.java
+++ b/gson/src/test/java/com/google/gson/functional/NamingPolicyTest.java
@@ -16,7 +16,7 @@
package com.google.gson.functional;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.gson.FieldNamingPolicy;
import com.google.gson.FieldNamingStrategy;
@@ -27,8 +27,8 @@
import com.google.gson.common.TestTypes.StringWrapper;
import java.lang.reflect.Field;
import java.util.Locale;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Functional tests for naming policies.
@@ -39,7 +39,7 @@
public class NamingPolicyTest {
private GsonBuilder builder;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
builder = new GsonBuilder();
}
diff --git a/gson/src/test/java/com/google/gson/functional/NullObjectAndFieldTest.java b/gson/src/test/java/com/google/gson/functional/NullObjectAndFieldTest.java
index 7c90bf6515..355dd02bdd 100644
--- a/gson/src/test/java/com/google/gson/functional/NullObjectAndFieldTest.java
+++ b/gson/src/test/java/com/google/gson/functional/NullObjectAndFieldTest.java
@@ -30,8 +30,8 @@
import com.google.gson.common.TestTypes.ClassWithObjects;
import java.lang.reflect.Type;
import java.util.Collection;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Functional tests for the different cases for serializing (or ignoring) null fields and object.
@@ -42,7 +42,7 @@
public class NullObjectAndFieldTest {
private GsonBuilder gsonBuilder;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
gsonBuilder = new GsonBuilder().serializeNulls();
}
diff --git a/gson/src/test/java/com/google/gson/functional/NumberLimitsTest.java b/gson/src/test/java/com/google/gson/functional/NumberLimitsTest.java
index 9df4d9fc65..e264216db0 100644
--- a/gson/src/test/java/com/google/gson/functional/NumberLimitsTest.java
+++ b/gson/src/test/java/com/google/gson/functional/NumberLimitsTest.java
@@ -1,7 +1,7 @@
package com.google.gson.functional;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.gson.Gson;
import com.google.gson.JsonParseException;
@@ -20,7 +20,7 @@
import java.io.StringReader;
import java.math.BigDecimal;
import java.math.BigInteger;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class NumberLimitsTest {
private static final int MAX_LENGTH = 10_000;
diff --git a/gson/src/test/java/com/google/gson/functional/ObjectTest.java b/gson/src/test/java/com/google/gson/functional/ObjectTest.java
index 5812daf8f1..6f773ba722 100644
--- a/gson/src/test/java/com/google/gson/functional/ObjectTest.java
+++ b/gson/src/test/java/com/google/gson/functional/ObjectTest.java
@@ -17,7 +17,7 @@
package com.google.gson.functional;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.gson.ExclusionStrategy;
import com.google.gson.FieldAttributes;
@@ -52,9 +52,9 @@
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Functional tests for Json serialization and deserialization of regular classes.
@@ -67,7 +67,7 @@ public class ObjectTest {
private TimeZone oldTimeZone;
private Locale oldLocale;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
gson = new Gson();
@@ -77,7 +77,7 @@ public void setUp() throws Exception {
Locale.setDefault(Locale.US);
}
- @After
+ @AfterEach
public void tearDown() {
TimeZone.setDefault(oldTimeZone);
Locale.setDefault(oldLocale);
diff --git a/gson/src/test/java/com/google/gson/functional/ParameterizedTypesTest.java b/gson/src/test/java/com/google/gson/functional/ParameterizedTypesTest.java
index 81de888043..17b84f3a53 100644
--- a/gson/src/test/java/com/google/gson/functional/ParameterizedTypesTest.java
+++ b/gson/src/test/java/com/google/gson/functional/ParameterizedTypesTest.java
@@ -38,8 +38,8 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Functional tests for the serialization and deserialization of parameterized types in Gson.
@@ -50,7 +50,7 @@
public class ParameterizedTypesTest {
private Gson gson;
- @Before
+ @BeforeEach
public void setUp() {
gson = new Gson();
}
diff --git a/gson/src/test/java/com/google/gson/functional/PrettyPrintingTest.java b/gson/src/test/java/com/google/gson/functional/PrettyPrintingTest.java
index 1671d50194..de8cd884d9 100644
--- a/gson/src/test/java/com/google/gson/functional/PrettyPrintingTest.java
+++ b/gson/src/test/java/com/google/gson/functional/PrettyPrintingTest.java
@@ -28,8 +28,8 @@
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Functional tests for pretty printing option.
@@ -41,7 +41,7 @@ public class PrettyPrintingTest {
private Gson gson;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
gson = new GsonBuilder().setPrettyPrinting().create();
}
diff --git a/gson/src/test/java/com/google/gson/functional/PrimitiveCharacterTest.java b/gson/src/test/java/com/google/gson/functional/PrimitiveCharacterTest.java
index 6f6f894ffe..9aa8bc499e 100644
--- a/gson/src/test/java/com/google/gson/functional/PrimitiveCharacterTest.java
+++ b/gson/src/test/java/com/google/gson/functional/PrimitiveCharacterTest.java
@@ -19,8 +19,8 @@
import static com.google.common.truth.Truth.assertThat;
import com.google.gson.Gson;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Functional tests for Java Character values.
@@ -31,7 +31,7 @@
public class PrimitiveCharacterTest {
private Gson gson;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
gson = new Gson();
}
diff --git a/gson/src/test/java/com/google/gson/functional/PrimitiveTest.java b/gson/src/test/java/com/google/gson/functional/PrimitiveTest.java
index 81cd894c0f..9db529d846 100644
--- a/gson/src/test/java/com/google/gson/functional/PrimitiveTest.java
+++ b/gson/src/test/java/com/google/gson/functional/PrimitiveTest.java
@@ -17,7 +17,7 @@
package com.google.gson.functional;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@@ -32,8 +32,8 @@
import java.math.BigInteger;
import java.util.Arrays;
import java.util.List;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Functional tests for Json primitive values: integers, and floating point numbers.
@@ -44,7 +44,7 @@
public class PrimitiveTest {
private Gson gson;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
gson = new Gson();
}
diff --git a/gson/src/test/java/com/google/gson/functional/PrintFormattingTest.java b/gson/src/test/java/com/google/gson/functional/PrintFormattingTest.java
index bd53944fa3..946284a2ee 100644
--- a/gson/src/test/java/com/google/gson/functional/PrintFormattingTest.java
+++ b/gson/src/test/java/com/google/gson/functional/PrintFormattingTest.java
@@ -27,8 +27,8 @@
import com.google.gson.common.TestTypes.PrimitiveArray;
import java.util.ArrayList;
import java.util.List;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Functional tests for print formatting.
@@ -40,7 +40,7 @@ public class PrintFormattingTest {
private Gson gson;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
gson = new Gson();
}
diff --git a/gson/src/test/java/com/google/gson/functional/RawSerializationTest.java b/gson/src/test/java/com/google/gson/functional/RawSerializationTest.java
index 4c317fec52..3525a86334 100644
--- a/gson/src/test/java/com/google/gson/functional/RawSerializationTest.java
+++ b/gson/src/test/java/com/google/gson/functional/RawSerializationTest.java
@@ -21,8 +21,8 @@
import com.google.gson.reflect.TypeToken;
import java.util.Arrays;
import java.util.Collection;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Unit tests to validate serialization of parameterized types without explicit types
@@ -33,7 +33,7 @@ public class RawSerializationTest {
private Gson gson;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
gson = new Gson();
}
diff --git a/gson/src/test/java/com/google/gson/functional/ReadersWritersTest.java b/gson/src/test/java/com/google/gson/functional/ReadersWritersTest.java
index 324ee0c426..23c6dca8fa 100644
--- a/gson/src/test/java/com/google/gson/functional/ReadersWritersTest.java
+++ b/gson/src/test/java/com/google/gson/functional/ReadersWritersTest.java
@@ -16,7 +16,7 @@
package com.google.gson.functional;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.gson.Gson;
@@ -35,8 +35,8 @@
import java.lang.reflect.Type;
import java.util.Arrays;
import java.util.Map;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Functional tests for the support of {@link Reader}s and {@link Writer}s.
@@ -47,7 +47,7 @@
public class ReadersWritersTest {
private Gson gson;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
gson = new Gson();
}
diff --git a/gson/src/test/java/com/google/gson/functional/ReflectionAccessFilterTest.java b/gson/src/test/java/com/google/gson/functional/ReflectionAccessFilterTest.java
index 5b50fbe1a9..dcfe2f548a 100644
--- a/gson/src/test/java/com/google/gson/functional/ReflectionAccessFilterTest.java
+++ b/gson/src/test/java/com/google/gson/functional/ReflectionAccessFilterTest.java
@@ -17,7 +17,7 @@
package com.google.gson.functional;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@@ -43,7 +43,7 @@
import java.util.LinkedList;
import java.util.List;
import org.junit.AssumptionViolatedException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class ReflectionAccessFilterTest {
// Reader has protected `lock` field which cannot be accessed
@@ -68,9 +68,9 @@ public void testBlockInaccessibleJava() {
// Note: This test is rather brittle and depends on the JDK implementation
var e =
assertThrows(
- "Expected exception; test needs to be run with Java >= 9",
JsonIOException.class,
- () -> gson.toJson(new File("a")));
+ () -> gson.toJson(new File("a")),
+ "Expected exception; test needs to be run with Java >= 9");
assertThat(e)
.hasMessageThat()
.isEqualTo(
@@ -111,9 +111,9 @@ public void testBlockInaccessibleJavaExtendingJdkClass() {
var e =
assertThrows(
- "Expected exception; test needs to be run with Java >= 9",
JsonIOException.class,
- () -> gson.toJson(new ClassExtendingJdkClass()));
+ () -> gson.toJson(new ClassExtendingJdkClass()),
+ "Expected exception; test needs to be run with Java >= 9");
assertThat(e)
.hasMessageThat()
.isEqualTo(
@@ -174,9 +174,9 @@ public FilterResult check(Class> rawClass) {
var e =
assertThrows(
- "Expected exception; test needs to be run with Java >= 9",
JsonIOException.class,
- () -> gson.toJson(new ClassWithStaticField()));
+ () -> gson.toJson(new ClassWithStaticField()),
+ "Expected exception; test needs to be run with Java >= 9");
assertThat(e)
.hasMessageThat()
.isEqualTo(
@@ -265,9 +265,9 @@ public FilterResult check(Class> rawClass) {
// First make sure test is implemented correctly and access is blocked
var e =
assertThrows(
- "Expected exception; test needs to be run with Java >= 9",
JsonIOException.class,
- () -> gson.toJson(new ExtendingClassWithPrivateField()));
+ () -> gson.toJson(new ExtendingClassWithPrivateField()),
+ "Expected exception; test needs to be run with Java >= 9");
assertThat(e)
.hasMessageThat()
.isEqualTo(
@@ -315,9 +315,9 @@ public FilterResult check(Class> rawClass) {
var e =
assertThrows(
- "Expected exception; test needs to be run with Java >= 9",
JsonIOException.class,
- () -> gson.fromJson("{}", ClassWithPrivateNoArgsConstructor.class));
+ () -> gson.fromJson("{}", ClassWithPrivateNoArgsConstructor.class),
+ "Expected exception; test needs to be run with Java >= 9");
assertThat(e)
.hasMessageThat()
.isEqualTo(
diff --git a/gson/src/test/java/com/google/gson/functional/ReflectionAccessTest.java b/gson/src/test/java/com/google/gson/functional/ReflectionAccessTest.java
index ba0542590c..167b6a7afb 100644
--- a/gson/src/test/java/com/google/gson/functional/ReflectionAccessTest.java
+++ b/gson/src/test/java/com/google/gson/functional/ReflectionAccessTest.java
@@ -17,8 +17,8 @@
package com.google.gson.functional;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
-import static org.junit.Assume.assumeTrue;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assumptions.assumeTrue;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@@ -34,7 +34,7 @@
import java.security.Permission;
import java.util.Collections;
import java.util.concurrent.atomic.AtomicBoolean;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class ReflectionAccessTest {
@SuppressWarnings("unused")
diff --git a/gson/src/test/java/com/google/gson/functional/ReusedTypeVariablesFullyResolveTest.java b/gson/src/test/java/com/google/gson/functional/ReusedTypeVariablesFullyResolveTest.java
index e83c5771b5..380b549011 100644
--- a/gson/src/test/java/com/google/gson/functional/ReusedTypeVariablesFullyResolveTest.java
+++ b/gson/src/test/java/com/google/gson/functional/ReusedTypeVariablesFullyResolveTest.java
@@ -23,8 +23,8 @@
import java.util.Collection;
import java.util.Iterator;
import java.util.Set;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* This test covers the scenario described in #1390 where a type variable needs to be used by a type
@@ -35,7 +35,7 @@ public class ReusedTypeVariablesFullyResolveTest {
private Gson gson;
- @Before
+ @BeforeEach
public void setUp() {
gson = new GsonBuilder().create();
}
diff --git a/gson/src/test/java/com/google/gson/functional/RuntimeTypeAdapterFactoryFunctionalTest.java b/gson/src/test/java/com/google/gson/functional/RuntimeTypeAdapterFactoryFunctionalTest.java
index 1a9e6bc916..0d3a12738f 100644
--- a/gson/src/test/java/com/google/gson/functional/RuntimeTypeAdapterFactoryFunctionalTest.java
+++ b/gson/src/test/java/com/google/gson/functional/RuntimeTypeAdapterFactoryFunctionalTest.java
@@ -33,7 +33,7 @@
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/** Functional tests for the RuntimeTypeAdapterFactory feature in extras. */
public final class RuntimeTypeAdapterFactoryFunctionalTest {
diff --git a/gson/src/test/java/com/google/gson/functional/SecurityTest.java b/gson/src/test/java/com/google/gson/functional/SecurityTest.java
index a0a76188c5..e8955df23a 100644
--- a/gson/src/test/java/com/google/gson/functional/SecurityTest.java
+++ b/gson/src/test/java/com/google/gson/functional/SecurityTest.java
@@ -21,8 +21,8 @@
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.common.TestTypes.BagOfPrimitives;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Tests for security-related aspects of Gson
@@ -35,7 +35,7 @@ public class SecurityTest {
private GsonBuilder gsonBuilder;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
gsonBuilder = new GsonBuilder();
}
diff --git a/gson/src/test/java/com/google/gson/functional/SerializedNameTest.java b/gson/src/test/java/com/google/gson/functional/SerializedNameTest.java
index 487abded87..2e565c739c 100644
--- a/gson/src/test/java/com/google/gson/functional/SerializedNameTest.java
+++ b/gson/src/test/java/com/google/gson/functional/SerializedNameTest.java
@@ -19,7 +19,7 @@
import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public final class SerializedNameTest {
private final Gson gson = new Gson();
diff --git a/gson/src/test/java/com/google/gson/functional/StreamingTypeAdaptersTest.java b/gson/src/test/java/com/google/gson/functional/StreamingTypeAdaptersTest.java
index c6245cb27a..2b9c6d0e98 100644
--- a/gson/src/test/java/com/google/gson/functional/StreamingTypeAdaptersTest.java
+++ b/gson/src/test/java/com/google/gson/functional/StreamingTypeAdaptersTest.java
@@ -17,7 +17,7 @@
package com.google.gson.functional;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.common.base.Splitter;
import com.google.gson.Gson;
@@ -37,7 +37,7 @@
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public final class StreamingTypeAdaptersTest {
private Gson miniGson = new GsonBuilder().create();
diff --git a/gson/src/test/java/com/google/gson/functional/StringTest.java b/gson/src/test/java/com/google/gson/functional/StringTest.java
index 075d8dfe01..62a1e424e0 100644
--- a/gson/src/test/java/com/google/gson/functional/StringTest.java
+++ b/gson/src/test/java/com/google/gson/functional/StringTest.java
@@ -19,8 +19,8 @@
import static com.google.common.truth.Truth.assertThat;
import com.google.gson.Gson;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Functional tests for Json serialization and deserialization of strings.
@@ -31,7 +31,7 @@
public class StringTest {
private Gson gson;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
gson = new Gson();
}
diff --git a/gson/src/test/java/com/google/gson/functional/ToNumberPolicyFunctionalTest.java b/gson/src/test/java/com/google/gson/functional/ToNumberPolicyFunctionalTest.java
index 3ee85e2fc3..bb971252b6 100644
--- a/gson/src/test/java/com/google/gson/functional/ToNumberPolicyFunctionalTest.java
+++ b/gson/src/test/java/com/google/gson/functional/ToNumberPolicyFunctionalTest.java
@@ -17,7 +17,7 @@
package com.google.gson.functional;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@@ -30,7 +30,7 @@
import java.math.BigDecimal;
import java.util.Collection;
import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class ToNumberPolicyFunctionalTest {
@Test
diff --git a/gson/src/test/java/com/google/gson/functional/TreeTypeAdaptersTest.java b/gson/src/test/java/com/google/gson/functional/TreeTypeAdaptersTest.java
index 6e9debbb0c..0d26872cda 100644
--- a/gson/src/test/java/com/google/gson/functional/TreeTypeAdaptersTest.java
+++ b/gson/src/test/java/com/google/gson/functional/TreeTypeAdaptersTest.java
@@ -33,8 +33,8 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/** Collection of functional tests for DOM tree based type adapters. */
public class TreeTypeAdaptersTest {
@@ -49,7 +49,7 @@ public class TreeTypeAdaptersTest {
private Gson gson;
private Course course;
- @Before
+ @BeforeEach
public void setUp() {
gson = new GsonBuilder().registerTypeAdapter(Id.class, new IdTreeTypeAdapter()).create();
course =
diff --git a/gson/src/test/java/com/google/gson/functional/TypeAdapterPrecedenceTest.java b/gson/src/test/java/com/google/gson/functional/TypeAdapterPrecedenceTest.java
index 4a26dda596..29d9849c2d 100644
--- a/gson/src/test/java/com/google/gson/functional/TypeAdapterPrecedenceTest.java
+++ b/gson/src/test/java/com/google/gson/functional/TypeAdapterPrecedenceTest.java
@@ -31,7 +31,7 @@
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.lang.reflect.Type;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public final class TypeAdapterPrecedenceTest {
@Test
diff --git a/gson/src/test/java/com/google/gson/functional/TypeAdapterRuntimeTypeWrapperTest.java b/gson/src/test/java/com/google/gson/functional/TypeAdapterRuntimeTypeWrapperTest.java
index b81907a335..47619f4295 100644
--- a/gson/src/test/java/com/google/gson/functional/TypeAdapterRuntimeTypeWrapperTest.java
+++ b/gson/src/test/java/com/google/gson/functional/TypeAdapterRuntimeTypeWrapperTest.java
@@ -30,7 +30,7 @@
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.lang.reflect.Type;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class TypeAdapterRuntimeTypeWrapperTest {
private static class Base {}
diff --git a/gson/src/test/java/com/google/gson/functional/TypeHierarchyAdapterTest.java b/gson/src/test/java/com/google/gson/functional/TypeHierarchyAdapterTest.java
index ccfa290d6e..98f307b008 100644
--- a/gson/src/test/java/com/google/gson/functional/TypeHierarchyAdapterTest.java
+++ b/gson/src/test/java/com/google/gson/functional/TypeHierarchyAdapterTest.java
@@ -29,7 +29,7 @@
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import java.lang.reflect.Type;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/** Test that the hierarchy adapter works when subtypes are used. */
public final class TypeHierarchyAdapterTest {
diff --git a/gson/src/test/java/com/google/gson/functional/TypeVariableTest.java b/gson/src/test/java/com/google/gson/functional/TypeVariableTest.java
index af1957e159..55e25d6778 100644
--- a/gson/src/test/java/com/google/gson/functional/TypeVariableTest.java
+++ b/gson/src/test/java/com/google/gson/functional/TypeVariableTest.java
@@ -25,7 +25,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Functional test for Gson serialization and deserialization of classes with type variables.
diff --git a/gson/src/test/java/com/google/gson/functional/UncategorizedTest.java b/gson/src/test/java/com/google/gson/functional/UncategorizedTest.java
index 9be2b36fd3..87ea77cf73 100644
--- a/gson/src/test/java/com/google/gson/functional/UncategorizedTest.java
+++ b/gson/src/test/java/com/google/gson/functional/UncategorizedTest.java
@@ -16,7 +16,7 @@
package com.google.gson.functional;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@@ -29,8 +29,8 @@
import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type;
import java.util.List;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Functional tests that do not fall neatly into any of the existing classification.
@@ -42,7 +42,7 @@ public class UncategorizedTest {
private Gson gson = null;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
gson = new Gson();
}
diff --git a/gson/src/test/java/com/google/gson/functional/VersioningTest.java b/gson/src/test/java/com/google/gson/functional/VersioningTest.java
index 075b9b4674..506a7d0cf0 100644
--- a/gson/src/test/java/com/google/gson/functional/VersioningTest.java
+++ b/gson/src/test/java/com/google/gson/functional/VersioningTest.java
@@ -22,7 +22,7 @@
import com.google.gson.annotations.Since;
import com.google.gson.annotations.Until;
import com.google.gson.common.TestTypes.BagOfPrimitives;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Functional tests for versioning support in Gson.
diff --git a/gson/src/test/java/com/google/gson/integration/OSGiManifestIT.java b/gson/src/test/java/com/google/gson/integration/OSGiManifestIT.java
index 9f6c5334aa..222b496b6d 100644
--- a/gson/src/test/java/com/google/gson/integration/OSGiManifestIT.java
+++ b/gson/src/test/java/com/google/gson/integration/OSGiManifestIT.java
@@ -17,7 +17,7 @@
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.fail;
import com.google.common.base.Splitter;
import com.google.gson.internal.GsonBuildConfig;
@@ -30,8 +30,8 @@
import java.util.jar.Attributes;
import java.util.jar.Manifest;
import java.util.stream.Collectors;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Performs assertions on the generated OSGi manifest attributes. This is an integration test
@@ -60,7 +60,7 @@ public ManifestData(URL url, Manifest manifest) {
private static final String GSON_VERSION = GsonBuildConfig.VERSION;
private Attributes manifestAttributes;
- @Before
+ @BeforeEach
public void getGsonManifestAttributes() throws Exception {
ManifestData manifestData = findManifest("com.google.gson");
// Make sure manifest was loaded from final Gson JAR (and not intermediate manifest is used)
diff --git a/gson/src/test/java/com/google/gson/internal/ConstructorConstructorTest.java b/gson/src/test/java/com/google/gson/internal/ConstructorConstructorTest.java
index 13a1fe2989..725ccffa53 100644
--- a/gson/src/test/java/com/google/gson/internal/ConstructorConstructorTest.java
+++ b/gson/src/test/java/com/google/gson/internal/ConstructorConstructorTest.java
@@ -17,11 +17,11 @@
package com.google.gson.internal;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.gson.reflect.TypeToken;
import java.util.Collections;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class ConstructorConstructorTest {
private ConstructorConstructor constructorConstructor =
diff --git a/gson/src/test/java/com/google/gson/internal/GsonBuildConfigTest.java b/gson/src/test/java/com/google/gson/internal/GsonBuildConfigTest.java
index a1af3a0861..70c125ce12 100644
--- a/gson/src/test/java/com/google/gson/internal/GsonBuildConfigTest.java
+++ b/gson/src/test/java/com/google/gson/internal/GsonBuildConfigTest.java
@@ -17,7 +17,7 @@
import static com.google.common.truth.Truth.assertThat;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Unit tests for {@code GsonBuildConfig}
diff --git a/gson/src/test/java/com/google/gson/internal/GsonTypesTest.java b/gson/src/test/java/com/google/gson/internal/GsonTypesTest.java
index facfd62731..d01ccc3eaa 100644
--- a/gson/src/test/java/com/google/gson/internal/GsonTypesTest.java
+++ b/gson/src/test/java/com/google/gson/internal/GsonTypesTest.java
@@ -17,7 +17,7 @@
package com.google.gson.internal;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
@@ -25,7 +25,7 @@
import java.lang.reflect.Type;
import java.util.List;
import java.util.Properties;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
@SuppressWarnings("ClassNamedLikeTypeParameter") // for dummy classes A, B, ...
public final class GsonTypesTest {
diff --git a/gson/src/test/java/com/google/gson/internal/JavaVersionTest.java b/gson/src/test/java/com/google/gson/internal/JavaVersionTest.java
index a07155a4f3..5c7552e63a 100644
--- a/gson/src/test/java/com/google/gson/internal/JavaVersionTest.java
+++ b/gson/src/test/java/com/google/gson/internal/JavaVersionTest.java
@@ -17,7 +17,7 @@
import static com.google.common.truth.Truth.assertThat;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Unit and functional tests for {@link JavaVersion}
diff --git a/gson/src/test/java/com/google/gson/internal/LazilyParsedNumberTest.java b/gson/src/test/java/com/google/gson/internal/LazilyParsedNumberTest.java
index 5dce379047..9d407ceb3d 100644
--- a/gson/src/test/java/com/google/gson/internal/LazilyParsedNumberTest.java
+++ b/gson/src/test/java/com/google/gson/internal/LazilyParsedNumberTest.java
@@ -23,7 +23,7 @@
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.math.BigDecimal;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class LazilyParsedNumberTest {
@Test
diff --git a/gson/src/test/java/com/google/gson/internal/LinkedTreeMapTest.java b/gson/src/test/java/com/google/gson/internal/LinkedTreeMapTest.java
index 2da7aae8cd..3513ac81b3 100644
--- a/gson/src/test/java/com/google/gson/internal/LinkedTreeMapTest.java
+++ b/gson/src/test/java/com/google/gson/internal/LinkedTreeMapTest.java
@@ -17,7 +17,7 @@
package com.google.gson.internal;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.gson.common.MoreAsserts;
import java.io.ByteArrayInputStream;
@@ -30,7 +30,7 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.Random;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public final class LinkedTreeMapTest {
diff --git a/gson/src/test/java/com/google/gson/internal/StreamsTest.java b/gson/src/test/java/com/google/gson/internal/StreamsTest.java
index 049a7ee0a1..ff544cc740 100644
--- a/gson/src/test/java/com/google/gson/internal/StreamsTest.java
+++ b/gson/src/test/java/com/google/gson/internal/StreamsTest.java
@@ -17,11 +17,11 @@
package com.google.gson.internal;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import java.io.IOException;
import java.io.Writer;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class StreamsTest {
@Test
diff --git a/gson/src/test/java/com/google/gson/internal/UnsafeAllocatorInstantiationTest.java b/gson/src/test/java/com/google/gson/internal/UnsafeAllocatorInstantiationTest.java
index 2a1c61f72c..ddc740a5ce 100644
--- a/gson/src/test/java/com/google/gson/internal/UnsafeAllocatorInstantiationTest.java
+++ b/gson/src/test/java/com/google/gson/internal/UnsafeAllocatorInstantiationTest.java
@@ -16,9 +16,9 @@
package com.google.gson.internal;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Test unsafe allocator instantiation
diff --git a/gson/src/test/java/com/google/gson/internal/bind/DefaultDateTypeAdapterTest.java b/gson/src/test/java/com/google/gson/internal/bind/DefaultDateTypeAdapterTest.java
index 81e1c28a8b..786fe8202d 100644
--- a/gson/src/test/java/com/google/gson/internal/bind/DefaultDateTypeAdapterTest.java
+++ b/gson/src/test/java/com/google/gson/internal/bind/DefaultDateTypeAdapterTest.java
@@ -18,7 +18,7 @@
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@@ -32,7 +32,7 @@
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* A simple unit test for the {@link DefaultDateTypeAdapter} class.
diff --git a/gson/src/test/java/com/google/gson/internal/bind/Java17ReflectiveTypeAdapterFactoryTest.java b/gson/src/test/java/com/google/gson/internal/bind/Java17ReflectiveTypeAdapterFactoryTest.java
index 931b1252b0..1c927fdd5a 100644
--- a/gson/src/test/java/com/google/gson/internal/bind/Java17ReflectiveTypeAdapterFactoryTest.java
+++ b/gson/src/test/java/com/google/gson/internal/bind/Java17ReflectiveTypeAdapterFactoryTest.java
@@ -28,8 +28,8 @@
import java.nio.file.attribute.GroupPrincipal;
import java.nio.file.attribute.UserPrincipal;
import java.security.Principal;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
public class Java17ReflectiveTypeAdapterFactoryTest {
@@ -39,7 +39,7 @@ public class Java17ReflectiveTypeAdapterFactoryTest {
// have record support at the language level for these tests. This class was added in JDK 16.
Class> unixDomainPrincipalClass;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
unixDomainPrincipalClass = Class.forName("jdk.net.UnixDomainPrincipal");
}
diff --git a/gson/src/test/java/com/google/gson/internal/bind/JsonElementReaderTest.java b/gson/src/test/java/com/google/gson/internal/bind/JsonElementReaderTest.java
index 2c6b353c52..3d20d8a061 100644
--- a/gson/src/test/java/com/google/gson/internal/bind/JsonElementReaderTest.java
+++ b/gson/src/test/java/com/google/gson/internal/bind/JsonElementReaderTest.java
@@ -17,7 +17,7 @@
package com.google.gson.internal.bind;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
@@ -26,7 +26,7 @@
import com.google.gson.stream.JsonToken;
import com.google.gson.stream.MalformedJsonException;
import java.io.IOException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
@SuppressWarnings("resource")
public final class JsonElementReaderTest {
diff --git a/gson/src/test/java/com/google/gson/internal/bind/JsonTreeReaderTest.java b/gson/src/test/java/com/google/gson/internal/bind/JsonTreeReaderTest.java
index 42d4649683..3934f1b23b 100644
--- a/gson/src/test/java/com/google/gson/internal/bind/JsonTreeReaderTest.java
+++ b/gson/src/test/java/com/google/gson/internal/bind/JsonTreeReaderTest.java
@@ -16,7 +16,7 @@
package com.google.gson.internal.bind;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
@@ -30,7 +30,7 @@
import java.io.Reader;
import java.util.Arrays;
import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
@SuppressWarnings("resource")
public class JsonTreeReaderTest {
diff --git a/gson/src/test/java/com/google/gson/internal/bind/JsonTreeWriterTest.java b/gson/src/test/java/com/google/gson/internal/bind/JsonTreeWriterTest.java
index 97dc2e56c0..346ec56b16 100644
--- a/gson/src/test/java/com/google/gson/internal/bind/JsonTreeWriterTest.java
+++ b/gson/src/test/java/com/google/gson/internal/bind/JsonTreeWriterTest.java
@@ -17,7 +17,7 @@
package com.google.gson.internal.bind;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.gson.JsonElement;
import com.google.gson.JsonNull;
@@ -28,7 +28,7 @@
import java.io.Writer;
import java.util.Arrays;
import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
@SuppressWarnings("resource")
public final class JsonTreeWriterTest {
diff --git a/gson/src/test/java/com/google/gson/internal/bind/RecursiveTypesResolveTest.java b/gson/src/test/java/com/google/gson/internal/bind/RecursiveTypesResolveTest.java
index 78d253dfb0..fe16eadefc 100644
--- a/gson/src/test/java/com/google/gson/internal/bind/RecursiveTypesResolveTest.java
+++ b/gson/src/test/java/com/google/gson/internal/bind/RecursiveTypesResolveTest.java
@@ -21,7 +21,7 @@
import com.google.gson.Gson;
import com.google.gson.TypeAdapter;
import com.google.gson.internal.$Gson$Types;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Test fixes for infinite recursion on {@link $Gson$Types#resolve(java.lang.reflect.Type, Class,
diff --git a/gson/src/test/java/com/google/gson/internal/bind/util/ISO8601UtilsTest.java b/gson/src/test/java/com/google/gson/internal/bind/util/ISO8601UtilsTest.java
index 1c2d254dec..b197971f01 100644
--- a/gson/src/test/java/com/google/gson/internal/bind/util/ISO8601UtilsTest.java
+++ b/gson/src/test/java/com/google/gson/internal/bind/util/ISO8601UtilsTest.java
@@ -17,7 +17,7 @@
package com.google.gson.internal.bind.util;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import java.text.ParseException;
import java.text.ParsePosition;
@@ -26,7 +26,7 @@
import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.TimeZone;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
@SuppressWarnings("MemberName") // class name
public class ISO8601UtilsTest {
diff --git a/gson/src/test/java/com/google/gson/internal/reflect/Java17ReflectionHelperTest.java b/gson/src/test/java/com/google/gson/internal/reflect/Java17ReflectionHelperTest.java
index a208289e96..65faca0d00 100644
--- a/gson/src/test/java/com/google/gson/internal/reflect/Java17ReflectionHelperTest.java
+++ b/gson/src/test/java/com/google/gson/internal/reflect/Java17ReflectionHelperTest.java
@@ -24,7 +24,7 @@
import java.nio.file.attribute.GroupPrincipal;
import java.nio.file.attribute.UserPrincipal;
import java.util.Objects;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class Java17ReflectionHelperTest {
@Test
diff --git a/gson/src/test/java/com/google/gson/internal/sql/SqlTypesGsonTest.java b/gson/src/test/java/com/google/gson/internal/sql/SqlTypesGsonTest.java
index 883b530a03..64f2831bee 100644
--- a/gson/src/test/java/com/google/gson/internal/sql/SqlTypesGsonTest.java
+++ b/gson/src/test/java/com/google/gson/internal/sql/SqlTypesGsonTest.java
@@ -25,9 +25,9 @@
import java.sql.Timestamp;
import java.util.Locale;
import java.util.TimeZone;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
// Suppression for `java.sql.Date` to make it explicit that this is not `java.util.Date`
@SuppressWarnings("UnnecessarilyFullyQualified")
@@ -36,7 +36,7 @@ public class SqlTypesGsonTest {
private TimeZone oldTimeZone;
private Locale oldLocale;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
this.oldTimeZone = TimeZone.getDefault();
TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles"));
@@ -45,7 +45,7 @@ public void setUp() throws Exception {
gson = new Gson();
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
TimeZone.setDefault(oldTimeZone);
Locale.setDefault(oldLocale);
diff --git a/gson/src/test/java/com/google/gson/internal/sql/SqlTypesSupportTest.java b/gson/src/test/java/com/google/gson/internal/sql/SqlTypesSupportTest.java
index 23778079c7..9c457eeb36 100644
--- a/gson/src/test/java/com/google/gson/internal/sql/SqlTypesSupportTest.java
+++ b/gson/src/test/java/com/google/gson/internal/sql/SqlTypesSupportTest.java
@@ -18,7 +18,7 @@
import static com.google.common.truth.Truth.assertThat;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class SqlTypesSupportTest {
@Test
diff --git a/gson/src/test/java/com/google/gson/metrics/PerformanceTest.java b/gson/src/test/java/com/google/gson/metrics/PerformanceTest.java
index 2e2add3050..a136d73fc7 100644
--- a/gson/src/test/java/com/google/gson/metrics/PerformanceTest.java
+++ b/gson/src/test/java/com/google/gson/metrics/PerformanceTest.java
@@ -28,9 +28,9 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
/**
* Tests to measure performance for Gson. All tests in this file will be disabled in code. To run
@@ -47,7 +47,7 @@ public class PerformanceTest {
private Gson gson;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
gson = new Gson();
}
@@ -58,7 +58,7 @@ public void testDummy() {
}
@Test
- @Ignore
+ @Disabled
public void testStringDeserialization() {
StringBuilder sb = new StringBuilder(8096);
sb.append("Error Yippie");
@@ -116,7 +116,7 @@ private CollectionEntry() {
/** Created in response to http://code.google.com/p/google-gson/issues/detail?id=96 */
@Test
- @Ignore
+ @Disabled
public void testLargeCollectionSerialization() {
int count = 1400000;
List list = new ArrayList<>(count);
@@ -128,7 +128,7 @@ public void testLargeCollectionSerialization() {
/** Created in response to http://code.google.com/p/google-gson/issues/detail?id=96 */
@Test
- @Ignore
+ @Disabled
public void testLargeCollectionDeserialization() {
StringBuilder sb = new StringBuilder();
int count = 87000;
@@ -152,7 +152,7 @@ public void testLargeCollectionDeserialization() {
/** Created in response to http://code.google.com/p/google-gson/issues/detail?id=96 */
// Last I tested, Gson was able to serialize upto 14MB byte array
@Test
- @Ignore
+ @Disabled
public void testByteArraySerialization() {
for (int size = 4145152; true; size += 1036288) {
byte[] ba = new byte[size];
@@ -167,7 +167,7 @@ public void testByteArraySerialization() {
/** Created in response to http://code.google.com/p/google-gson/issues/detail?id=96 */
// Last I tested, Gson was able to deserialize a byte array of 11MB
@Test
- @Ignore
+ @Disabled
public void testByteArrayDeserialization() {
for (int numElements = 10639296; true; numElements += 16384) {
StringBuilder sb = new StringBuilder(numElements * 2);
@@ -198,7 +198,7 @@ public void testByteArrayDeserialization() {
// Deserialized exposed classes avg time: 173 ms
@Test
- @Ignore
+ @Disabled
public void testSerializeClasses() {
ClassWithList c = new ClassWithList("str");
for (int i = 0; i < COLLECTION_SIZE; ++i) {
@@ -215,7 +215,7 @@ public void testSerializeClasses() {
}
@Test
- @Ignore
+ @Disabled
public void testDeserializeClasses() {
String json = buildJsonForClassWithList();
ClassWithList[] target = new ClassWithList[NUM_ITERATIONS];
@@ -229,7 +229,7 @@ public void testDeserializeClasses() {
}
@Test
- @Ignore
+ @Disabled
public void testLargeObjectSerializationAndDeserialization() {
Map largeObject = new HashMap<>();
for (long l = 0; l < 100000; l++) {
@@ -248,7 +248,7 @@ public void testLargeObjectSerializationAndDeserialization() {
}
@Test
- @Ignore
+ @Disabled
public void testSerializeExposedClasses() {
ClassWithListOfObjects c1 = new ClassWithListOfObjects("str");
for (int i1 = 0; i1 < COLLECTION_SIZE; ++i1) {
@@ -266,7 +266,7 @@ public void testSerializeExposedClasses() {
}
@Test
- @Ignore
+ @Disabled
public void testDeserializeExposedClasses() {
String json = buildJsonForClassWithList();
ClassWithListOfObjects[] target = new ClassWithListOfObjects[NUM_ITERATIONS];
@@ -280,7 +280,7 @@ public void testDeserializeExposedClasses() {
}
@Test
- @Ignore
+ @Disabled
public void testLargeGsonMapRoundTrip() throws Exception {
Map original = new HashMap<>();
for (long i = 0; i < 1000000; i++) {
diff --git a/gson/src/test/java/com/google/gson/reflect/TypeTokenTest.java b/gson/src/test/java/com/google/gson/reflect/TypeTokenTest.java
index ddc6b92973..a506a85d6f 100644
--- a/gson/src/test/java/com/google/gson/reflect/TypeTokenTest.java
+++ b/gson/src/test/java/com/google/gson/reflect/TypeTokenTest.java
@@ -17,7 +17,7 @@
package com.google.gson.reflect;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import java.lang.reflect.GenericArrayType;
import java.lang.reflect.Method;
@@ -30,7 +30,7 @@
import java.util.Map;
import java.util.RandomAccess;
import java.util.Set;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Tests for {@link TypeToken}.
diff --git a/gson/src/test/java/com/google/gson/stream/JsonReaderPathTest.java b/gson/src/test/java/com/google/gson/stream/JsonReaderPathTest.java
index de902f553b..ad1a87f6d8 100644
--- a/gson/src/test/java/com/google/gson/stream/JsonReaderPathTest.java
+++ b/gson/src/test/java/com/google/gson/stream/JsonReaderPathTest.java
@@ -17,7 +17,7 @@
package com.google.gson.stream;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assume.assumeTrue;
+import static org.junit.jupiter.api.Assumptions.assumeTrue;
import com.google.gson.JsonElement;
import com.google.gson.Strictness;
@@ -27,7 +27,7 @@
import java.io.StringReader;
import java.util.Arrays;
import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
diff --git a/gson/src/test/java/com/google/gson/stream/JsonReaderTest.java b/gson/src/test/java/com/google/gson/stream/JsonReaderTest.java
index f8a33be0df..dc49db993a 100644
--- a/gson/src/test/java/com/google/gson/stream/JsonReaderTest.java
+++ b/gson/src/test/java/com/google/gson/stream/JsonReaderTest.java
@@ -26,7 +26,7 @@
import static com.google.gson.stream.JsonToken.NULL;
import static com.google.gson.stream.JsonToken.NUMBER;
import static com.google.gson.stream.JsonToken.STRING;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.gson.Strictness;
import java.io.EOFException;
@@ -34,8 +34,8 @@
import java.io.Reader;
import java.io.StringReader;
import java.util.Arrays;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
@SuppressWarnings("resource")
public final class JsonReaderTest {
@@ -839,9 +839,9 @@ private static void assertNotANumber(String s) throws IOException {
JsonReader strictReader = new JsonReader(reader(s));
var e =
assertThrows(
- "Should have failed reading " + s + " as double",
MalformedJsonException.class,
- () -> strictReader.nextDouble());
+ () -> strictReader.nextDouble(),
+ "Should have failed reading " + s + " as double");
assertThat(e)
.hasMessageThat()
.startsWith("Use JsonReader.setStrictness(Strictness.LENIENT) to accept malformed JSON");
@@ -909,7 +909,7 @@ public void testNegativeZero() throws Exception {
* Double.parseDouble() for fractional values.
*/
@Test
- @Ignore
+ @Disabled
public void testPeekLargerThanLongMaxValue() throws IOException {
JsonReader reader = new JsonReader(reader("[9223372036854775808]"));
reader.setStrictness(Strictness.LENIENT);
@@ -923,7 +923,7 @@ public void testPeekLargerThanLongMaxValue() throws IOException {
* Double.parseDouble() for fractional values.
*/
@Test
- @Ignore
+ @Disabled
public void testPeekLargerThanLongMinValue() throws IOException {
@SuppressWarnings("FloatingPointLiteralPrecision")
double d = -9223372036854775809d;
@@ -940,7 +940,7 @@ public void testPeekLargerThanLongMinValue() throws IOException {
* Double.parseDouble() for fractional values.
*/
@Test
- @Ignore
+ @Disabled
public void testHighPrecisionLong() throws IOException {
String json = "[9223372036854775806.000]";
JsonReader reader = new JsonReader(reader(json));
diff --git a/gson/src/test/java/com/google/gson/stream/JsonWriterTest.java b/gson/src/test/java/com/google/gson/stream/JsonWriterTest.java
index fd171e880f..fa338884eb 100644
--- a/gson/src/test/java/com/google/gson/stream/JsonWriterTest.java
+++ b/gson/src/test/java/com/google/gson/stream/JsonWriterTest.java
@@ -17,7 +17,7 @@
package com.google.gson.stream;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.gson.FormattingStyle;
import com.google.gson.Strictness;
@@ -26,7 +26,7 @@
import java.io.StringWriter;
import java.math.BigDecimal;
import java.math.BigInteger;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
@SuppressWarnings("resource")
public final class JsonWriterTest {
diff --git a/pom.xml b/pom.xml
index 05e88c04bb..0b6ff59c99 100644
--- a/pom.xml
+++ b/pom.xml
@@ -92,9 +92,9 @@
- junit
- junit
- 4.13.2
+ org.junit.jupiter
+ junit-jupiter-api
+ 5.11.3
@@ -102,6 +102,12 @@
truth
1.4.4
+
+ org.junit.vintage
+ junit-vintage-engine
+ 5.11.3
+ test
+
diff --git a/proto/pom.xml b/proto/pom.xml
index 120016d0a3..6cf09c34b1 100644
--- a/proto/pom.xml
+++ b/proto/pom.xml
@@ -64,8 +64,8 @@
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
test
@@ -73,6 +73,12 @@
truth
test
+
+ org.junit.vintage
+ junit-vintage-engine
+ 5.11.3
+ test
+
diff --git a/proto/src/test/java/com/google/gson/protobuf/functional/ProtosWithAnnotationsAndJsonNamesTest.java b/proto/src/test/java/com/google/gson/protobuf/functional/ProtosWithAnnotationsAndJsonNamesTest.java
index 7eeae44f41..b37b9bf118 100644
--- a/proto/src/test/java/com/google/gson/protobuf/functional/ProtosWithAnnotationsAndJsonNamesTest.java
+++ b/proto/src/test/java/com/google/gson/protobuf/functional/ProtosWithAnnotationsAndJsonNamesTest.java
@@ -24,7 +24,7 @@
import com.google.gson.protobuf.generated.Bag.ProtoWithAnnotationsAndJsonNames;
import com.google.protobuf.GeneratedMessage;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Functional tests for protocol buffers using annotations and custom json_name values for field
diff --git a/proto/src/test/java/com/google/gson/protobuf/functional/ProtosWithAnnotationsTest.java b/proto/src/test/java/com/google/gson/protobuf/functional/ProtosWithAnnotationsTest.java
index f66f54d6d5..7f373087fd 100644
--- a/proto/src/test/java/com/google/gson/protobuf/functional/ProtosWithAnnotationsTest.java
+++ b/proto/src/test/java/com/google/gson/protobuf/functional/ProtosWithAnnotationsTest.java
@@ -16,7 +16,7 @@
package com.google.gson.protobuf.functional;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.common.base.CaseFormat;
import com.google.gson.Gson;
@@ -29,8 +29,8 @@
import com.google.gson.protobuf.generated.Bag.ProtoWithAnnotations;
import com.google.gson.protobuf.generated.Bag.ProtoWithAnnotations.InnerMessage;
import com.google.protobuf.GeneratedMessage;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Functional tests for protocol buffers using annotations for field names and enum values.
@@ -42,7 +42,7 @@ public class ProtosWithAnnotationsTest {
private Gson gsonWithEnumNumbers;
private Gson gsonWithLowerHyphen;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
ProtoTypeAdapter.Builder protoTypeAdapter =
ProtoTypeAdapter.newBuilder()
diff --git a/proto/src/test/java/com/google/gson/protobuf/functional/ProtosWithComplexAndRepeatedFieldsTest.java b/proto/src/test/java/com/google/gson/protobuf/functional/ProtosWithComplexAndRepeatedFieldsTest.java
index d85577e5e0..79a358ba19 100644
--- a/proto/src/test/java/com/google/gson/protobuf/functional/ProtosWithComplexAndRepeatedFieldsTest.java
+++ b/proto/src/test/java/com/google/gson/protobuf/functional/ProtosWithComplexAndRepeatedFieldsTest.java
@@ -27,8 +27,8 @@
import com.google.gson.protobuf.generated.Bag.ProtoWithRepeatedFields;
import com.google.gson.protobuf.generated.Bag.SimpleProto;
import com.google.protobuf.GeneratedMessage;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Functional tests for protocol buffers using complex and repeated fields
@@ -39,7 +39,7 @@ public class ProtosWithComplexAndRepeatedFieldsTest {
private Gson gson;
private Gson upperCamelGson;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
gson =
new GsonBuilder()
diff --git a/proto/src/test/java/com/google/gson/protobuf/functional/ProtosWithPrimitiveTypesTest.java b/proto/src/test/java/com/google/gson/protobuf/functional/ProtosWithPrimitiveTypesTest.java
index 2ca0867017..35f2751d88 100644
--- a/proto/src/test/java/com/google/gson/protobuf/functional/ProtosWithPrimitiveTypesTest.java
+++ b/proto/src/test/java/com/google/gson/protobuf/functional/ProtosWithPrimitiveTypesTest.java
@@ -23,13 +23,13 @@
import com.google.gson.protobuf.ProtoTypeAdapter.EnumSerialization;
import com.google.gson.protobuf.generated.Bag.SimpleProto;
import com.google.protobuf.GeneratedMessage;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
public class ProtosWithPrimitiveTypesTest {
private Gson gson;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
gson =
new GsonBuilder()
diff --git a/test-jpms/pom.xml b/test-jpms/pom.xml
index 06239433c7..4f98687b2f 100644
--- a/test-jpms/pom.xml
+++ b/test-jpms/pom.xml
@@ -40,8 +40,8 @@
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
test
@@ -49,5 +49,11 @@
truth
test
+
+ org.junit.vintage
+ junit-vintage-engine
+ 5.11.3
+ test
+
diff --git a/test-jpms/src/test/java/com/google/gson/jpms_test/ExportedPackagesTest.java b/test-jpms/src/test/java/com/google/gson/jpms_test/ExportedPackagesTest.java
index c30b3fb75e..8178ea69d9 100644
--- a/test-jpms/src/test/java/com/google/gson/jpms_test/ExportedPackagesTest.java
+++ b/test-jpms/src/test/java/com/google/gson/jpms_test/ExportedPackagesTest.java
@@ -17,7 +17,7 @@
package com.google.gson.jpms_test;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
@@ -30,7 +30,7 @@
import java.lang.reflect.InaccessibleObjectException;
import java.lang.reflect.Modifier;
import java.util.Arrays;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Verifies that Gson's {@code module-info.class} properly 'exports' all its packages containing
diff --git a/test-jpms/src/test/java/com/google/gson/jpms_test/ModuleTest.java b/test-jpms/src/test/java/com/google/gson/jpms_test/ModuleTest.java
index 14e2917b77..844d07acee 100644
--- a/test-jpms/src/test/java/com/google/gson/jpms_test/ModuleTest.java
+++ b/test-jpms/src/test/java/com/google/gson/jpms_test/ModuleTest.java
@@ -26,7 +26,7 @@
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Verifies that this test project is properly set up and has a module descriptor, and checks Gson's
diff --git a/test-jpms/src/test/java/com/google/gson/jpms_test/ReflectionInaccessibleTest.java b/test-jpms/src/test/java/com/google/gson/jpms_test/ReflectionInaccessibleTest.java
index 0358b78df9..5c9b67170b 100644
--- a/test-jpms/src/test/java/com/google/gson/jpms_test/ReflectionInaccessibleTest.java
+++ b/test-jpms/src/test/java/com/google/gson/jpms_test/ReflectionInaccessibleTest.java
@@ -17,11 +17,11 @@
package com.google.gson.jpms_test;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.gson.Gson;
import com.google.gson.JsonIOException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Verifies that Gson cannot use reflection for classes in a package if it has not been 'opened' to
diff --git a/test-jpms/src/test/java/com/google/gson/jpms_test/opened/ReflectionTest.java b/test-jpms/src/test/java/com/google/gson/jpms_test/opened/ReflectionTest.java
index 140472cfa8..3df3960771 100644
--- a/test-jpms/src/test/java/com/google/gson/jpms_test/opened/ReflectionTest.java
+++ b/test-jpms/src/test/java/com/google/gson/jpms_test/opened/ReflectionTest.java
@@ -20,7 +20,7 @@
import static com.google.common.truth.Truth.assertThat;
import com.google.gson.Gson;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Verifies that Gson can use reflection for classes in a package if it has been 'opened' to the
diff --git a/test-shrinker/pom.xml b/test-shrinker/pom.xml
index 5decdd6048..2c77305a19 100644
--- a/test-shrinker/pom.xml
+++ b/test-shrinker/pom.xml
@@ -48,8 +48,8 @@
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
test
@@ -190,6 +190,12 @@
r8
8.5.35
+
+ org.junit.vintage
+ junit-vintage-engine
+ 5.11.3
+ test
+
diff --git a/test-shrinker/src/test/java/com/google/gson/it/ShrinkingIT.java b/test-shrinker/src/test/java/com/google/gson/it/ShrinkingIT.java
index 527faac0d2..6e01ec34b1 100644
--- a/test-shrinker/src/test/java/com/google/gson/it/ShrinkingIT.java
+++ b/test-shrinker/src/test/java/com/google/gson/it/ShrinkingIT.java
@@ -17,9 +17,9 @@
package com.google.gson.it;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
-import static org.junit.Assert.fail;
-import static org.junit.Assume.assumeTrue;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.fail;
+import static org.junit.jupiter.api.Assumptions.assumeTrue;
import com.example.UnusedClass;
import java.lang.reflect.InvocationTargetException;
@@ -32,8 +32,8 @@
import java.util.Arrays;
import java.util.List;
import java.util.function.BiConsumer;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameter;
@@ -54,7 +54,7 @@ public static List jarsToTest() {
@Parameter public Path jarToTest;
- @Before
+ @BeforeEach
public void verifyJarExists() {
if (!Files.isRegularFile(jarToTest)) {
fail("JAR file " + jarToTest + " does not exist; run this test with `mvn clean verify`");