INT-1614 added more tests, added si-test as sftp project dependency to fix the previosu build error, code coverage 77%
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
|
||||
|
||||
<bean id="sftpSessionFactory" class="org.springframework.integration.sftp.session.SftpSessionFactory">
|
||||
<property name="host" value="loclahost"/>
|
||||
<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"/>
|
||||
@@ -21,13 +21,19 @@
|
||||
<int:channel id="inputChannel"/>
|
||||
|
||||
<int-sftp:outbound-channel-adapter id="sftpOutboundAdapter"
|
||||
session-factory="sftpSessionFactory"
|
||||
session-factory="sftpSessionFactory"
|
||||
channel="inputChannel"
|
||||
charset="UTF-8"
|
||||
filename-generator="fileNameGenerator"
|
||||
remote-directory="foo/bar"/>
|
||||
|
||||
|
||||
<int-sftp:outbound-channel-adapter id="sftpOutboundAdapterWithExpression"
|
||||
session-factory="sftpSessionFactory"
|
||||
channel="inputChannel"
|
||||
charset="UTF-8"
|
||||
filename-generator="fileNameGenerator"
|
||||
remote-directory-expression="'foo' + '/' + 'bar'"/>
|
||||
|
||||
<int-sftp:outbound-channel-adapter
|
||||
session-factory="sftpSessionFactory"
|
||||
channel="inputChannel"
|
||||
|
||||
@@ -4,16 +4,25 @@
|
||||
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;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.expression.Expression;
|
||||
import org.springframework.expression.common.LiteralExpression;
|
||||
import org.springframework.expression.spel.standard.SpelExpression;
|
||||
import org.springframework.integration.endpoint.EventDrivenConsumer;
|
||||
import org.springframework.integration.sftp.outbound.SftpSendingMessageHandler;
|
||||
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
|
||||
*
|
||||
@@ -29,19 +38,35 @@ public class OutboundChannelAdapaterParserTests {
|
||||
assertEquals(context.getBean("inputChannel"), TestUtils.getPropertyValue(consumer, "inputChannel"));
|
||||
assertEquals("sftpOutboundAdapter", ((EventDrivenConsumer)consumer).getComponentName());
|
||||
SftpSendingMessageHandler handler = (SftpSendingMessageHandler) TestUtils.getPropertyValue(consumer, "handler");
|
||||
Expression remoteDirectoryExpression = (Expression) TestUtils.getPropertyValue(handler, "remoteDirectoryExpression");
|
||||
assertNotNull(remoteDirectoryExpression);
|
||||
assertTrue(remoteDirectoryExpression instanceof LiteralExpression);
|
||||
assertEquals(context.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"));
|
||||
assertNotNull(TestUtils.getPropertyValue(handler, "temporaryBufferFolder"));
|
||||
assertNotNull(TestUtils.getPropertyValue(handler, "temporaryBufferFolderFile"));
|
||||
QueuedSftpSessionPool clientPoll = (QueuedSftpSessionPool) TestUtils.getPropertyValue(handler, "pool");
|
||||
SftpSessionFactory clientFactory = (SftpSessionFactory) TestUtils.getPropertyValue(clientPoll, "sftpSessionFactory");
|
||||
assertEquals("localhost", TestUtils.getPropertyValue(clientFactory, "host"));
|
||||
assertEquals(2222, TestUtils.getPropertyValue(clientFactory, "port"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOutboundChannelAdapaterWithNoId(){
|
||||
public void testOutboundChannelAdapaterWithWithRemoteDirectoryExopression(){
|
||||
ApplicationContext context =
|
||||
new ClassPathXmlApplicationContext("OutboundChannelAdapaterParserTests-context.xml", this.getClass());
|
||||
Object consumer = context.getBean("sftpOutboundAdapterWithExpression");
|
||||
assertTrue(consumer instanceof EventDrivenConsumer);
|
||||
assertEquals(context.getBean("inputChannel"), TestUtils.getPropertyValue(consumer, "inputChannel"));
|
||||
assertEquals("sftpOutboundAdapterWithExpression", ((EventDrivenConsumer)consumer).getComponentName());
|
||||
SftpSendingMessageHandler handler = (SftpSendingMessageHandler) TestUtils.getPropertyValue(consumer, "handler");
|
||||
SpelExpression remoteDirectoryExpression = (SpelExpression) TestUtils.getPropertyValue(handler, "remoteDirectoryExpression");
|
||||
assertNotNull(remoteDirectoryExpression);
|
||||
assertEquals("'foo' + '/' + 'bar'", remoteDirectoryExpression.getExpressionString());
|
||||
assertEquals(context.getBean("fileNameGenerator"), TestUtils.getPropertyValue(handler, "fileNameGenerator"));
|
||||
assertEquals("UTF-8", TestUtils.getPropertyValue(handler, "charset"));
|
||||
assertNotNull(TestUtils.getPropertyValue(handler, "temporaryBufferFolder"));
|
||||
assertNotNull(TestUtils.getPropertyValue(handler, "temporaryBufferFolderFile"));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user