Configuring FTP Server Utility in an MUnit Test

Assume that you want to test the following Mule application:

<sftp:config name="SFTP_Config">
    <sftp:connection host="${}" port="${ftp.port}" username="${ftp.user}" password="${ftp.password}"/>

<configuration-properties file="" />

<flow name="listFlow">
    <sftp:list config-ref="SFTP_Config" directoryPath="."/>
        <logger level="INFO" message="#[attributes.fileName]"/>

The in src/main/resources has the following content:

The username field cannot be empty. If you do not 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.

Install the FTP Server

  1. From Anypoint Studio, go to the Mule Palette view and locate Search in Exchange…​.

  2. In the search bar look for MUnit Utils FTP Server and add the module to your project:

    <!-- Ftp Server Dependency -->

    The MUnit FTP server artifact in your POM file must have the test scope.

Define the FTP Server

  1. In your Studio canvas, go to the Global Elements tab and select your MUnit FTP Server Config element.

  2. Click Edit and complete the fields:

    Attribute Value













    <ftpserver:config name="MUnit_FTP_Server_Config">
        <ftpserver:connection port="${ftp.port}" username="${ftp.user}" password="${ftp.password}" secure="true" homeDir="${app.home}"/>

Run the Test

After configuring the FTP server you can run the test:

<munit:test name="listFlowTest" description="Test listFlow" >
        <flow-ref name="listFlow"/>
        <munit-tools:assert-that expression="#[sizeOf(payload)]" is="#[MunitTools::greaterThan(0)]"/>

This FTP accepts any user, so there is no need to set up a user database or list.

See Also

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub
Give us your feedback!
We want to build the best documentation experience for you!
Help us improve with your feedback.
Take the survey!