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

# FTP Utils

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

![logo acb active](/mulesoft/current/en-us/_/img/icons/anypoint-code-builder.svg "Anypoint Code Builder")Anypoint Code
Builder

![logo studio active](/mulesoft/current/en-us/_/img/icons/studio.svg "Anypoint Studio")Anypoint Studio

To test a piece of code that connects with an FTP server, install an FTP server in your local
environment to run the tests. You can also use a dedicated external FTP server for testing, but your
Maven project can’t be portable. A third party must install the testing FTP server to compile your
project.

To test the FTP connections, you can implement an FTP server in your local environment with MUnit.

## Install the MUnit FTP Server Module

To install the MUnit FTP server module:

1.  Look for the **MUnit Utils FTP Server** module.

2.  Add the module to your project:

    ```xml
    <!-- Ftp Server Dependency -->
    <dependency>
        <groupId>com.mulesoft.munit.utils</groupId>
        <artifactId>munit-ftpserver-module</artifactId>
        <version>LATEST_VERSION</version> (1)
        <classifier>mule-plugin</classifier>
        <scope>test</scope>
    </dependency>
    ```

    <table><tbody><tr><td><i data-value="1"></i><b>1</b></td><td>Check the <a href="https://repository.mulesoft.org/nexus/content/repositories/releases/com/mulesoft/munit/utils/munit-ftpserver-module/">MuleSoft Nexus repository</a> to get the <strong>LATEST_VERSION</strong>.</td></tr></tbody></table>

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

> [!NOTE] The **MUnit FTP Server** module is located at
> [MuleSoft Nexus repository](https://repository.mulesoft.org/nexus/content/repositories/releases/com/mulesoft/munit/utils/munit-ftpserver-module/).
> The **MUnit FTP Server** module version 3 and later is compatible with Java 17. Previous versions
> of this module available at Anypoint Exchange are deprecated.

## Attributes Reference

The FTP server module 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.<br>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 you set <code>anonymous</code> to <code>true</code>, don’t set a password to access the FTP server when using the <code>anonymous</code> username.<br>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. If you set the <code>secure</code> parameter to <code>true</code>, the server behaves as an SFTP server and connections must be authenticated. If you set the <code>secure</code> parameter to <code>false</code>, the server behaves as an FTP server and allows either authenticated or anonymous connections.<br>The default value is <code>false</code>.</p></div></div></td></tr><tr><td><div><div><p><code>homeDir</code></p></div></div></td><td><div><div><p>Defines the user’s home directory. The default value is the filesystem root.<br>You can define the FTP user home directory by 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 validates the existence of a file in the FTP server. If there is no
file 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.</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 an operation that 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>Defines 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/3.6/ftp-server-cookbook)
