From 98b46c61f30a044b04daf8a3139ba6d8a7d63754 Mon Sep 17 00:00:00 2001 From: Biju Kunjummen Date: Tue, 11 Mar 2014 22:32:28 -0400 Subject: [PATCH] INT-3323: Add poller element to HTTP-outbound JIRA: https://jira.spring.io/browse/INT-3323 Poller is internally supported in the bean definition of an http outbound gateway and outbound adapter, but it is not supported by their schema. This change attempts to fix the schema. * Added in schema element for base poller, in both outbound adapter and outbound gateway * Added in tests to ensure that a PollingConsumer is the instance type * Polishing `import` for test classes --- .../config/spring-integration-http-4.0.xsd | 6 ++- ...boundChannelAdapterParserTests-context.xml | 36 ++++++++++++++++++ ...HttpOutboundChannelAdapterParserTests.java | 14 ++++++- ...HttpOutboundGatewayParserTests-context.xml | 37 +++++++++++++++++++ .../HttpOutboundGatewayParserTests.java | 14 ++++++- 5 files changed, 103 insertions(+), 4 deletions(-) diff --git a/spring-integration-http/src/main/resources/org/springframework/integration/http/config/spring-integration-http-4.0.xsd b/spring-integration-http/src/main/resources/org/springframework/integration/http/config/spring-integration-http-4.0.xsd index f51f0afb4c..46a29c940e 100644 --- a/spring-integration-http/src/main/resources/org/springframework/integration/http/config/spring-integration-http-4.0.xsd +++ b/spring-integration-http/src/main/resources/org/springframework/integration/http/config/spring-integration-http-4.0.xsd @@ -317,7 +317,7 @@ - + @@ -327,6 +327,7 @@ + @@ -352,7 +353,7 @@ - + @@ -361,6 +362,7 @@ + diff --git a/spring-integration-http/src/test/java/org/springframework/integration/http/config/HttpOutboundChannelAdapterParserTests-context.xml b/spring-integration-http/src/test/java/org/springframework/integration/http/config/HttpOutboundChannelAdapterParserTests-context.xml index 17f4fcb0e5..0748a3b255 100644 --- a/spring-integration-http/src/test/java/org/springframework/integration/http/config/HttpOutboundChannelAdapterParserTests-context.xml +++ b/spring-integration-http/src/test/java/org/springframework/integration/http/config/HttpOutboundChannelAdapterParserTests-context.xml @@ -32,6 +32,7 @@ order="77" auto-startup="false"> + @@ -56,6 +57,41 @@ url-expression="'http://localhost/test1'" channel="requests" rest-template="customRestTemplate"/> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-integration-http/src/test/java/org/springframework/integration/http/config/HttpOutboundChannelAdapterParserTests.java b/spring-integration-http/src/test/java/org/springframework/integration/http/config/HttpOutboundChannelAdapterParserTests.java index 1a5e33641d..236da46498 100644 --- a/spring-integration-http/src/test/java/org/springframework/integration/http/config/HttpOutboundChannelAdapterParserTests.java +++ b/spring-integration-http/src/test/java/org/springframework/integration/http/config/HttpOutboundChannelAdapterParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,11 +21,13 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import java.io.IOException; import java.util.Map; +import org.hamcrest.Matchers; import org.junit.Test; import org.junit.runner.RunWith; @@ -41,6 +43,7 @@ import org.springframework.http.HttpMethod; import org.springframework.http.client.ClientHttpRequestFactory; import org.springframework.http.client.ClientHttpResponse; import org.springframework.http.client.SimpleClientHttpRequestFactory; +import org.springframework.integration.endpoint.PollingConsumer; import org.springframework.messaging.Message; import org.springframework.messaging.MessageHandler; import org.springframework.integration.endpoint.AbstractEndpoint; @@ -59,6 +62,7 @@ import org.springframework.web.client.RestTemplate; * @author Gary Russell * @author Gunnar Hillert * @author Artem Bilan + * @author Biju Kunjummen */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration @@ -88,6 +92,9 @@ public class HttpOutboundChannelAdapterParserTests { @Autowired @Qualifier("withUrlExpressionAndTemplate") private AbstractEndpoint withUrlExpressionAndTemplate; + @Autowired @Qualifier("withPoller1") + private AbstractEndpoint withPoller1; + @Autowired private ApplicationContext applicationContext; @@ -250,6 +257,11 @@ public class HttpOutboundChannelAdapterParserTests { assertEquals(true, handlerAccessor.getPropertyValue("extractPayload")); } + @Test + public void withPoller() { + assertThat(this.withPoller1, Matchers.instanceOf(PollingConsumer.class)); + } + @Test(expected=BeanDefinitionParsingException.class) public void failWithUrlAndExpression() { new ClassPathXmlApplicationContext("HttpOutboundChannelAdapterParserTests-url-fail-context.xml", this.getClass()); diff --git a/spring-integration-http/src/test/java/org/springframework/integration/http/config/HttpOutboundGatewayParserTests-context.xml b/spring-integration-http/src/test/java/org/springframework/integration/http/config/HttpOutboundGatewayParserTests-context.xml index f2abb0d2d3..6704b2d5e1 100644 --- a/spring-integration-http/src/test/java/org/springframework/integration/http/config/HttpOutboundGatewayParserTests-context.xml +++ b/spring-integration-http/src/test/java/org/springframework/integration/http/config/HttpOutboundGatewayParserTests-context.xml @@ -40,6 +40,7 @@ + @@ -54,6 +55,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-integration-http/src/test/java/org/springframework/integration/http/config/HttpOutboundGatewayParserTests.java b/spring-integration-http/src/test/java/org/springframework/integration/http/config/HttpOutboundGatewayParserTests.java index e532aef845..a42109e963 100644 --- a/spring-integration-http/src/test/java/org/springframework/integration/http/config/HttpOutboundGatewayParserTests.java +++ b/spring-integration-http/src/test/java/org/springframework/integration/http/config/HttpOutboundGatewayParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,12 +19,14 @@ package org.springframework.integration.http.config; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import java.io.IOException; import java.util.Map; +import org.hamcrest.Matchers; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.BeansException; @@ -40,6 +42,7 @@ import org.springframework.http.HttpMethod; import org.springframework.http.client.ClientHttpRequestFactory; import org.springframework.http.client.ClientHttpResponse; import org.springframework.http.client.SimpleClientHttpRequestFactory; +import org.springframework.integration.endpoint.PollingConsumer; import org.springframework.messaging.Message; import org.springframework.messaging.MessageChannel; import org.springframework.integration.endpoint.AbstractEndpoint; @@ -56,6 +59,7 @@ import org.springframework.web.client.ResponseErrorHandler; * @author Mark Fisher * @author Gary Russell * @author Artem Bilan + * @author Biju Kunjummen */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration @@ -73,6 +77,9 @@ public class HttpOutboundGatewayParserTests { @Autowired @Qualifier("withAdvice") private AbstractEndpoint withAdvice; + @Autowired @Qualifier("withPoller1") + private AbstractEndpoint withPoller1; + @Autowired private ApplicationContext applicationContext; @@ -200,6 +207,11 @@ public class HttpOutboundGatewayParserTests { } } + @Test + public void withPoller() { + assertThat(this.withPoller1, Matchers.instanceOf(PollingConsumer.class)); + } + public static class StubErrorHandler implements ResponseErrorHandler {