use of org.springframework.integration.gateway.TestService in project spring-integration by spring-projects.
the class GatewayParserTests method testAsyncCompletableNoAsyncMessage.
@Test
public void testAsyncCompletableNoAsyncMessage() 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);
CompletableFuture<Message<?>> result = service.completableReturnsMessage("flowCompletableM");
Message<?> reply = result.get(10, TimeUnit.SECONDS);
assertEquals("flowCompletableM", 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 testAsyncDisabledGateway.
@Test
public void testAsyncDisabledGateway() throws Exception {
PollableChannel requestChannel = (PollableChannel) context.getBean("requestChannel");
MessageChannel replyChannel = (MessageChannel) context.getBean("replyChannel");
this.startResponder(requestChannel, replyChannel);
TestService service = context.getBean("asyncOff", TestService.class);
Future<Message<?>> result = service.async("futureSync");
Message<?> reply = result.get(10, TimeUnit.SECONDS);
assertEquals("futureSync", reply.getPayload());
Object serviceBean = context.getBean("&asyncOff");
assertNull(TestUtils.getPropertyValue(serviceBean, "asyncExecutor"));
}
use of org.springframework.integration.gateway.TestService in project spring-integration by spring-projects.
the class GatewayParserTests method testRequestReply.
@Test
public void testRequestReply() {
PollableChannel requestChannel = (PollableChannel) context.getBean("requestChannel");
MessageChannel replyChannel = (MessageChannel) context.getBean("replyChannel");
this.startResponder(requestChannel, replyChannel);
TestService service = (TestService) context.getBean("requestReply");
String result = service.requestReply("foo");
assertEquals("foo", result);
}
use of org.springframework.integration.gateway.TestService in project spring-integration by spring-projects.
the class GatewayParserTests method testCustomCompletableNoAsync.
@Test
public void testCustomCompletableNoAsync() 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);
MyCompletableFuture result = service.customCompletable("flowCustomCompletable");
String reply = result.get(10, TimeUnit.SECONDS);
assertEquals("SYNC_CUSTOM_COMPLETABLE", reply);
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 testMonoGateway.
@Test
public void testMonoGateway() throws Exception {
PollableChannel requestChannel = context.getBean("requestChannel", PollableChannel.class);
MessageChannel replyChannel = context.getBean("replyChannel", MessageChannel.class);
this.startResponder(requestChannel, replyChannel);
TestService service = context.getBean("promise", TestService.class);
Mono<Message<?>> result = service.promise("foo");
Message<?> reply = result.block(Duration.ofSeconds(1));
assertEquals("foo", reply.getPayload());
assertNotNull(TestUtils.getPropertyValue(context.getBean("&promise"), "asyncExecutor"));
}
Aggregations