Repository: johnzon
Updated Branches:
  refs/heads/master 218a8abfc -> 307a7cb51


JOHNZON-157 more tests for the regression


Project: http://git-wip-us.apache.org/repos/asf/johnzon/repo
Commit: http://git-wip-us.apache.org/repos/asf/johnzon/commit/307a7cb5
Tree: http://git-wip-us.apache.org/repos/asf/johnzon/tree/307a7cb5
Diff: http://git-wip-us.apache.org/repos/asf/johnzon/diff/307a7cb5

Branch: refs/heads/master
Commit: 307a7cb5105439403a1beb37066f5e30629c6ffa
Parents: 218a8ab
Author: Mark Struberg <strub...@apache.org>
Authored: Mon Feb 12 11:25:25 2018 +0100
Committer: Mark Struberg <strub...@apache.org>
Committed: Mon Feb 12 11:26:14 2018 +0100

----------------------------------------------------------------------
 .../apache/johnzon/core/JohnzonJsonParserImpl.java   |  4 ++--
 .../java/org/apache/johnzon/jsonb/JsonbReadTest.java | 15 +++++++++++++++
 2 files changed, 17 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/johnzon/blob/307a7cb5/johnzon-core/src/main/java/org/apache/johnzon/core/JohnzonJsonParserImpl.java
----------------------------------------------------------------------
diff --git 
a/johnzon-core/src/main/java/org/apache/johnzon/core/JohnzonJsonParserImpl.java 
b/johnzon-core/src/main/java/org/apache/johnzon/core/JohnzonJsonParserImpl.java
index 5fa051a..ce93a5d 100644
--- 
a/johnzon-core/src/main/java/org/apache/johnzon/core/JohnzonJsonParserImpl.java
+++ 
b/johnzon-core/src/main/java/org/apache/johnzon/core/JohnzonJsonParserImpl.java
@@ -38,7 +38,7 @@ public abstract class JohnzonJsonParserImpl implements 
JohnzonJsonParser {
     @Override
     public JsonObject getObject() {
         Event current = current();
-        if (current != Event.START_OBJECT) {
+        if (current != null && current != Event.START_OBJECT) {
             throw new IllegalStateException(current + " doesn't support 
getObject()");
         }
 
@@ -50,7 +50,7 @@ public abstract class JohnzonJsonParserImpl implements 
JohnzonJsonParser {
     @Override
     public JsonArray getArray() {
         Event current = current();
-        if (current != Event.START_ARRAY) {
+        if (current != null && current != Event.START_ARRAY) {
             throw new IllegalStateException(current + " doesn't support 
getArray()");
         }
 

http://git-wip-us.apache.org/repos/asf/johnzon/blob/307a7cb5/johnzon-jsonb/src/test/java/org/apache/johnzon/jsonb/JsonbReadTest.java
----------------------------------------------------------------------
diff --git 
a/johnzon-jsonb/src/test/java/org/apache/johnzon/jsonb/JsonbReadTest.java 
b/johnzon-jsonb/src/test/java/org/apache/johnzon/jsonb/JsonbReadTest.java
index 4b03916..37e5d23 100644
--- a/johnzon-jsonb/src/test/java/org/apache/johnzon/jsonb/JsonbReadTest.java
+++ b/johnzon-jsonb/src/test/java/org/apache/johnzon/jsonb/JsonbReadTest.java
@@ -18,11 +18,16 @@
  */
 package org.apache.johnzon.jsonb;
 
+import org.junit.Assert;
 import org.junit.Test;
 
+import javax.json.Json;
+import javax.json.JsonObject;
 import javax.json.bind.annotation.JsonbDateFormat;
 import javax.json.bind.annotation.JsonbProperty;
 import javax.json.bind.spi.JsonbProvider;
+import javax.json.stream.JsonParser;
+
 import java.io.ByteArrayInputStream;
 import java.io.StringReader;
 import java.time.LocalDate;
@@ -66,6 +71,16 @@ public class JsonbReadTest {
             JsonbProvider.provider().create().build().fromJson(new 
StringReader("{\"date\":\"" + date + "\"}"), 
DateFormatting.class).date.getYear());
     }
 
+    @Test
+    public void propertyMappingNewLine() {
+        String json = "{\n" +
+                "  \"simple\":\"test\"\n" +
+                "}\n";
+
+        assertEquals("test", 
JsonbProvider.provider().create().build().fromJson(new StringReader(json), 
SimpleProperty.class).value);
+    }
+
+
     public static class Simple {
         private String value;
 

Reply via email to