GH-3026: Fix chmod support for DSL
Fixes https://github.com/spring-projects/spring-integration/issues/3026 **Cherry-pick to `5.1.x`** * Populate proper `FileTransferringMessageHandler` impl from DSL spec implementations. This way we are able to use a provided `chmod` from Java DSL * Added `FileTransferringMessageHandlerSpec` ctor TODO * Update SftpTests * Code cleanup; `@Ignore` `SftpTests.testSftpOutboundFlowWithChmod()` since it doesn't work properly on Windows
This commit is contained in:
committed by
Artem Bilan
parent
66c3eff2ba
commit
7aea76c6c4
@@ -66,6 +66,7 @@ import org.springframework.util.FileCopyUtils;
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
* @author Joaquin Santana
|
||||
*
|
||||
* @since 5.0
|
||||
*/
|
||||
@@ -192,6 +193,30 @@ public class FtpTests extends FtpTestSupport {
|
||||
registration.destroy();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFtpOutboundFlowWithChmod() {
|
||||
IntegrationFlow flow = f -> f
|
||||
.handle(Ftp.outboundAdapter(sessionFactory(), FileExistsMode.FAIL)
|
||||
.useTemporaryFileName(false)
|
||||
.fileNameExpression("headers['" + FileHeaders.FILENAME + "']")
|
||||
.chmod(0644)
|
||||
.remoteDirectory("ftpTarget"));
|
||||
IntegrationFlowRegistration registration = this.flowContext.registration(flow).register();
|
||||
String fileName = "foo.file";
|
||||
Message<ByteArrayInputStream> message = MessageBuilder
|
||||
.withPayload(new ByteArrayInputStream("foo".getBytes(StandardCharsets.UTF_8)))
|
||||
.setHeader(FileHeaders.FILENAME, fileName)
|
||||
.build();
|
||||
registration.getInputChannel().send(message);
|
||||
RemoteFileTemplate<FTPFile> template = new RemoteFileTemplate<>(sessionFactory());
|
||||
FTPFile[] files = template.execute(session ->
|
||||
session.list(getTargetRemoteDirectory().getName() + "/" + fileName));
|
||||
assertThat(files.length).isEqualTo(1);
|
||||
assertThat(files[0].getSize()).isEqualTo(3);
|
||||
|
||||
registration.destroy();
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testFtpMgetFlow() {
|
||||
|
||||
Reference in New Issue
Block a user