Skip to content

Commit

Permalink
Clean up gson-extras project, make it submodule of gson-parent
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcono1234 committed Sep 11, 2021
1 parent 7f51945 commit bb6ce33
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 151 deletions.
176 changes: 31 additions & 145 deletions extras/pom.xml
@@ -1,47 +1,37 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.google.code.gson</groupId>
<parent>
<groupId>com.google.code.gson</groupId>
<artifactId>gson-parent</artifactId>
<version>2.8.9-SNAPSHOT</version>
</parent>

<artifactId>gson-extras</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<inceptionYear>2008</inceptionYear>
<name>Gson Extras</name>
<parent>
<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
<version>9</version>
</parent>
<url>http://code.google.com/p/google-gson/</url>
<description>Google Gson grab bag of utilities, type adapters, etc.</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
<name>Apache-2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>
<scm>
<connection>scm:svn:http://google-gson.googlecode.com/svn/trunk/extras</connection>
<developerConnection>scm:svn:https://google-gson.googlecode.com/svn/trunk/extras</developerConnection>
<url>http://google-gson.codegoogle.com/svn/trunk/extras</url>
</scm>
<issueManagement>
<system>Google Code Issue Tracking</system>
<url>http://code.google.com/p/google-gson/issues/list</url>
</issueManagement>

<organization>
<name>Google, Inc.</name>
<url>http://www.google.com</url>
<url>https://www.google.com</url>
</organization>

<dependencies>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.7</version>
<scope>compile</scope>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
Expand All @@ -51,130 +41,26 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<profiles>
<!-- Activate PGP signing only when performing a release -->
<profile>
<id>release-sign-artifacts</id>
<activation>
<property>
<name>performRelease</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<build>
<defaultGoal>package</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<configuration>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>attach-sources</id>
<phase>verify</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.4</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<configuration>
<links>
<link>http://download.oracle.com/javase/1.5.0/docs/api/</link>
</links>
<version>true</version>
<show>public</show>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.10</version>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
<workspace>
../eclipse-ws/
</workspace>
<workspaceCodeStylesURL>
file:///${basedir}/../lib/gson-formatting-styles.xml
</workspaceCodeStylesURL>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<!-- version>2.3.2</version -->
<configuration>
<arguments>-DenableCiProfile=true</arguments>
<tagBase>https://google-gson.googlecode.com/svn/tags/</tagBase>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.0.0-M1</version>
<configuration>
<!-- Currently not deployed -->
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>

<developers>
<developer>
<name>Inderjeet Singh</name>
Expand Down
Expand Up @@ -16,16 +16,23 @@

package com.google.gson.graph;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import junit.framework.TestCase;

public final class GraphAdapterBuilderTest extends TestCase {
import org.junit.Ignore;
import org.junit.Test;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;

public final class GraphAdapterBuilderTest {
@Test
public void testSerialization() {
Roshambo rock = new Roshambo("ROCK");
Roshambo scissors = new Roshambo("SCISSORS");
Expand All @@ -46,6 +53,7 @@ public void testSerialization() {
gson.toJson(rock).replace('"', '\''));
}

@Test
public void testDeserialization() {
String json = "{'0x1':{'name':'ROCK','beats':'0x2'}," +
"'0x2':{'name':'SCISSORS','beats':'0x3'}," +
Expand All @@ -66,6 +74,8 @@ public void testDeserialization() {
assertSame(rock, paper.beats);
}

@Ignore("Does not work anymore due to ReflectiveTypeAdapterFactory ignoring self references")
@Test
public void testSerializationDirectSelfReference() {
Roshambo suicide = new Roshambo("SUICIDE");
suicide.beats = suicide;
Expand All @@ -80,6 +90,7 @@ public void testSerializationDirectSelfReference() {
gson.toJson(suicide).replace('"', '\''));
}

@Test
public void testDeserializationDirectSelfReference() {
String json = "{'0x1':{'name':'SUICIDE','beats':'0x1'}}";

Expand All @@ -94,6 +105,7 @@ public void testDeserializationDirectSelfReference() {
assertSame(suicide, suicide.beats);
}

@Test
public void testSerializeListOfLists() {
Type listOfListsType = new TypeToken<List<List<?>>>() {}.getType();
Type listOfAnyType = new TypeToken<List<?>>() {}.getType();
Expand All @@ -113,6 +125,7 @@ public void testSerializeListOfLists() {
assertEquals("{'0x1':['0x1','0x2'],'0x2':[]}", json.replace('"', '\''));
}

@Test
public void testDeserializeListOfLists() {
Type listOfAnyType = new TypeToken<List<?>>() {}.getType();
Type listOfListsType = new TypeToken<List<List<?>>>() {}.getType();
Expand All @@ -130,6 +143,7 @@ public void testDeserializeListOfLists() {
assertEquals(Collections.emptyList(), listOfLists.get(1));
}

@Test
public void testSerializationWithMultipleTypes() {
Company google = new Company("Google");
new Employee("Jesse", google);
Expand All @@ -148,6 +162,7 @@ public void testSerializationWithMultipleTypes() {
gson.toJson(google).replace('"', '\''));
}

@Test
public void testDeserializationWithMultipleTypes() {
GsonBuilder gsonBuilder = new GsonBuilder();
new GraphAdapterBuilder()
Expand Down
3 changes: 2 additions & 1 deletion pom.xml
Expand Up @@ -20,6 +20,7 @@

<modules>
<module>gson</module>
<module>extras</module>
</modules>

<properties>
Expand All @@ -41,7 +42,7 @@

<licenses>
<license>
<name>Apache 2.0</name>
<name>Apache-2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>
Expand Down

0 comments on commit bb6ce33

Please sign in to comment.