From f248394682b4f5165e4d1fbc40a1b66d2e9996ff Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Tue, 17 Feb 2015 13:34:59 +0200 Subject: [PATCH] INT-3589: Upgrade Dependencies JIRA: https://jira.spring.io/browse/INT-3589, https://jira.spring.io/browse/INT-3624 * SF - 4.2. Fix Breaking changes for the `ApplicationEventPublisher` * AMQP 1.5. Without issues * Reactor - 2.0. Fix for the new `Stream` foundation * jsonPath - 1.2.0. Fix for new `Predicate` abstraction. Add 'fail-fast error' to the `IntegrationRegistrar` * Sshd - 0.13.0. Fix for new `VirtualFileSystemFactory` usage * Spring Data - Fowler * And others without issues * Get rid of `reactor.util.StringUtils` usage INT-3589: Address PR comments Polishing --- build.gradle | 59 +++++++++---------- .../annotation/MessagingGateway.java | 6 +- .../integration/channel/NullChannel.java | 3 +- .../config/IntegrationRegistrar.java | 18 +++++- .../gateway/GatewayProxyFactoryBean.java | 13 ++-- .../integration/json/JsonPathUtils.java | 16 ++--- .../splitter/AbstractMessageSplitter.java | 2 +- .../integration/util/FunctionIterator.java | 2 +- .../aggregator/AggregatorTests.java | 8 ++- .../channel/QueueChannelTests.java | 10 ++-- .../config/xml/GatewayParserTests-context.xml | 2 +- .../config/xml/GatewayParserTests.java | 4 +- .../configuration/EnableIntegrationTests.java | 52 ++++++---------- .../gateway/AsyncGatewayTests.java | 19 +++--- .../integration/gateway/TestService.java | 4 +- .../integration/json/JsonPathTests.java | 10 ++-- .../routingslip/RoutingSlipTests.java | 22 ++----- ...ionEventListeningMessageProducerTests.java | 31 ++++++---- ...ionEventPublishingMessageHandlerTests.java | 14 +++-- ...emoteFileOutboundChannelAdapterParser.java | 5 +- .../tail/FileTailingMessageProducerTests.java | 9 ++- .../config/GroovyServiceActivatorTests.java | 30 ++++++---- .../tcp/AbstractTcpChannelAdapterTests.java | 9 ++- .../CachingClientConnectionFactoryTests.java | 15 ++++- .../tcp/connection/ConnectionEventTests.java | 10 +++- .../connection/ConnectionFactoryTests.java | 11 +++- .../connection/ConnectionTimeoutTests.java | 9 ++- .../FailoverClientConnectionFactoryTests.java | 9 ++- .../tcp/connection/TcpNetConnectionTests.java | 15 ++++- .../tcp/connection/TcpNioConnectionTests.java | 15 ++++- .../tcp/serializer/DeserializationTests.java | 8 ++- .../mail/ImapMailReceiverTests.java | 8 ++- .../mqtt/BackToBackAdapterTests.java | 7 ++- .../RedisQueueInboundGatewayParserTests.java | 7 +-- .../RedisQueueMessageDrivenEndpointTests.java | 6 ++ .../integration/sftp/TestSftpServer.java | 32 +++------- .../sftp/session/SftpServerTests.java | 57 ++++-------------- 37 files changed, 312 insertions(+), 245 deletions(-) diff --git a/build.gradle b/build.gradle index 4f143cd251..ce83fed0ed 100644 --- a/build.gradle +++ b/build.gradle @@ -27,10 +27,9 @@ allprojects { repositories { if (version.endsWith('BUILD-SNAPSHOT') || project.hasProperty('platformVersion')) { - maven { url 'http://repo.spring.io/libs-snapshot' } + maven { url 'https://repo.spring.io/libs-snapshot' } } maven { url 'https://repo.spring.io/libs-milestone' } - maven { url 'https://repo.spring.io/plugins-release' } mavenCentral() } @@ -76,59 +75,58 @@ subprojects { subproject -> ext { - activeMqVersion = '5.10.0' - aspectjVersion = '1.8.2' - apacheSshdVersion = '0.10.1' - boonVersion = '0.25' - chronicleVersion = '3.2.2' + activeMqVersion = '5.11.0' + aspectjVersion = '1.8.4' + apacheSshdVersion = '0.13.0' + boonVersion = '0.31' + chronicleVersion = '3.3.4' commonsDbcpVersion = '1.4' commonsIoVersion = '2.4' commonsNetVersion = '3.3' - derbyVersion = '10.10.2.0' + derbyVersion = '10.11.1.1' eclipseLinkVersion = '2.4.2' ftpServerVersion = '1.0.6' - groovyVersion = '2.3.6' - guavaVersion = '16.0.1' + groovyVersion = '2.4.0' + guavaVersion = '18.0' hamcrestVersion = '1.3' - hibernateVersion = '4.3.6.Final' + hibernateVersion = '4.3.8.Final' hsqldbVersion = '2.3.2' h2Version = '1.4.180' - jackson2Version = '2.4.2' + jackson2Version = '2.5.1' javaxActivationVersion = '1.1.1' javaxMailVersion = '1.5.2' - jedisVersion = '2.5.2' - jettyVersion = '9.2.2.v20140723' + jedisVersion = '2.6.2' jmsApiVersion = '1.1-rev-1' jpaApiVersion = '2.0.0' - jrubyVersion = '1.7.15' + jrubyVersion = '1.7.19' jschVersion = '0.1.51' - jsonpathVersion = '0.9.1' + jsonpathVersion = '1.2.0' junitVersion = '4.11' jythonVersion = '2.5.3' log4jVersion = '1.2.17' mockitoVersion = '1.9.5' - mysqlVersion = '5.1.29' + mysqlVersion = '5.1.34' openJpaVersion = '2.3.0' pahoMqttClientVersion = '0.4.0' postgresVersion = '9.1-901-1.jdbc4' - reactorVersion = '1.1.4.RELEASE' - reactorSpringVersion = '1.1.3.RELEASE' + reactorVersion = '2.0.0.RC1' + reactorSpringVersion = '2.0.0.M2' romeToolsVersion = '1.5.0' saajApiVersion = '1.3.5' saajImplVersion = '1.3.23' servletApiVersion = '3.1.0' - slf4jVersion = "1.7.6" - tomcatVersion = "7.0.55" + slf4jVersion = "1.7.8" + tomcatVersion = "8.0.18" smack3Version = '3.2.1' - smackVersion = '4.0.0' - springAmqpVersion = project.hasProperty('springAmqpVersion') ? project.springAmqpVersion : '1.4.2.RELEASE' - springDataMongoVersion = '1.6.0.RELEASE' - springDataRedisVersion = '1.4.0.RELEASE' - springGemfireVersion = '1.5.0.RELEASE' + smackVersion = '4.0.6' + springAmqpVersion = project.hasProperty('springAmqpVersion') ? project.springAmqpVersion : '1.5.0.BUILD-SNAPSHOT' + springDataMongoVersion = '1.7.0.M1' + springDataRedisVersion = '1.5.0.M1' + springGemfireVersion = '1.6.0.M1' springSecurityVersion = '3.2.5.RELEASE' springSocialTwitterVersion = '1.1.0.RELEASE' - springRetryVersion = '1.1.1.RELEASE' - springVersion = project.hasProperty('springVersion') ? project.springVersion : '4.1.4.RELEASE' + springRetryVersion = '1.1.2.RELEASE' + springVersion = project.hasProperty('springVersion') ? project.springVersion : '4.2.0.BUILD-SNAPSHOT' springWsVersion = '2.2.0.RELEASE' xmlUnitVersion = '1.5' xstreamVersion = '1.4.7' @@ -259,16 +257,15 @@ project('spring-integration-core') { compile "org.springframework:spring-context:$springVersion" compile "org.springframework:spring-messaging:$springVersion" compile "org.springframework:spring-tx:$springVersion" - compile ("org.springframework:spring-context-support:$springVersion", optional) // override the reactor version compile "org.springframework.retry:spring-retry:$springRetryVersion" - compile "org.projectreactor:reactor-core:$reactorVersion" - compile("org.projectreactor.spring:reactor-spring-context:$reactorSpringVersion", optional) + compile ("io.projectreactor:reactor-core:$reactorVersion", optional) compile("com.fasterxml.jackson.core:jackson-databind:$jackson2Version", optional) compile("com.jayway.jsonpath:json-path:$jsonpathVersion", optional) compile("io.fastjson:boon:$boonVersion", optional) testCompile ("org.aspectj:aspectjweaver:$aspectjVersion") testCompile ("net.openhft:chronicle:$chronicleVersion") + testCompile ("io.projectreactor.spring:reactor-spring-context:$reactorSpringVersion") } } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/annotation/MessagingGateway.java b/spring-integration-core/src/main/java/org/springframework/integration/annotation/MessagingGateway.java index 1fa3169c74..29a9012039 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/annotation/MessagingGateway.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/annotation/MessagingGateway.java @@ -115,11 +115,11 @@ public @interface MessagingGateway { String mapper() default ""; /** - * Provide a reference to an {@link reactor.core.Environment} - * to use for any of the interface methods that have a {@link reactor.core.composable.Promise} return type. + * Provide a reference to an {@link reactor.Environment} + * to use for any of the interface methods that have a {@link reactor.rx.Promise} return type. * This {@code reactor.core.Environment} will only be used for those async methods; the sync methods * will be invoked in the caller's thread. - *

This attribute is required in case of {@link reactor.core.composable.Promise} usage. + *

This attribute is required in case of {@link reactor.rx.Promise} usage. * @return the suggested reactor Environment bean name. * @since 4.1 */ diff --git a/spring-integration-core/src/main/java/org/springframework/integration/channel/NullChannel.java b/spring-integration-core/src/main/java/org/springframework/integration/channel/NullChannel.java index f5943c830f..662e8aa683 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/channel/NullChannel.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/channel/NullChannel.java @@ -27,8 +27,7 @@ import org.springframework.integration.support.management.Statistics; import org.springframework.jmx.export.annotation.ManagedResource; import org.springframework.messaging.Message; import org.springframework.messaging.PollableChannel; - -import reactor.util.StringUtils; +import org.springframework.util.StringUtils; /** * A channel implementation that essentially behaves like "/dev/null". diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/IntegrationRegistrar.java b/spring-integration-core/src/main/java/org/springframework/integration/config/IntegrationRegistrar.java index e87716fe5c..f9fe88faad 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/config/IntegrationRegistrar.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/config/IntegrationRegistrar.java @@ -1,5 +1,5 @@ /* - * Copyright 2014 the original author or authors. + * Copyright 2014-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -216,10 +216,24 @@ public class IntegrationRegistrar implements ImportBeanDefinitionRegistrar, Bean jsonPathClass = ClassUtils.forName("com.jayway.jsonpath.JsonPath", this.classLoader); } catch (ClassNotFoundException e) { - logger.debug("SpEL function '#jsonPath' isn't registered: " + + logger.debug("The '#jsonPath' SpEL function cannot be registered: " + "there is no jayway json-path.jar on the classpath."); } + if (jsonPathClass != null) { + try { + ClassUtils.forName("com.jayway.jsonpath.Predicate", this.classLoader); + } + catch (ClassNotFoundException e) { + jsonPathClass = null; + logger.warn("The '#jsonPath' SpEL function cannot be registered. " + + "An old json-path.jar version is detected in the classpath." + + "At least 1.2.0 is required; see version information at: " + + "https://github.com/jayway/JsonPath/releases", e); + + } + } + if (jsonPathClass != null) { IntegrationConfigUtils.registerSpelFunctionBean(registry, jsonPathBeanName, IntegrationConfigUtils.BASE_PACKAGE + ".json.JsonPathUtils", "evaluate"); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/gateway/GatewayProxyFactoryBean.java b/spring-integration-core/src/main/java/org/springframework/integration/gateway/GatewayProxyFactoryBean.java index 104af0e7e9..1008284bf3 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/gateway/GatewayProxyFactoryBean.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/gateway/GatewayProxyFactoryBean.java @@ -63,10 +63,10 @@ import org.springframework.util.ObjectUtils; import org.springframework.util.ReflectionUtils; import org.springframework.util.StringUtils; -import reactor.core.Environment; -import reactor.core.composable.Promise; -import reactor.core.composable.spec.Promises; -import reactor.function.Functions; +import reactor.Environment; +import reactor.rx.Promise; +import reactor.rx.Promises; +import reactor.fn.Functions; /** * Generates a proxy for the provided service interface to enable interaction @@ -358,9 +358,8 @@ public class GatewayProxyFactoryBean extends AbstractEndpoint if (this.reactorEnvironment == null) { throw new IllegalStateException("'reactorEnvironment' is required in case of 'Promise' return type."); } - return Promises.task(Functions.supplier(new AsyncInvocationTask(invocation))) - .env(this.reactorEnvironment) - .get(); + return Promises.task(this.reactorEnvironment, + Functions.supplier(new AsyncInvocationTask(invocation))); } return this.doInvoke(invocation); } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/json/JsonPathUtils.java b/spring-integration-core/src/main/java/org/springframework/integration/json/JsonPathUtils.java index 59138ae110..7065e36744 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/json/JsonPathUtils.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/json/JsonPathUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 the original author or authors. + * Copyright 2013-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,8 +20,8 @@ import java.io.File; import java.io.InputStream; import java.net.URL; -import com.jayway.jsonpath.Filter; import com.jayway.jsonpath.JsonPath; +import com.jayway.jsonpath.Predicate; /** * Utility class to {@link #evaluate} a jsonPath on the provided object. @@ -33,21 +33,21 @@ import com.jayway.jsonpath.JsonPath; */ public final class JsonPathUtils { - public static T evaluate(Object json, String jsonPath, Filter... filters) throws Exception { + public static T evaluate(Object json, String jsonPath, Predicate... predicates) throws Exception { if (json instanceof String) { - return JsonPath.read((String) json, jsonPath, filters); + return JsonPath.read((String) json, jsonPath, predicates); } else if (json instanceof File) { - return JsonPath.read((File) json, jsonPath, filters); + return JsonPath.read((File) json, jsonPath, predicates); } else if (json instanceof URL) { - return JsonPath.read((URL) json, jsonPath, filters); + return JsonPath.read((URL) json, jsonPath, predicates); } else if (json instanceof InputStream) { - return JsonPath.read((InputStream) json, jsonPath, filters); + return JsonPath.read((InputStream) json, jsonPath, predicates); } else { - return JsonPath.read(json, jsonPath, filters); + return JsonPath.read(json, jsonPath, predicates); } } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/splitter/AbstractMessageSplitter.java b/spring-integration-core/src/main/java/org/springframework/integration/splitter/AbstractMessageSplitter.java index 4294431442..2811be686b 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/splitter/AbstractMessageSplitter.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/splitter/AbstractMessageSplitter.java @@ -28,7 +28,7 @@ import org.springframework.integration.util.FunctionIterator; import org.springframework.messaging.Message; import org.springframework.messaging.MessageHeaders; -import reactor.function.Function; +import reactor.fn.Function; /** * Base class for Message-splitting handlers. diff --git a/spring-integration-core/src/main/java/org/springframework/integration/util/FunctionIterator.java b/spring-integration-core/src/main/java/org/springframework/integration/util/FunctionIterator.java index 749e0de7cf..45909ba147 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/util/FunctionIterator.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/util/FunctionIterator.java @@ -19,7 +19,7 @@ package org.springframework.integration.util; import java.util.Iterator; import java.util.NoSuchElementException; -import reactor.function.Function; +import reactor.fn.Function; /** * An {@link Iterator} implementation to convert each item from the target diff --git a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/AggregatorTests.java b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/AggregatorTests.java index 79c007e295..db90896917 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/AggregatorTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/AggregatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -76,6 +76,12 @@ public class AggregatorTests { public void publishEvent(ApplicationEvent event) { expiryEvents.add((MessageGroupExpiredEvent) event); } + + @Override + public void publishEvent(Object event) { + + } + }); this.aggregator.setBeanName("testAggregator"); this.aggregator.afterPropertiesSet(); diff --git a/spring-integration-core/src/test/java/org/springframework/integration/channel/QueueChannelTests.java b/spring-integration-core/src/test/java/org/springframework/integration/channel/QueueChannelTests.java index 4bad9f8005..f58951d63e 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/channel/QueueChannelTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/channel/QueueChannelTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; @@ -37,9 +38,9 @@ import org.springframework.integration.support.MessageBuilder; import org.springframework.messaging.Message; import org.springframework.messaging.support.GenericMessage; -import reactor.io.encoding.JavaSerializationCodec; -import reactor.queue.PersistentQueue; -import reactor.queue.spec.PersistentQueueSpec; +import reactor.io.codec.JavaSerializationCodec; +import reactor.io.queue.PersistentQueue; +import reactor.io.queue.spec.PersistentQueueSpec; /** * @author Mark Fisher @@ -248,6 +249,7 @@ public class QueueChannelTests { public final TemporaryFolder tempFolder = new TemporaryFolder(); @Test + @Ignore //INT-3644 public void testReactorPersistentQueue() throws InterruptedException { final AtomicBoolean messageReceived = new AtomicBoolean(false); final CountDownLatch latch = new CountDownLatch(1); diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/GatewayParserTests-context.xml b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/GatewayParserTests-context.xml index 5d5249f2c1..b31f5a41a7 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/GatewayParserTests-context.xml +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/GatewayParserTests-context.xml @@ -53,6 +53,6 @@ - + diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/GatewayParserTests.java b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/GatewayParserTests.java index 0e6136849c..0b47149b21 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/GatewayParserTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/GatewayParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,7 +44,7 @@ import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import reactor.core.composable.Promise; +import reactor.rx.Promise; /** * @author Mark Fisher diff --git a/spring-integration-core/src/test/java/org/springframework/integration/configuration/EnableIntegrationTests.java b/spring-integration-core/src/test/java/org/springframework/integration/configuration/EnableIntegrationTests.java index 72922b482b..e4b6c719c2 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/configuration/EnableIntegrationTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/configuration/EnableIntegrationTests.java @@ -32,7 +32,6 @@ import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import java.util.Arrays; import java.util.Date; import java.util.List; import java.util.concurrent.CountDownLatch; @@ -125,12 +124,10 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.AnnotationConfigContextLoader; -import reactor.core.Environment; -import reactor.core.composable.Composable; -import reactor.core.composable.Promise; -import reactor.core.composable.spec.Streams; -import reactor.function.Consumer; -import reactor.function.Function; +import reactor.Environment; +import reactor.fn.Consumer; +import reactor.rx.Promise; +import reactor.rx.Streams; import reactor.spring.context.config.EnableReactor; /** @@ -597,30 +594,15 @@ public class EnableIntegrationTests { final AtomicReference> ref = new AtomicReference>(); final CountDownLatch consumeLatch = new CountDownLatch(1); - Streams.defer(Arrays.asList("1", "2", "3", "4", "5")) - .env(this.environment) - .get() - .map(new Function() { - @Override - public Integer apply(String s) { - return Integer.parseInt(s); - } - }) - .mapMany(new Function>() { - @Override - public Composable apply(Integer integer) { - return testGateway.multiply(integer); - } - }) - .collect() - .consume(new Consumer>() { - @Override - public void accept(List integers) { - ref.set(integers); - consumeLatch.countDown(); - } - }) - .flush(); + Streams.just("1", "2", "3", "4", "5") + .dispatchOn(this.environment) + .map(Integer::parseInt) + .flatMap(this.testGateway::multiply) + .toList() + .onSuccess(integers -> { + ref.set(integers); + consumeLatch.countDown(); + }); assertTrue(consumeLatch.await(2, TimeUnit.SECONDS)); @@ -1255,7 +1237,7 @@ public class EnableIntegrationTests { } @TestMessagingGateway - public static interface TestGateway { + public interface TestGateway { @Gateway(headers = @GatewayHeader(name = "calledMethod", expression = "#gatewayMethod.name")) String echo(String payload); @@ -1270,7 +1252,7 @@ public class EnableIntegrationTests { } @TestMessagingGateway2 - public static interface TestGateway2 { + public interface TestGateway2 { @Gateway(headers = @GatewayHeader(name = "calledMethod", expression = "#gatewayMethod.name")) String echo2(String payload); @@ -1281,7 +1263,7 @@ public class EnableIntegrationTests { @Retention(RetentionPolicy.RUNTIME) @MessagingGateway(defaultRequestChannel = "gatewayChannel", reactorEnvironment = "reactorEnv", defaultHeaders = @GatewayHeader(name = "foo", value = "FOO")) - public static @interface TestMessagingGateway { + public @interface TestMessagingGateway { String defaultRequestChannel() default ""; @@ -1290,7 +1272,7 @@ public class EnableIntegrationTests { @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @TestMessagingGateway(defaultRequestChannel = "gatewayChannel2") - public static @interface TestMessagingGateway2 { + public @interface TestMessagingGateway2 { String defaultRequestChannel() default ""; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/gateway/AsyncGatewayTests.java b/spring-integration-core/src/test/java/org/springframework/integration/gateway/AsyncGatewayTests.java index b88c476312..beca06f0d9 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/gateway/AsyncGatewayTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/gateway/AsyncGatewayTests.java @@ -46,9 +46,9 @@ import org.springframework.messaging.support.MessageBuilder; import org.springframework.util.concurrent.ListenableFuture; import org.springframework.util.concurrent.ListenableFutureCallback; -import reactor.core.Environment; -import reactor.core.composable.Promise; -import reactor.function.Consumer; +import reactor.Environment; +import reactor.rx.Promise; +import reactor.fn.Consumer; /** * @author Mark Fisher @@ -266,7 +266,7 @@ public class AsyncGatewayTests { long start = System.currentTimeMillis(); Object result = promise.await(1, TimeUnit.SECONDS); long elapsed = System.currentTimeMillis() - start; - assertTrue(elapsed >= 200); + assertTrue(elapsed <= 200); assertEquals("foobar", ((Message) result).getPayload()); } @@ -287,7 +287,7 @@ public class AsyncGatewayTests { Object result = promise.await(1, TimeUnit.SECONDS); long elapsed = System.currentTimeMillis() - start; - assertTrue(elapsed >= 200 - safety); + assertTrue(elapsed <= 200 - safety); assertEquals("foobar", result); } @@ -308,7 +308,7 @@ public class AsyncGatewayTests { Object result = promise.await(1, TimeUnit.SECONDS); long elapsed = System.currentTimeMillis() - start; - assertTrue(elapsed >= 200 - safety); + assertTrue(elapsed <= 200 - safety); assertTrue(result instanceof String); assertEquals("foobar", result); } @@ -331,19 +331,18 @@ public class AsyncGatewayTests { final AtomicReference result = new AtomicReference(); final CountDownLatch latch = new CountDownLatch(1); - promise.consume(new Consumer() { + promise.onSuccess(new Consumer() { @Override public void accept(String s) { result.set(s); latch.countDown(); } - }) - .flush(); + }); latch.await(1, TimeUnit.SECONDS); long elapsed = System.currentTimeMillis() - start; - assertTrue(elapsed >= 200 - safety); + assertTrue(elapsed <= 200 - safety); assertEquals("foobar", result.get()); } diff --git a/spring-integration-core/src/test/java/org/springframework/integration/gateway/TestService.java b/spring-integration-core/src/test/java/org/springframework/integration/gateway/TestService.java index 3aeb15582e..9a7e834549 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/gateway/TestService.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/gateway/TestService.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ import java.util.concurrent.Future; import org.springframework.messaging.handler.annotation.Payload; import org.springframework.messaging.Message; -import reactor.core.composable.Promise; +import reactor.rx.Promise; /** * @author Mark Fisher diff --git a/spring-integration-core/src/test/java/org/springframework/integration/json/JsonPathTests.java b/spring-integration-core/src/test/java/org/springframework/integration/json/JsonPathTests.java index 85bcddc94e..2cc3237d8e 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/json/JsonPathTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/json/JsonPathTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 the original author or authors. + * Copyright 2013-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,6 +50,8 @@ import org.springframework.test.context.support.AnnotationConfigContextLoader; import com.jayway.jsonpath.Criteria; import com.jayway.jsonpath.Filter; +import com.jayway.jsonpath.PathNotFoundException; +import com.jayway.jsonpath.Predicate; /** * @author Artem Bilan @@ -132,8 +134,8 @@ public class JsonPathTests { catch (Exception e) { //MessageTransformationException / MessageHandlingException / InvocationTargetException / IllegalArgumentException Throwable cause = e.getCause().getCause().getCause(); - assertTrue(cause instanceof IllegalArgumentException); - assertEquals("Invalid container object", cause.getMessage()); + assertTrue(cause instanceof PathNotFoundException); + assertEquals("Property ['store'] not found in path $", cause.getMessage()); } } @@ -211,7 +213,7 @@ public class JsonPathTests { public static class JsonPathTestsContextConfiguration { @Bean - public Filter jsonPathFilter() { + public Predicate jsonPathFilter() { return Filter.filter(Criteria.where("isbn").exists(true).and("category").ne("fiction")); } diff --git a/spring-integration-core/src/test/java/org/springframework/integration/routingslip/RoutingSlipTests.java b/spring-integration-core/src/test/java/org/springframework/integration/routingslip/RoutingSlipTests.java index 18712a2978..0fcb325823 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/routingslip/RoutingSlipTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/routingslip/RoutingSlipTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014 the original author or authors. + * Copyright 2014-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -60,8 +60,7 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.GenericXmlContextLoader; -import reactor.core.Environment; -import reactor.core.composable.spec.Streams; +import reactor.rx.Streams; import reactor.spring.context.config.EnableReactor; /** @@ -179,9 +178,6 @@ public class RoutingSlipTests { @EnableIntegration public static class RoutingSlipConfiguration { - @Autowired - private Environment reactorEnv; - @Bean public MessagingTemplate messagingTemplate() { return new MessagingTemplate(); @@ -196,19 +192,13 @@ public class RoutingSlipTests { public RoutingSlipRouteStrategy routeStrategy() { return (requestMessage, reply) -> requestMessage.getPayload() instanceof String ? new FixedSubscriberChannel(m -> - Streams.defer((String) m.getPayload()) - .env(this.reactorEnv) - .get() + Streams.just((String) m.getPayload()) .map(String::toUpperCase) - .consume(v -> messagingTemplate().convertAndSend(resultsChannel(), v)) - .flush()) + .consume(v -> messagingTemplate().convertAndSend(resultsChannel(), v))) : new FixedSubscriberChannel(m -> - Streams.defer((Integer) m.getPayload()) - .env(this.reactorEnv) - .get() + Streams.just((Integer) m.getPayload()) .map(v -> v * 2) - .consume(v -> messagingTemplate().convertAndSend(resultsChannel(), v)) - .flush()); + .consume(v -> messagingTemplate().convertAndSend(resultsChannel(), v))); } @Bean diff --git a/spring-integration-event/src/test/java/org/springframework/integration/event/inbound/ApplicationEventListeningMessageProducerTests.java b/spring-integration-event/src/test/java/org/springframework/integration/event/inbound/ApplicationEventListeningMessageProducerTests.java index a622746bb5..7fc58323dd 100644 --- a/spring-integration-event/src/test/java/org/springframework/integration/event/inbound/ApplicationEventListeningMessageProducerTests.java +++ b/spring-integration-event/src/test/java/org/springframework/integration/event/inbound/ApplicationEventListeningMessageProducerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -225,7 +225,8 @@ public class ApplicationEventListeningMessageProducerTests { ConfigurableListableBeanFactory beanFactory = ctx.getBeanFactory(); QueueChannel channel = new QueueChannel(); - ApplicationEventListeningMessageProducer listenerMessageProducer = new ApplicationEventListeningMessageProducer(); + ApplicationEventListeningMessageProducer listenerMessageProducer = + new ApplicationEventListeningMessageProducer(); listenerMessageProducer.setOutputChannel(channel); listenerMessageProducer.setEventTypes(TestApplicationEvent2.class); beanFactory.registerSingleton("testListenerMessageProducer", listenerMessageProducer); @@ -236,7 +237,8 @@ public class ApplicationEventListeningMessageProducerTests { ctx.refresh(); ApplicationEventMulticaster multicaster = - ctx.getBean(AbstractApplicationContext.APPLICATION_EVENT_MULTICASTER_BEAN_NAME, ApplicationEventMulticaster.class); + ctx.getBean(AbstractApplicationContext.APPLICATION_EVENT_MULTICASTER_BEAN_NAME, + ApplicationEventMulticaster.class); Map retrieverCache = TestUtils.getPropertyValue(multicaster, "retrieverCache", Map.class); ctx.publishEvent(new TestApplicationEvent1()); @@ -246,10 +248,11 @@ public class ApplicationEventListeningMessageProducerTests { * event if not supported. */ assertEquals(2, retrieverCache.size()); - for (Object key : retrieverCache.keySet()) { - Class event = TestUtils.getPropertyValue(key, "eventType", Class.class); + for (Map.Entry entry : retrieverCache.entrySet()) { + Class event = TestUtils.getPropertyValue(entry.getKey(), "eventType.resolved", + Class.class); assertThat(event, Matchers.is(Matchers.isOneOf(ContextRefreshedEvent.class, TestApplicationEvent1.class))); - Set listeners = TestUtils.getPropertyValue(retrieverCache.get(key), "applicationListenerBeans", Set.class); + Set listeners = TestUtils.getPropertyValue(entry.getValue(), "applicationListenerBeans", Set.class); assertEquals(1, listeners.size()); assertEquals("testListener", listeners.iterator().next()); } @@ -257,19 +260,21 @@ public class ApplicationEventListeningMessageProducerTests { TestApplicationEvent2 event2 = new TestApplicationEvent2(); ctx.publishEvent(event2); assertEquals(3, retrieverCache.size()); - for (Object key : retrieverCache.keySet()) { - Class event = TestUtils.getPropertyValue(key, "eventType", Class.class); + for (Map.Entry entry : retrieverCache.entrySet()) { + Class event = TestUtils.getPropertyValue(entry.getKey(), "eventType.resolved", Class.class); if (TestApplicationEvent2.class.isAssignableFrom(event)) { - Set listeners = TestUtils.getPropertyValue(retrieverCache.get(key), "applicationListenerBeans", Set.class); + Set listeners = TestUtils.getPropertyValue(entry.getValue(), "applicationListenerBeans", Set.class); assertEquals(2, listeners.size()); for (Object listener : listeners) { - assertThat((String) listener, Matchers.is(Matchers.isOneOf("testListenerMessageProducer", "testListener"))); + assertThat((String) listener, + Matchers.is(Matchers.isOneOf("testListenerMessageProducer", "testListener"))); } break; } } - ctx.publishEvent(new ApplicationEvent("Some event") {}); + ctx.publishEvent(new ApplicationEvent("Some event") { + }); assertEquals(4, listenerCounter.get()); @@ -286,6 +291,7 @@ public class ApplicationEventListeningMessageProducerTests { public TestApplicationEvent1() { super("event1"); } + } @SuppressWarnings("serial") @@ -294,6 +300,7 @@ public class ApplicationEventListeningMessageProducerTests { public TestApplicationEvent2() { super("event2"); } + } @SuppressWarnings("serial") @@ -302,6 +309,7 @@ public class ApplicationEventListeningMessageProducerTests { public TestMessagingEvent(Message message) { super(message); } + } private static class TestApplicationListener implements ApplicationListener { @@ -315,6 +323,7 @@ public class ApplicationEventListeningMessageProducerTests { public void onApplicationEvent(ApplicationEvent event) { this.counter.incrementAndGet(); } + } } diff --git a/spring-integration-event/src/test/java/org/springframework/integration/event/outbound/ApplicationEventPublishingMessageHandlerTests.java b/spring-integration-event/src/test/java/org/springframework/integration/event/outbound/ApplicationEventPublishingMessageHandlerTests.java index 10ac631ce3..55b2d7dade 100644 --- a/spring-integration-event/src/test/java/org/springframework/integration/event/outbound/ApplicationEventPublishingMessageHandlerTests.java +++ b/spring-integration-event/src/test/java/org/springframework/integration/event/outbound/ApplicationEventPublishingMessageHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,9 +23,8 @@ import org.junit.Test; import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationEventPublisher; -import org.springframework.messaging.Message; import org.springframework.integration.event.core.MessagingEvent; -import org.springframework.integration.event.outbound.ApplicationEventPublishingMessageHandler; +import org.springframework.messaging.Message; import org.springframework.messaging.support.GenericMessage; /** @@ -56,7 +55,7 @@ public class ApplicationEventPublishingMessageHandlerTests { handler.handleMessage(message); ApplicationEvent event = publisher.getLastEvent(); assertEquals(TestEvent.class, event.getClass()); - assertEquals("foo", ((TestEvent) event).getSource()); + assertEquals("foo", ((TestEvent) event).getSource()); } @@ -68,9 +67,16 @@ public class ApplicationEventPublishingMessageHandlerTests { return this.lastEvent; } + @Override public void publishEvent(ApplicationEvent event) { this.lastEvent = event; } + + @Override + public void publishEvent(Object event) { + + } + } diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/config/RemoteFileOutboundChannelAdapterParser.java b/spring-integration-file/src/main/java/org/springframework/integration/file/config/RemoteFileOutboundChannelAdapterParser.java index f1af695d3e..efbefe9cac 100644 --- a/spring-integration-file/src/main/java/org/springframework/integration/file/config/RemoteFileOutboundChannelAdapterParser.java +++ b/spring-integration-file/src/main/java/org/springframework/integration/file/config/RemoteFileOutboundChannelAdapterParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,8 +25,7 @@ import org.springframework.beans.factory.xml.ParserContext; import org.springframework.integration.config.xml.AbstractOutboundChannelAdapterParser; import org.springframework.integration.file.remote.RemoteFileOperations; import org.springframework.integration.file.remote.handler.FileTransferringMessageHandler; - -import reactor.util.StringUtils; +import org.springframework.util.StringUtils; /** * @author Oleg Zhurakousky diff --git a/spring-integration-file/src/test/java/org/springframework/integration/file/tail/FileTailingMessageProducerTests.java b/spring-integration-file/src/test/java/org/springframework/integration/file/tail/FileTailingMessageProducerTests.java index 53eaad9284..2d4ea1b0c5 100644 --- a/spring-integration-file/src/test/java/org/springframework/integration/file/tail/FileTailingMessageProducerTests.java +++ b/spring-integration-file/src/test/java/org/springframework/integration/file/tail/FileTailingMessageProducerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -95,12 +95,19 @@ public class FileTailingMessageProducerTests { this.adapter = adapter; final List events = new ArrayList(); adapter.setApplicationEventPublisher(new ApplicationEventPublisher() { + @Override public void publishEvent(ApplicationEvent event) { FileTailingEvent tailEvent = (FileTailingEvent) event; logger.warn(event); events.add(tailEvent); } + + @Override + public void publishEvent(Object event) { + + } + }); adapter.setFile(new File(testDir, "foo")); QueueChannel outputChannel = new QueueChannel(); diff --git a/spring-integration-groovy/src/test/java/org/springframework/integration/groovy/config/GroovyServiceActivatorTests.java b/spring-integration-groovy/src/test/java/org/springframework/integration/groovy/config/GroovyServiceActivatorTests.java index 49d3b18d20..6dc494a1fb 100644 --- a/spring-integration-groovy/src/test/java/org/springframework/integration/groovy/config/GroovyServiceActivatorTests.java +++ b/spring-integration-groovy/src/test/java/org/springframework/integration/groovy/config/GroovyServiceActivatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -91,7 +91,7 @@ public class GroovyServiceActivatorTests { @Test - public void referencedScriptAndCustomiser() throws Exception{ + public void referencedScriptAndCustomiser() throws Exception { groovyCustomizer.executed = false; QueueChannel replyChannel = new QueueChannel(); replyChannel.setBeanName("returnAddress"); @@ -115,7 +115,7 @@ public class GroovyServiceActivatorTests { } @Test - public void withScriptVariableGenerator() throws Exception{ + public void withScriptVariableGenerator() throws Exception { groovyCustomizer.executed = false; QueueChannel replyChannel = new QueueChannel(); replyChannel.setBeanName("returnAddress"); @@ -139,7 +139,7 @@ public class GroovyServiceActivatorTests { } @Test - public void inlineScript() throws Exception{ + public void inlineScript() throws Exception { groovyCustomizer.executed = false; QueueChannel replyChannel = new QueueChannel(); replyChannel.setBeanName("returnAddress"); @@ -161,7 +161,7 @@ public class GroovyServiceActivatorTests { } @Test - public void testScriptWithoutVariables() throws Exception{ + public void testScriptWithoutVariables() throws Exception { PollableChannel replyChannel = new QueueChannel(); for (int i = 1; i <= 3; i++) { Message message = MessageBuilder.withPayload("test-" + i).setReplyChannel(replyChannel).build(); @@ -182,7 +182,8 @@ public class GroovyServiceActivatorTests { //INT-2399 @Test(expected = MessageHandlingException.class) public void invalidInlineScript() throws Exception { - Message message = new ErrorMessage(new ReplyRequiredException(new GenericMessage("test"), "reply required!")); + Message message = + new ErrorMessage(new ReplyRequiredException(new GenericMessage("test"), "reply required!")); try { this.invalidInlineScript.send(message); fail("MessageHandlingException expected!"); @@ -190,15 +191,17 @@ public class GroovyServiceActivatorTests { catch (Exception e) { Throwable cause = e.getCause(); assertEquals(MissingPropertyException.class, cause.getClass()); - assertThat(cause.getMessage(), Matchers.containsString("No such property: ReplyRequiredException for class: groovy.lang")); - throw e; + assertThat(cause.getMessage(), + Matchers.containsString("No such property: ReplyRequiredException for class: groovy_lang")); + throw e; } } - @Test(expected=BeanDefinitionParsingException.class) - public void variablesAndScriptVariableGenerator() throws Exception{ - new ClassPathXmlApplicationContext("GroovyServiceActivatorTests-fail-withgenerator-context.xml", this.getClass()); + @Test(expected = BeanDefinitionParsingException.class) + public void variablesAndScriptVariableGenerator() throws Exception { + new ClassPathXmlApplicationContext("GroovyServiceActivatorTests-fail-withgenerator-context.xml", + this.getClass()).close(); } @Test @@ -208,7 +211,8 @@ public class GroovyServiceActivatorTests { } - public static class SampleScriptVariSource implements ScriptVariableGenerator{ + public static class SampleScriptVariSource implements ScriptVariableGenerator { + public Map generateScriptVariables(Message message) { Map variables = new HashMap(); variables.put("foo", "foo"); @@ -218,6 +222,7 @@ public class GroovyServiceActivatorTests { variables.put("headers", message.getHeaders()); return variables; } + } @@ -228,6 +233,7 @@ public class GroovyServiceActivatorTests { public void customize(GroovyObject goo) { this.executed = true; } + } } diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/AbstractTcpChannelAdapterTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/AbstractTcpChannelAdapterTests.java index a4610afd09..08d1d63ba2 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/AbstractTcpChannelAdapterTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/AbstractTcpChannelAdapterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 the original author or authors. + * Copyright 2013-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.integration.ip.tcp; import org.springframework.context.ApplicationEvent; @@ -32,6 +33,12 @@ public class AbstractTcpChannelAdapterTests { @Override public void publishEvent(ApplicationEvent event) { } + + @Override + public void publishEvent(Object event) { + + } + }; protected HelloWorldInterceptorFactory newInterceptorFactory() { diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/CachingClientConnectionFactoryTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/CachingClientConnectionFactoryTests.java index d14ea70ee7..a3b11056a2 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/CachingClientConnectionFactoryTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/CachingClientConnectionFactoryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.integration.ip.tcp.connection; import static org.junit.Assert.assertEquals; @@ -355,6 +356,12 @@ public class CachingClientConnectionFactoryTests { @Override public void publishEvent(ApplicationEvent event) { } + + @Override + public void publishEvent(Object event) { + + } + }, "foo"); conn.setMapper(new TcpMessageMapper()); conn.setSerializer(new ByteArrayCrLfSerializer()); @@ -371,6 +378,12 @@ public class CachingClientConnectionFactoryTests { @Override public void publishEvent(ApplicationEvent event) { } + + @Override + public void publishEvent(Object event) { + + } + }, "foo"); conn.setMapper(new TcpMessageMapper()); conn.setSerializer(new ByteArrayCrLfSerializer()); diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/ConnectionEventTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/ConnectionEventTests.java index 4888a3dd60..02d9a197b5 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/ConnectionEventTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/ConnectionEventTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.integration.ip.tcp.connection; import static org.junit.Assert.assertNotNull; @@ -48,9 +49,16 @@ public class ConnectionEventTests { final List theEvent = new ArrayList(); TcpNetConnection conn = new TcpNetConnection(socket, false, false, new ApplicationEventPublisher() { + @Override public void publishEvent(ApplicationEvent event) { theEvent.add((TcpConnectionEvent) event); } + + @Override + public void publishEvent(Object event) { + + } + }, "foo"); /* * Open is not published by the connection itself; the factory publishes it after initialization. diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/ConnectionFactoryTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/ConnectionFactoryTests.java index ffe4422241..169ed2f460 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/ConnectionFactoryTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/ConnectionFactoryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.integration.ip.tcp.connection; import static org.junit.Assert.assertEquals; @@ -53,9 +54,17 @@ public class ConnectionFactoryTests { final List events = Collections.synchronizedList(new ArrayList()); ApplicationEventPublisher publisher = new ApplicationEventPublisher() { + + @Override public void publishEvent(ApplicationEvent event) { events.add((TcpConnectionEvent) event); } + + @Override + public void publishEvent(Object event) { + + } + }; int port = SocketUtils.findAvailableServerSocket(); TcpNetServerConnectionFactory serverFactory = new TcpNetServerConnectionFactory(port); diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/ConnectionTimeoutTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/ConnectionTimeoutTests.java index 828a396ecb..48126929fb 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/ConnectionTimeoutTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/ConnectionTimeoutTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -269,12 +269,19 @@ public class ConnectionTimeoutTests { final CountDownLatch clientClosedLatch; clientClosedLatch = new CountDownLatch(1); client.setApplicationEventPublisher(new ApplicationEventPublisher() { + @Override public void publishEvent(ApplicationEvent event) { if (event instanceof TcpConnectionCloseEvent) { clientClosedLatch.countDown(); } } + + @Override + public void publishEvent(Object event) { + + } + }); return clientClosedLatch; } diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/FailoverClientConnectionFactoryTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/FailoverClientConnectionFactoryTests.java index 4fad08a21d..530a3d7a9d 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/FailoverClientConnectionFactoryTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/FailoverClientConnectionFactoryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.integration.ip.tcp.connection; import static org.junit.Assert.assertNotNull; @@ -309,6 +310,12 @@ public class FailoverClientConnectionFactoryTests { @Override public void publishEvent(ApplicationEvent event) { } + + @Override + public void publishEvent(Object event) { + + } + }; client1.setApplicationEventPublisher(pub); client2.setApplicationEventPublisher(pub); diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/TcpNetConnectionTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/TcpNetConnectionTests.java index b236e9466c..d9ba501d9a 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/TcpNetConnectionTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/TcpNetConnectionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.integration.ip.tcp.connection; import static org.junit.Assert.assertEquals; @@ -55,8 +56,16 @@ import org.springframework.messaging.support.ErrorMessage; public class TcpNetConnectionTests { private final ApplicationEventPublisher nullPublisher = new ApplicationEventPublisher() { + + @Override public void publishEvent(ApplicationEvent event) { } + + @Override + public void publishEvent(Object event) { + + } + }; @Test @@ -93,7 +102,8 @@ public class TcpNetConnectionTests { Socket socket = mock(Socket.class); when(socketChannel.socket()).thenReturn(socket); TcpNioConnection connection = new TcpNioConnection(socketChannel, true, false, nullPublisher, null); - ChannelInputStream inputStream = TestUtils.getPropertyValue(connection, "channelInputStream", ChannelInputStream.class); + ChannelInputStream inputStream = + TestUtils.getPropertyValue(connection, "channelInputStream", ChannelInputStream.class); inputStream.write(new byte[] {(byte) 0x80}, 1); assertEquals(0x80, inputStream.read()); } @@ -145,4 +155,5 @@ public class TcpNetConnectionTests { assertEquals("foo", inboundMessage.get().getPayload()); assertEquals("baz", inboundMessage.get().getHeaders().get("bar")); } + } diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/TcpNioConnectionTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/TcpNioConnectionTests.java index e32b27db66..b746b0d0a3 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/TcpNioConnectionTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/TcpNioConnectionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -98,9 +98,16 @@ import org.springframework.util.ReflectionUtils.FieldFilter; public class TcpNioConnectionTests { private final ApplicationEventPublisher nullPublisher = new ApplicationEventPublisher() { + @Override public void publishEvent(ApplicationEvent event) { } + + @Override + public void publishEvent(Object event) { + + } + }; @Test @@ -713,6 +720,12 @@ public class TcpNioConnectionTests { public void publishEvent(ApplicationEvent event) { connectionLatch.countDown(); } + + @Override + public void publishEvent(Object event) { + + } + }); final CountDownLatch assemblerLatch = new CountDownLatch(1); final AtomicReference assembler = new AtomicReference(); diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/serializer/DeserializationTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/serializer/DeserializationTests.java index 74df17d6d2..50c41434d0 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/serializer/DeserializationTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/serializer/DeserializationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -302,6 +302,12 @@ public class DeserializationTests { public void publishEvent(ApplicationEvent anEvent) { event.set((TcpDeserializationExceptionEvent) anEvent); } + + @Override + public void publishEvent(Object event) { + + } + } Publisher publisher = new Publisher(); ByteArrayInputStream bais = new ByteArrayInputStream(data); diff --git a/spring-integration-mail/src/test/java/org/springframework/integration/mail/ImapMailReceiverTests.java b/spring-integration-mail/src/test/java/org/springframework/integration/mail/ImapMailReceiverTests.java index de6833de2a..59fe8216c1 100644 --- a/spring-integration-mail/src/test/java/org/springframework/integration/mail/ImapMailReceiverTests.java +++ b/spring-integration-mail/src/test/java/org/springframework/integration/mail/ImapMailReceiverTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -752,6 +752,12 @@ public class ImapMailReceiverTests { theEvent.set((ImapIdleExceptionEvent) event); latch.countDown(); } + + @Override + public void publishEvent(Object event) { + + } + }); ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler(); taskScheduler.initialize(); diff --git a/spring-integration-mqtt/src/test/java/org/springframework/integration/mqtt/BackToBackAdapterTests.java b/spring-integration-mqtt/src/test/java/org/springframework/integration/mqtt/BackToBackAdapterTests.java index d27f56e3f0..5cba1ae340 100644 --- a/spring-integration-mqtt/src/test/java/org/springframework/integration/mqtt/BackToBackAdapterTests.java +++ b/spring-integration-mqtt/src/test/java/org/springframework/integration/mqtt/BackToBackAdapterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -346,6 +346,11 @@ public class BackToBackAdapterTests { latch.countDown(); } + @Override + public void publishEvent(Object event) { + + } + } } diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisQueueInboundGatewayParserTests.java b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisQueueInboundGatewayParserTests.java index c4cb78a9b4..b5bdf10fd8 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisQueueInboundGatewayParserTests.java +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisQueueInboundGatewayParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014 the original author or authors. + * Copyright 2014-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ package org.springframework.integration.redis.config; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; @@ -34,8 +35,6 @@ import org.springframework.messaging.PollableChannel; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import reactor.util.Assert; - /** * @author David Liu * @author Artem Bilan @@ -68,7 +67,7 @@ public class RedisQueueInboundGatewayParserTests { assertSame(this.receiveChannel, TestUtils.getPropertyValue(this.defaultGateway, "replyChannel")); assertSame(this.requestChannel, TestUtils.getPropertyValue(this.defaultGateway, "requestChannel")); assertEquals(2000L, TestUtils.getPropertyValue(this.defaultGateway, "replyTimeout")); - Assert.notNull(TestUtils.getPropertyValue(this.defaultGateway, "taskExecutor")); + assertNotNull(TestUtils.getPropertyValue(this.defaultGateway, "taskExecutor")); assertFalse(TestUtils.getPropertyValue(this.defaultGateway, "autoStartup", Boolean.class)); assertEquals(3, TestUtils.getPropertyValue(this.defaultGateway, "phase")); } diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/inbound/RedisQueueMessageDrivenEndpointTests.java b/spring-integration-redis/src/test/java/org/springframework/integration/redis/inbound/RedisQueueMessageDrivenEndpointTests.java index 690355ab3e..56e70fb883 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/inbound/RedisQueueMessageDrivenEndpointTests.java +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/inbound/RedisQueueMessageDrivenEndpointTests.java @@ -283,6 +283,12 @@ public class RedisQueueMessageDrivenEndpointTests extends RedisAvailableTests { exceptionEvents.add(event); exceptionsLatch.countDown(); } + + @Override + public void publishEvent(Object event) { + + } + }); endpoint.setOutputChannel(channel); endpoint.setReceiveTimeout(100); diff --git a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/TestSftpServer.java b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/TestSftpServer.java index a9965f4b78..8d2df4397c 100644 --- a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/TestSftpServer.java +++ b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/TestSftpServer.java @@ -1,5 +1,5 @@ /* - * Copyright 2014 the original author or authors. + * Copyright 2014-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,18 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.integration.sftp; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; -import java.util.Arrays; +import java.util.Collections; import org.apache.sshd.SshServer; import org.apache.sshd.common.NamedFactory; -import org.apache.sshd.common.file.FileSystemView; -import org.apache.sshd.common.file.nativefs.NativeFileSystemFactory; -import org.apache.sshd.common.file.nativefs.NativeFileSystemView; +import org.apache.sshd.common.file.virtualfs.VirtualFileSystemFactory; import org.apache.sshd.server.Command; import org.apache.sshd.server.PasswordAuthenticator; import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider; @@ -121,33 +120,20 @@ public class TestSftpServer implements InitializingBean, DisposableBean { @SuppressWarnings("unchecked") @Override public void afterPropertiesSet() throws Exception { + this.sftpFolder.create(); + this.localFolder.create(); server.setPasswordAuthenticator(new PasswordAuthenticator() { @Override public boolean authenticate(String arg0, String arg1, ServerSession arg2) { return true; } + }); server.setPort(port); server.setKeyPairProvider(new SimpleGeneratorHostKeyProvider("hostkey.ser")); - SftpSubsystem.Factory sftp = new SftpSubsystem.Factory(); - server.setSubsystemFactories(Arrays.>asList(sftp)); - server.setFileSystemFactory(new NativeFileSystemFactory() { - - @Override - public FileSystemView createFileSystemView(org.apache.sshd.common.Session session) { - return new NativeFileSystemView(session.getUsername(), false) { - - @Override - public String getVirtualUserDir() { - return sftpRootFolder.getAbsolutePath(); - } - }; - } - - }); - this.sftpFolder.create(); - this.localFolder.create(); + this.server.setSubsystemFactories(Collections.>singletonList(new SftpSubsystem.Factory())); + this.server.setFileSystemFactory(new VirtualFileSystemFactory(sftpRootFolder.getAbsolutePath())); server.start(); } diff --git a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/session/SftpServerTests.java b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/session/SftpServerTests.java index 910e4c2faf..5698228b04 100644 --- a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/session/SftpServerTests.java +++ b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/session/SftpServerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014 the original author or authors. + * Copyright 2014-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,13 +28,11 @@ import java.nio.ByteBuffer; import java.security.KeyFactory; import java.security.PublicKey; import java.security.spec.RSAPublicKeySpec; -import java.util.Arrays; +import java.util.Collections; import org.apache.sshd.SshServer; import org.apache.sshd.common.NamedFactory; -import org.apache.sshd.common.file.FileSystemView; -import org.apache.sshd.common.file.nativefs.NativeFileSystemFactory; -import org.apache.sshd.common.file.nativefs.NativeFileSystemView; +import org.apache.sshd.common.file.virtualfs.VirtualFileSystemFactory; import org.apache.sshd.common.util.Base64; import org.apache.sshd.server.Command; import org.apache.sshd.server.PasswordAuthenticator; @@ -53,6 +51,7 @@ import org.springframework.util.StreamUtils; import com.jcraft.jsch.ChannelSftp.LsEntry; /** + * * * @author Gary Russell * @author David Liu * @since 4.1 @@ -75,26 +74,10 @@ public class SftpServerTests { }); server.setPort(port); server.setKeyPairProvider(new SimpleGeneratorHostKeyProvider("hostkey.ser")); - SftpSubsystem.Factory sftp = new SftpSubsystem.Factory(); - server.setSubsystemFactories(Arrays.>asList(sftp)); - server.setFileSystemFactory(new NativeFileSystemFactory() { - - @Override - public FileSystemView createFileSystemView(org.apache.sshd.common.Session session) { - final String pathname = System.getProperty("java.io.tmpdir") + File.separator + "sftptest" - + File.separator; - File f = new File(pathname); - f.mkdirs(); - return new NativeFileSystemView(session.getUsername(), false) { - - @Override - public String getVirtualUserDir() { - return pathname; - } - }; - } - - }); + server.setSubsystemFactories(Collections.>singletonList(new SftpSubsystem.Factory())); + final String pathname = System.getProperty("java.io.tmpdir") + File.separator + "sftptest" + File.separator; + new File(pathname).mkdirs(); + server.setFileSystemFactory(new VirtualFileSystemFactory(pathname)); server.start(); DefaultSftpSessionFactory f = new DefaultSftpSessionFactory(); @@ -127,26 +110,10 @@ public class SftpServerTests { }); server.setPort(port); server.setKeyPairProvider(new SimpleGeneratorHostKeyProvider("hostkey.ser")); - SftpSubsystem.Factory sftp = new SftpSubsystem.Factory(); - server.setSubsystemFactories(Arrays.>asList(sftp)); - server.setFileSystemFactory(new NativeFileSystemFactory() { - - @Override - public FileSystemView createFileSystemView(org.apache.sshd.common.Session session) { - final String pathname = System.getProperty("java.io.tmpdir") + File.separator + "sftptest" - + File.separator; - File f = new File(pathname); - f.mkdirs(); - return new NativeFileSystemView(session.getUsername(), false) { - - @Override - public String getVirtualUserDir() { - return pathname; - } - }; - } - - }); + server.setSubsystemFactories(Collections.>singletonList(new SftpSubsystem.Factory())); + final String pathname = System.getProperty("java.io.tmpdir") + File.separator + "sftptest" + File.separator; + new File(pathname).mkdirs(); + server.setFileSystemFactory(new VirtualFileSystemFactory(pathname)); server.start(); DefaultSftpSessionFactory f = new DefaultSftpSessionFactory();