Uploading Files to DataPower from SoapUI Tests

SoapUI is the de facto standard tool for testing Web services and APIs. It is used by many DataPower developers. However, when SoapUI is used to test DataPower services that rely on XSLT files or other artifacts that have to be authored locally, having to manually upload these files to the device could substantially impair a developer’s productivity.

File uploads and many other test preparation steps can be easily automated using DPBuddy. All that is required is to invoke an Ant target containing DPBuddy’s copy task from the setup script of a SoapUI test step or a test suite.

First, we need to add Ant jar files to the SoapUI classpath. You can simply copy ant.jar and ant-launcher.jar to the “lib” directory of your SoapUI installation. If you’re on Windows, run soapui.bat instead of “SoapUI.exe” so you can see Ant’s output in the console window.

Second, create an Ant file containing “copy” task to copy your files to the appliance, e.g.,

<target name="copy.xslt">
    <dp:copy toDir="/xslt">
        <dpFileset dir="./xslt" includes="*.xslt"/>

Note that you must add the “reverseLoader” attribute to the “taskdef” used to define DPBuddy’s antlib:

<taskdef uri="antlib:com.myarch.dpbuddy" reverseLoader="true">

This is required because DPBuddy and SoapUI use different versions of various open-source libraries.

Lastly, open the “Setup Script” window of the test suite and add the following lines to the script:

def ant = new AntBuilder()
ant.ant(dir:"<location of build.xml>", target:"copy.xslt")

This script relies on Groovy’s AntBuilder for invoking Ant from SoapUI. It is also possible to invoke DPBuddy’s tasks directly without creating an external Ant file. This will be covered in a later post.

That’s it! Now our XSLT files will be automatically copied to the device whenever we run our test suite or a test.

If you’re interested in automating the rest of your DataPower deployment and administration tasks, download DPBuddy and give it a try. You can find various examples of DPBuddy’s tasks here, including copy-related examples.

A Few Simple Commands is All You Need

Automate without scripting, monitor your services, check for compliance
Realize full potential of DataPower gateways

Download DPBuddy Request A Demo