INT-3872: Document Gateway's Exception as Reply

JIRA: https://jira.spring.io/browse/INT-3872

Polishing

Also, we had no tests for method element parsing.
This commit is contained in:
Artem Bilan
2015-11-03 19:34:30 -05:00
committed by Gary Russell
parent 7edef1d9f1
commit 703bc5fb82
3 changed files with 79 additions and 11 deletions

View File

@@ -15,6 +15,10 @@
<queue capacity="100"/>
</channel>
<channel id="otherRequestChannel">
<queue capacity="100"/>
</channel>
<gateway id="oneWay"
service-interface="org.springframework.integration.gateway.TestService"
default-request-channel="requestChannel"/>
@@ -72,6 +76,21 @@
default-reply-channel="replyChannel"
async-executor="testExecutor"/>
<gateway id="methodOverride"
service-interface="org.springframework.integration.gateway.TestService"
default-request-channel="requestChannel"
default-reply-channel="replyChannel"
async-executor="testExecutor">
<default-header name="baz" value="qux"/>
<method name="oneWay" request-channel="otherRequestChannel"
request-timeout="456"
reply-timeout="123"
payload-expression="'fiz'"
reply-channel="foo">
<header name="foo" value="bar"/>
</method>
</gateway>
<!-- no assertions for this. The fact that this config does not result in error is sufficient -->
<gateway id="defaultConfig" default-request-channel="nullChannel"/>

View File

@@ -25,6 +25,7 @@ import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executors;
@@ -45,6 +46,8 @@ import org.springframework.context.support.GenericApplicationContext;
import org.springframework.core.task.SimpleAsyncTaskExecutor;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.config.IntegrationConfigUtils;
import org.springframework.integration.gateway.GatewayMethodMetadata;
import org.springframework.integration.gateway.GatewayProxyFactoryBean;
import org.springframework.integration.gateway.RequestReplyExchanger;
import org.springframework.integration.gateway.TestService;
import org.springframework.integration.gateway.TestService.MyCompletableFuture;
@@ -85,6 +88,24 @@ public class GatewayParserTests {
assertEquals("foo", result.getPayload());
}
@Test
public void testOneWayOverride() {
TestService service = (TestService) context.getBean("methodOverride");
service.oneWay("foo");
PollableChannel channel = (PollableChannel) context.getBean("otherRequestChannel");
Message<?> result = channel.receive(1000);
assertEquals("fiz", result.getPayload());
assertEquals("bar", result.getHeaders().get("foo"));
assertEquals("qux", result.getHeaders().get("baz"));
GatewayProxyFactoryBean fb = context.getBean("&methodOverride", GatewayProxyFactoryBean.class);
Map<?,?> methods = TestUtils.getPropertyValue(fb, "methodMetadataMap", Map.class);
GatewayMethodMetadata meta = (GatewayMethodMetadata) methods.get("oneWay");
assertNotNull(meta);
assertEquals("456", meta.getRequestTimeout());
assertEquals("123", meta.getReplyTimeout());
assertEquals("foo", meta.getReplyChannelName());
}
@Test
public void testSolicitResponse() {
PollableChannel channel = (PollableChannel) context.getBean("replyChannel");