List of usage examples for org.springframework.integration.test.util TestUtils getPropertyValue
public static Object getPropertyValue(Object root, String propertyPath)
From source file:org.springframework.cloud.stream.app.ftp.source.FtpSourceIntegrationTests.java
@Test public void sourceFilesAsRef() throws InterruptedException { assertEquals("*", TestUtils.getPropertyValue(TestUtils .getPropertyValue(sourcePollingChannelAdapter, "source.synchronizer.filter.fileFilters", Set.class) .iterator().next(), "path")); for (int i = 1; i <= 2; i++) { @SuppressWarnings("unchecked") Message<File> received = (Message<File>) messageCollector.forChannel(ftpSource.output()).poll(10, TimeUnit.SECONDS); assertNotNull(received);// ww w . j av a 2s . co m assertThat(received.getPayload(), equalTo(new File(config.getLocalDir() + "/ftpSource" + i + ".txt"))); } assertThat(this.sessionFactory, instanceOf(CachingSessionFactory.class)); }
From source file:org.springframework.integration.channel.DirectChannelTests.java
@Test // See INT-2434 public void testChannelCreationWithBeanDefinitionOverrideTrue() throws Exception { ClassPathXmlApplicationContext parentContext = new ClassPathXmlApplicationContext("parent-config.xml", this.getClass()); MessageChannel parentChannelA = parentContext.getBean("parentChannelA", MessageChannel.class); MessageChannel parentChannelB = parentContext.getBean("parentChannelB", MessageChannel.class); ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(); context.setAllowBeanDefinitionOverriding(false); context.setConfigLocations(// ww w.j a v a 2 s. c o m new String[] { "classpath:org/springframework/integration/channel/channel-override-config.xml" }); context.setParent(parentContext); Method method = ReflectionUtils.findMethod(ClassPathXmlApplicationContext.class, "obtainFreshBeanFactory"); method.setAccessible(true); method.invoke(context); assertFalse(context.containsBean("channelA")); assertFalse(context.containsBean("channelB")); assertTrue(context.containsBean("channelC")); assertTrue(context.containsBean("channelD")); context.refresh(); PublishSubscribeChannel channelEarly = context.getBean("channelEarly", PublishSubscribeChannel.class); assertTrue(context.containsBean("channelA")); assertTrue(context.containsBean("channelB")); assertTrue(context.containsBean("channelC")); assertTrue(context.containsBean("channelD")); EventDrivenConsumer consumerA = context.getBean("serviceA", EventDrivenConsumer.class); assertEquals(context.getBean("channelA"), TestUtils.getPropertyValue(consumerA, "inputChannel")); assertEquals(context.getBean("channelB"), TestUtils.getPropertyValue(consumerA, "handler.outputChannel")); EventDrivenConsumer consumerB = context.getBean("serviceB", EventDrivenConsumer.class); assertEquals(context.getBean("channelB"), TestUtils.getPropertyValue(consumerB, "inputChannel")); assertEquals(context.getBean("channelC"), TestUtils.getPropertyValue(consumerB, "handler.outputChannel")); EventDrivenConsumer consumerC = context.getBean("serviceC", EventDrivenConsumer.class); assertEquals(context.getBean("channelC"), TestUtils.getPropertyValue(consumerC, "inputChannel")); assertEquals(context.getBean("channelD"), TestUtils.getPropertyValue(consumerC, "handler.outputChannel")); EventDrivenConsumer consumerD = context.getBean("serviceD", EventDrivenConsumer.class); assertEquals(parentChannelA, TestUtils.getPropertyValue(consumerD, "inputChannel")); assertEquals(parentChannelB, TestUtils.getPropertyValue(consumerD, "handler.outputChannel")); EventDrivenConsumer consumerE = context.getBean("serviceE", EventDrivenConsumer.class); assertEquals(parentChannelB, TestUtils.getPropertyValue(consumerE, "inputChannel")); EventDrivenConsumer consumerF = context.getBean("serviceF", EventDrivenConsumer.class); assertEquals(channelEarly, TestUtils.getPropertyValue(consumerF, "inputChannel")); }
From source file:org.springframework.integration.config.ChainParserTests.java
@Test //INT-2605 public void checkSmartLifecycleConfig() { ApplicationContext ctx = new ClassPathXmlApplicationContext("ChainParserSmartLifecycleAttributesTest.xml", this.getClass()); MessageHandlerChain handlerChain = ctx.getBean(MessageHandlerChain.class); assertEquals(false, handlerChain.isAutoStartup()); assertEquals(256, handlerChain.getPhase()); assertEquals(3000L, TestUtils.getPropertyValue(handlerChain, "sendTimeout")); assertEquals(false, TestUtils.getPropertyValue(handlerChain, "running")); //INT-3108/*from w w w . j a v a 2s. c om*/ MessageHandler serviceActivator = ctx.getBean("chain$child.sa-within-chain.handler", MessageHandler.class); assertTrue(TestUtils.getPropertyValue(serviceActivator, "requiresReply", Boolean.class)); }
From source file:org.springframework.integration.config.xml.GatewayParserTests.java
@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(1, TimeUnit.SECONDS); assertEquals("foo", reply.getPayload()); assertEquals("testExecutor", reply.getHeaders().get("executor")); assertNotNull(TestUtils.getPropertyValue(context.getBean("&async"), "asyncExecutor")); }
From source file:org.springframework.integration.config.xml.GatewayParserTests.java
@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(1, TimeUnit.SECONDS); assertEquals("futureSync", reply.getPayload()); Object serviceBean = context.getBean("&asyncOff"); assertNull(TestUtils.getPropertyValue(serviceBean, "asyncExecutor")); }
From source file:org.springframework.integration.config.xml.GatewayParserTests.java
@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")); }
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//from ww w .jav a2 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 w w .j a v a2s . co 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")); }
From source file:org.springframework.integration.config.xml.GatewayParserTests.java
@Test public void testCustomCompletableNoAsync() throws Exception { QueueChannel requestChannel = (QueueChannel) context.getBean("requestChannel"); final AtomicReference<Thread> thread = new AtomicReference<>(); requestChannel.addInterceptor(new ChannelInterceptorAdapter() { @Override/*from ww w . j a v a 2 s. com*/ 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(1, TimeUnit.SECONDS); assertEquals("SYNC_CUSTOM_COMPLETABLE", reply); assertEquals(Thread.currentThread(), thread.get()); assertNull(TestUtils.getPropertyValue(context.getBean("&completableNoAsync"), "asyncExecutor")); }
From source file:org.springframework.integration.config.xml.GatewayParserTests.java
@Test public void testAsyncCompletableMessage() 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 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<Message<?>> result = service.completableReturnsMessage("foo"); Message<?> reply = result.get(1, TimeUnit.SECONDS); assertEquals("foo", reply.getPayload()); assertThat(thread.get().getName(), startsWith("testExec-")); assertNotNull(TestUtils.getPropertyValue(context.getBean("&asyncCompletable"), "asyncExecutor")); }