INT-3426: Add <r-h-a-c> for all outbound-c-a
JIRA: https://jira.spring.io/browse/INT-3426 Provide other fixes for XSD. E.g. not all adapter have had `<poller>`
This commit is contained in:
@@ -1133,6 +1133,7 @@
|
||||
<xsd:all>
|
||||
<xsd:element name="poller" type="basePollerType" minOccurs="0" maxOccurs="1" />
|
||||
<xsd:element ref="beans:bean" minOccurs="0" maxOccurs="1" />
|
||||
<xsd:element name="request-handler-advice-chain" type="handlerAdviceChainType" minOccurs="0" maxOccurs="1" />
|
||||
</xsd:all>
|
||||
<xsd:attributeGroup ref="channelAdapterAttributes" />
|
||||
<xsd:attribute name="order">
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd">
|
||||
|
||||
<channel id="channel"/>
|
||||
|
||||
|
||||
<channel id="channelB">
|
||||
<queue capacity="2"/>
|
||||
</channel>
|
||||
@@ -22,10 +22,13 @@
|
||||
|
||||
<outbound-channel-adapter id="adapterB" channel="channelB" method="out" order="99" auto-startup="false">
|
||||
<beans:bean class="org.springframework.integration.config.xml.DefaultOutboundChannelAdapterParserTests$TestBean"/>
|
||||
<poller task-executor="executor" max-messages-per-poll="5" fixed-delay="20" />
|
||||
<poller task-executor="executor" max-messages-per-poll="5" fixed-delay="20" />
|
||||
<request-handler-advice-chain>
|
||||
<retry-advice/>
|
||||
</request-handler-advice-chain>
|
||||
</outbound-channel-adapter>
|
||||
|
||||
<task:executor id="executor" pool-size="5" />
|
||||
<task:executor id="executor" pool-size="5" />
|
||||
|
||||
<outbound-channel-adapter id="adapterC" channel="channelC" order="99">
|
||||
<beans:bean class="org.springframework.integration.config.TestConsumer"/>
|
||||
|
||||
@@ -16,15 +16,19 @@
|
||||
|
||||
package org.springframework.integration.config.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.aop.support.AopUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.integration.config.TestConsumer;
|
||||
import org.springframework.integration.handler.MethodInvokingMessageHandler;
|
||||
import org.springframework.integration.handler.advice.RequestHandlerRetryAdvice;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
@@ -59,14 +63,15 @@ public class DefaultOutboundChannelAdapterParserTests {
|
||||
assertEquals(MethodInvokingMessageHandler.class, handler.getClass());
|
||||
assertEquals(99, TestUtils.getPropertyValue(handler, "order"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void checkConfigWithInnerBeanAndPoller() {
|
||||
Object adapter = context.getBean("adapterB");
|
||||
assertEquals(Boolean.FALSE, TestUtils.getPropertyValue(adapter, "autoStartup"));
|
||||
Object handler = TestUtils.getPropertyValue(adapter, "handler");
|
||||
assertEquals(MethodInvokingMessageHandler.class, handler.getClass());
|
||||
assertEquals(99, TestUtils.getPropertyValue(handler, "order"));
|
||||
assertTrue(AopUtils.isAopProxy(handler));
|
||||
assertThat(TestUtils.getPropertyValue(handler, "h.advised.advisors.first.item.advice"),
|
||||
Matchers.instanceOf(RequestHandlerRetryAdvice.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -80,9 +80,11 @@
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:all>
|
||||
<xsd:element ref="integration:poller" minOccurs="0" maxOccurs="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:element name="request-handler-advice-chain" type="integration:handlerAdviceChainType"
|
||||
minOccurs="0" maxOccurs="1" />
|
||||
</xsd:all>
|
||||
<xsd:attributeGroup ref="coreMqttComponentAttributes"/>
|
||||
<xsd:attribute name="channel" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
|
||||
@@ -11,15 +11,19 @@
|
||||
<int:channel id="target"/>
|
||||
|
||||
<int-mqtt:outbound-channel-adapter id="withConverter"
|
||||
client-id="foo"
|
||||
url="tcp://localhost:1883"
|
||||
auto-startup="false"
|
||||
converter="myConverter"
|
||||
client-factory="clientFactory"
|
||||
default-topic="bar"
|
||||
phase="25"
|
||||
order="1"
|
||||
channel="target" />
|
||||
client-id="foo"
|
||||
url="tcp://localhost:1883"
|
||||
auto-startup="false"
|
||||
converter="myConverter"
|
||||
client-factory="clientFactory"
|
||||
default-topic="bar"
|
||||
phase="25"
|
||||
order="1"
|
||||
channel="target">
|
||||
<int-mqtt:request-handler-advice-chain>
|
||||
<int:retry-advice/>
|
||||
</int-mqtt:request-handler-advice-chain>
|
||||
</int-mqtt:outbound-channel-adapter>
|
||||
|
||||
<int-mqtt:outbound-channel-adapter id="withDefaultConverter"
|
||||
client-id="foo"
|
||||
|
||||
@@ -13,37 +13,44 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.mqtt.config.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.aop.framework.Advised;
|
||||
import org.springframework.aop.support.AopUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.integration.endpoint.EventDrivenConsumer;
|
||||
import org.springframework.integration.handler.advice.RequestHandlerRetryAdvice;
|
||||
import org.springframework.integration.mqtt.core.DefaultMqttPahoClientFactory;
|
||||
import org.springframework.integration.mqtt.outbound.MqttPahoMessageHandler;
|
||||
import org.springframework.integration.mqtt.support.DefaultPahoMessageConverter;
|
||||
import org.springframework.integration.mqtt.support.MqttMessageConverter;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @since 4.0
|
||||
*
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class MqttOutboundChannelAdapterParserTests {
|
||||
|
||||
@Autowired @Qualifier("withConverter")
|
||||
private EventDrivenConsumer withConverterEndpoint;
|
||||
|
||||
@Autowired @Qualifier("withConverter.handler")
|
||||
private MqttPahoMessageHandler withConverterHandler;
|
||||
private MessageHandler withConverterHandler;
|
||||
|
||||
@Autowired @Qualifier("withDefaultConverter.handler")
|
||||
private MqttPahoMessageHandler withDefaultConverterHandler;
|
||||
@@ -55,7 +62,7 @@ public class MqttOutboundChannelAdapterParserTests {
|
||||
private DefaultMqttPahoClientFactory clientFactory;
|
||||
|
||||
@Test
|
||||
public void testWithConverter() {
|
||||
public void testWithConverter() throws Exception {
|
||||
assertEquals("tcp://localhost:1883", TestUtils.getPropertyValue(withConverterHandler, "url"));
|
||||
assertFalse(TestUtils.getPropertyValue(withConverterHandler, "autoStartup", Boolean.class));
|
||||
assertEquals(25, TestUtils.getPropertyValue(withConverterHandler, "phase"));
|
||||
@@ -63,6 +70,15 @@ public class MqttOutboundChannelAdapterParserTests {
|
||||
assertEquals("bar", TestUtils.getPropertyValue(withConverterHandler, "defaultTopic"));
|
||||
assertSame(converter, TestUtils.getPropertyValue(withConverterHandler, "converter"));
|
||||
assertSame(clientFactory, TestUtils.getPropertyValue(withConverterHandler, "clientFactory"));
|
||||
|
||||
Object handler = TestUtils.getPropertyValue(this.withConverterEndpoint, "handler");
|
||||
|
||||
assertTrue(AopUtils.isAopProxy(handler));
|
||||
|
||||
assertSame(((Advised) handler).getTargetSource().getTarget(), this.withConverterHandler);
|
||||
|
||||
assertThat(TestUtils.getPropertyValue(handler, "h.advised.advisors.first.item.advice"),
|
||||
Matchers.instanceOf(RequestHandlerRetryAdvice.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -203,9 +203,11 @@
|
||||
<xsd:complexType>
|
||||
<xsd:complexContent>
|
||||
<xsd:extension base="redisAdapterType">
|
||||
<xsd:sequence>
|
||||
<xsd:all>
|
||||
<xsd:element ref="integration:poller" minOccurs="0" maxOccurs="1"/>
|
||||
</xsd:sequence>
|
||||
<xsd:element name="request-handler-advice-chain" type="integration:handlerAdviceChainType"
|
||||
minOccurs="0" maxOccurs="1" />
|
||||
</xsd:all>
|
||||
<xsd:attribute name="topic" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
@@ -296,6 +298,11 @@
|
||||
<xsd:complexType>
|
||||
<xsd:complexContent>
|
||||
<xsd:extension base="redisAdapterType">
|
||||
<xsd:all>
|
||||
<xsd:element ref="integration:poller" minOccurs="0" maxOccurs="1" />
|
||||
<xsd:element name="request-handler-advice-chain" type="integration:handlerAdviceChainType"
|
||||
minOccurs="0" maxOccurs="1" />
|
||||
</xsd:all>
|
||||
<xsd:attributeGroup ref="storeAdapterAttributeGroup"/>
|
||||
<xsd:attribute name="redis-template" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
@@ -410,9 +417,11 @@
|
||||
<xsd:complexType>
|
||||
<xsd:complexContent>
|
||||
<xsd:extension base="redisAdapterType">
|
||||
<xsd:sequence>
|
||||
<xsd:element ref="integration:poller" minOccurs="0" maxOccurs="1"/>
|
||||
</xsd:sequence>
|
||||
<xsd:all>
|
||||
<xsd:element ref="integration:poller" minOccurs="0" maxOccurs="1" />
|
||||
<xsd:element name="request-handler-advice-chain" type="integration:handlerAdviceChainType"
|
||||
minOccurs="0" maxOccurs="1" />
|
||||
</xsd:all>
|
||||
<xsd:attribute name="queue" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
@@ -472,7 +481,8 @@
|
||||
<xsd:complexType>
|
||||
<xsd:choice minOccurs="0" maxOccurs="2">
|
||||
<xsd:element ref="integration:poller" minOccurs="0" maxOccurs="1"/>
|
||||
<xsd:element name="request-handler-advice-chain" type="integration:adviceChainType" minOccurs="0" maxOccurs="1" />
|
||||
<xsd:element name="request-handler-advice-chain" type="integration:handlerAdviceChainType"
|
||||
minOccurs="0" maxOccurs="1" />
|
||||
</xsd:choice>
|
||||
<xsd:attributeGroup ref="integration:smartLifeCycleAttributeGroup"/>
|
||||
<xsd:attribute name="connection-factory" type="xsd:string">
|
||||
|
||||
@@ -10,10 +10,14 @@
|
||||
<int:channel id="sendChannel"/>
|
||||
|
||||
<int-redis:outbound-channel-adapter id="outboundAdapter"
|
||||
channel="sendChannel"
|
||||
topic-expression="headers['topic'] ?: 'foo'"
|
||||
message-converter="testConverter"
|
||||
serializer="serializer"/>
|
||||
channel="sendChannel"
|
||||
topic-expression="headers['topic'] ?: 'foo'"
|
||||
message-converter="testConverter"
|
||||
serializer="serializer">
|
||||
<int-redis:request-handler-advice-chain>
|
||||
<int:retry-advice/>
|
||||
</int-redis:request-handler-advice-chain>
|
||||
</int-redis:outbound-channel-adapter>
|
||||
|
||||
<int-redis:inbound-channel-adapter id="fooInbound" channel="receiveChannel" topics="foo"/>
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -16,13 +16,14 @@
|
||||
|
||||
package org.springframework.integration.redis.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.aop.framework.Advised;
|
||||
import org.springframework.aop.support.AopUtils;
|
||||
import org.springframework.beans.DirectFieldAccessor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
@@ -30,6 +31,7 @@ import org.springframework.data.redis.listener.RedisMessageListenerContainer;
|
||||
import org.springframework.expression.Expression;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.endpoint.EventDrivenConsumer;
|
||||
import org.springframework.integration.handler.advice.RequestHandlerRetryAdvice;
|
||||
import org.springframework.integration.redis.inbound.RedisInboundChannelAdapter;
|
||||
import org.springframework.integration.redis.outbound.RedisPublishingMessageHandler;
|
||||
import org.springframework.integration.redis.rules.RedisAvailable;
|
||||
@@ -65,8 +67,8 @@ public class RedisOutboundChannelAdapterParserTests extends RedisAvailableTests
|
||||
@RedisAvailable
|
||||
public void validateConfiguration() {
|
||||
EventDrivenConsumer adapter = context.getBean("outboundAdapter", EventDrivenConsumer.class);
|
||||
RedisPublishingMessageHandler handler = (RedisPublishingMessageHandler)
|
||||
new DirectFieldAccessor(adapter).getPropertyValue("handler");
|
||||
Object handler = context.getBean("outboundAdapter.handler");
|
||||
|
||||
assertEquals("outboundAdapter", adapter.getComponentName());
|
||||
DirectFieldAccessor accessor = new DirectFieldAccessor(handler);
|
||||
Object topicExpression = accessor.getPropertyValue("topicExpression");
|
||||
@@ -77,6 +79,13 @@ public class RedisOutboundChannelAdapterParserTests extends RedisAvailableTests
|
||||
assertEquals(context.getBean("serializer"), accessor.getPropertyValue("serializer"));
|
||||
Object mbf = context.getBean(IntegrationUtils.INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME);
|
||||
assertSame(mbf, TestUtils.getPropertyValue(handler, "messageConverter.messageBuilderFactory"));
|
||||
|
||||
Object endpointHandler = TestUtils.getPropertyValue(adapter, "handler");
|
||||
|
||||
assertTrue(AopUtils.isAopProxy(endpointHandler));
|
||||
|
||||
assertThat(TestUtils.getPropertyValue(endpointHandler, "h.advised.advisors.first.item.advice"),
|
||||
Matchers.instanceOf(RequestHandlerRetryAdvice.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -16,7 +16,11 @@
|
||||
|
||||
<int:channel id="sendChannel"/>
|
||||
|
||||
<int-redis:queue-outbound-channel-adapter id="defaultAdapter" channel="sendChannel" queue="foo"/>
|
||||
<int-redis:queue-outbound-channel-adapter id="defaultAdapter" channel="sendChannel" queue="foo">
|
||||
<int-redis:request-handler-advice-chain>
|
||||
<int:retry-advice/>
|
||||
</int-redis:request-handler-advice-chain>
|
||||
</int-redis:queue-outbound-channel-adapter>
|
||||
|
||||
<int-redis:queue-outbound-channel-adapter id="customAdapter" channel="sendChannel"
|
||||
queue-expression="headers['redis_queue']"
|
||||
|
||||
@@ -16,19 +16,21 @@
|
||||
|
||||
package org.springframework.integration.redis.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.aop.framework.Advised;
|
||||
import org.springframework.aop.support.AopUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.serializer.RedisSerializer;
|
||||
import org.springframework.expression.Expression;
|
||||
import org.springframework.integration.endpoint.EventDrivenConsumer;
|
||||
import org.springframework.integration.handler.advice.RequestHandlerRetryAdvice;
|
||||
import org.springframework.integration.redis.outbound.RedisQueueOutboundChannelAdapter;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
@@ -50,6 +52,10 @@ public class RedisQueueOutboundChannelAdapterParserTests {
|
||||
@Qualifier("customRedisConnectionFactory")
|
||||
private RedisConnectionFactory customRedisConnectionFactory;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("defaultAdapter")
|
||||
private EventDrivenConsumer defaultEndpoint;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("defaultAdapter.handler")
|
||||
private RedisQueueOutboundChannelAdapter defaultAdapter;
|
||||
@@ -62,11 +68,20 @@ public class RedisQueueOutboundChannelAdapterParserTests {
|
||||
private RedisSerializer<?> serializer;
|
||||
|
||||
@Test
|
||||
public void testInt3017DefaultConfig() {
|
||||
public void testInt3017DefaultConfig() throws Exception {
|
||||
assertSame(this.connectionFactory, TestUtils.getPropertyValue(this.defaultAdapter, "template.connectionFactory"));
|
||||
assertEquals("foo", TestUtils.getPropertyValue(this.defaultAdapter, "queueNameExpression", Expression.class).getExpressionString());
|
||||
assertTrue(TestUtils.getPropertyValue(this.defaultAdapter, "extractPayload", Boolean.class));
|
||||
assertFalse(TestUtils.getPropertyValue(this.defaultAdapter, "serializerExplicitlySet", Boolean.class));
|
||||
|
||||
Object handler = TestUtils.getPropertyValue(this.defaultEndpoint, "handler");
|
||||
|
||||
assertTrue(AopUtils.isAopProxy(handler));
|
||||
|
||||
assertSame(((Advised) handler).getTargetSource().getTarget(), this.defaultAdapter);
|
||||
|
||||
assertThat(TestUtils.getPropertyValue(handler, "h.advised.advisors.first.item.advice"),
|
||||
Matchers.instanceOf(RequestHandlerRetryAdvice.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -22,7 +22,11 @@
|
||||
<int-redis:store-outbound-channel-adapter id="withStringTemplate"
|
||||
collection-type="${collection.type}"
|
||||
key="pepboys"
|
||||
auto-startup="false"/>
|
||||
auto-startup="false">
|
||||
<int-redis:request-handler-advice-chain>
|
||||
<int:retry-advice/>
|
||||
</int-redis:request-handler-advice-chain>
|
||||
</int-redis:store-outbound-channel-adapter>
|
||||
|
||||
<int-redis:store-outbound-channel-adapter id="withStringObjectTemplate"
|
||||
collection-type="PROPERTIES"
|
||||
@@ -40,9 +44,9 @@
|
||||
<property name="keySerializer" ref="keySerializer"/>
|
||||
<property name="valueSerializer" ref="valueSerializer"/>
|
||||
<property name="hashKeySerializer" ref="hashKeySerializer"/>
|
||||
<property name="hashValueSerializer" ref="hashValueSerializer"/>
|
||||
<property name="hashValueSerializer" ref="hashValueSerializer"/>
|
||||
</bean>
|
||||
|
||||
|
||||
<bean id="redisConnectionFactory" class="org.mockito.Mockito" factory-method="mock">
|
||||
<constructor-arg value="org.springframework.data.redis.connection.RedisConnectionFactory"/>
|
||||
</bean>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2007-2012 the original author or authors
|
||||
* Copyright 2007-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.
|
||||
@@ -16,21 +16,22 @@
|
||||
|
||||
package org.springframework.integration.redis.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.aop.framework.Advised;
|
||||
import org.springframework.aop.support.AopUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.data.redis.serializer.JdkSerializationRedisSerializer;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
import org.springframework.data.redis.support.collections.RedisCollectionFactoryBean.CollectionType;
|
||||
import org.springframework.expression.common.LiteralExpression;
|
||||
import org.springframework.integration.handler.advice.RequestHandlerRetryAdvice;
|
||||
import org.springframework.integration.redis.outbound.RedisStoreWritingMessageHandler;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
@@ -39,6 +40,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
*
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@@ -51,33 +53,52 @@ public class RedisStoreOutboundChannelAdapterParserTests {
|
||||
private RedisTemplate<?,?> redisTemplate;
|
||||
|
||||
@Test
|
||||
public void validateWithStringTemplate(){
|
||||
RedisStoreWritingMessageHandler withStringTemplate =
|
||||
TestUtils.getPropertyValue(context.getBean("withStringTemplate.adapter"), "handler", RedisStoreWritingMessageHandler.class);
|
||||
assertEquals("pepboys", ((LiteralExpression)TestUtils.getPropertyValue(withStringTemplate, "keyExpression")).getExpressionString());
|
||||
assertEquals("PROPERTIES", ((CollectionType)TestUtils.getPropertyValue(withStringTemplate, "collectionType")).toString());
|
||||
public void validateWithStringTemplate() throws Exception {
|
||||
RedisStoreWritingMessageHandler withStringTemplate = context.getBean("withStringTemplate.handler",
|
||||
RedisStoreWritingMessageHandler.class);
|
||||
assertEquals("pepboys", ((LiteralExpression)TestUtils.getPropertyValue(withStringTemplate,
|
||||
"keyExpression")).getExpressionString());
|
||||
assertEquals("PROPERTIES", (TestUtils.getPropertyValue(withStringTemplate, "collectionType")).toString());
|
||||
assertTrue(TestUtils.getPropertyValue(withStringTemplate, "redisTemplate") instanceof StringRedisTemplate);
|
||||
|
||||
Object handler = TestUtils.getPropertyValue(context.getBean("withStringTemplate.adapter"), "handler");
|
||||
|
||||
assertTrue(AopUtils.isAopProxy(handler));
|
||||
|
||||
assertSame(((Advised) handler).getTargetSource().getTarget(), withStringTemplate);
|
||||
|
||||
assertThat(TestUtils.getPropertyValue(handler, "h.advised.advisors.first.item.advice"),
|
||||
Matchers.instanceOf(RequestHandlerRetryAdvice.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void validateWithStringObjectTemplate(){
|
||||
RedisStoreWritingMessageHandler withStringObjectTemplate =
|
||||
TestUtils.getPropertyValue(context.getBean("withStringObjectTemplate.adapter"), "handler", RedisStoreWritingMessageHandler.class);
|
||||
assertEquals("pepboys", ((LiteralExpression)TestUtils.getPropertyValue(withStringObjectTemplate, "keyExpression")).getExpressionString());
|
||||
assertEquals("PROPERTIES", ((CollectionType)TestUtils.getPropertyValue(withStringObjectTemplate, "collectionType")).toString());
|
||||
TestUtils.getPropertyValue(context.getBean("withStringObjectTemplate.adapter"), "handler",
|
||||
RedisStoreWritingMessageHandler.class);
|
||||
assertEquals("pepboys", ((LiteralExpression)TestUtils.getPropertyValue(withStringObjectTemplate,
|
||||
"keyExpression")).getExpressionString());
|
||||
assertEquals("PROPERTIES", (TestUtils.getPropertyValue(withStringObjectTemplate, "collectionType")).toString());
|
||||
assertFalse(TestUtils.getPropertyValue(withStringObjectTemplate, "redisTemplate") instanceof StringRedisTemplate);
|
||||
assertTrue(TestUtils.getPropertyValue(withStringObjectTemplate, "redisTemplate.keySerializer") instanceof StringRedisSerializer);
|
||||
assertTrue(TestUtils.getPropertyValue(withStringObjectTemplate, "redisTemplate.hashKeySerializer") instanceof StringRedisSerializer);
|
||||
assertTrue(TestUtils.getPropertyValue(withStringObjectTemplate, "redisTemplate.valueSerializer") instanceof JdkSerializationRedisSerializer);
|
||||
assertTrue(TestUtils.getPropertyValue(withStringObjectTemplate, "redisTemplate.hashValueSerializer") instanceof JdkSerializationRedisSerializer);
|
||||
assertTrue(TestUtils.getPropertyValue(withStringObjectTemplate,
|
||||
"redisTemplate.keySerializer") instanceof StringRedisSerializer);
|
||||
assertTrue(TestUtils.getPropertyValue(withStringObjectTemplate,
|
||||
"redisTemplate.hashKeySerializer") instanceof StringRedisSerializer);
|
||||
assertTrue(TestUtils.getPropertyValue(withStringObjectTemplate,
|
||||
"redisTemplate.valueSerializer") instanceof JdkSerializationRedisSerializer);
|
||||
assertTrue(TestUtils.getPropertyValue(withStringObjectTemplate,
|
||||
"redisTemplate.hashValueSerializer") instanceof JdkSerializationRedisSerializer);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void validateWithExternalTemplate(){
|
||||
RedisStoreWritingMessageHandler withExternalTemplate =
|
||||
TestUtils.getPropertyValue(context.getBean("withExternalTemplate.adapter"), "handler", RedisStoreWritingMessageHandler.class);
|
||||
assertEquals("pepboys", ((LiteralExpression)TestUtils.getPropertyValue(withExternalTemplate, "keyExpression")).getExpressionString());
|
||||
assertEquals("PROPERTIES", ((CollectionType)TestUtils.getPropertyValue(withExternalTemplate, "collectionType")).toString());
|
||||
TestUtils.getPropertyValue(context.getBean("withExternalTemplate.adapter"), "handler",
|
||||
RedisStoreWritingMessageHandler.class);
|
||||
assertEquals("pepboys", ((LiteralExpression)TestUtils.getPropertyValue(withExternalTemplate,
|
||||
"keyExpression")).getExpressionString());
|
||||
assertEquals("PROPERTIES", (TestUtils.getPropertyValue(withExternalTemplate, "collectionType")).toString());
|
||||
assertSame(redisTemplate, TestUtils.getPropertyValue(withExternalTemplate, "redisTemplate"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,7 +24,9 @@
|
||||
<xsd:complexContent>
|
||||
<xsd:extension base="base-sftp-adapter-type">
|
||||
<xsd:all>
|
||||
<xsd:element name="request-handler-advice-chain" type="integration:handlerAdviceChainType" minOccurs="0" maxOccurs="1" />
|
||||
<xsd:element ref="integration:poller" minOccurs="0" maxOccurs="1" />
|
||||
<xsd:element name="request-handler-advice-chain" type="integration:handlerAdviceChainType"
|
||||
minOccurs="0" maxOccurs="1" />
|
||||
</xsd:all>
|
||||
<xsd:attribute name="order" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
|
||||
@@ -41,9 +41,9 @@
|
||||
remote-directory-expression="'foo' + '/' + 'bar'"
|
||||
remote-filename-generator-expression="payload.getName() + '-foo'"
|
||||
order="12"/>
|
||||
|
||||
<int-sftp:outbound-channel-adapter
|
||||
session-factory="sftpSessionFactory"
|
||||
|
||||
<int-sftp:outbound-channel-adapter
|
||||
session-factory="sftpSessionFactory"
|
||||
channel="inputChannel"
|
||||
charset="UTF-8"
|
||||
remote-directory="foo/bar"/>
|
||||
@@ -55,17 +55,22 @@
|
||||
use-temporary-file-name="false"
|
||||
remote-directory="foo/bar"/>
|
||||
|
||||
<int:channel id="queueChannel">
|
||||
<int:queue/>
|
||||
</int:channel>
|
||||
|
||||
<int-sftp:outbound-channel-adapter id="advised"
|
||||
session-factory="sftpSessionFactory"
|
||||
channel="inputChannel"
|
||||
channel="queueChannel"
|
||||
charset="UTF-8"
|
||||
use-temporary-file-name="false"
|
||||
remote-directory="foo/bar">
|
||||
<int:poller fixed-delay="1000"/>
|
||||
<int-sftp:request-handler-advice-chain>
|
||||
<bean class="org.springframework.integration.sftp.config.OutboundChannelAdapterParserTests$FooAdvice" />
|
||||
</int-sftp:request-handler-advice-chain>
|
||||
</int-sftp:outbound-channel-adapter>
|
||||
|
||||
|
||||
<bean id="fileNameGenerator" class="org.mockito.Mockito" factory-method="mock">
|
||||
<constructor-arg value="org.springframework.integration.file.FileNameGenerator"/>
|
||||
</bean>
|
||||
|
||||
@@ -45,6 +45,11 @@
|
||||
or to stderr (System.err) depending on the element name.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:all>
|
||||
<xsd:element ref="integration:poller" minOccurs="0" maxOccurs="1" />
|
||||
<xsd:element name="request-handler-advice-chain" type="integration:handlerAdviceChainType"
|
||||
minOccurs="0" maxOccurs="1" />
|
||||
</xsd:all>
|
||||
<xsd:attributeGroup ref="integration:channelAdapterAttributes"/>
|
||||
<xsd:attribute name="charset" type="xsd:string"/>
|
||||
<xsd:attribute name="append-newline" type="xsd:string" default="false"/>
|
||||
|
||||
Reference in New Issue
Block a user