forked from FasterXML/jackson-jr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding Test Module with Groovy and Java 21 Support (FasterXML#128)
- Loading branch information
Showing
5 changed files
with
146 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 0 additions & 62 deletions
62
jr-objects/src/test/groovy/com/fasterxml/jackson/jr/GroovyTest.groovy
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
57
jr-test-module/src/test/groovy/GroovyObjectSupportTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters