Configure the MUnit FTP Server utility to run MUnit tests against an in-memory FTP server without connecting to an external FTP server. Use it to test Mule flows that interact with FTP or SFTP connectors in an isolated environment.
If you want to test the following Mule application:
<sftp:config name="SFTP_Config">
<sftp:connection host="${ftp.host}" port="${ftp.port}" username="${ftp.user}" password="${ftp.password}"/>
</sftp:config>
<configuration-properties file="ftp.properties" />
<flow name="listFlow">
<sftp:list config-ref="SFTP_Config" directoryPath="."/>
<foreach>
<logger level="INFO" message="#[attributes.fileName]"/>
</foreach>
</flow>
The ftp.properties in src/main/resources has the following content:
ftp.host=localhost
ftp.port=22
ftp.user=max
ftp.password=munittest
The username field can’t be empty. If you don’t have a username-password pair, set the username to anonymous and don’t set any password. By default, the anonymous attribute is set to true.