List of usage examples for org.springframework.integration.gateway TestService completable
CompletableFuture<String> completable(String s);
From source file:org.springframework.integration.config.xml.GatewayParserTests.java
@Test public void testAsyncCompletable() throws Exception { QueueChannel requestChannel = (QueueChannel) context.getBean("requestChannel"); final AtomicReference<Thread> thread = new AtomicReference<>(); requestChannel.addInterceptor(new ChannelInterceptorAdapter() { @Override// w ww . ja v a 2 s .c o m 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")); }
From source file:org.springframework.integration.config.xml.GatewayParserTests.java
@Test public void testAsyncCompletableNoAsync() throws Exception { QueueChannel requestChannel = (QueueChannel) context.getBean("requestChannel"); final AtomicReference<Thread> thread = new AtomicReference<>(); requestChannel.addInterceptor(new ChannelInterceptorAdapter() { @Override/*from w ww .j a v a 2s . c o m*/ 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<String> result = service.completable("flowCompletable"); String reply = result.get(1, TimeUnit.SECONDS); assertEquals("SYNC_COMPLETABLE", reply); assertEquals(Thread.currentThread(), thread.get()); assertNull(TestUtils.getPropertyValue(context.getBean("&completableNoAsync"), "asyncExecutor")); }