---
schema_version: "1"
id: 87ba4f0db1a102fee27b59eb2b3301b40d9b2019fd14f4176ba532457f4a889b
title: FTP Utils
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/munit/2.3/ftp-util.md
canonical_url: https://docs.mulesoft.com/munit/2.3/ftp-util
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 652be90478947fc1cc5bf0239595e10f339e198e9cfdc7cc629122023e443962
description: MuleSoft Documentation Site
release: "2.3"
latest: false
---
---
product: MUnit
version: 2.3
---

# FTP Utils

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

To test a piece of code that connects with an FTP server, you must install an FTP server in your
local environment to run the tests. You could also have a dedicated external FTP server for testing,
but your Maven project would not be portable — a third party would need to install the testing FTP
server to compile your project.

To make it easier for you to test FTP connections, MUnit allows you to implement an FTP server in
your local environment.

## Install the MUnit FTP Server Module

1.  From Anypoint Studio, go to the **Mule Palette** and **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.

## Attributes Reference

The FTP Server takes the following parameters:

<table><colgroup><col> <col></colgroup><thead><tr><th>Attribute Name</th><th>Description</th></tr></thead><tbody><tr><td><div><div><p><code>name</code></p></div></div></td><td><div><div><p>Defines the configuration name of the FTP server.</p></div><div><p>This value must be unique.</p></div></div></td></tr><tr><td><div><div><p><code>port</code></p></div></div></td><td><div><div><p>Defines the port on which the FTP server listens.</p></div></div></td></tr><tr><td><div><div><p><code>anonymous</code></p></div></div></td><td><div><div><p>(Boolean) Sets anonymous access to the FTP server. If <code>anonymous</code> is set to <code>true</code>, you don’t need to set a password to access the FTP server when using the <code>anonymous</code> username.</p></div><div><p>The default value is <code>true</code>.</p></div></div></td></tr><tr><td><div><div><p><code>secure</code></p></div></div></td><td><div><div><p>(Boolean) Defines the FTP protocol. When the secure parameter is set to true, the server behaves as an SFTP server and connections are allowed only through authentication. If this parameter is set to false, the server behaves as an FTP server and allows either authenticated or anonymous connections.</p></div><div><p>The default value is false.</p></div></div></td></tr><tr><td><div><div><p><code>homeDir</code></p></div></div></td><td><div><div><p>Defines the user home directory. The default value is the filesystem root.<br>It is possible to define the FTP user home directory using the <code>~</code> character to represent the home directory on the file system.</p></div></div></td></tr></tbody></table>

## MUnit FTP server Processors

The FTP Utility has two processors to interact with your FTP server:

contains-files

The `contains-files` processor attempts to validate the existence of a file in the FTP server. If
the file is not present, the processor fails causing the test to fail.

```xml
<ftpserver:contains-files config-ref="MUnit_FTP_Server_Config" path="/" file="example.txt"/>
```

<table><colgroup><col> <col></colgroup><thead><tr><th>Attribute Name</th><th>Description</th></tr></thead><tbody><tr><td><p><code>config-ref</code></p></td><td><p>Defines the FTP server configuration.</p></td></tr><tr><td><p><code>path</code></p></td><td><p>Defines in which folder to search based on the user home directory defined previously.</p></td></tr><tr><td><p><code>file</code></p></td><td><p>Defines the name of the file to look for.</p></td></tr></tbody></table>

remove

The `remove` processor provides another operation that may be of use. This operation instructs the
FTP server to remove a file from storage.

```xml
<ftpserver:remove config-ref="MUnit_FTP_Server_Config" path="example.txt"/>
```

<table><colgroup><col> <col></colgroup><thead><tr><th>Attribute Name</th><th>Description</th></tr></thead><tbody><tr><td><p><code>config-ref</code></p></td><td><p>Defines the FTP server configuration.</p></td></tr><tr><td><p><code>path</code></p></td><td><p>The full path of the file to remove.</p></td></tr></tbody></table>

This feature is useful when creating the same file name several times. You can configure it in
`after-test` to ensure that no name collisions cause the test to fail.

## See Also

- [Configuring FTP Server Utility in an MUnit Test](https://docs.mulesoft.com/munit/2.3/ftp-server-cookbook)
