|
|
|
@ -5,7 +5,7 @@ |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* You may obtain a copy of the License at |
|
|
|
* You may obtain a copy of the License at |
|
|
|
* |
|
|
|
* |
|
|
|
* http://www.apache.org/licensesch/LICENSE-2.0
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
* |
|
|
|
* |
|
|
|
* Unless required by applicable law or agreed to in writing, software |
|
|
|
* Unless required by applicable law or agreed to in writing, software |
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
|
|
|
@ -970,6 +970,7 @@ public class ServletAnnotationControllerTests { |
|
|
|
request.addHeader("Accept", "text/*"); |
|
|
|
request.addHeader("Accept", "text/*"); |
|
|
|
MockHttpServletResponse response = new MockHttpServletResponse(); |
|
|
|
MockHttpServletResponse response = new MockHttpServletResponse(); |
|
|
|
servlet.service(request, response); |
|
|
|
servlet.service(request, response); |
|
|
|
|
|
|
|
assertEquals(200, response.getStatus()); |
|
|
|
assertEquals(requestBody, response.getContentAsString()); |
|
|
|
assertEquals(requestBody, response.getContentAsString()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -1016,6 +1017,20 @@ public class ServletAnnotationControllerTests { |
|
|
|
assertNotNull("No Accept response header set", response.getHeader("Accept")); |
|
|
|
assertNotNull("No Accept response header set", response.getHeader("Accept")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
|
|
public void responseBodyNoAcceptHeader() throws ServletException, IOException { |
|
|
|
|
|
|
|
initServlet(RequestBodyController.class); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MockHttpServletRequest request = new MockHttpServletRequest("PUT", "/something"); |
|
|
|
|
|
|
|
String requestBody = "Hello World"; |
|
|
|
|
|
|
|
request.setContent(requestBody.getBytes("UTF-8")); |
|
|
|
|
|
|
|
request.addHeader("Content-Type", "text/plain; charset=utf-8"); |
|
|
|
|
|
|
|
MockHttpServletResponse response = new MockHttpServletResponse(); |
|
|
|
|
|
|
|
servlet.service(request, response); |
|
|
|
|
|
|
|
assertEquals(200, response.getStatus()); |
|
|
|
|
|
|
|
assertEquals(requestBody, response.getContentAsString()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void badRequestRequestBody() throws ServletException, IOException { |
|
|
|
public void badRequestRequestBody() throws ServletException, IOException { |
|
|
|
@SuppressWarnings("serial") DispatcherServlet servlet = new DispatcherServlet() { |
|
|
|
@SuppressWarnings("serial") DispatcherServlet servlet = new DispatcherServlet() { |
|
|
|
|