diff --git a/src/test/java/org/json/junit/CookieListTest.java b/src/test/java/org/json/junit/CookieListTest.java index 80cbaa8..7149644 100644 --- a/src/test/java/org/json/junit/CookieListTest.java +++ b/src/test/java/org/json/junit/CookieListTest.java @@ -65,7 +65,7 @@ public class CookieListTest { public void emptyStringCookieList() { String cookieStr = ""; JSONObject jsonObject = CookieList.toJSONObject(cookieStr); - assertTrue(jsonObject.length() == 0); + assertTrue(jsonObject.isEmpty()); } /** diff --git a/src/test/java/org/json/junit/EnumTest.java b/src/test/java/org/json/junit/EnumTest.java index cd0d8c0..366643e 100644 --- a/src/test/java/org/json/junit/EnumTest.java +++ b/src/test/java/org/json/junit/EnumTest.java @@ -35,7 +35,7 @@ public class EnumTest { // If there are no getters then the object is empty. MyEnum myEnum = MyEnum.VAL2; JSONObject jsonObject = new JSONObject(myEnum); - assertTrue("simple enum has no getters", jsonObject.length() == 0); + assertTrue("simple enum has no getters", jsonObject.isEmpty()); // enum with a getters should create a non-empty object MyEnumField myEnumField = MyEnumField.VAL2; diff --git a/src/test/java/org/json/junit/JSONArrayTest.java b/src/test/java/org/json/junit/JSONArrayTest.java index 8a31c87..845f4e7 100644 --- a/src/test/java/org/json/junit/JSONArrayTest.java +++ b/src/test/java/org/json/junit/JSONArrayTest.java @@ -691,7 +691,7 @@ public class JSONArrayTest { JSONArray jsonArray = new JSONArray(arrayStr1); jsonArray.remove(0); assertTrue("array should be empty", null == jsonArray.remove(5)); - assertTrue("jsonArray should be empty", jsonArray.length() == 0); + assertTrue("jsonArray should be empty", jsonArray.isEmpty()); } /** diff --git a/src/test/java/org/json/junit/JSONObjectTest.java b/src/test/java/org/json/junit/JSONObjectTest.java index 5dc31c7..e3b9529 100644 --- a/src/test/java/org/json/junit/JSONObjectTest.java +++ b/src/test/java/org/json/junit/JSONObjectTest.java @@ -141,7 +141,7 @@ public class JSONObjectTest { @Test public void emptyJsonObject() { JSONObject jsonObject = new JSONObject(); - assertTrue("jsonObject should be empty", jsonObject.length() == 0); + assertTrue("jsonObject should be empty", jsonObject.isEmpty()); } /** @@ -184,7 +184,7 @@ public class JSONObjectTest { public void jsonObjectByNullMap() { Map map = null; JSONObject jsonObject = new JSONObject(map); - assertTrue("jsonObject should be empty", jsonObject.length() == 0); + assertTrue("jsonObject should be empty", jsonObject.isEmpty()); } /** @@ -1122,7 +1122,7 @@ public class JSONObjectTest { BigDecimal bigDecimal = new BigDecimal( "123456789012345678901234567890.12345678901234567890123456789"); jsonObject = new JSONObject(bigDecimal); - assertTrue("large bigDecimal is not stored", jsonObject.length() == 0); + assertTrue("large bigDecimal is not stored", jsonObject.isEmpty()); /** * JSONObject put(String, Object) method stores and serializes @@ -2244,11 +2244,11 @@ public class JSONObjectTest { public void jsonObjectPutOnceNull() { JSONObject jsonObject = new JSONObject(); jsonObject.putOnce(null, null); - assertTrue("jsonObject should be empty", jsonObject.length() == 0); + assertTrue("jsonObject should be empty", jsonObject.isEmpty()); jsonObject.putOnce("", null); - assertTrue("jsonObject should be empty", jsonObject.length() == 0); + assertTrue("jsonObject should be empty", jsonObject.isEmpty()); jsonObject.putOnce(null, ""); - assertTrue("jsonObject should be empty", jsonObject.length() == 0); + assertTrue("jsonObject should be empty", jsonObject.isEmpty()); } /** @@ -2424,11 +2424,11 @@ public class JSONObjectTest { String str = "{\"myKey\": \"myval\"}"; JSONObject jsonObjectRemove = new JSONObject(str); jsonObjectRemove.remove("myKey"); - assertEquals("jsonObject should be empty",0 ,jsonObjectRemove.length()); + assertTrue("jsonObject should be empty", jsonObjectRemove.isEmpty()); JSONObject jsonObjectPutNull = new JSONObject(str); jsonObjectPutNull.put("myKey", (Object) null); - assertEquals("jsonObject should be empty",0 ,jsonObjectPutNull.length()); + assertTrue("jsonObject should be empty", jsonObjectPutNull.isEmpty()); } diff --git a/src/test/java/org/json/junit/PropertyTest.java b/src/test/java/org/json/junit/PropertyTest.java index 60d3eb5..8804284 100644 --- a/src/test/java/org/json/junit/PropertyTest.java +++ b/src/test/java/org/json/junit/PropertyTest.java @@ -21,7 +21,7 @@ public class PropertyTest { public void shouldHandleNullProperties() { Properties properties = null; JSONObject jsonObject = Property.toJSONObject(properties); - assertTrue("jsonObject should be empty", jsonObject.length() == 0); + assertTrue("jsonObject should be empty", jsonObject.isEmpty()); } /** @@ -32,7 +32,7 @@ public class PropertyTest { public void shouldHandleEmptyProperties() { Properties properties = new Properties(); JSONObject jsonObject = Property.toJSONObject(properties); - assertTrue("jsonObject should be empty", jsonObject.length() == 0); + assertTrue("jsonObject should be empty", jsonObject.isEmpty()); } /** diff --git a/src/test/java/org/json/junit/XMLTest.java b/src/test/java/org/json/junit/XMLTest.java index c34bf0f..651d1a7 100644 --- a/src/test/java/org/json/junit/XMLTest.java +++ b/src/test/java/org/json/junit/XMLTest.java @@ -34,7 +34,7 @@ public class XMLTest { public void shouldHandleNullXML() { String xmlStr = null; JSONObject jsonObject = XML.toJSONObject(xmlStr); - assertTrue("jsonObject should be empty", jsonObject.length() == 0); + assertTrue("jsonObject should be empty", jsonObject.isEmpty()); } /** @@ -45,7 +45,7 @@ public class XMLTest { String xmlStr = ""; JSONObject jsonObject = XML.toJSONObject(xmlStr); - assertTrue("jsonObject should be empty", jsonObject.length() == 0); + assertTrue("jsonObject should be empty", jsonObject.isEmpty()); } /** @@ -55,7 +55,7 @@ public class XMLTest { public void shouldHandleNonXML() { String xmlStr = "{ \"this is\": \"not xml\"}"; JSONObject jsonObject = XML.toJSONObject(xmlStr); - assertTrue("xml string should be empty", jsonObject.length() == 0); + assertTrue("xml string should be empty", jsonObject.isEmpty()); } /** @@ -200,7 +200,7 @@ public class XMLTest { public void shouldHandleEmptyJSONXML() { JSONObject jsonObject= new JSONObject(); String xmlStr = XML.toString(jsonObject); - assertTrue("xml string should be empty", xmlStr.length() == 0); + assertTrue("xml string should be empty", xmlStr.isEmpty()); } /**