Merge pull request #256 from artembilan/INT-2316

INT-2316: xsd improve for reply- & error-channels
This commit is contained in:
Mark Fisher
2011-12-20 11:14:18 -05:00
3 changed files with 40 additions and 6 deletions

View File

@@ -1603,17 +1603,21 @@ endpoint itself is a Polling Consumer for a channel with a queue.
<xsd:complexType name="header-enricher-type">
<xsd:choice minOccurs="1" maxOccurs="unbounded">
<xsd:element name="reply-channel" type="referenceHeaderType">
<xsd:element name="reply-channel" type="referenceOrValueHeaderType">
<xsd:annotation>
<xsd:documentation>
Shortcut to specify value for 'replyChannel' header
Shortcut to specify value for 'replyChannel' header.
Can be a 'ref' to the MessageChannel, a 'value' as name of the MessageChannel,
or some valid SpEL 'expression' which returns the MessageChannel reference or name of the MessageChannel.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="error-channel" type="referenceHeaderType">
<xsd:element name="error-channel" type="referenceOrValueHeaderType">
<xsd:annotation>
<xsd:documentation>
Shortcut to specify value for 'errorChannel' header
Shortcut to specify value for 'errorChannel' header.
Can be a 'ref' to the MessageChannel, a 'value' as name of the MessageChannel,
or some valid SpEL 'expression' which returns the MessageChannel reference or name of the MessageChannel.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
@@ -1795,7 +1799,7 @@ endpoint itself is a Polling Consumer for a channel with a queue.
<xsd:attribute name="expression" type="xsd:string">
<xsd:annotation>
<xsd:documentation>
Expression to be evaulated at runtime to determine the header value.
Expression to be evaluated at runtime to determine the header value.
The EvaluationContext will
include variables for 'payload' and
'headers'.

View File

@@ -11,6 +11,14 @@
<reply-channel ref="testReplyChannel"/>
</header-enricher>
<header-enricher input-channel="replyChannelNameInput" output-channel="echoInput">
<reply-channel value="testReplyChannel"/>
</header-enricher>
<header-enricher input-channel="replyChannelExpressionInput" output-channel="echoInput">
<reply-channel expression="@testReplyChannel" type="org.springframework.integration.MessageChannel"/>
</header-enricher>
<transformer input-channel="echoInput" expression="payload.toUpperCase()"/>
<channel id="testReplyChannel">

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2011 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.
@@ -60,6 +60,28 @@ public class HeaderEnricherTests {
assertEquals(replyChannel, result.getHeaders().getReplyChannel());
}
@Test //INT-2316
public void replyChannelName() {
PollableChannel replyChannel = context.getBean("testReplyChannel", PollableChannel.class);
MessageChannel inputChannel = context.getBean("replyChannelNameInput", MessageChannel.class);
inputChannel.send(new GenericMessage<String>("test"));
Message<?> result = replyChannel.receive(0);
assertNotNull(result);
assertEquals("TEST", result.getPayload());
assertEquals("testReplyChannel", result.getHeaders().getReplyChannel());
}
@Test //INT-2316
public void replyChannelExpression() {
PollableChannel replyChannel = context.getBean("testReplyChannel", PollableChannel.class);
MessageChannel inputChannel = context.getBean("replyChannelExpressionInput", MessageChannel.class);
inputChannel.send(new GenericMessage<String>("test"));
Message<?> result = replyChannel.receive(0);
assertNotNull(result);
assertEquals("TEST", result.getPayload());
assertEquals(replyChannel, result.getHeaders().getReplyChannel());
}
@Test
public void errorChannel() {
PollableChannel errorChannel = context.getBean("testErrorChannel", PollableChannel.class);