INT-1409 added proper support for the 'send-timeout' attribute on <bridge>

This commit is contained in:
Mark Fisher
2010-09-02 19:30:58 +00:00
parent 84b00a2862
commit f78794f900
3 changed files with 21 additions and 2 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2010 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.
@@ -30,8 +30,10 @@ public class BridgeParser extends AbstractConsumerEndpointParser {
@Override
protected BeanDefinitionBuilder parseHandler(Element element, ParserContext parserContext) {
return BeanDefinitionBuilder.genericBeanDefinition(
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(
IntegrationNamespaceUtils.BASE_PACKAGE + ".handler.BridgeHandler");
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "send-timeout");
return builder;
}
}

View File

@@ -35,5 +35,6 @@
<channel id="stopperChannel" />
<bridge input-channel="stopperChannel" />
<bridge id="bridgeWithSendTimeout" input-channel="bridgeWithSendTimeoutChannel" send-timeout="1234"/>
</beans:beans>

View File

@@ -16,19 +16,24 @@
package org.springframework.integration.config.xml;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import org.hamcrest.Factory;
import org.hamcrest.Matcher;
import org.junit.Test;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.integration.Message;
import org.springframework.integration.MessageChannel;
import org.springframework.integration.MessagingException;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.core.MessagingTemplate;
import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.endpoint.EventDrivenConsumer;
import org.springframework.integration.handler.BridgeHandler;
import org.springframework.integration.message.GenericMessage;
import org.springframework.integration.message.MessageMatcher;
import org.springframework.integration.support.MessageBuilder;
@@ -62,6 +67,10 @@ public class BridgeParserTests extends AbstractJUnit4SpringContextTests {
@Qualifier("output2")
private PollableChannel output2;
@Autowired
private EventDrivenConsumer bridgeWithSendTimeout;
@Factory
public static Matcher<Message<?>> sameExceptImmutableHeaders(Message<?> expected) {
return new MessageMatcher(expected);
@@ -98,4 +107,11 @@ public class BridgeParserTests extends AbstractJUnit4SpringContextTests {
this.stopperChannel.send(message);
}
@Test
public void bridgeWithSendTimeout() {
BridgeHandler handler = (BridgeHandler) new DirectFieldAccessor(bridgeWithSendTimeout).getPropertyValue("handler");
MessagingTemplate template = (MessagingTemplate) new DirectFieldAccessor(handler).getPropertyValue("messagingTemplate");
assertEquals(new Long(1234), new DirectFieldAccessor(template).getPropertyValue("sendTimeout"));
}
}