INT-1677 finished the namespace support for payload-expression attribute and header sub-element, added parser test

This commit is contained in:
Oleg Zhurakousky
2011-09-02 08:26:13 -04:00
committed by Mark Fisher
parent 90a5936803
commit a6c85c1dd9
4 changed files with 81 additions and 0 deletions

View File

@@ -26,5 +26,13 @@
<inbound-channel-adapter id="withMappedHeaders" channel="requests"
mapped-request-headers="foo,bar"/>
<inbound-channel-adapter id="inboundAdapterWithExpressions"
path="/fname/{f}/lname/{l}"
channel="requests"
mapped-request-headers="foo,bar"
payload-expression="#f">
<header name="lname" expression="#l"/>
</inbound-channel-adapter>
</beans:beans>

View File

@@ -72,6 +72,9 @@ public class HttpInboundChannelAdapterParserTests {
@Autowired
private HttpRequestHandlingMessagingGateway withMappedHeaders;
@Autowired
private HttpRequestHandlingMessagingGateway inboundAdapterWithExpressions;
@Autowired
private HttpRequestHandlingController inboundController;
@@ -113,6 +116,27 @@ public class HttpInboundChannelAdapterParserTests {
assertEquals("foo", map.get("foo"));
assertEquals("bar", map.get("bar"));
}
@Test
@SuppressWarnings("unchecked")// INT-1677
public void withExpressions() throws Exception {
MockHttpServletRequest request = new MockHttpServletRequest();
request.setMethod("POST");
request.setContentType("text/plain");
request.setParameter("foo", "bar");
request.setContent("hello".getBytes());
request.setRequestURI("/fname/bill/lname/clinton");
MockHttpServletResponse response = new MockHttpServletResponse();
inboundAdapterWithExpressions.handleRequest(request, response);
assertEquals(HttpServletResponse.SC_OK, response.getStatus());
Message<?> message = requests.receive(0);
assertNotNull(message);
Object payload = message.getPayload();
assertTrue(payload instanceof String);
assertEquals("bill", payload);
assertEquals("clinton", message.getHeaders().get("lname"));
}
@Test
public void getRequestNotAllowed() throws Exception {