Using Jenkins to test your OSB/SOA Suite services

This is a very short post on how you can test your webservices build in the OSB or SOA Suite. We are going to use SoapUI for our tests, Maven for our build process, SVN as our repository and Jenkins as our Continuous Integration server.

First we need a service which we want to test. Lets use a very simple Hello service. All this service does is greet the user. This looks like this in SoapUI:

We can make a few simple assertions like for our testcase:

Now save your soapUI project. You can save this for example in a test directory in your OSB project. Something like this.

Now check the whole OSB project into SVN. Now how are we going to make it possible for Jenkins to run my SoapUI tests? We are going to use Maven for that using the SoapUI plugin. You can create a pom.xml under your OSB project which can look like this:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>nl.redrock</groupId>
	<artifactId>HelloService</artifactId>
	<name>HelloService</name>
	<packaging>jar</packaging>
	<version>1.0</version>

	<pluginRepositories>
		<pluginRepository>
			<id>eviwarePluginRepository</id>
			<url>http://www.eviware.com/repository/maven2/</url>
		</pluginRepository>
	</pluginRepositories>
	
	<build>
		<plugins>
			<plugin>
				<groupId>eviware</groupId>
				<artifactId>maven-soapui-plugin</artifactId>
				<version>4.0.0</version>
				<executions>
					<execution>
						<phase>verify</phase>
						<id>soapui-tests</id>
						<configuration>
							<projectFile>${basedir}/Test/HelloService-soapui-project.xml</projectFile>
							<outputFolder>${basedir}/target/soapui</outputFolder>
							<junitReport>true</junitReport>
							<exportAll>true</exportAll>
							<printReport>true</printReport>
							<settingsFile>soapui-settings.xml</settingsFile>
						</configuration>
						<goals>
							<goal>test</goal>
						</goals>
					</execution>
				</executions>
				<dependencies>
					<dependency> 
						<groupId>com.oracle</groupId> 
						<artifactId>ojdbc5</artifactId> 
						<version>11.1.0</version> 
					</dependency>
				</dependencies>
			</plugin>
		</plugins>
	</build>

	
	<reporting>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-surefire-report-plugin</artifactId>
				<configuration>
					<outputDirectory>target/site/soapui</outputDirectory>
					<reportsDirectories>
						<reportsDirectories>target/soapui/</reportsDirectories>
					</reportsDirectories>
				</configuration>
			</plugin>
		</plugins>
	</reporting>
</project>

You can see here that we use the maven-soapui-plugin plugin to point to the soapui project. I also added an extra dependency for an oracle driver because I might want to do some database actions in SoapUI using Groovy to test if some values actually have reached the database. You can locally test if the build works by running >mvn test

If it all works, check in the whole project into SVN or your any other versioning system you are using. Next we want to create a job in Jenkins which runs the test. Go to your Jenkins machine and create a new job.

Next configure your job to your liking. In the Source Code Management section, enter the path of the repository where your pom.xml is located.

Next you want to configure it’s build pattern. This is all very straight forward so I won’t go into many details here.

And finally set some parameters for the output.

Save the job and run it. In the console output you can see that it retrieves the project from SVN and call the Maven action which then runs the SoapUI tests using the Maven plugin. Now you can automaticaly test your service whenever you want and keep this man happy 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

*