What is the Apache James MTP?
Apache James Mail Protocol Tester (MTP) is a library providing a framework for the
scritable functional testing of ASCII based line protocols.
An antlib defines a suite of extensions for Apache Ant.
This antlib defines a suite of functional testing tools particularly suitable for
use with ASCII based line protocols (as are common in mail).
Tasks
mpt
Executes
MPT scripts against a running independent server.
If these scripts require users then these can be added by script by using the
AddUser
element.
Parameters
Attribute Description Required
port
Port number that the scripts should be executed against
Yes
host
Host name or IP address of the server against which the scripts should be executed
No (Defaults to 127.0.0.1)
script
File containing a script to be executed. To execute multiple scripts,
use a
Resource Collection
When no resource collections elements exist
skip
Skips execution of scripts. For simple conditional execution.
No
shabang
Optional server shabang will be substituted for first server response.
No
quiet
Optional boolean setting when true will suppress progress output.
No (defaults to false)
errorproperty
Optionally names a property which will be set (with error message) when test fails.
When unset, the build will terminate when test fails.
No
Nested Elements
Any Resource Collection
Resource Collections
are used to specify a group of scripts to execute. When resource collections are set, attribute
AddUser
Allows scripted addition of any users required by the tests.
The port can vary but the host is inherited.
Attribute Description Required
port
Port number that the user addition script should be executed against
Yes
passwd
Password to be set for user created. Will be passed to the script.
No
user
Name of the user to be created. Will be passed to the script.
No
script
File containing the user creation script
Either this attribute must be set, or the user addition script
User addition scripts are typically short. As an alternative to the script attribute
(which specifies the file containing the script), the script text can be added directly
as text to the body of this element.
Examples
<project
name="tests"
default="main"
xmlns:mpt="antlib:org.apache.james.mpt.ant">
<!-- Connect to port 10000 on localhost and run all scripts in src/test/resources/ -->
<target name='ConnectToServerPort10000'>
<mpt:mpt port='10000'>
<fileset dir='src/test/resources/>
<include name='**/*.mpt'/>
</fileset>
</mpt:mpt>
</target>
<!--
Connects to port 4001 on example.org then runs user addition script
Then connects to port 143 on example.org and runs test script 'test.mpt'
-->
<target name='ConnectToExampleDotOrgPort143'>
<mpt:mpt port='143' host='example.org' script='test.mpt'>
<!-- Add users by running 'Add User "${user}" "${passwd}"' -->
<addUser port='4001' user='user' passwd='passwd'>C: Add User "${user}" "${passwd}"</addUser>
</mpt:mpt>
</target>
</project>