added test for @Payload annotation with SpEL on a Gateway
This commit is contained in:
@@ -12,6 +12,10 @@
|
||||
<int:method name="send2" request-channel="input" payload-expression="@testBean.sum(#args[0])"/>
|
||||
</int:gateway>
|
||||
|
||||
<int:gateway id="annotatedGateway"
|
||||
service-interface="org.springframework.integration.gateway.GatewayWithPayloadExpressionTests.SampleAnnotatedGateway"
|
||||
default-request-channel="input"/>
|
||||
|
||||
<int:channel id="input">
|
||||
<int:queue/>
|
||||
</int:channel>
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.annotation.Payload;
|
||||
import org.springframework.integration.core.PollableChannel;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
@@ -38,6 +39,9 @@ public class GatewayWithPayloadExpressionTests {
|
||||
@Autowired
|
||||
private SampleGateway gateway;
|
||||
|
||||
@Autowired
|
||||
private SampleAnnotatedGateway annotatedGateway;
|
||||
|
||||
@Autowired
|
||||
private PollableChannel input;
|
||||
|
||||
@@ -56,6 +60,13 @@ public class GatewayWithPayloadExpressionTests {
|
||||
assertEquals(324, result.getPayload());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void payloadAnnotationExpression() throws Exception {
|
||||
annotatedGateway.send("foo", "bar");
|
||||
Message<?> result = input.receive(0);
|
||||
assertEquals("foobar", result.getPayload());
|
||||
}
|
||||
|
||||
|
||||
public static interface SampleGateway {
|
||||
|
||||
@@ -65,6 +76,14 @@ public class GatewayWithPayloadExpressionTests {
|
||||
}
|
||||
|
||||
|
||||
public static interface SampleAnnotatedGateway {
|
||||
|
||||
@Payload("#args[0] + #args[1]")
|
||||
void send(String value1, String value2);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static class TestBean {
|
||||
|
||||
public int sum(String s) {
|
||||
|
||||
Reference in New Issue
Block a user