INT-1767 using MediaType.ALL as the default Accept when writing a response in HttpRequestHandlingMessagingGateway

This commit is contained in:
Mark Fisher
2011-01-26 18:56:07 -05:00
parent 403855fea6
commit 1857d5b6c0
2 changed files with 27 additions and 2 deletions

View File

@@ -108,6 +108,26 @@ public class HttpRequestHandlingMessagingGatewayTests {
assertEquals("HELLO", response.getContentAsString());
}
@Test // INT-1767
public void noAcceptHeaderOnRequest() throws Exception {
DirectChannel requestChannel = new DirectChannel();
requestChannel.subscribe(new AbstractReplyProducingMessageHandler() {
protected Object handleRequestMessage(Message<?> requestMessage) {
return requestMessage.getPayload().toString().toUpperCase();
}
});
HttpRequestHandlingMessagingGateway gateway = new HttpRequestHandlingMessagingGateway(true);
gateway.setRequestPayloadType(String.class);
gateway.setRequestChannel(requestChannel);
MockHttpServletRequest request = new MockHttpServletRequest();
request.setMethod("POST");
request.setContentType("text/plain");
request.setContent("hello".getBytes());
MockHttpServletResponse response = new MockHttpServletResponse();
gateway.handleRequest(request, response);
assertEquals("HELLO", response.getContentAsString());
}
@Test
public void testExceptionConversion() throws Exception {
QueueChannel requestChannel = new QueueChannel() {