Skip to content

Commit

Permalink
Attempt to fix org.apache.cxf.systest.jaxrs.JAXRSMultipartTest.testAd…
Browse files Browse the repository at this point in the history
…dBookMixedMultiValueMapParameter test case on Windows
  • Loading branch information
reta committed Jul 13, 2023
1 parent 70f67d1 commit f90be23
Showing 1 changed file with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,13 @@ public void testAddBookAsListOfStreams() throws Exception {
@Test
public void testAddBookMixedMultiValueMapParameter() throws Exception {
String address = "http://localhost:" + PORT + "/bookstore/books/mixedmultivaluedmap";
doAddBook("multipart/mixed", address, "attachmentFormMixed", 200);

InputStream is = getClass().getResourceAsStream("/org/apache/cxf/systest/jaxrs/resources/attachmentFormMixed");
if (System.getProperty("os.name").startsWith("Windows")) {
is = new NoCarriageReturnFileInputStream(is);
}

doAddBook("multipart/mixed", address, is, 200);
}

@Test
Expand Down Expand Up @@ -1124,4 +1130,25 @@ private String stripXmlInstructionIfNeeded(String str) {
return str;
}

/**
* Windows attachment handling
*/
private static class NoCarriageReturnFileInputStream extends InputStream {
private final InputStream is;

NoCarriageReturnFileInputStream(InputStream is) {
this.is = is;
}

@Override
public int read() throws IOException {
int c;

do {
c = is.read();
} while(c != -1 && c == 13);

return c;
}
}
}

0 comments on commit f90be23

Please sign in to comment.