mirror of
https://github.com/stleary/JSON-java.git
synced 2025-08-03 11:25:30 -04:00
fix failing test XML test on Windows machines
This commit is contained in:
parent
79af389f7a
commit
0e4a94d91d
@ -1223,32 +1223,18 @@ public class XMLTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIndentComplicatedJsonObjectWithArrayAndWithConfig(){
|
public void testIndentComplicatedJsonObjectWithArrayAndWithConfig(){
|
||||||
try {
|
try (InputStream jsonStream = XMLTest.class.getClassLoader().getResourceAsStream("Issue593.json")) {
|
||||||
InputStream jsonStream = null;
|
final JSONObject object = new JSONObject(new JSONTokener(jsonStream));
|
||||||
try {
|
String actualString = XML.toString(object, null, XMLParserConfiguration.KEEP_STRINGS, 2);
|
||||||
jsonStream = XMLTest.class.getClassLoader().getResourceAsStream("Issue593.json");
|
try (InputStream xmlStream = XMLTest.class.getClassLoader().getResourceAsStream("Issue593.xml")) {
|
||||||
final JSONObject object = new JSONObject(new JSONTokener(jsonStream));
|
int bufferSize = 1024;
|
||||||
String actualString = XML.toString(object, null, XMLParserConfiguration.KEEP_STRINGS,2);
|
char[] buffer = new char[bufferSize];
|
||||||
InputStream xmlStream = null;
|
StringBuilder expected = new StringBuilder();
|
||||||
try {
|
Reader in = new InputStreamReader(xmlStream, "UTF-8");
|
||||||
xmlStream = XMLTest.class.getClassLoader().getResourceAsStream("Issue593.xml");
|
for (int numRead; (numRead = in.read(buffer, 0, buffer.length)) > 0; ) {
|
||||||
int bufferSize = 1024;
|
expected.append(buffer, 0, numRead);
|
||||||
char[] buffer = new char[bufferSize];
|
|
||||||
StringBuilder expected = new StringBuilder();
|
|
||||||
Reader in = new InputStreamReader(xmlStream, "UTF-8");
|
|
||||||
for (int numRead; (numRead = in.read(buffer, 0, buffer.length)) > 0; ) {
|
|
||||||
expected.append(buffer, 0, numRead);
|
|
||||||
}
|
|
||||||
assertEquals(expected.toString(), actualString.replaceAll("\\n|\\r\\n", System.getProperty("line.separator")));
|
|
||||||
} finally {
|
|
||||||
if (xmlStream != null) {
|
|
||||||
xmlStream.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
if (jsonStream != null) {
|
|
||||||
jsonStream.close();
|
|
||||||
}
|
}
|
||||||
|
assertEquals(expected.toString(), actualString);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
fail("file writer error: " +e.getMessage());
|
fail("file writer error: " +e.getMessage());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user