INT-1614 finished polishing SFTP, fixed tests, imports etc.
This commit is contained in:
@@ -18,7 +18,9 @@
|
||||
http://www.springframework.org/schema/integration/sftp http://www.springframework.org/schema/integration/sftp/spring-integration-sftp-2.0.xsd">
|
||||
|
||||
|
||||
<channel id="requestChannel"/>
|
||||
<channel id="requestChannel">
|
||||
<queue/>
|
||||
</channel>
|
||||
|
||||
<beans:bean id="sftpSessionFactory" class="org.springframework.integration.sftp.session.SftpSessionFactory">
|
||||
<beans:property name="host" value="loclahost"/>
|
||||
@@ -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">
|
||||
<poller fixed-rate="1000"/>
|
||||
</sftp:inbound-channel-adapter>
|
||||
@@ -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 @@
|
||||
</sftp:inbound-channel-adapter>
|
||||
|
||||
|
||||
<beans:bean id="filter" class="org.mockito.Mockito" factory-method="mock">
|
||||
<beans:constructor-arg value="org.springframework.integration.file.filters.FileListFilter"/>
|
||||
<beans:bean id="filter" class="org.springframework.integration.sftp.filters.SftpPatternMatchingFileListFilter">
|
||||
<beans:constructor-arg value="."/>
|
||||
</beans:bean>
|
||||
|
||||
</beans:beans>
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user