<?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/integration/ftp https://www.springframework.org/schema/integration/ftp/spring-integration-ftp.xsd
		http://www.springframework.org/schema/integration https://www.springframework.org/schema/integration/spring-integration.xsd
		http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd">

	<bean id="sf" class="org.mockito.Mockito" factory-method="mock">
		<constructor-arg value="org.springframework.integration.file.remote.session.SessionFactory" type="java.lang.Class"/>
	</bean>

	<bean id="csf" class="org.springframework.integration.file.remote.session.CachingSessionFactory">
		<constructor-arg ref="sf"/>
	</bean>

	<int:channel id="inbound1">
		<int:queue/>
	</int:channel>

	<int-ftp:outbound-gateway id="gateway1"
							  local-directory="local-test-dir"
							  session-factory="sf"
							  request-channel="inbound1"
							  reply-channel="outbound"
							  reply-timeout="777"
							  auto-create-local-directory="false"
							  auto-startup="false"
							  filename-pattern="*"
							  remote-file-separator="X"
							  command="ls"
							  command-options="-1 -f"
							  expression="payload"
							  order="1"
							  mode="APPEND"
							  mput-filter-expression="name matches '.*'">
		<int:poller fixed-delay="1000"/>
	</int-ftp:outbound-gateway>

	<bean id="fooString" class="java.lang.String">
		<constructor-arg value="foo" />
	</bean>

	<int-ftp:outbound-gateway id="gateway2"
		local-directory="local-test-dir"
		session-factory="csf"
		request-channel="inbound2"
		reply-channel="outbound"
		auto-create-local-directory="false"
		auto-startup="false"
		remote-file-separator="X"
		command="get"
		command-options="-P"
		expression="payload"
		order="2"
		requires-reply="false"
		local-filename-generator-expression="#remoteFileName.toUpperCase() + '.a' + @fooString"
		mput-pattern="*"
		>
		<int-ftp:request-handler-advice-chain>
			<bean class="org.springframework.integration.ftp.config.FtpOutboundGatewayParserTests$FooAdvice" />
		</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:poller fixed-delay="1000"/>
	</int-ftp:outbound-gateway>

	<int-ftp:outbound-gateway id="gateway4"
							  session-factory="csf"
							  request-channel="inbound1"
							  reply-channel="outbound"
							  command="mput"
							  expression="payload"
							  remote-directory="/foo"
							  remote-file-separator="X"
							  auto-create-directory="true"
							  remote-filename-generator="fileNameGenerator"
							  temporary-remote-directory="/bar"
							  rename-expression="'foo'"
							  order="1"
							  mput-regex=".*">
		<int:poller fixed-delay="1000"/>
	</int-ftp:outbound-gateway>

	<bean id="fileNameGenerator" class="org.mockito.Mockito" factory-method="mock">
		<constructor-arg value="org.springframework.integration.file.FileNameGenerator" type="java.lang.Class"/>
	</bean>

	<int-ftp:outbound-gateway id="withBeanExpression"
		local-directory="local-test-dir"
		session-factory="sf"
		request-channel="inbound3"
		reply-channel="outbound"
		auto-startup="false"
		filename-pattern="*"
		remote-file-separator="X"
		command="ls"
		command-options="-1 -f"
		expression="@fooBean"
		order="1"
		/>

	<int:channel id="outbound"/>

	<bean id="fooBean" class="java.lang.String">
		<constructor-arg value="foo" />
	</bean>

</beans>
