GH-145: Some SFTP consumer props were not applied
Fixes https://github.com/spring-cloud/stream-applications/issues/145
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2020 the original author or authors.
|
||||
* Copyright 2015-2021 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.
|
||||
@@ -40,22 +40,23 @@ import org.springframework.messaging.Message;
|
||||
@Import(SftpConsumerSessionFactoryConfiguration.class)
|
||||
public class SftpConsumerConfiguration {
|
||||
|
||||
private static final ExpressionParser EXPRESSION_PARSER = new SpelExpressionParser();
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow ftpInboundFlow(SftpConsumerProperties properties, SessionFactory<ChannelSftp.LsEntry> ftpSessionFactory) {
|
||||
public IntegrationFlow ftpOutboundFlow(SftpConsumerProperties properties,
|
||||
SessionFactory<ChannelSftp.LsEntry> ftpSessionFactory) {
|
||||
|
||||
IntegrationFlowBuilder integrationFlowBuilder =
|
||||
IntegrationFlows.from(MessageConsumer.class, (gateway) -> gateway.beanName("sftpConsumer"));
|
||||
|
||||
SftpMessageHandlerSpec handlerSpec =
|
||||
Sftp.outboundAdapter(new SftpRemoteFileTemplate(ftpSessionFactory), properties.getMode())
|
||||
.remoteDirectory(properties.getRemoteDir())
|
||||
.temporaryRemoteDirectory(properties.getTemporaryRemoteDir())
|
||||
.remoteFileSeparator(properties.getRemoteFileSeparator())
|
||||
.autoCreateDirectory(properties.isAutoCreateDir())
|
||||
.useTemporaryFileName(properties.isUseTemporaryFilename())
|
||||
.temporaryFileSuffix(properties.getTmpFileSuffix());
|
||||
if (properties.getFilenameExpression() != null) {
|
||||
handlerSpec.fileNameExpression(EXPRESSION_PARSER.parseExpression(properties.getFilenameExpression())
|
||||
.getExpressionString());
|
||||
handlerSpec.fileNameExpression(properties.getFilenameExpression());
|
||||
}
|
||||
return integrationFlowBuilder
|
||||
.handle(handlerSpec)
|
||||
|
||||
@@ -16,6 +16,10 @@
|
||||
|
||||
package org.springframework.cloud.fn.consumer.sftp;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -42,8 +46,6 @@ import org.springframework.integration.file.remote.session.SessionFactory;
|
||||
import org.springframework.integration.file.support.FileExistsMode;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author David Turanski
|
||||
* @author Gary Russell
|
||||
@@ -138,8 +140,9 @@ public class SftpConsumerPropertiesTests {
|
||||
context.register(Factory.class);
|
||||
context.refresh();
|
||||
SessionFactory<?> sessionFactory = context.getBean(SessionFactory.class);
|
||||
assertThat(TestUtils.getPropertyValue(sessionFactory, "sessionFactory.knownHosts").toString().endsWith(
|
||||
"/.ssh/known_hosts]")).isTrue();
|
||||
assertThat(TestUtils.getPropertyValue(sessionFactory, "sessionFactory.knownHosts")
|
||||
.toString().replaceAll(java.util.regex.Matcher.quoteReplacement(File.separator), "/")
|
||||
.endsWith("/.ssh/known_hosts]")).isTrue();
|
||||
context.close();
|
||||
}
|
||||
|
||||
@@ -199,5 +202,7 @@ public class SftpConsumerPropertiesTests {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user