log WARN message for irrelevant extractPayload
Added a WARN log message to HttpRequestExecutingMessageHandler. The warn message will let the user know that the 'extractPayload' attribute is meaningless if the provided 'httpMethod' will not send a request body.
This commit is contained in:
committed by
Mark Fisher
parent
d9d3c14a6c
commit
bb8409f96f
@@ -530,6 +530,35 @@ public class HttpRequestExecutingMessageHandlerTests {
|
||||
assertEquals(MediaType.TEXT_XML, request.getHeaders().getContentType());
|
||||
}
|
||||
|
||||
@Test // no asertions just a warn message in a log
|
||||
public void testWarnMessageForNonPostPutAndExtractPayload() throws Exception {
|
||||
// should see a warn message
|
||||
|
||||
HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler("http://www.springsource.org/spring-integration");
|
||||
MockRestTemplate template = new MockRestTemplate();
|
||||
new DirectFieldAccessor(handler).setPropertyValue("restTemplate", template);
|
||||
handler.setHttpMethod(HttpMethod.GET);
|
||||
handler.setExtractPayload(true);
|
||||
handler.afterPropertiesSet();
|
||||
|
||||
// should not see a warn message since 'setExtractPayload' is not set explicitly
|
||||
|
||||
handler = new HttpRequestExecutingMessageHandler("http://www.springsource.org/spring-integration");
|
||||
template = new MockRestTemplate();
|
||||
new DirectFieldAccessor(handler).setPropertyValue("restTemplate", template);
|
||||
handler.setHttpMethod(HttpMethod.GET);
|
||||
handler.afterPropertiesSet();
|
||||
|
||||
// should not see a warn message since HTTP method is not GET
|
||||
|
||||
handler = new HttpRequestExecutingMessageHandler("http://www.springsource.org/spring-integration");
|
||||
template = new MockRestTemplate();
|
||||
new DirectFieldAccessor(handler).setPropertyValue("restTemplate", template);
|
||||
handler.setHttpMethod(HttpMethod.POST);
|
||||
handler.setExtractPayload(true);
|
||||
handler.afterPropertiesSet();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void contentTypeIsNotSetForGetRequest() throws Exception {
|
||||
//GET
|
||||
|
||||
Reference in New Issue
Block a user