private MultipartHttpServletRequest getMockedMultipartHttpServletRequest(final String body) throws IOException { final HttpServletRequest httpServletRequest = Mockito.mock(HttpServletRequest.class); final HttpServletRequest httpServletRequestWrapper = new HttpServletRequestTest(httpServletRequest, body); final MultipartHttpServletRequest multipartHttpServletRequest = Mockito.mock(MultipartHttpServletRequest.class); when(multipartHttpServletRequest.getRequestURI()).thenReturn(CONTEXT + SLASH + MOCK + SLASH + SOAP + SLASH + PROJECT + SLASH + PROJECT_ID + SLASH + SOAP_PORT_ID); String contextType = "multipart/related; type=\"text/xml\"; start=\"<test@castlemock.org>\"; boundary=\"----=_Part_64_1526053806.1517665317492\""; when(multipartHttpServletRequest.getContentType()).thenReturn(contextType); when(multipartHttpServletRequest.getReader()).thenReturn(httpServletRequestWrapper.getReader()); Enumeration<String> parameterName = Mockito.mock(Enumeration.class); Enumeration<String> headerNames = Collections.enumeration(Arrays.asList("Content-Type", "Accept")); when(multipartHttpServletRequest.getParameterNames()).thenReturn(parameterName); when(multipartHttpServletRequest.getHeaderNames()).thenReturn(headerNames); when(multipartHttpServletRequest.getHeader(contextType)).thenReturn(APPLICATION_XML); when(multipartHttpServletRequest.getHeader(ACCEPT_HEADER)).thenReturn(APPLICATION_XML); when(multipartHttpServletRequest.getMethod()).thenReturn("POST"); return multipartHttpServletRequest; }