@@ -54,10 +54,7 @@ public void testDoGetCore() throws Exception {
5454
5555 webStartServlet .doGet (request , response );
5656
57- assertEquals (
58- CORE_JNLP .trim ().replaceAll ("\\ s+" , "" ),
59- response .getResponseString ().trim ().replaceAll ("\\ s+" , "" )
60- );
57+ assertEquals (normalizeWhitespace (CORE_JNLP ), normalizeWhitespace (response .getResponseString ()));
6158 assertEquals ("application/x-java-jnlp-file" , response .getContentType ());
6259 assertEquals ("no-cache" , response .getHeader ("Pragma" ));
6360 assertEquals ("nosniff" , response .getHeader ("X-Content-Type-Options" ));
@@ -73,10 +70,7 @@ public void testDoGetCore() throws Exception {
7370
7471 webStartServlet .doGet (request , response );
7572
76- assertEquals (
77- CORE_JNLP .trim ().replaceAll ("\\ s+" , "" ),
78- response .getResponseString ().trim ().replaceAll ("\\ s+" , "" )
79- );
73+ assertEquals (normalizeWhitespace (CORE_JNLP ), normalizeWhitespace (response .getResponseString ()));
8074 assertEquals ("application/x-java-jnlp-file" , response .getContentType ());
8175 assertEquals ("no-cache" , response .getHeader ("Pragma" ));
8276 assertEquals ("nosniff" , response .getHeader ("X-Content-Type-Options" ));
@@ -106,10 +100,7 @@ public String answer(InvocationOnMock invocation) throws Throwable {
106100
107101 webStartServlet .doGet (request , response );
108102
109- assertEquals (
110- CORE_JNLP .trim ().replaceAll ("\\ s+" , "" ),
111- response .getResponseString ().trim ().replaceAll ("\\ s+" , "" )
112- );
103+ assertEquals (normalizeWhitespace (CORE_JNLP ), normalizeWhitespace (response .getResponseString ()));
113104 assertEquals ("application/x-java-jnlp-file" , response .getContentType ());
114105 assertEquals ("attachment; filename = \" webstart.jnlp\" " , response .getHeader ("Content-Disposition" ));
115106 }
@@ -225,10 +216,7 @@ public void testDoGetExtension() throws Exception {
225216
226217 webStartServlet .doGet (request , response );
227218
228- assertEquals (
229- EXTENSION_JNLP .trim ().replaceAll ("\\ s+" , "" ),
230- response .getResponseString ().trim ().replaceAll ("\\ s+" , "" )
231- );
219+ assertEquals (normalizeWhitespace (EXTENSION_JNLP ), normalizeWhitespace (response .getResponseString ()));
232220 assertEquals ("application/x-java-jnlp-file" , response .getContentType ());
233221 assertEquals ("no-cache" , response .getHeader ("Pragma" ));
234222 assertEquals ("nosniff" , response .getHeader ("X-Content-Type-Options" ));
@@ -245,10 +233,7 @@ public void testDoGetExtension() throws Exception {
245233
246234 webStartServlet .doGet (request , response );
247235
248- assertEquals (
249- EXTENSION_JNLP .trim ().replaceAll ("\\ s+" , "" ),
250- response .getResponseString ().trim ().replaceAll ("\\ s+" , "" )
251- );
236+ assertEquals (normalizeWhitespace (EXTENSION_JNLP ), normalizeWhitespace (response .getResponseString ()));
252237 assertEquals ("application/x-java-jnlp-file" , response .getContentType ());
253238 assertEquals ("no-cache" , response .getHeader ("Pragma" ));
254239 assertEquals ("nosniff" , response .getHeader ("X-Content-Type-Options" ));
@@ -551,6 +536,12 @@ private static DocumentBuilderFactory getSecureDocumentBuilderFactory() throws E
551536 return dbf ;
552537 }
553538
539+ private static String normalizeWhitespace (String input ) {
540+ // normalize whitespace (including new lines) to a single space
541+ // (the round-trip munges newlines depending on OS and on the phase of the moon)
542+ return input .trim ().replaceAll ("[\\ s\\ r\\ n ]+" , " " );
543+ }
544+
554545 private static String CORE_JNLP = "<jnlp codebase=\" https://localhost:8443\" version=\" 4.5.2\" >\n "
555546 + " <information>\n " + " <title>Mirth Connect Administrator 4.5.2</title>\n "
556547 + " <vendor>NextGen Healthcare</vendor>\n " + " <homepage href=\" http://www.nextgen.com\" />\n "
0 commit comments