Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
Signed-off-by: Roman Grigoriadi <[email protected]>
  • Loading branch information
Roman Grigoriadi committed Nov 10, 2017
0 parents commit 75191e2
Show file tree
Hide file tree
Showing 4 changed files with 203 additions and 0 deletions.
23 changes: 23 additions & 0 deletions README.md
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"}
```
97 changes: 97 additions & 0 deletions pom.xml
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>
45 changes: 45 additions & 0 deletions src/main/java/info/grigoriadi/App.java
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;
}
}
}
38 changes: 38 additions & 0 deletions src/test/java/info/grigoriadi/AppTest.java
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 );
}
}

0 comments on commit 75191e2

Please sign in to comment.