INT-1614 added prser test for outbound
This commit is contained in:
14
spring-integration-ftp/.springBeans
Normal file
14
spring-integration-ftp/.springBeans
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beansProjectDescription>
|
||||
<version>1</version>
|
||||
<pluginVersion><![CDATA[2.5.0.201010221000-RELEASE]]></pluginVersion>
|
||||
<configSuffixes>
|
||||
<configSuffix><![CDATA[xml]]></configSuffix>
|
||||
</configSuffixes>
|
||||
<enableImports><![CDATA[false]]></enableImports>
|
||||
<configs>
|
||||
<config>src/test/java/org/springframework/integration/ftp/config/FtpOutboundChannelAdapterParserTests-context.xml</config>
|
||||
</configs>
|
||||
<configSets>
|
||||
</configSets>
|
||||
</beansProjectDescription>
|
||||
@@ -31,8 +31,7 @@ public abstract class AbstractFtpOutboundChannelAdapterParser extends AbstractOu
|
||||
|
||||
@Override
|
||||
protected AbstractBeanDefinition parseConsumer(Element element, ParserContext parserContext) {
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(
|
||||
FtpSendingMessageHandlerFactoryBean.class.getName());
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(this.getClassName());
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder,element,"charset");
|
||||
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder,element,"filename-generator", "fileNameGenerator");
|
||||
FtpNamespaceParserSupport.configureCoreFtpClient(builder, element, parserContext);
|
||||
|
||||
@@ -125,6 +125,7 @@ class FtpsInboundRemoteFileSystemSynchronizingMessageSourceFactoryBean extends F
|
||||
factory.setRemoteWorkingDirectory(this.remoteDirectory);
|
||||
factory.setFileType(this.fileType);
|
||||
factory.setClientMode(this.clientMode);
|
||||
|
||||
factory.setCipherSuites(this.cipherSuites);
|
||||
factory.setAuthValue(this.authValue);
|
||||
factory.setTrustManager(this.trustManager);
|
||||
|
||||
@@ -84,8 +84,8 @@
|
||||
<xsd:attribute name="username" type="xsd:string" use="required"/>
|
||||
<xsd:attribute name="remote-directory" type="xsd:string" use="required"/>
|
||||
<xsd:attribute name="host" type="xsd:string" use="required"/>
|
||||
<xsd:attribute name="password" type="xsd:string"/>
|
||||
<xsd:attribute name="charset" type="xsd:string" default="UTF-8"/>
|
||||
<xsd:attribute name="password" type="xsd:string" use="required"/>
|
||||
<xsd:attribute name="charset" type="xsd:string" default="UTF-8"/>
|
||||
<xsd:attribute name="port" type="xsd:int" default="22"/>
|
||||
<xsd:attribute name="client-mode" default="active-local-data-connection-mode" use="optional" >
|
||||
<xsd:annotation>
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<?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-ftp="http://www.springframework.org/schema/integration/ftp"
|
||||
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/ftp http://www.springframework.org/schema/integration/ftp/spring-integration-ftp-2.0.xsd">
|
||||
|
||||
|
||||
<int-ftp:outbound-channel-adapter
|
||||
id="ftpOutbound"
|
||||
username="user"
|
||||
password="password"
|
||||
channel="ftpChannel"
|
||||
remote-directory="foo/bar"
|
||||
host="localhost"
|
||||
charset="UTF-8"
|
||||
client-mode="active-local-data-connection-mode"
|
||||
file-type="binary-file-type"
|
||||
filename-generator="fileNameGenerator"
|
||||
port="22"/>
|
||||
|
||||
<int:channel id="ftpChannel"/>
|
||||
|
||||
<bean id="fileNameGenerator" class="org.mockito.Mockito" factory-method="mock">
|
||||
<constructor-arg value="org.springframework.integration.file.FileNameGenerator"/>
|
||||
</bean>
|
||||
</beans>
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* 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.config;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertNotNull;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.integration.endpoint.EventDrivenConsumer;
|
||||
import org.springframework.integration.ftp.client.FtpClientFactory;
|
||||
import org.springframework.integration.ftp.client.FtpClientPool;
|
||||
import org.springframework.integration.ftp.outbound.FtpSendingMessageHandler;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
|
||||
/**
|
||||
* @author Oleg Zhurakousky
|
||||
*
|
||||
*/
|
||||
public class FtpOutboundChannelAdapterParserTests {
|
||||
|
||||
@Test
|
||||
public void testFtpOutboundChannelAdapterComplete() throws Exception{
|
||||
ApplicationContext ac =
|
||||
new ClassPathXmlApplicationContext("FtpOutboundChannelAdapterParserTests-context.xml", this.getClass());
|
||||
Object consumer = ac.getBean("ftpOutbound");
|
||||
assertTrue(consumer instanceof EventDrivenConsumer);
|
||||
assertEquals(ac.getBean("ftpChannel"), TestUtils.getPropertyValue(consumer, "inputChannel"));
|
||||
assertEquals("ftpOutbound", ((EventDrivenConsumer)consumer).getComponentName());
|
||||
FtpSendingMessageHandler handler = (FtpSendingMessageHandler) TestUtils.getPropertyValue(consumer, "handler");
|
||||
assertEquals(ac.getBean("fileNameGenerator"), TestUtils.getPropertyValue(handler, "fileNameGenerator"));
|
||||
assertEquals("UTF-8", TestUtils.getPropertyValue(handler, "charset"));
|
||||
assertNotNull(TestUtils.getPropertyValue(handler, "temporaryBufferFolder"));
|
||||
assertNotNull(TestUtils.getPropertyValue(handler, "temporaryBufferFolderFile"));
|
||||
FtpClientPool clientPoll = (FtpClientPool) TestUtils.getPropertyValue(handler, "ftpClientPool");
|
||||
FtpClientFactory<?> clientFactory = (FtpClientFactory<?>) TestUtils.getPropertyValue(clientPoll, "factory");
|
||||
assertEquals("localhost", TestUtils.getPropertyValue(clientFactory, "host"));
|
||||
assertEquals(22, TestUtils.getPropertyValue(clientFactory, "port"));
|
||||
assertEquals("user", TestUtils.getPropertyValue(clientFactory, "username"));
|
||||
assertEquals("password", TestUtils.getPropertyValue(clientFactory, "password"));
|
||||
assertEquals("foo/bar", TestUtils.getPropertyValue(clientFactory, "remoteWorkingDirectory"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?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-ftp="http://www.springframework.org/schema/integration/ftp"
|
||||
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/ftp http://www.springframework.org/schema/integration/ftp/spring-integration-ftp-2.0.xsd">
|
||||
|
||||
|
||||
<int-ftp:outbound-channel-adapter
|
||||
id="ftpOutbound"
|
||||
username="user"
|
||||
password="password"
|
||||
channel="ftpChannel"
|
||||
remote-directory="foo/bar"
|
||||
host="localhost"
|
||||
charset="UTF-8"
|
||||
client-mode="active-local-data-connection-mode"
|
||||
file-type="binary-file-type"
|
||||
filename-generator="fileNameGenerator"
|
||||
port="22"/>
|
||||
|
||||
<int:channel id="ftpChannel"/>
|
||||
|
||||
<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