Fix XMLTest on Windows

XMLTest.testIndentComplicatedJsonObjectWithArrayAndWithConfig fails
when run on Windows due to mismatching linebreaks (that aren't
important for the test's functionality) between the actual and
expected strings.

For the actual strings, linebreaks are canonized to the platform's
native linebreak using `replaceAll("\\n|\\r\\n",
System.getProperty("line.separator")`. However, the expected result is
read from a file, and is left with the linebreaks that were originally
used to create it.

The solution is to perform the same canonization on both strings.

Closes #781
This commit is contained in:
Allon Mureinik 2023-10-05 15:29:51 +03:00
parent 79af389f7a
commit fe45fa9cfb

View File

@ -1239,7 +1239,8 @@ public class XMLTest {
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")));
assertEquals(expected.toString().replaceAll("\\n|\\r\\n", System.getProperty("line.separator")),
actualString.replaceAll("\\n|\\r\\n", System.getProperty("line.separator")));
} finally {
if (xmlStream != null) {
xmlStream.close();