---
schema_version: "1"
id: 0e9a72db9d681244845d4570c31e2de3b6a8290c337be345346b910466d3d7bd
title: Configuring FTP Server Utility in an MUnit Test
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/munit/2.3/ftp-server-cookbook.md
canonical_url: https://docs.mulesoft.com/munit/2.3/ftp-server-cookbook
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 5817a0c5ec771637a1169bb3a9f14f8d6bd5690efc2233e72eb2133f7d59c2c8
description: MuleSoft Documentation Site
release: "2.3"
latest: false
---
---
product: MUnit
version: 2.3
---

# Configuring FTP Server Utility in an MUnit Test

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

Assume that you want to test the following Mule application:

```xml
<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:

```none
ftp.host=localhost
ftp.port=22
ftp.user=max
ftp.password=munittest
```

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:

    ```xml
    <!-- Ftp Server Dependency -->
    <dependency>
        <groupId>com.mulesoft.munit.utils</groupId>
        <artifactId>munit-ftpserver-module</artifactId>
        <version>2.0.1</version>
        <classifier>mule-plugin</classifier>
        <scope>test</scope>
    </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:

    <table><colgroup><col> <col></colgroup><thead><tr><th>Attribute</th><th>Value</th></tr></thead><tbody><tr><td><div><div><p>Name</p></div></div></td><td><div><div><p><code>MUnit_FTP_Server_Config</code></p></div></div></td></tr><tr><td><div><div><p>Port</p></div></div></td><td><div><div><p><code>${ftp.port}</code></p></div></div></td></tr><tr><td><div><div><p>Username</p></div></div></td><td><div><div><p><code>${ftp.user}</code></p></div></div></td></tr><tr><td><div><div><p>Password</p></div></div></td><td><div><div><p><code>${ftp.password}</code></p></div></div></td></tr><tr><td><div><div><p>Secure</p></div></div></td><td><div><div><p><code>true</code></p></div></div></td></tr><tr><td><div><div><p>homeDir</p></div></div></td><td><div><div><p><code>${app.home}</code></p></div></div></td></tr></tbody></table>

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

## Run the Test

After configuring the FTP server you can run the test:

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

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

## See Also

- [FTP Util](https://docs.mulesoft.com/munit/2.3/ftp-util)
