Skip to content

Commit 4df6984

Browse files
committed
Merge pull request #34 from stleary/util-cleanup
util cleanup
2 parents 0dc886d + c88d06e commit 4df6984

File tree

2 files changed

+3
-46
lines changed

2 files changed

+3
-46
lines changed

JSONMLTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,9 @@ public void toJSONObjectToJSONArray() {
655655

656656
// lastly, confirm the restored JSONObject XML and JSONArray XML look
657657
// reasonably similar
658-
Util.compareXML(jsonObjectXmlToStr, jsonArrayXmlToStr);
658+
JSONObject jsonObjectFromObject = JSONML.toJSONObject(jsonObjectXmlToStr);
659+
JSONObject jsonObjectFromArray = JSONML.toJSONObject(jsonArrayXmlToStr);
660+
Util.compareActualVsExpectedJsonObjects(jsonObjectFromObject, jsonObjectFromArray);
659661
}
660662

661663
/**

Util.java

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -94,49 +94,4 @@ private static void compareActualVsExpectedObjects(Object value,
9494
value.toString().equals(expectedValue.toString()));
9595
}
9696
}
97-
98-
/**
99-
* Sometimes test completion requires comparison of JSONArray objects that
100-
* were produced from a JSONObject, and so unordered. This method is
101-
* imperfect since it only compares the array elements and won't catch
102-
* JSON syntax errors but at least it does not rely on ordering
103-
* <p>
104-
* It is expected that the arrays to be compared come from JSONArray
105-
* instances which have been rendered by toString(), and whose syntax
106-
* chars have been removed.
107-
* <p>
108-
* TODO: why are we not simply comparing the JSONArrays?
109-
* <p>
110-
* @param names an array of strings for comparison
111-
* @param expectedNames the other array of strings for comparison
112-
*/
113-
public static void compareActualVsExpectedStringArrays(String[] names,
114-
String [] expectedNames) {
115-
assertTrue("Array lengths should be equal",
116-
names.length == expectedNames.length);
117-
List<String> lNames = new ArrayList<String>(Arrays.asList(names));
118-
for (int i = 0; i < expectedNames.length; ++i) {
119-
String expectedName = expectedNames[i];
120-
assertTrue("expected to find "+expectedName,
121-
lNames.contains(expectedName));
122-
lNames.remove(expectedName);
123-
}
124-
}
125-
126-
/**
127-
* This is stopgap test utility. It is meant to compare strings
128-
* of XML, but it does not take ordering into account and should
129-
* not be expected to work correctly with complex XML.
130-
* @param aXmlStr an XML doc to be compared
131-
* @param bXmlStr the other XML doc to be compared
132-
*/
133-
public static void compareXML(String aXmlStr, String bXmlStr) {
134-
// TODO For simple tests this may be adequate, but it won't work for
135-
// elements with multiple attributes and possibly other cases as well.
136-
// Should use XMLUnit or similar.
137-
assertTrue("expected equal XML strings \naXmlStr: "+
138-
aXmlStr+ "\nbXmlStr: " +bXmlStr, aXmlStr.equals(bXmlStr));
139-
140-
}
141-
14297
}

0 commit comments

Comments
 (0)