INT-2981 - Add Rename (mv) to (S)FTP Gateway
* (S)FTP Change Commands, Options to Enums * INT-2981 Add Support For 'mv' To File/Remote/GW * INT-2981 (S)FTP Namespace Support and Docs * INT-2981 Create Remote Dirs if Needed * INT-2981 Add 'mv' Command to What's New * INT-2981 Polishing - PR Comments * Add javadocs to enums. * Polish schemas to use an enumerated type for available gateway commands
This commit is contained in:
committed by
Gunnar Hillert
parent
2e2986d354
commit
c224d445ac
@@ -3,6 +3,7 @@
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xmlns:tool="http://www.springframework.org/schema/tool"
|
||||
xmlns:integration="http://www.springframework.org/schema/integration"
|
||||
xmlns:int-file="http://www.springframework.org/schema/integration/file"
|
||||
targetNamespace="http://www.springframework.org/schema/integration/ftp"
|
||||
elementFormDefault="qualified" attributeFormDefault="unqualified">
|
||||
|
||||
@@ -10,6 +11,8 @@
|
||||
<xsd:import namespace="http://www.springframework.org/schema/tool" />
|
||||
<xsd:import namespace="http://www.springframework.org/schema/integration"
|
||||
schemaLocation="http://www.springframework.org/schema/integration/spring-integration-3.0.xsd" />
|
||||
<xsd:import namespace="http://www.springframework.org/schema/integration/file"
|
||||
schemaLocation="http://www.springframework.org/schema/integration/file/spring-integration-file-3.0.xsd" />
|
||||
|
||||
<xsd:element name="outbound-channel-adapter">
|
||||
<xsd:annotation>
|
||||
@@ -238,12 +241,15 @@
|
||||
<xsd:all>
|
||||
<xsd:element name="request-handler-advice-chain" type="integration:adviceChainType" minOccurs="0" maxOccurs="1" />
|
||||
</xsd:all>
|
||||
<xsd:attribute name="command" use="required" type="xsd:string">
|
||||
<xsd:attribute name="command" use="required">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
FTP command - ls, get or rm
|
||||
FTP command.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:simpleType>
|
||||
<xsd:union memberTypes="int-file:remoteGatewayCommand xsd:string"/>
|
||||
</xsd:simpleType>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="command-options" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
@@ -270,6 +276,15 @@
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="rename-expression" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
SpEL expression representing the path for the
|
||||
new filename when using the 'mv' command. Defaults
|
||||
to "headers.['file_renameTo']".
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="request-channel" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:appinfo>
|
||||
@@ -507,5 +522,4 @@
|
||||
</xsd:attribute>
|
||||
</xsd:complexType>
|
||||
|
||||
|
||||
</xsd:schema>
|
||||
|
||||
@@ -47,6 +47,17 @@
|
||||
</int-ftp:request-handler-advice-chain>
|
||||
</int-ftp:outbound-gateway>
|
||||
|
||||
<int-ftp:outbound-gateway id="gateway3"
|
||||
session-factory="sf"
|
||||
request-channel="inbound1"
|
||||
reply-channel="outbound"
|
||||
auto-startup="false"
|
||||
command="mv"
|
||||
expression="payload"
|
||||
rename-expression="'foo'"
|
||||
order="1"
|
||||
/>
|
||||
|
||||
<int-ftp:outbound-gateway id="withBeanExpression"
|
||||
local-directory="local-test-dir"
|
||||
session-factory="sf"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 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.
|
||||
@@ -28,6 +28,8 @@ import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.endpoint.AbstractEndpoint;
|
||||
import org.springframework.integration.file.remote.gateway.AbstractRemoteFileOutboundGateway.Command;
|
||||
import org.springframework.integration.file.remote.gateway.AbstractRemoteFileOutboundGateway.Option;
|
||||
import org.springframework.integration.file.remote.session.CachingSessionFactory;
|
||||
import org.springframework.integration.ftp.gateway.FtpOutboundGateway;
|
||||
import org.springframework.integration.handler.ExpressionEvaluatingMessageProcessor;
|
||||
@@ -56,6 +58,9 @@ public class FtpOutboundGatewayParserTests {
|
||||
@Autowired
|
||||
AbstractEndpoint gateway2;
|
||||
|
||||
@Autowired
|
||||
AbstractEndpoint gateway3;
|
||||
|
||||
@Autowired
|
||||
AbstractEndpoint withBeanExpression;
|
||||
|
||||
@@ -71,11 +76,11 @@ public class FtpOutboundGatewayParserTests {
|
||||
assertEquals(new File("local-test-dir"), TestUtils.getPropertyValue(gateway, "localDirectory"));
|
||||
assertFalse((Boolean) TestUtils.getPropertyValue(gateway, "autoCreateLocalDirectory"));
|
||||
assertNotNull(TestUtils.getPropertyValue(gateway, "filter"));
|
||||
assertEquals("ls", TestUtils.getPropertyValue(gateway, "command"));
|
||||
assertEquals(Command.LS, TestUtils.getPropertyValue(gateway, "command"));
|
||||
@SuppressWarnings("unchecked")
|
||||
Set<String> options = TestUtils.getPropertyValue(gateway, "options", Set.class);
|
||||
assertTrue(options.contains("-1"));
|
||||
assertTrue(options.contains("-f"));
|
||||
assertTrue(options.contains(Option.NAME_ONLY));
|
||||
assertTrue(options.contains(Option.NOSORT));
|
||||
|
||||
Long sendTimeout = TestUtils.getPropertyValue(gateway, "messagingTemplate.sendTimeout", Long.class);
|
||||
assertEquals(Long.valueOf(777), sendTimeout);
|
||||
@@ -91,19 +96,29 @@ public class FtpOutboundGatewayParserTests {
|
||||
assertNotNull(TestUtils.getPropertyValue(gateway, "outputChannel"));
|
||||
assertEquals(new File("local-test-dir"), TestUtils.getPropertyValue(gateway, "localDirectory"));
|
||||
assertFalse((Boolean) TestUtils.getPropertyValue(gateway, "autoCreateLocalDirectory"));
|
||||
assertEquals("get", TestUtils.getPropertyValue(gateway, "command"));
|
||||
assertEquals(Command.GET, TestUtils.getPropertyValue(gateway, "command"));
|
||||
@SuppressWarnings("unchecked")
|
||||
Set<String> options = TestUtils.getPropertyValue(gateway, "options", Set.class);
|
||||
assertTrue(options.contains("-P"));
|
||||
assertTrue(options.contains(Option.PRESERVE_TIMESTAMP));
|
||||
gateway.handleMessage(new GenericMessage<String>("foo"));
|
||||
assertEquals(1, adviceCalled);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGatewayMv() {
|
||||
FtpOutboundGateway gateway = TestUtils.getPropertyValue(gateway3,
|
||||
"handler", FtpOutboundGateway.class);
|
||||
assertNotNull(TestUtils.getPropertyValue(gateway, "sessionFactory"));
|
||||
assertNotNull(TestUtils.getPropertyValue(gateway, "outputChannel"));
|
||||
assertEquals(Command.MV, TestUtils.getPropertyValue(gateway, "command"));
|
||||
assertEquals("'foo'", TestUtils.getPropertyValue(gateway, "renameProcessor.expression.expression"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithBeanExpression() {
|
||||
FtpOutboundGateway gateway = TestUtils.getPropertyValue(withBeanExpression,
|
||||
"handler", FtpOutboundGateway.class);
|
||||
ExpressionEvaluatingMessageProcessor<?> processor = TestUtils.getPropertyValue(gateway, "processor",
|
||||
ExpressionEvaluatingMessageProcessor<?> processor = TestUtils.getPropertyValue(gateway, "fileNameProcessor",
|
||||
ExpressionEvaluatingMessageProcessor.class);
|
||||
assertNotNull(processor);
|
||||
assertEquals("foo", processor.processMessage(MessageBuilder.withPayload("bar").build()));
|
||||
|
||||
Reference in New Issue
Block a user