<!-- 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>
FTP Utils
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:
-
Look for the MUnit Utils FTP Server module in Exchange.
-
Add the module to your project:
The MUnit FTP server artifact in your POM file must have the
test
scope.
Attributes Reference
The FTP server module takes the following parameters:
Attribute Name | Description |
---|---|
|
Defines the configuration name of the FTP server. |
|
Defines the port on which the FTP server listens. |
|
(Boolean) Sets anonymous access to the FTP server. If you set |
|
(Boolean) Defines the FTP protocol. If you set the |
|
Defines the user’s home directory. The default value is the filesystem root. |
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.<ftpserver:contains-files config-ref="MUnit_FTP_Server_Config" path="/" file="example.txt"/>
Attribute Name Description config-ref
Defines the FTP server configuration.
path
Defines in which folder to search based on the user home directory defined.
file
Defines the name of the file to look for.
- remove
-
The
remove
processor provides an operation that instructs the FTP server to remove a file from storage.<ftpserver:remove config-ref="MUnit_FTP_Server_Config" path="example.txt"/>
Attribute Name Description config-ref
Defines the FTP server configuration.
path
Defines the full path of the file to remove.
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.