use of org.springframework.integration.gateway.TestService in project spring-integration by spring-projects.
the class GatewayParserTests method testOneWay.
@Test
public void testOneWay() {
TestService service = (TestService) context.getBean("oneWay");
service.oneWay("foo");
PollableChannel channel = (PollableChannel) context.getBean("requestChannel");
Message<?> result = channel.receive(10000);
assertEquals("foo", result.getPayload());
}
use of org.springframework.integration.gateway.TestService in project spring-integration by spring-projects.
the class GatewayParserTests method testAsyncGateway.
@Test
public void testAsyncGateway() throws Exception {
PollableChannel requestChannel = (PollableChannel) context.getBean("requestChannel");
MessageChannel replyChannel = (MessageChannel) context.getBean("replyChannel");
this.startResponder(requestChannel, replyChannel);
TestService service = context.getBean("async", TestService.class);
Future<Message<?>> result = service.async("foo");
Message<?> reply = result.get(10, TimeUnit.SECONDS);
assertEquals("foo", reply.getPayload());
assertEquals("testExecutor", reply.getHeaders().get("executor"));
assertNotNull(TestUtils.getPropertyValue(context.getBean("&async"), "asyncExecutor"));
}
use of org.springframework.integration.gateway.TestService in project spring-integration by spring-projects.
the class GatewayParserTests method testCustomCompletableNoAsyncMessage.
@Test
public void testCustomCompletableNoAsyncMessage() throws Exception {
QueueChannel requestChannel = (QueueChannel) context.getBean("requestChannel");
final AtomicReference<Thread> thread = new AtomicReference<>();
requestChannel.addInterceptor(new ChannelInterceptorAdapter() {
@Override
public Message<?> preSend(Message<?> message, MessageChannel channel) {
thread.set(Thread.currentThread());
return super.preSend(message, channel);
}
});
MessageChannel replyChannel = (MessageChannel) context.getBean("replyChannel");
this.startResponder(requestChannel, replyChannel);
TestService service = context.getBean("completableNoAsync", TestService.class);
MyCompletableMessageFuture result = service.customCompletableReturnsMessage("flowCustomCompletableM");
Message<?> reply = result.get(10, TimeUnit.SECONDS);
assertEquals("flowCustomCompletableM", reply.getPayload());
assertEquals(Thread.currentThread(), thread.get());
assertNull(TestUtils.getPropertyValue(context.getBean("&completableNoAsync"), "asyncExecutor"));
}
use of org.springframework.integration.gateway.TestService in project spring-integration by spring-projects.
the class GatewayParserTests method testAsyncCompletable.
@Test
public void testAsyncCompletable() throws Exception {
QueueChannel requestChannel = (QueueChannel) context.getBean("requestChannel");
final AtomicReference<Thread> thread = new AtomicReference<>();
requestChannel.addInterceptor(new ChannelInterceptorAdapter() {
@Override
public Message<?> preSend(Message<?> message, MessageChannel channel) {
thread.set(Thread.currentThread());
return super.preSend(message, channel);
}
});
MessageChannel replyChannel = (MessageChannel) context.getBean("replyChannel");
this.startResponder(requestChannel, replyChannel);
TestService service = context.getBean("asyncCompletable", TestService.class);
CompletableFuture<String> result = service.completable("foo").thenApply(String::toUpperCase);
String reply = result.get(10, TimeUnit.SECONDS);
assertEquals("FOO", reply);
assertThat(thread.get().getName(), startsWith("testExec-"));
assertNotNull(TestUtils.getPropertyValue(context.getBean("&asyncCompletable"), "asyncExecutor"));
}
Aggregations