-
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.
Signed-off-by: Roman Grigoriadi <[email protected]>
- Loading branch information
Roman Grigoriadi
committed
Nov 10, 2017
0 parents
commit 75191e2
Showing
4 changed files
with
203 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Tests Yasson deployed on JDK 9 JPMS module path | ||
|
||
Client for Jsonb RI Yasson, which puts it natively on module path with all its dependencies (Jsonb API, Jsonp API and Jsonp RI). | ||
|
||
Set your java runtime to 9+ | ||
|
||
``` | ||
mvn clean install | ||
mve exec:exec | ||
``` | ||
|
||
|
||
Output: | ||
|
||
``` | ||
[INFO] --- exec-maven-plugin:1.6.0:exec (default-cli) @ yasson-client --- | ||
JSONB API module: module java.json.bind | ||
JSONB impl module: module org.eclipse.yasson | ||
JSONP API module: module java.json | ||
JSONP impl module: module org.glassfish.java.json | ||
Serialized JSON: {"strValue":"abc"} | ||
``` |
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,97 @@ | ||
<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/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>info.grigoriadi</groupId> | ||
<artifactId>yasson-client</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<packaging>jar</packaging> | ||
|
||
<name>yasson-client</name> | ||
<url>http://maven.apache.org</url> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.8.2</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse</groupId> | ||
<artifactId>yasson</artifactId> | ||
<version>1.0.1-SNAPSHOT</version> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>javax.enterprise</groupId> | ||
<artifactId>cdi-api</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>javax.json.bind</groupId> | ||
<artifactId>javax.json.bind-api</artifactId> | ||
<version>1.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.glassfish</groupId> | ||
<artifactId>javax.json</artifactId> | ||
<version>1.1.2</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.7.0</version> | ||
<configuration> | ||
<source>9</source> | ||
<target>9</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<version>3.0.2</version> | ||
<configuration> | ||
<archive> | ||
<manifest> | ||
<addClasspath>false</addClasspath> | ||
<mainClass> | ||
info.grigoriadi.App | ||
</mainClass> | ||
</manifest> | ||
</archive> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>exec-maven-plugin</artifactId> | ||
<version>1.6.0</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>exec</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<executable>java</executable> | ||
<arguments> | ||
<argument>--module-path</argument> <!-- or -p --> | ||
<modulepath/> | ||
<argument>--add-modules</argument> | ||
<argument>org.eclipse.yasson</argument> | ||
<argument>-jar</argument> | ||
<argument>${project.build.directory}/yasson-client-1.0-SNAPSHOT.jar</argument> | ||
</arguments> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
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,45 @@ | ||
package info.grigoriadi; | ||
|
||
import javax.json.Json; | ||
import javax.json.bind.Jsonb; | ||
import javax.json.bind.JsonbBuilder; | ||
import java.util.Arrays; | ||
|
||
/** | ||
* Hello world! | ||
* | ||
*/ | ||
public class App | ||
{ | ||
public static void main( String[] args ) throws ClassNotFoundException { | ||
System.out.println("JSONB API module: " + Jsonb.class.getModule()); | ||
|
||
Class yassonCls = Class.forName("org.eclipse.yasson.JsonBindingProvider"); | ||
System.out.println("JSONB impl module: " + yassonCls.getModule()); | ||
|
||
System.out.println("JSONP API module: " + Json.class.getModule()); | ||
|
||
Class jsonpCls = Class.forName("org.glassfish.json.JsonGeneratorImpl"); | ||
System.out.println("JSONP impl module: " + jsonpCls.getModule()); | ||
|
||
Jsonb jsonb = JsonbBuilder.create(); | ||
|
||
System.out.println( "Serialized JSON: " + jsonb.toJson(new Pojo("abc")) ); | ||
} | ||
|
||
public static final class Pojo { | ||
private String strValue; | ||
|
||
public Pojo(String strValue) { | ||
this.strValue = strValue; | ||
} | ||
|
||
public String getStrValue() { | ||
return strValue; | ||
} | ||
|
||
public void setStrValue(String strValue) { | ||
this.strValue = strValue; | ||
} | ||
} | ||
} |
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,38 @@ | ||
package info.grigoriadi; | ||
|
||
import junit.framework.Test; | ||
import junit.framework.TestCase; | ||
import junit.framework.TestSuite; | ||
|
||
/** | ||
* Unit test for simple App. | ||
*/ | ||
public class AppTest | ||
extends TestCase | ||
{ | ||
/** | ||
* Create the test case | ||
* | ||
* @param testName name of the test case | ||
*/ | ||
public AppTest( String testName ) | ||
{ | ||
super( testName ); | ||
} | ||
|
||
/** | ||
* @return the suite of tests being tested | ||
*/ | ||
public static Test suite() | ||
{ | ||
return new TestSuite( AppTest.class ); | ||
} | ||
|
||
/** | ||
* Rigourous Test :-) | ||
*/ | ||
public void testApp() | ||
{ | ||
assertTrue( true ); | ||
} | ||
} |