INT-1631 added tests for auto-creation of the local directories if doen's exist
This commit is contained in:
@@ -26,7 +26,6 @@ import org.springframework.integration.file.synchronization.AbstractInboundRemot
|
||||
import org.springframework.integration.sftp.filters.SftpPatternMatchingFileListFilter;
|
||||
import org.springframework.integration.sftp.session.SftpSession;
|
||||
import org.springframework.integration.sftp.session.SftpSessionPool;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.jcraft.jsch.ChannelSftp;
|
||||
import com.jcraft.jsch.SftpATTRS;
|
||||
|
||||
@@ -69,6 +69,17 @@
|
||||
<poller fixed-rate="1000"/>
|
||||
</sftp:inbound-channel-adapter>
|
||||
|
||||
<sftp:inbound-channel-adapter id="sftpAdapterNoLocalDir"
|
||||
session-factory="sftpSessionFactory"
|
||||
channel="requestChannel"
|
||||
filename-pattern="pattern"
|
||||
remote-directory="/foo"
|
||||
local-directory="file:foo"
|
||||
auto-create-directories="true"
|
||||
auto-delete-remote-files-on-sync="false">
|
||||
<poller fixed-rate="1000"/>
|
||||
</sftp:inbound-channel-adapter>
|
||||
|
||||
|
||||
<beans:bean id="filter" class="org.springframework.integration.sftp.filters.SftpPatternMatchingFileListFilter">
|
||||
<beans:constructor-arg value="."/>
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.integration.sftp.config;
|
||||
|
||||
import static junit.framework.Assert.assertFalse;
|
||||
import static junit.framework.Assert.assertNotNull;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
|
||||
@@ -41,7 +42,7 @@ public class InboundChannelAdapaterParserTests {
|
||||
|
||||
@Before
|
||||
public void prepare(){
|
||||
new File("target/foo").delete();
|
||||
new File("foo").delete();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -73,9 +74,16 @@ public class InboundChannelAdapaterParserTests {
|
||||
assertTrue(new File("target").exists());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLocalDirAutoCreated() throws Exception{
|
||||
assertFalse(new File("foo").exists());
|
||||
new ClassPathXmlApplicationContext("InboundChannelAdapaterParserTests-context.xml", this.getClass());
|
||||
assertTrue(new File("foo").exists());
|
||||
}
|
||||
|
||||
@After
|
||||
public void cleanUp() throws Exception{
|
||||
new File("target/foo").delete();
|
||||
new File("foo").delete();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:int-sftp="http://www.springframework.org/schema/integration/sftp"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.0.xsd
|
||||
http://www.springframework.org/schema/integration/sftp http://www.springframework.org/schema/integration/sftp/spring-integration-sftp-2.0.xsd">
|
||||
|
||||
|
||||
<bean id="sftpSessionFactory" class="org.springframework.integration.sftp.session.SftpSessionFactory">
|
||||
<property name="host" value="localhost"/>
|
||||
<property name="knownHosts" value="local, foo.com, bar.foo"/>
|
||||
<property name="privateKey" value="classpath:org/springframework/integration/sftp/config/sftpTest"/>
|
||||
<property name="privateKeyPassphrase" value="ghj"/>
|
||||
<property name="password" value="hello"/>
|
||||
<property name="port" value="2222"/>
|
||||
<property name="user" value="oleg"/>
|
||||
</bean>
|
||||
|
||||
<int:channel id="inputChannel"/>
|
||||
|
||||
<int-sftp:outbound-channel-adapter id="sftpOutboundAdapter"
|
||||
session-factory="sftpSessionFactory"
|
||||
channel="inputChannel"
|
||||
charset="UTF-8"
|
||||
filename-generator="fileNameGenerator"
|
||||
remote-directory="foo/bar"
|
||||
remote-directory-expression="'foo'"/>
|
||||
|
||||
|
||||
<bean id="fileNameGenerator" class="org.mockito.Mockito" factory-method="mock">
|
||||
<constructor-arg value="org.springframework.integration.file.FileNameGenerator"/>
|
||||
</bean>
|
||||
</beans>
|
||||
Reference in New Issue
Block a user