diff --git a/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/config/SftpInboundSynchronizingMessageSourceFactoryBean.java b/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/config/SftpInboundSynchronizingMessageSourceFactoryBean.java index b029530b39..16a93d6a8d 100644 --- a/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/config/SftpInboundSynchronizingMessageSourceFactoryBean.java +++ b/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/config/SftpInboundSynchronizingMessageSourceFactoryBean.java @@ -28,8 +28,8 @@ import org.springframework.core.io.ResourceLoader; import org.springframework.integration.file.filters.CompositeFileListFilter; import org.springframework.integration.file.filters.FileListFilter; import org.springframework.integration.sftp.filters.SftpPatternMatchingFileListFilter; -import org.springframework.integration.sftp.inbound.SftpInboundRemoteFileSystemSynchronizer; -import org.springframework.integration.sftp.inbound.SftpInboundRemoteFileSystemSynchronizingMessageSource; +import org.springframework.integration.sftp.inbound.SftpInboundSynchronizer; +import org.springframework.integration.sftp.inbound.SftpInboundSynchronizingMessageSource; import org.springframework.integration.sftp.session.QueuedSftpSessionPool; import org.springframework.integration.sftp.session.SftpSessionFactory; import org.springframework.util.StringUtils; @@ -44,7 +44,7 @@ import com.jcraft.jsch.ChannelSftp; * @since 2.0 */ class SftpInboundSynchronizingMessageSourceFactoryBean - extends AbstractFactoryBean implements ResourceLoaderAware { + extends AbstractFactoryBean implements ResourceLoaderAware { private volatile ResourceLoader resourceLoader; @@ -126,10 +126,10 @@ class SftpInboundSynchronizingMessageSourceFactoryBean * @return Fully configured SftpInboundRemoteFileSystemSynchronizingMessageSource */ @Override - protected SftpInboundRemoteFileSystemSynchronizingMessageSource createInstance() throws Exception { + protected SftpInboundSynchronizingMessageSource createInstance() throws Exception { boolean autoCreatDirs = Boolean.parseBoolean(this.autoCreateDirectories); boolean ackRemoteDir = Boolean.parseBoolean(this.autoDeleteRemoteFilesOnSync); - SftpInboundRemoteFileSystemSynchronizingMessageSource sftpMsgSrc = new SftpInboundRemoteFileSystemSynchronizingMessageSource(); + SftpInboundSynchronizingMessageSource sftpMsgSrc = new SftpInboundSynchronizingMessageSource(); sftpMsgSrc.setAutoCreateDirectories(autoCreatDirs); // local directories @@ -156,7 +156,7 @@ class SftpInboundSynchronizingMessageSourceFactoryBean QueuedSftpSessionPool pool = new QueuedSftpSessionPool(15, sftpSessionFactory); pool.afterPropertiesSet(); - SftpInboundRemoteFileSystemSynchronizer sftpSync = new SftpInboundRemoteFileSystemSynchronizer(); + SftpInboundSynchronizer sftpSync = new SftpInboundSynchronizer(); sftpSync.setClientPool(pool); sftpSync.setLocalDirectory(this.localDirectoryResource); sftpSync.setShouldDeleteSourceFile(ackRemoteDir); diff --git a/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/inbound/SftpInboundRemoteFileSystemSynchronizer.java b/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/inbound/SftpInboundSynchronizer.java similarity index 97% rename from spring-integration-sftp/src/main/java/org/springframework/integration/sftp/inbound/SftpInboundRemoteFileSystemSynchronizer.java rename to spring-integration-sftp/src/main/java/org/springframework/integration/sftp/inbound/SftpInboundSynchronizer.java index 31316c65b8..fa87e59697 100644 --- a/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/inbound/SftpInboundRemoteFileSystemSynchronizer.java +++ b/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/inbound/SftpInboundSynchronizer.java @@ -41,7 +41,7 @@ import java.util.Collection; * @author Josh Long * @since 2.0 */ -public class SftpInboundRemoteFileSystemSynchronizer extends AbstractInboundRemoteFileSystemSychronizer { +public class SftpInboundSynchronizer extends AbstractInboundRemoteFileSystemSychronizer { /** * the path on the remote mount diff --git a/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/inbound/SftpInboundRemoteFileSystemSynchronizingMessageSource.java b/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/inbound/SftpInboundSynchronizingMessageSource.java similarity index 94% rename from spring-integration-sftp/src/main/java/org/springframework/integration/sftp/inbound/SftpInboundRemoteFileSystemSynchronizingMessageSource.java rename to spring-integration-sftp/src/main/java/org/springframework/integration/sftp/inbound/SftpInboundSynchronizingMessageSource.java index 44972d3827..c82a0891e9 100644 --- a/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/inbound/SftpInboundRemoteFileSystemSynchronizingMessageSource.java +++ b/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/inbound/SftpInboundSynchronizingMessageSource.java @@ -31,7 +31,7 @@ import org.springframework.util.Assert; * @author Oleg Zhurakousky * @since 2.0 */ -public class SftpInboundRemoteFileSystemSynchronizingMessageSource extends AbstractInboundRemoteFileSystemSynchronizingMessageSource { +public class SftpInboundSynchronizingMessageSource extends AbstractInboundRemoteFileSystemSynchronizingMessageSource { /** * the pool of sessions */ diff --git a/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/session/SftpSession.java b/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/session/SftpSession.java index 509648e7fc..1efb08602c 100644 --- a/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/session/SftpSession.java +++ b/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/session/SftpSession.java @@ -16,17 +16,14 @@ package org.springframework.integration.sftp.session; +import java.io.InputStream; + +import org.apache.commons.lang.StringUtils; + import com.jcraft.jsch.ChannelSftp; -import com.jcraft.jsch.Identity; import com.jcraft.jsch.JSch; import com.jcraft.jsch.Session; import com.jcraft.jsch.UserInfo; -import org.apache.commons.lang.StringUtils; - -import org.springframework.core.io.Resource; - -import java.io.File; -import java.io.InputStream; /** * There are many ways to create a {@link SftpSession} just as there are many ways to SSH into a remote system. diff --git a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/InboundChannelAdapaterParserTests-context.xml b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/InboundChannelAdapaterParserTests-context.xml index 7e5310e2de..d4a8d39cbe 100644 --- a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/InboundChannelAdapaterParserTests-context.xml +++ b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/InboundChannelAdapaterParserTests-context.xml @@ -18,7 +18,9 @@ http://www.springframework.org/schema/integration/sftp http://www.springframework.org/schema/integration/sftp/spring-integration-sftp-2.0.xsd"> - + + + @@ -34,10 +36,10 @@ session-factory="sftpSessionFactory" channel="requestChannel" filter="filter" - filename-pattern="foo*.txt" + filename-pattern="foo.txt" remote-directory="ftp://foo" - local-directory-path="file:target/foo" - auto-create-directories="true" + local-directory-path="file:src/main/resources" + auto-create-directories="false" auto-delete-remote-files-on-sync="false"> @@ -46,7 +48,7 @@ channel="requestChannel" session-factory="sftpSessionFactory" filter="filter" - filename-pattern="foo*.txt" + filename-pattern="foo.txt" remote-directory="ftp://foo" local-directory-path="file:target" auto-create-directories="true" @@ -55,8 +57,8 @@ - - + + diff --git a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/InboundChannelAdapaterParserTests.java b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/InboundChannelAdapaterParserTests.java index fa3dae5344..91339ca08c 100644 --- a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/InboundChannelAdapaterParserTests.java +++ b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/InboundChannelAdapaterParserTests.java @@ -16,6 +16,7 @@ package org.springframework.integration.sftp.config; +import static junit.framework.Assert.assertNotNull; import static junit.framework.Assert.assertTrue; import java.io.File; @@ -25,7 +26,12 @@ import org.junit.Before; import org.junit.Test; import org.springframework.beans.factory.BeanCreationException; +import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; +import org.springframework.integration.core.PollableChannel; +import org.springframework.integration.endpoint.SourcePollingChannelAdapter; +import org.springframework.integration.sftp.inbound.SftpInboundSynchronizingMessageSource; +import org.springframework.integration.test.util.TestUtils; /** * @author Oleg Zhurakousky @@ -38,11 +44,18 @@ public class InboundChannelAdapaterParserTests { } @Test - public void testLocalFilesAutoCreationTrue() throws Exception{ - assertTrue(!new File("target/foo").exists()); - new ClassPathXmlApplicationContext("InboundChannelAdapaterParserTests-context.xml", this.getClass()); - assertTrue(new File("target/foo").exists()); - assertTrue(!new File("target/bar").exists()); + public void testWithLocalFiles() throws Exception{ + ApplicationContext context = + new ClassPathXmlApplicationContext("InboundChannelAdapaterParserTests-context.xml", this.getClass()); + assertTrue(new File("src/main/resources").exists()); + + Object adapter = context.getBean("sftpAdapterAutoCreate"); + assertTrue(adapter instanceof SourcePollingChannelAdapter); + SftpInboundSynchronizingMessageSource source = + (SftpInboundSynchronizingMessageSource) TestUtils.getPropertyValue(adapter, "source"); + assertNotNull(source); + PollableChannel requestChannel = context.getBean("requestChannel", PollableChannel.class); + assertNotNull(requestChannel.receive(2000)); } @Test(expected=BeanCreationException.class) diff --git a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/OutboundChannelAdapaterParserTests.java b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/OutboundChannelAdapaterParserTests.java index ab915c2294..e4d62dfdc6 100644 --- a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/OutboundChannelAdapaterParserTests.java +++ b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/OutboundChannelAdapaterParserTests.java @@ -1,11 +1,22 @@ -/** - * +/* + * Copyright 2002-2010 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.springframework.integration.sftp.config; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertNotNull; -import static junit.framework.Assert.assertNull; import static junit.framework.Assert.assertTrue; import org.junit.Test; @@ -21,10 +32,8 @@ import org.springframework.integration.sftp.session.QueuedSftpSessionPool; import org.springframework.integration.sftp.session.SftpSessionFactory; import org.springframework.integration.test.util.TestUtils; -import com.sun.tools.doclets.internal.toolkit.taglets.LiteralTaglet; - /** - * @author ozhurakousky + * @author Oleg Zhurakousky * */ public class OutboundChannelAdapaterParserTests { diff --git a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/impl/SftpInboundRemoteFileSystemSynchronizerTests.java b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/impl/SftpInboundRemoteFileSystemSynchronizerTests.java index 7b9d659c71..6fac0504df 100644 --- a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/impl/SftpInboundRemoteFileSystemSynchronizerTests.java +++ b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/impl/SftpInboundRemoteFileSystemSynchronizerTests.java @@ -26,7 +26,7 @@ import org.junit.Test; import org.springframework.core.io.FileSystemResource; import org.springframework.core.io.Resource; import org.springframework.integration.file.synchronization.AbstractInboundRemoteFileSystemSychronizer.EntryAcknowledgmentStrategy; -import org.springframework.integration.sftp.inbound.SftpInboundRemoteFileSystemSynchronizer; +import org.springframework.integration.sftp.inbound.SftpInboundSynchronizer; import org.springframework.integration.sftp.session.SftpSession; import org.springframework.util.ReflectionUtils; @@ -62,7 +62,7 @@ public class SftpInboundRemoteFileSystemSynchronizerTests { */ @Test public void testCopyAndRenameWhenLocalFileExists() throws Exception { - SftpInboundRemoteFileSystemSynchronizer synchronizer = new SftpInboundRemoteFileSystemSynchronizer(); + SftpInboundSynchronizer synchronizer = new SftpInboundSynchronizer(); Method method = ReflectionUtils.findMethod(synchronizer.getClass(), "copyFromRemoteToLocalDirectory", SftpSession.class, LsEntry.class, Resource.class); method.setAccessible(true); @@ -84,7 +84,7 @@ public class SftpInboundRemoteFileSystemSynchronizerTests { @org.junit.Ignore @Test public void testCopyAndRenameWhenLocalFileDoesntExist() throws Exception { - SftpInboundRemoteFileSystemSynchronizer synchronizer = new SftpInboundRemoteFileSystemSynchronizer(); + SftpInboundSynchronizer synchronizer = new SftpInboundSynchronizer(); synchronizer.setEntryAcknowledgmentStrategy(mock(EntryAcknowledgmentStrategy.class)); Method method = ReflectionUtils.findMethod(synchronizer.getClass(), "copyFromRemoteToLocalDirectory", SftpSession.class, LsEntry.class, Resource.class); diff --git a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/inbound/SftpInboundRemoteFileSystemSynchronizerTests.java b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/inbound/SftpInboundRemoteFileSystemSynchronizerTests.java index b5c02e7fbb..fad303f5bd 100644 --- a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/inbound/SftpInboundRemoteFileSystemSynchronizerTests.java +++ b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/inbound/SftpInboundRemoteFileSystemSynchronizerTests.java @@ -49,7 +49,7 @@ public class SftpInboundRemoteFileSystemSynchronizerTests { if (file.exists()){ file.delete(); } - SftpInboundRemoteFileSystemSynchronizer syncronizer = new SftpInboundRemoteFileSystemSynchronizer(); + SftpInboundSynchronizer syncronizer = new SftpInboundSynchronizer(); syncronizer.setLocalDirectory(new FileSystemResource(System.getProperty("java.io.tmpdir"))); syncronizer.setRemotePath("foo/bar");