Skip to content

Commit

Permalink
Adding Test Module with Groovy and Java 21 Support (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shounaks authored Mar 5, 2024
1 parent 124341c commit 68f23bf
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 85 deletions.
23 changes: 0 additions & 23 deletions jr-objects/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ has no other dependencies, and provides additional builder-style content generat
<artifactId>jackson-core</artifactId>
<version>${jackson.version.core}</version>
</dependency>
<dependency>
<groupId>org.apache.groovy</groupId>
<artifactId>groovy</artifactId>
<version>4.0.18</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand All @@ -58,22 +52,6 @@ has no other dependencies, and provides additional builder-style content generat
<link>https://javadoc.io/doc/com.fasterxml.jackson.core/jackson-core/2.17/</link>
</links>
</configuration>

</plugin>

<!-- 20-Feb-2024, tatu: Need Groovy compilation for one test
-->
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
Expand All @@ -91,5 +69,4 @@ has no other dependencies, and provides additional builder-style content generat
</plugin>
</plugins>
</build>

</project>

This file was deleted.

88 changes: 88 additions & 0 deletions jr-test-module/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<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>
<parent>
<groupId>com.fasterxml.jackson.jr</groupId>
<artifactId>jackson-jr-parent</artifactId>
<version>2.17.0-SNAPSHOT</version>
</parent>
<artifactId>jackson-jr-test-module</artifactId>
<packaging>pom</packaging>
<description>Test Module with higher JDK Version + Groovy support to test Jackson-Jr</description>
<url>https://github.com/FasterXML/jackson-jr</url>
<properties>
<!-- To Test Latest Java Features Lets use this settings -->
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.jr</groupId>
<artifactId>jackson-jr-objects</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.groovy</groupId>
<artifactId>groovy</artifactId>
<version>4.0.18</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>

<!-- 20-Feb-2024, tatu: Need Groovy compilation for one test-->
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.5</version>
<dependencies>
<dependency>
<groupId>org.apache.groovy</groupId>
<artifactId>groovy</artifactId>
<version>4.0.18</version>
</dependency>
</dependencies>
<configuration>
<providerSelection>2.0</providerSelection>
<source>2.0</source>
</configuration>
<executions>
<execution>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
<configuration>
<includes>
<include>**/*Test.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>

</project>
57 changes: 57 additions & 0 deletions jr-test-module/src/test/groovy/GroovyObjectSupportTest.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import com.fasterxml.jackson.jr.ob.JSON
import org.junit.Assert
import org.junit.Test

class GroovyObjectSupportTest {
@Test
void testSimpleGroovyObject() throws Exception {
def json = JSON.std.asString(new GroovyOb())
def expected = """{"AAAAA_A_Field_Starting_With_Two_Capital_Letters":"XYZ","aDouble":0.0,"aPublicInitializedInteger":56,"aPublicInitializedIntegerObject":1516,"aPublicUninitializedInteger":0,"anInitializedIntegerObject":1112,"anInitializedPublicString":"stringData","anInitializedString":"ABC","anInteger":0,"anIntegerWithValue":12}"""
Assert.assertEquals(json, expected)
}
}

class GroovyOb {
int anInteger
int anIntegerWithValue = 12

static int anStaticInteger = 34
static int anStaticIntegerWithValue = 34

public int aPublicUninitializedInteger
public int aPublicInitializedInteger = 56

private int aPrivateUninitializedInteger
private int aPrivateInitializedInteger = 78

public static int aPublicStaticUninitializedInteger
public static int aPublicStaticInitializedInteger = 910

Integer anIntegerObject
Integer anInitializedIntegerObject = 1112

static Integer aStaticIntegerObject
static Integer aStaticInitializedIntegerObject = 1314

public Integer aPublicUninitializedIntegerObject
public Integer aPublicInitializedIntegerObject = 1516

public static Integer aPublicStaticUninitializedIntegerObject
public static Integer aPublicStaticInitializedIntegerObject = 1718

String aString
String anInitializedString = "ABC"

static String aStaticString = "jacksonJR"

public String aPublicString
public String anInitializedPublicString = "stringData"

public String AAAAA_A_Field_Starting_With_Two_Capital_Letters = "XYZ"
//Other Items
public static String staticStr = "jacksonJR" // Public Static Object
static int anStaticInt // Uninitialized Static Object
public double aDouble // uninitialized primitive
public Double aDoubleObject // testing boxing object
private int hiddenvalue = 123 // private value
}
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<module>jr-stree</module>
<module>jr-annotation-support</module>
<module>jr-extension-javatime</module>
<module>jr-test-module</module>
<module>jr-all</module>
</modules>

Expand Down

0 comments on commit 68f23bf

Please sign in to comment.