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
This commit is contained in:
Artem Bilan
2015-02-17 13:34:59 +02:00
committed by Gary Russell
parent b07686cdc0
commit f248394682
37 changed files with 312 additions and 245 deletions

View File

@@ -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")
}
}

View File

@@ -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.
* <p> This attribute is required in case of {@link reactor.core.composable.Promise} usage.
* <p> This attribute is required in case of {@link reactor.rx.Promise} usage.
* @return the suggested reactor Environment bean name.
* @since 4.1
*/

View File

@@ -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".

View File

@@ -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");

View File

@@ -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.<Object>task(Functions.supplier(new AsyncInvocationTask(invocation)))
.env(this.reactorEnvironment)
.get();
return Promises.<Object>task(this.reactorEnvironment,
Functions.supplier(new AsyncInvocationTask(invocation)));
}
return this.doInvoke(invocation);
}

View File

@@ -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> T evaluate(Object json, String jsonPath, Filter<?>... filters) throws Exception {
public static <T> 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);
}
}

View File

@@ -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.

View File

@@ -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

View File

@@ -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();

View File

@@ -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);

View File

@@ -53,6 +53,6 @@
<beans:bean id="testExecutor" class="org.springframework.integration.config.xml.GatewayParserTests$TestExecutor"/>
<beans:bean id="reactorEnvironment" class="reactor.core.Environment" destroy-method="shutdown"/>
<beans:bean id="reactorEnvironment" class="reactor.Environment" destroy-method="shutdown"/>
</beans:beans>

View File

@@ -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

View File

@@ -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<List<Integer>> ref = new AtomicReference<List<Integer>>();
final CountDownLatch consumeLatch = new CountDownLatch(1);
Streams.defer(Arrays.asList("1", "2", "3", "4", "5"))
.env(this.environment)
.get()
.map(new Function<String, Integer>() {
@Override
public Integer apply(String s) {
return Integer.parseInt(s);
}
})
.mapMany(new Function<Integer, Composable<Integer>>() {
@Override
public Composable<Integer> apply(Integer integer) {
return testGateway.multiply(integer);
}
})
.collect()
.consume(new Consumer<List<Integer>>() {
@Override
public void accept(List<Integer> 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 "";

View File

@@ -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<String> result = new AtomicReference<String>();
final CountDownLatch latch = new CountDownLatch(1);
promise.consume(new Consumer<String>() {
promise.onSuccess(new Consumer<String>() {
@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());
}

View File

@@ -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

View File

@@ -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"));
}

View File

@@ -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

View File

@@ -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<? extends ApplicationEvent> event = TestUtils.getPropertyValue(key, "eventType", Class.class);
for (Map.Entry<?, ?> entry : retrieverCache.entrySet()) {
Class<? extends ApplicationEvent> 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<ApplicationEvent> {
@@ -315,6 +323,7 @@ public class ApplicationEventListeningMessageProducerTests {
public void onApplicationEvent(ApplicationEvent event) {
this.counter.incrementAndGet();
}
}
}

View File

@@ -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) {
}
}

View File

@@ -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

View File

@@ -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<FileTailingEvent> events = new ArrayList<FileTailingEvent>();
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();

View File

@@ -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<String>("test"), "reply required!"));
Message<?> message =
new ErrorMessage(new ReplyRequiredException(new GenericMessage<String>("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<String, Object> generateScriptVariables(Message<?> message) {
Map<String, Object> variables = new HashMap<String, Object>();
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;
}
}
}

View File

@@ -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() {

View File

@@ -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());

View File

@@ -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<TcpConnectionEvent> theEvent = new ArrayList<TcpConnectionEvent>();
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.

View File

@@ -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<TcpConnectionEvent> events =
Collections.synchronizedList(new ArrayList<TcpConnectionEvent>());
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);

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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"));
}
}

View File

@@ -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<Thread> assembler = new AtomicReference<Thread>();

View File

@@ -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);

View File

@@ -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();

View File

@@ -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) {
}
}
}

View File

@@ -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"));
}

View File

@@ -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);

View File

@@ -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.<NamedFactory<Command>>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.<NamedFactory<Command>>singletonList(new SftpSubsystem.Factory()));
this.server.setFileSystemFactory(new VirtualFileSystemFactory(sftpRootFolder.getAbsolutePath()));
server.start();
}

View File

@@ -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.<NamedFactory<Command>>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.<NamedFactory<Command>>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.<NamedFactory<Command>>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.<NamedFactory<Command>>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();