INT-1263, added tests in FYP to validate MH

This commit is contained in:
Oleg Zhurakousky
2010-09-22 20:46:42 -04:00
parent c195edf9de
commit 1bb6eafe04
5 changed files with 108 additions and 4 deletions

View File

@@ -10,14 +10,15 @@ import org.springframework.integration.ftp.FtpClientPool;
*
* @author Josh Long
*/
public class FtpInboundRemoteFileSystemSynchronizingMessageSource extends AbstractInboundRemoteFileSystemSynchronizingMessageSource<FTPFile, FtpInboundRemoteFileSystemSynchronizer> {
public class FtpInboundRemoteFileSystemSynchronizingMessageSource
extends AbstractInboundRemoteFileSystemSynchronizingMessageSource<FTPFile, FtpInboundRemoteFileSystemSynchronizer> {
private volatile FtpClientPool clientPool;
public void setClientPool(FtpClientPool clientPool) {
this.clientPool = clientPool;
}
@Override
@Override
protected void doStart() {
this.synchronizer.start();
}
@@ -32,4 +33,8 @@ public class FtpInboundRemoteFileSystemSynchronizingMessageSource extends Abstra
super.onInit();
this.synchronizer.setClientPool(this.clientPool);
}
public String getComponentType(){
return "ftp:inbound-channel-adapter";
}
}

View File

@@ -0,0 +1,40 @@
/*
* 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.assertEquals;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.endpoint.SourcePollingChannelAdapter;
/**
* @author Oleg Zhurakousky
*
*/
public class FtpMessageHistoryTests {
@Test
public void testMessageHistory() throws Exception{
ClassPathXmlApplicationContext ac = new ClassPathXmlApplicationContext("ftp-message-history-context.xml", this.getClass());
SourcePollingChannelAdapter adapter = ac.getBean("adapterFtp", SourcePollingChannelAdapter.class);
assertEquals("adapterFtp", adapter.getComponentName());
assertEquals("ftp:inbound-channel-adapter", adapter.getComponentType());
adapter = ac.getBean("adapterFtps", SourcePollingChannelAdapter.class);
assertEquals("adapterFtps", adapter.getComponentName());
assertEquals("ftp:inbound-channel-adapter", adapter.getComponentType());
}
}

View File

@@ -0,0 +1,41 @@
<?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">
<int:message-history/>
<ftp:inbound-channel-adapter id="adapterFtp" remote-directory="ftp://localhost" channel="ftpIn" auto-create-directories="true"
host="localhost" auto-delete-remote-files-on-sync="false"
username="oleg" password="zhurakousky" port="21"
file-type="binary-file-type"
filename-pattern=".*?jpg">
<int:poller fixed-rate="1000"/>
</ftp:inbound-channel-adapter>
<ftps:inbound-channel-adapter id="adapterFtps" remote-directory="ftp://localhost"
channel="ftpIn"
auto-create-directories="true"
host="locahost"
auto-delete-remote-files-on-sync="false"
username="oleg"
password="zhurakousky"
port="21"
file-type="binary-file-type"
filename-pattern=".*?java"
client-mode="passive-local-data-connection-mode">
<int:poller fixed-rate="1000"/>
</ftps:inbound-channel-adapter>
<int:channel id="ftpIn">
<int:queue/>
</int:channel>
</beans>

View File

@@ -0,0 +1,11 @@
log4j.rootCategory=WARN, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %t %c{2}:%L - %m%n
log4j.category.org.springframework=WARN
# log4j.category.org.springframework.integration=DEBUG
# log4j.category.org.springframework.integration.jdbc=DEBUG
log4j.category.org.springframework.ftp=DEBUG

View File

@@ -28,6 +28,7 @@ import java.util.Properties;
import javax.sql.DataSource;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -54,7 +55,7 @@ public class JdbcPollingChannelAdapterParserTests {
private MessagingTemplate messagingTemplate;
private ConfigurableApplicationContext appCtx;
private ClassPathXmlApplicationContext appCtx;
private PlatformTransactionManager transactionManager;
@@ -148,7 +149,7 @@ public class JdbcPollingChannelAdapterParserTests {
appCtx.close();
}
}
public void setUp(String name, Class<?> cls){
appCtx = new ClassPathXmlApplicationContext(name, cls);
setupJdbcTemplate();
@@ -156,6 +157,12 @@ public class JdbcPollingChannelAdapterParserTests {
setupTransactionManager();
setupMessagingTemplate();
}
@After
public void destroy(){
if (appCtx != null){
appCtx.destroy();
}
}
protected void setupMessagingTemplate() {