INT-1444, added tests to validate namespace attributes for FTP and FTPS
This commit is contained in:
@@ -85,5 +85,9 @@
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>1.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-all</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
<?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:ftp="http://www.springframework.org/schema/integration/ftp"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:ftps="http://www.springframework.org/schema/integration/ftps"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/integration/ftps http://www.springframework.org/schema/integration/ftp/spring-integration-ftps.xsd
|
||||
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/integration/ftp http://www.springframework.org/schema/integration/ftp/spring-integration-ftp.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
|
||||
|
||||
<ftp:inbound-channel-adapter id="adapterFtpDontAutoCreate"
|
||||
channel="ftpIn"
|
||||
file-type="binary-file-type"
|
||||
filter="filter"
|
||||
filename-pattern="foo"
|
||||
local-working-directory="file:target/bar"
|
||||
auto-create-directories="false"
|
||||
auto-delete-remote-files-on-sync="false"
|
||||
username="oleg"
|
||||
remote-directory="ftp://localhost"
|
||||
host="localhost"
|
||||
password="zhurakousky"
|
||||
port="21"
|
||||
client-mode="passive-local-data-connection-mode">
|
||||
<int:poller fixed-rate="1000"/>
|
||||
</ftp:inbound-channel-adapter>
|
||||
|
||||
<bean id="filter" class="org.mockito.Mockito" factory-method="mock">
|
||||
<constructor-arg value="org.springframework.integration.file.entries.EntryListFilter"/>
|
||||
</bean>
|
||||
|
||||
<int:channel id="ftpIn">
|
||||
<int:queue/>
|
||||
</int:channel>
|
||||
|
||||
</beans>
|
||||
@@ -0,0 +1,72 @@
|
||||
<?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:ftp="http://www.springframework.org/schema/integration/ftp"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:ftps="http://www.springframework.org/schema/integration/ftps"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/integration/ftps http://www.springframework.org/schema/integration/ftp/spring-integration-ftps.xsd
|
||||
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/integration/ftp http://www.springframework.org/schema/integration/ftp/spring-integration-ftp.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
|
||||
|
||||
|
||||
<ftp:inbound-channel-adapter id="adapterFtp"
|
||||
channel="ftpIn"
|
||||
file-type="binary-file-type"
|
||||
filter="filter"
|
||||
filename-pattern="foo"
|
||||
local-working-directory="file:target/foo"
|
||||
auto-create-directories="true"
|
||||
auto-delete-remote-files-on-sync="false"
|
||||
username="oleg"
|
||||
remote-directory="ftp://localhost"
|
||||
host="localhost"
|
||||
password="zhurakousky"
|
||||
port="21"
|
||||
client-mode="passive-local-data-connection-mode">
|
||||
<int:poller fixed-rate="1000"/>
|
||||
</ftp:inbound-channel-adapter>
|
||||
<ftp:inbound-channel-adapter id="adapterFtp"
|
||||
channel="ftpIn"
|
||||
file-type="binary-file-type"
|
||||
filter="filter"
|
||||
filename-pattern="foo"
|
||||
local-working-directory="file:target"
|
||||
auto-create-directories="true"
|
||||
auto-delete-remote-files-on-sync="false"
|
||||
username="oleg"
|
||||
remote-directory="ftp://localhost"
|
||||
host="localhost"
|
||||
password="zhurakousky"
|
||||
port="21"
|
||||
client-mode="passive-local-data-connection-mode">
|
||||
<int:poller fixed-rate="1000"/>
|
||||
</ftp:inbound-channel-adapter>
|
||||
|
||||
<!-- <ftps:inbound-channel-adapter id="adapterFtp" -->
|
||||
<!-- channel="ftpIn"-->
|
||||
<!-- file-type="binary-file-type" -->
|
||||
<!-- filter="filter" -->
|
||||
<!-- filename-pattern="foo"-->
|
||||
<!-- local-working-directory="file:target/ftps"-->
|
||||
<!-- auto-create-directories="true"-->
|
||||
<!-- auto-delete-remote-files-on-sync="false"-->
|
||||
<!-- username="oleg"-->
|
||||
<!-- remote-directory="ftp://localhost" -->
|
||||
<!-- host="localhost" -->
|
||||
<!-- password="zhurakousky" -->
|
||||
<!-- port="21"-->
|
||||
<!-- client-mode="passive-local-data-connection-mode">-->
|
||||
<!-- <int:poller fixed-rate="1000"/>-->
|
||||
<!-- </ftps:inbound-channel-adapter>-->
|
||||
|
||||
<bean id="filter" class="org.mockito.Mockito" factory-method="mock">
|
||||
<constructor-arg value="org.springframework.integration.file.entries.EntryListFilter"/>
|
||||
</bean>
|
||||
|
||||
<int:channel id="ftpIn">
|
||||
<int:queue/>
|
||||
</int:channel>
|
||||
|
||||
</beans>
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* 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.ftp;
|
||||
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.junit.After;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author Oleg Zhurakousky
|
||||
*
|
||||
*/
|
||||
public class FtpParserTests {
|
||||
@Before
|
||||
public void prepare(){
|
||||
new File("target/foo").delete();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLocalFilesAutoCreationTrue() throws Exception{
|
||||
assertTrue(!new File("target/foo").exists());
|
||||
new ClassPathXmlApplicationContext("FtpParserTests-inbound.xml", this.getClass());
|
||||
assertTrue(new File("target/foo").exists());
|
||||
assertTrue(!new File("target/bar").exists());
|
||||
}
|
||||
@Test(expected=BeanCreationException.class)
|
||||
public void testLocalFilesAutoCreationFalse() throws Exception{
|
||||
assertTrue(!new File("target/bar").exists());
|
||||
new ClassPathXmlApplicationContext("FtpParserTests-inbound-fail.xml", this.getClass());
|
||||
}
|
||||
|
||||
@After
|
||||
public void cleanUp() throws Exception{
|
||||
new File("target/foo").delete();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user