martes, 10 de marzo de 2015

SoapUI Project Generator - Maven Plugin

I've been working with SoapUI for years, it's an excellent tool for testing.
Creating one project manually is nothing, but when you are into a big project and lots of apps need their soapUI file it's tedious to create them manually.
So, for the app template o archetype i wanted to add an utility to automatic create that SoapUI Project. I just wanted to create the skeleton of the soapUI file so later someone else could add all the tests.
The idea is to build a soapui project based on a list of wsdls to create the TestSuites and another list of Wsdls for the mock services.

I used the plugin to create unit test for a OSB (Oracle Service BUS) project, but it could be used for any kind of project that uses web services and maven ;)

To use it you should use as base the three project that are in github https://github.com/carlgira/soa-utils/tree/master/soapui-projectgen  . To use it, follow this general instructions:
  1.  Download all the soapui-projectgen directory (git clone, or download the zip from github).
  2. Go to the soapui-projectgen-maven-plugin and execute:
    • mvn clean install
  3. Once you have instaled the maven plugin you can test the generation, with soapui-projectgen-test using one of the several configurations in the list of profiles in the pom.xml. The profiles has configuration to create the TestSuites and MocksServices in several ways (using list of WSDL files, WSDLs URLs, or a directories of WSDLs). Execute one of the profiles and see the result in the directory test/resources.
    • mvn generate-sources -P soapui-projectgen-wsdl-dirs
  4. I added a real OSB project to see how it could be used for real. You can configure the project with your local enviroment variables, deploy the jar and do the test.
    • Configure in the properties section all the variables of your enviroment.  (weblogic, osb.home, host, admin port, listen port etc).
    • Deploy the jar using. 
      • mvn clean package exec:exec
    • And make the test with. 
      • mvn test -P run-unit-test

In github are these three maven apps:

soapui-projectgen-maven-plugin

It's a maven plugin to create the soapui project. It's posible to pass the WSDLs files or URLs one by one or just pass a entire directory of WSDLs to be procesed.

It receives as input the next parameters:
- testWSDLDir: Directory of WSDLs to create TestSuites
- mockWSDLDir: Directory of WSDLs to create MockServices
- soapUIProjectFileName: Absolute path for the soapUI project
- projectName: Project Name of the soapUI project
- testWSDLFiles: WSDL list of files to create MockServices
- mockWSDLFiles: WSDL list of files to create MockServices
- testPropertiesFile: Absolute path for the properties file (Endpoints of the services)
- initialMockPort: Initial port for the mock services

As output this plugin creates two files, the soapui project and a properties files to indicate the endpoint of services to test (This file must be modified manually).

soapui-projectgen-tests

Has several examples of how to use the maven plugin in the pom.xml
To execute the maven plugin execute one of the possible maven profiles.

- mvn generate-sources -P soapui-projectgen-wsdl-dirs

osb-soapui-test

This is a OSB project to use the soapui project created. Look the pom.xml for the profiles "run-unit-test" or "run-integration-test".
Install and deploy the project
1. Configure in the properties section all the variables of your enviroment.
2. Deploy. mvn clean package exec:exec
3. Test. mvn test -P run-unit-test

The run-unit-test has two steps (soapui plugin executions)
- Start mock services of soapui project
- Execute testSuites
The reports of the tests are writen in the target directory