List of usage examples for org.springframework.integration.http.inbound HttpRequestHandlingController setReplyKey
public void setReplyKey(String replyKey)
From source file:org.springframework.integration.http.inbound.HttpRequestHandlingControllerTests.java
@Test public void requestReplyWithCustomReplyKey() throws Exception { DirectChannel requestChannel = new DirectChannel(); AbstractReplyProducingMessageHandler handler = new AbstractReplyProducingMessageHandler() { @Override/*from w ww . jav a2 s . c om*/ protected Object handleRequestMessage(Message<?> requestMessage) { return requestMessage.getPayload().toString().toUpperCase(); } }; requestChannel.subscribe(handler); HttpRequestHandlingController controller = new HttpRequestHandlingController(true); controller.setBeanFactory(mock(BeanFactory.class)); controller.setRequestChannel(requestChannel); controller.setViewName("foo"); controller.setReplyKey("myReply"); controller.afterPropertiesSet(); controller.start(); MockHttpServletRequest request = new MockHttpServletRequest(); request.setMethod("POST"); request.setContent("howdy".getBytes()); //request.setContentType("text/plain"); //Works in Spring 3.1.2.RELEASE but NOT in 3.0.7.RELEASE //Instead do: request.addHeader("Content-Type", "text/plain"); MockHttpServletResponse response = new MockHttpServletResponse(); ModelAndView modelAndView = controller.handleRequest(request, response); assertEquals("foo", modelAndView.getViewName()); assertEquals(1, modelAndView.getModel().size()); assertNull(modelAndView.getModel().get("reply")); Object reply = modelAndView.getModel().get("myReply"); assertEquals("HOWDY", reply); }