protected static MockHttpServletRequest constructPropfindRequest(Propfind propfind,
String requestURI,
int depth) throws IOException {
MockHttpServletRequest mockRequest = new MockHttpServletRequestWrapper() {
public String getPathTranslated() {
return null; // prevent Spring to resolve the file on the file
// system which fails
}
};
// headers
mockRequest.setMethod(WebDAVMethod.PROPFIND.name());
mockRequest.setRequestURI(requestURI);
mockRequest.setContentType(MediaType.APPLICATION_XML);
if (depth >= 0) {
mockRequest.addHeader(WebDAVHeaders.DEPTH, String.valueOf(depth));
}
// body
StringWriter writer = new StringWriter();
Propfind.marshal(propfind, writer);
mockRequest.setContent(writer.toString().getBytes());
return mockRequest;
}