From 58932dc31fcd9b3d4744295d0fcff15cc50ae891 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Wed, 2 Jul 2014 16:02:55 +0300 Subject: [PATCH] INT-3426: Add `` 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 `` --- .../config/xml/spring-integration-4.1.xsd | 1 + ...boundChannelAdapterParserTests-context.xml | 9 ++- ...aultOutboundChannelAdapterParserTests.java | 13 ++-- .../xml/spring-integration-mqtt-4.1.xsd | 6 +- ...boundChannelAdapterParserTests-context.xml | 22 ++++--- ...MqttOutboundChannelAdapterParserTests.java | 30 ++++++--- .../config/spring-integration-redis-4.1.xsd | 22 +++++-- ...boundChannelAdapterParserTests-context.xml | 12 ++-- ...edisOutboundChannelAdapterParserTests.java | 21 +++++-- ...boundChannelAdapterParserTests-context.xml | 6 +- ...ueueOutboundChannelAdapterParserTests.java | 25 ++++++-- ...boundChannelAdapterParserTests-context.xml | 10 ++- ...toreOutboundChannelAdapterParserTests.java | 63 ++++++++++++------- .../config/spring-integration-sftp-4.1.xsd | 4 +- ...boundChannelAdapterParserTests-context.xml | 15 +++-- .../config/spring-integration-stream-4.1.xsd | 5 ++ 16 files changed, 187 insertions(+), 77 deletions(-) diff --git a/spring-integration-core/src/main/resources/org/springframework/integration/config/xml/spring-integration-4.1.xsd b/spring-integration-core/src/main/resources/org/springframework/integration/config/xml/spring-integration-4.1.xsd index 0937f0d642..a6dd4c7fb4 100644 --- a/spring-integration-core/src/main/resources/org/springframework/integration/config/xml/spring-integration-4.1.xsd +++ b/spring-integration-core/src/main/resources/org/springframework/integration/config/xml/spring-integration-4.1.xsd @@ -1133,6 +1133,7 @@ + diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/DefaultOutboundChannelAdapterParserTests-context.xml b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/DefaultOutboundChannelAdapterParserTests-context.xml index fa3a430b79..51233fde6c 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/DefaultOutboundChannelAdapterParserTests-context.xml +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/DefaultOutboundChannelAdapterParserTests-context.xml @@ -8,7 +8,7 @@ http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd"> - + @@ -22,10 +22,13 @@ - + + + + - + diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/DefaultOutboundChannelAdapterParserTests.java b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/DefaultOutboundChannelAdapterParserTests.java index dcbccb277a..445f01187a 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/DefaultOutboundChannelAdapterParserTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/DefaultOutboundChannelAdapterParserTests.java @@ -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 diff --git a/spring-integration-mqtt/src/main/resources/org/springframework/integration/mqtt/config/xml/spring-integration-mqtt-4.1.xsd b/spring-integration-mqtt/src/main/resources/org/springframework/integration/mqtt/config/xml/spring-integration-mqtt-4.1.xsd index 9994058c2c..6025456f77 100644 --- a/spring-integration-mqtt/src/main/resources/org/springframework/integration/mqtt/config/xml/spring-integration-mqtt-4.1.xsd +++ b/spring-integration-mqtt/src/main/resources/org/springframework/integration/mqtt/config/xml/spring-integration-mqtt-4.1.xsd @@ -80,9 +80,11 @@ - + - + + diff --git a/spring-integration-mqtt/src/test/java/org/springframework/integration/mqtt/config/xml/MqttOutboundChannelAdapterParserTests-context.xml b/spring-integration-mqtt/src/test/java/org/springframework/integration/mqtt/config/xml/MqttOutboundChannelAdapterParserTests-context.xml index 203066d0d8..252524d560 100644 --- a/spring-integration-mqtt/src/test/java/org/springframework/integration/mqtt/config/xml/MqttOutboundChannelAdapterParserTests-context.xml +++ b/spring-integration-mqtt/src/test/java/org/springframework/integration/mqtt/config/xml/MqttOutboundChannelAdapterParserTests-context.xml @@ -11,15 +11,19 @@ + client-id="foo" + url="tcp://localhost:1883" + auto-startup="false" + converter="myConverter" + client-factory="clientFactory" + default-topic="bar" + phase="25" + order="1" + channel="target"> + + + + - + - + + + + + + @@ -410,9 +417,11 @@ - - - + + + + - + diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisOutboundChannelAdapterParserTests-context.xml b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisOutboundChannelAdapterParserTests-context.xml index c2c7fc0399..c2bf271837 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisOutboundChannelAdapterParserTests-context.xml +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisOutboundChannelAdapterParserTests-context.xml @@ -10,10 +10,14 @@ + channel="sendChannel" + topic-expression="headers['topic'] ?: 'foo'" + message-converter="testConverter" + serializer="serializer"> + + + + diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisOutboundChannelAdapterParserTests.java b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisOutboundChannelAdapterParserTests.java index 33445c83da..feb4f20fa4 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisOutboundChannelAdapterParserTests.java +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisOutboundChannelAdapterParserTests.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. @@ -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 diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisQueueOutboundChannelAdapterParserTests-context.xml b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisQueueOutboundChannelAdapterParserTests-context.xml index 09a2acd581..0e585480c1 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisQueueOutboundChannelAdapterParserTests-context.xml +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisQueueOutboundChannelAdapterParserTests-context.xml @@ -16,7 +16,11 @@ - + + + + + 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 diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisStoreOutboundChannelAdapterParserTests-context.xml b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisStoreOutboundChannelAdapterParserTests-context.xml index 15e423ef6f..1c63209d8c 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisStoreOutboundChannelAdapterParserTests-context.xml +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisStoreOutboundChannelAdapterParserTests-context.xml @@ -22,7 +22,11 @@ + auto-startup="false"> + + + + - + - + diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisStoreOutboundChannelAdapterParserTests.java b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisStoreOutboundChannelAdapterParserTests.java index ac1a795df3..9e8393841e 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisStoreOutboundChannelAdapterParserTests.java +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisStoreOutboundChannelAdapterParserTests.java @@ -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")); } + } diff --git a/spring-integration-sftp/src/main/resources/org/springframework/integration/sftp/config/spring-integration-sftp-4.1.xsd b/spring-integration-sftp/src/main/resources/org/springframework/integration/sftp/config/spring-integration-sftp-4.1.xsd index 017d4a948c..beec300df9 100644 --- a/spring-integration-sftp/src/main/resources/org/springframework/integration/sftp/config/spring-integration-sftp-4.1.xsd +++ b/spring-integration-sftp/src/main/resources/org/springframework/integration/sftp/config/spring-integration-sftp-4.1.xsd @@ -24,7 +24,9 @@ - + + diff --git a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/OutboundChannelAdapterParserTests-context.xml b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/OutboundChannelAdapterParserTests-context.xml index 978849904a..72ea5c4c0e 100644 --- a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/OutboundChannelAdapterParserTests-context.xml +++ b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/OutboundChannelAdapterParserTests-context.xml @@ -41,9 +41,9 @@ remote-directory-expression="'foo' + '/' + 'bar'" remote-filename-generator-expression="payload.getName() + '-foo'" order="12"/> - - @@ -55,17 +55,22 @@ use-temporary-file-name="false" remote-directory="foo/bar"/> + + + + + - + diff --git a/spring-integration-stream/src/main/resources/org/springframework/integration/stream/config/spring-integration-stream-4.1.xsd b/spring-integration-stream/src/main/resources/org/springframework/integration/stream/config/spring-integration-stream-4.1.xsd index 9b7e485e0e..353d333e19 100644 --- a/spring-integration-stream/src/main/resources/org/springframework/integration/stream/config/spring-integration-stream-4.1.xsd +++ b/spring-integration-stream/src/main/resources/org/springframework/integration/stream/config/spring-integration-stream-4.1.xsd @@ -45,6 +45,11 @@ or to stderr (System.err) depending on the element name. + + + +