INT-2718 & INT-2721: fixes for <chain> & fix bugs
* ban to use 'channel' and 'request-channel' attributes for 'outbound-channel-adapters' and 'outbound-gateways' when they are declared inside the `<chain>` * fix usage of `<request-handler-advice-chain>` for components when they are declared inside the `<chain>` * ban to use `<request-handler-advice-chain>` for 'outbound-channel-adapters' when they are declared inside the `<chain>` don't implement `AbstractReplyProducingMessageHandler` * refactor `IntegrationNamespaceUtils` to use `BeanDefinition` instead of `BeanDefinitionBuilder` for 'advice-chain' parsing * tests for new logic for 'channel' and 'request-channel' attributes within `<chain>` * tests for new logic for `<request-handler-advice-chain>` within `<chain>` * fix failed test on slow machine * fix `SysLogTransformer` tests For reference: https://jira.springsource.org/browse/INT-2718 https://jira.springsource.org/browse/INT-2721 https://jira.springsource.org/browse/INT-2719 INT-2718 Polishing
This commit is contained in:
committed by
Gary Russell
parent
063c5c8269
commit
31d0e42c1a
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans:beans xmlns="http://www.springframework.org/schema/integration"
|
||||
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:twitter="http://www.springframework.org/schema/integration/twitter"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/integration/twitter http://www.springframework.org/schema/integration/twitter/spring-integration-twitter.xsd">
|
||||
|
||||
<beans:bean id="twitter" class="org.springframework.social.twitter.api.impl.TwitterTemplate"/>
|
||||
|
||||
<chain input-channel="inputChannel">
|
||||
<twitter:outbound-channel-adapter twitter-template="twitter">
|
||||
<twitter:request-handler-advice-chain>
|
||||
<beans:bean class="org.springframework.integration.twitter.config.TestSendingMessageHandlerParserTests$FooAdvice" />
|
||||
</twitter:request-handler-advice-chain>
|
||||
</twitter:outbound-channel-adapter>
|
||||
</chain>
|
||||
|
||||
</beans:beans>
|
||||
|
||||
|
||||
@@ -18,8 +18,12 @@ package org.springframework.integration.twitter.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.integration.Message;
|
||||
@@ -33,6 +37,7 @@ import org.springframework.integration.twitter.outbound.DirectMessageSendingMess
|
||||
/**
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @since 2.0
|
||||
*/
|
||||
public class TestSendingMessageHandlerParserTests {
|
||||
@@ -56,6 +61,20 @@ public class TestSendingMessageHandlerParserTests {
|
||||
assertEquals(2, adviceCalled);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInt2718FailForOutboundAdapterWithRequestHandlerAdviceChainWithinChainConfig() {
|
||||
try {
|
||||
new ClassPathXmlApplicationContext("OutboundAdapterWithRHACWithinChain-fail-context.xml", this.getClass());
|
||||
fail("Expected BeanDefinitionParsingException");
|
||||
}
|
||||
catch (BeansException e) {
|
||||
assertTrue(e instanceof BeanDefinitionParsingException);
|
||||
assertTrue(e.getMessage().contains("'request-handler-advice-chain' isn't allowed " +
|
||||
"for 'twitter:outbound-channel-adapter' within a <chain/>, because its Handler isn't an AbstractReplyProducingMessageHandler"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class FooAdvice extends AbstractRequestHandlerAdvice {
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user