diff --git a/pom.xml b/pom.xml
index b3f817c0..22457567 100644
--- a/pom.xml
+++ b/pom.xml
@@ -80,6 +80,12 @@
1.20
test
+
+ org.skyscreamer
+ jsonassert
+ 1.5.1
+ test
+
diff --git a/src/test/java/com/jsoniter/extra/TestPreciseFloat.java b/src/test/java/com/jsoniter/extra/TestPreciseFloat.java
index d63082ae..56a2f305 100644
--- a/src/test/java/com/jsoniter/extra/TestPreciseFloat.java
+++ b/src/test/java/com/jsoniter/extra/TestPreciseFloat.java
@@ -1,5 +1,6 @@
package com.jsoniter.extra;
-
+import org.json.JSONException;
+import org.skyscreamer.jsonassert.JSONAssert;
import com.jsoniter.output.JsonStream;
import junit.framework.TestCase;
@@ -20,12 +21,12 @@ public static class TestObject1 {
public float field4;
}
- public void test_indirect_encode() {
+ public void test_indirect_encode() throws JSONException {
TestObject1 obj = new TestObject1();
obj.field1 = 0.12345678d;
obj.field2 = 0.12345678d;
obj.field3 = 0.12345678f;
obj.field4 = 0.12345678f;
- assertEquals("{\"field1\":0.12345678,\"field2\":0.12345678,\"field3\":0.12345678,\"field4\":0.12345678}", JsonStream.serialize(obj));
+ JSONAssert.assertEquals("{\"field1\":0.12345678,\"field2\":0.12345678,\"field3\":0.12345678,\"field4\":0.12345678}", JsonStream.serialize(obj), false);
}
}
diff --git a/src/test/java/com/jsoniter/output/TestGenerics.java b/src/test/java/com/jsoniter/output/TestGenerics.java
index ff06d780..e986ba4f 100644
--- a/src/test/java/com/jsoniter/output/TestGenerics.java
+++ b/src/test/java/com/jsoniter/output/TestGenerics.java
@@ -1,6 +1,8 @@
package com.jsoniter.output;
import junit.framework.TestCase;
+import org.json.JSONException;
+import org.skyscreamer.jsonassert.JSONAssert;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -44,7 +46,7 @@ public static class TestObject7 {
public Map, ?> field2;
}
- public void test_wildcard() throws IOException {
+ public void test_wildcard() throws IOException, JSONException {
TestObject7 obj = new TestObject7();
ArrayList list = new ArrayList();
list.add(1);
@@ -52,6 +54,6 @@ public void test_wildcard() throws IOException {
HashMap map = new HashMap();
map.put("hello", 1);
obj.field2 = map;
- assertEquals("{\"field\":[1],\"field2\":{\"hello\":1}}", JsonStream.serialize(obj));
+ JSONAssert.assertEquals("{\"field\":[1],\"field2\":{\"hello\":1}}", JsonStream.serialize(obj), false);
}
}
diff --git a/src/test/java/com/jsoniter/output/TestGson.java b/src/test/java/com/jsoniter/output/TestGson.java
index afa78828..b2cf70d7 100644
--- a/src/test/java/com/jsoniter/output/TestGson.java
+++ b/src/test/java/com/jsoniter/output/TestGson.java
@@ -8,6 +8,8 @@
import com.jsoniter.extra.GsonCompatibilityMode;
import com.jsoniter.spi.JsoniterSpi;
import junit.framework.TestCase;
+import org.json.JSONException;
+import org.skyscreamer.jsonassert.JSONAssert;
import java.lang.reflect.Field;
import java.text.DateFormat;
@@ -86,7 +88,7 @@ public static class TestObject5 {
public int field2;
}
- public void test_serializeNulls() {
+ public void test_serializeNulls() throws JSONException {
TestObject5 obj = new TestObject5();
Gson gson = new GsonBuilder().create();
String output = gson.toJson(obj);
@@ -94,7 +96,7 @@ public void test_serializeNulls() {
gson = new GsonBuilder().serializeNulls().create();
output = gson.toJson(obj);
- assertEquals("{\"field1\":null,\"field2\":0}", output);
+ JSONAssert.assertEquals("{\"field1\":null,\"field2\":0}", output, false);
GsonCompatibilityMode config = new GsonCompatibilityMode.Builder()
.build();
@@ -104,7 +106,7 @@ public void test_serializeNulls() {
config = new GsonCompatibilityMode.Builder()
.serializeNulls().build();
output = JsonStream.serialize(config, obj);
- assertEquals("{\"field1\":null,\"field2\":0}", output);
+ JSONAssert.assertEquals("{\"field1\":null,\"field2\":0}", output, false);
}
public void test_setDateFormat_with_style() {
diff --git a/src/test/java/com/jsoniter/output/TestNested.java b/src/test/java/com/jsoniter/output/TestNested.java
index 00fd8d6d..8cb26d5b 100644
--- a/src/test/java/com/jsoniter/output/TestNested.java
+++ b/src/test/java/com/jsoniter/output/TestNested.java
@@ -4,6 +4,8 @@
import com.jsoniter.spi.JsoniterSpi;
import com.jsoniter.spi.TypeLiteral;
import junit.framework.TestCase;
+import org.json.JSONException;
+import org.skyscreamer.jsonassert.JSONAssert;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -56,7 +58,7 @@ public static class TestObject2 {
public TestObject1[] objs;
}
- public void test_object_of_array() throws IOException {
+ public void test_object_of_array() throws IOException, JSONException {
if (JsoniterSpi.getCurrentConfig().encodingMode() != EncodingMode.REFLECTION_MODE) {
return;
}
@@ -69,20 +71,20 @@ public void test_object_of_array() throws IOException {
obj.objs[0].field2 = "2";
stream.writeVal(obj);
stream.close();
- assertEquals("{\n" +
+ JSONAssert.assertEquals("{\n" +
" \"objs\": [\n" +
" {\n" +
" \"field1\": \"1\",\n" +
" \"field2\": \"2\"\n" +
" }\n" +
" ]\n" +
- "}".replace('\'', '"'), baos.toString());
+ "}".replace('\'', '"'), baos.toString(), false);
} finally {
JsonStream.setIndentionStep(0);
}
}
- public void test_map_of_objects() throws IOException {
+ public void test_map_of_objects() throws IOException, JSONException {
if (JsoniterSpi.getCurrentConfig().encodingMode() != EncodingMode.REFLECTION_MODE) {
return;
}
@@ -96,12 +98,12 @@ public void test_map_of_objects() throws IOException {
put("hello", obj1);
}});
stream.close();
- assertEquals("{\n" +
+ JSONAssert.assertEquals("{\n" +
" \"hello\": {\n" +
" \"field1\": \"1\",\n" +
" \"field2\": \"2\"\n" +
" }\n" +
- "}".replace('\'', '"'), baos.toString());
+ "}".replace('\'', '"'), baos.toString(), false);
} finally {
JsonStream.setIndentionStep(0);
}
diff --git a/src/test/java/com/jsoniter/output/TestObject.java b/src/test/java/com/jsoniter/output/TestObject.java
index 9563b966..d5f9aea2 100644
--- a/src/test/java/com/jsoniter/output/TestObject.java
+++ b/src/test/java/com/jsoniter/output/TestObject.java
@@ -7,6 +7,8 @@
import com.jsoniter.spi.JsoniterSpi;
import com.jsoniter.spi.TypeLiteral;
import junit.framework.TestCase;
+import org.json.JSONException;
+import org.skyscreamer.jsonassert.JSONAssert;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -225,14 +227,14 @@ public static class TestObject11 {
public Integer field3;
}
- public void test_omit_null() {
+ public void test_omit_null() throws JSONException {
assertEquals("{\"field3\":null}", JsonStream.serialize(new TestObject11()));
TestObject11 obj = new TestObject11();
obj.field1 = "hello";
- assertEquals("{\"field1\":\"hello\",\"field3\":null}", JsonStream.serialize(obj));
+ JSONAssert.assertEquals("{\"field1\":\"hello\",\"field3\":null}", JsonStream.serialize(obj), false);
obj = new TestObject11();
obj.field2 = "hello";
- assertEquals("{\"field2\":\"hello\",\"field3\":null}", JsonStream.serialize(obj));
+ JSONAssert.assertEquals("{\"field2\":\"hello\",\"field3\":null}", JsonStream.serialize(obj), false);
obj = new TestObject11();
obj.field3 = 3;
assertEquals("{\"field3\":3}", JsonStream.serialize(obj));
@@ -279,7 +281,7 @@ public static class TestObject14 {
public String field3;
}
- public void test_indention() {
+ public void test_indention() throws JSONException {
Config dynamicCfg = new Config.Builder()
.indentionStep(2)
.encodingMode(EncodingMode.DYNAMIC_MODE)
@@ -288,21 +290,21 @@ public void test_indention() {
obj.field1 = "1";
obj.field2 = "2";
String output = JsonStream.serialize(dynamicCfg, obj);
- assertEquals("{\n" +
+ JSONAssert.assertEquals("{\n" +
" \"field1\": \"1\",\n" +
" \"field2\": \"2\",\n" +
" \"field3\": null\n" +
- "}", output);
+ "}", output, false);
Config reflectionCfg = new Config.Builder()
.indentionStep(2)
.encodingMode(EncodingMode.REFLECTION_MODE)
.build();
output = JsonStream.serialize(reflectionCfg, obj);
- assertEquals("{\n" +
+ JSONAssert.assertEquals("{\n" +
" \"field1\": \"1\",\n" +
" \"field2\": \"2\",\n" +
" \"field3\": null\n" +
- "}", output);
+ "}", output, false);
}
public static class TestObject15 {
@@ -351,16 +353,16 @@ public static class TestObject17 {
public char e;
}
- public void test_omit_default() {
+ public void test_omit_default() throws JSONException {
Config cfg = new Config.Builder()
.omitDefaultValue(true)
.build();
- assertEquals("{\"l\":1,\"d\":1}", JsonStream.serialize(cfg, new TestObject17()));
+ JSONAssert.assertEquals("{\"l\":1,\"d\":1}", JsonStream.serialize(cfg, new TestObject17()), false);
cfg = new Config.Builder()
.omitDefaultValue(true)
.encodingMode(EncodingMode.DYNAMIC_MODE)
.build();
- assertEquals("{\"l\":1,\"d\":1}", JsonStream.serialize(cfg, new TestObject17()));
+ JSONAssert.assertEquals("{\"l\":1,\"d\":1}", JsonStream.serialize(cfg, new TestObject17()), false);
}
public static class TestObject18 {