JOHNZON-164 add test for json-p behaviour

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

Branch: refs/heads/master
Commit: cec66e8e351919564f979c0947fea2207ec6e3ca
Parents: df26192
Author: Mark Struberg <[email protected]>
Authored: Thu Mar 29 10:41:11 2018 +0200
Committer: Mark Struberg <[email protected]>
Committed: Thu Mar 29 10:41:11 2018 +0200

----------------------------------------------------------------------
 .../apache/johnzon/core/JsonReaderImplTest.java    | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/johnzon/blob/cec66e8e/johnzon-core/src/test/java/org/apache/johnzon/core/JsonReaderImplTest.java
----------------------------------------------------------------------
diff --git 
a/johnzon-core/src/test/java/org/apache/johnzon/core/JsonReaderImplTest.java 
b/johnzon-core/src/test/java/org/apache/johnzon/core/JsonReaderImplTest.java
index 216610e..1fa809d 100644
--- a/johnzon-core/src/test/java/org/apache/johnzon/core/JsonReaderImplTest.java
+++ b/johnzon-core/src/test/java/org/apache/johnzon/core/JsonReaderImplTest.java
@@ -49,7 +49,6 @@ import org.junit.Test;
 public class JsonReaderImplTest {
 
 
-
     public JsonReaderImplTest() {
         if (!Charset.defaultCharset().equals(Charset.forName("UTF-8"))) {
             System.err.println("Default charset is " + 
Charset.defaultCharset() + ", must must be UTF-8");
@@ -184,7 +183,7 @@ public class JsonReaderImplTest {
         assertEquals("hallo\u20acö\uffff \u08a5 
থ?ß§$%&´'`*+#\udbff\udfff", object.getString("নa"));
         reader.close();
     }
-    
+
     @Test
     public void specialKeysWithStringAsByteArrayInputStream() {
         final String s = "{\"\\\"a\":\"\u0055\",\"\u0055\":\"test2\"}";
@@ -359,7 +358,7 @@ public class JsonReaderImplTest {
         assertEquals(-2, array.getInt(1));
         reader.close();
     }
-    
+
     @Test
     public void simple2BadBufferSize8() {
         final JsonReader reader = Json.createReaderFactory(new HashMap<String, 
Object>() {
@@ -446,8 +445,8 @@ public class JsonReaderImplTest {
 
     @Test
     public void stringescapeVariousBufferSizes() {
-        final int[] buffersizes = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 
11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
-                26, 27, 28, 32, 64, 128, 1024, 8192 };
+        final int[] buffersizes = new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 
12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
+                26, 27, 28, 32, 64, 128, 1024, 8192};
 
         for (final int buffersize : buffersizes) {
             final String value = String.valueOf(buffersize);
@@ -569,4 +568,12 @@ public class JsonReaderImplTest {
             assertEquals(1234.5, JsonNumber.class.cast(value).doubleValue(), 
0.);
         }
     }
+
+
+    @Test(expected = JsonParsingException.class)
+    public void testInvalidNumber() {
+        String jsonWithIllegalNumber = "{\"val\":12.34-2}";
+        JsonReaderImpl.class.cast(Json.createReader(new 
StringReader(jsonWithIllegalNumber))).readObject();
+    }
+
 }
\ No newline at end of file

Reply via email to