Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
10 changes: 8 additions & 2 deletions extras/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,21 @@
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.truth</groupId>
<artifactId>truth</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>5.11.3</version>
<scope>test</scope>
</dependency>
</dependencies>

<developers>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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}.
Expand All @@ -44,7 +44,7 @@ public final class InterceptorTest {

private Gson gson;

@Before
@BeforeEach
public void setUp() throws Exception {
this.gson =
new GsonBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
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 java.util.Arrays;
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down
10 changes: 8 additions & 2 deletions gson/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -243,6 +243,12 @@
<artifactId>proguard-core</artifactId>
<version>9.1.6</version>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>5.11.3</version>
<scope>test</scope>
</dependency>
</dependencies>
<configuration>
<obfuscate>true</obfuscate>
Expand Down
2 changes: 1 addition & 1 deletion gson/src/test/java/com/google/gson/CommentsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -30,7 +30,7 @@
public class DefaultInetAddressTypeAdapterTest {
private Gson gson;

@Before
@BeforeEach
public void setUp() throws Exception {
gson = new Gson();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions gson/src/test/java/com/google/gson/FieldAttributesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -35,7 +35,7 @@
public class FieldAttributesTest {
private FieldAttributes fieldAttributes;

@Before
@BeforeEach
public void setUp() throws Exception {
fieldAttributes = new FieldAttributes(Foo.class.getField("bar"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions gson/src/test/java/com/google/gson/GenericArrayTypeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -35,7 +35,7 @@
public class GenericArrayTypeTest {
private GenericArrayType ourType;

@Before
@BeforeEach
public void setUp() throws Exception {
ourType =
$Gson$Types.arrayOf(
Expand Down
4 changes: 2 additions & 2 deletions gson/src/test/java/com/google/gson/GsonBuilderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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}.
Expand Down
4 changes: 2 additions & 2 deletions gson/src/test/java/com/google/gson/GsonTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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}.
Expand Down
8 changes: 4 additions & 4 deletions gson/src/test/java/com/google/gson/GsonTypeAdapterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -35,7 +35,7 @@
public class GsonTypeAdapterTest {
private Gson gson;

@Before
@BeforeEach
public void setUp() throws Exception {
gson =
new GsonBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions gson/src/test/java/com/google/gson/JsonArrayAsListTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions gson/src/test/java/com/google/gson/JsonArrayTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion gson/src/test/java/com/google/gson/JsonNullTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions gson/src/test/java/com/google/gson/JsonObjectAsMapTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down
Loading