SoapUI JUnit MockRunner Project

This application will bootstrap SoapUI Mock in its own classloader context to prevent clashes with any project dependencies that are under test. The mockrunner uses Plexus Classworlds/Container and Aether to decouple the execution of the mock from the projects under test.

License

License

Categories

Categories

JUnit Unit Testing
GroupId

GroupId

io.fares.junit.soapui
ArtifactId

ArtifactId

soapui-junit-mockrunner-project
Last Version

Last Version

0.0.3
Release Date

Release Date

Type

Type

pom
Description

Description

SoapUI JUnit MockRunner Project
This application will bootstrap SoapUI Mock in its own classloader context to prevent clashes with any project dependencies that are under test. The mockrunner uses Plexus Classworlds/Container and Aether to decouple the execution of the mock from the projects under test.
Project URL

Project URL

https://github.com/bertramn/soapui-junit-mockrunner
Source Code Management

Source Code Management

https://github.com/bertramn/soapui-junit-mockrunner.git

Download soapui-junit-mockrunner-project

How to add to project

<!-- https://jarcasting.com/artifacts/io.fares.junit.soapui/soapui-junit-mockrunner-project/ -->
<dependency>
    <groupId>io.fares.junit.soapui</groupId>
    <artifactId>soapui-junit-mockrunner-project</artifactId>
    <version>0.0.3</version>
    <type>pom</type>
</dependency>
// https://jarcasting.com/artifacts/io.fares.junit.soapui/soapui-junit-mockrunner-project/
implementation 'io.fares.junit.soapui:soapui-junit-mockrunner-project:0.0.3'
// https://jarcasting.com/artifacts/io.fares.junit.soapui/soapui-junit-mockrunner-project/
implementation ("io.fares.junit.soapui:soapui-junit-mockrunner-project:0.0.3")
'io.fares.junit.soapui:soapui-junit-mockrunner-project:pom:0.0.3'
<dependency org="io.fares.junit.soapui" name="soapui-junit-mockrunner-project" rev="0.0.3">
  <artifact name="soapui-junit-mockrunner-project" type="pom" />
</dependency>
@Grapes(
@Grab(group='io.fares.junit.soapui', module='soapui-junit-mockrunner-project', version='0.0.3')
)
libraryDependencies += "io.fares.junit.soapui" % "soapui-junit-mockrunner-project" % "0.0.3"
[io.fares.junit.soapui/soapui-junit-mockrunner-project "0.0.3"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

  • soapui-junit-mockrunner
  • soapui-junit-mockrunner-tests

SoapUI JUnit MockRunner

Overview

Ever tried to start a soapui mock service from within your junit test? Sure the soapui-maven-plugin make a good job when you just run from command line ... but if you develop in an IDE that is not always the case.

This module can be used to execute a soapui mock service within a classloader jail. This will ensure the project under test is not dependent on SoapUI itself. The classloader jail will resolve all required dependencies from the official soapui maven repository.

Example

The most simple example on how to fire up a Junit test with a SoapUI mock service running in the background.

import static org.junit.Assert.*;
import org.junit.ClassRule;
import org.junit.Test;

public class SomeMockServiceTest {

  @ClassRule
  public static SoapUIMockRunner runner = new SoapUIMockRunner()
                                                  .simpleBinding()
                                                  .withProjectPath("embedded-soapui/TestSoapUIProject-soapui-project.xml")
                                                  .withMockServiceName("WeatherMockService")
                                                  .withMockHost("localhost")
                                                  .withMockPort(8097)
                                                  .withMockPath("/weather-change");

  @Test
  public void testMockRunner() throws Exception {
    assertTrue(runner.isRunning());
    System.out.println("do some testing against endpoint: " + runner.getMockEndpoint());
  }

}

Configure SoapUI Version

Because the soapui starts in a classloader jail, one can also a) compile this libary against a different version:

mvn clean install -Dsoapui.version=5.1.2

or if the compiled version of soapui-junit-mockrunner is largely compatible with what you are trying to run, simply specify the version on the SoapUIMockRunner:

new SoapUIMockRunner()
        .simpleBinding()
        .withProjectPath("embedded-soapui/TestSoapUIProject-soapui-project.xml")
        .withMockServiceName("WeatherMockService")
        .soapuiVersion("5.1.2");

The option is risky when you specify a runner version that is incompatible with the soapui classes that are loaded.

I sucessfully ran a soapui-junit-mockrunner compiled against SoapUI 5.0.0 using a 5.1.2 runtime version (as above example).

TODO

Instead of the dodgy simple binding, should really use com.eviware.soapui.tools.SoapUIMockServiceRunner.main() with a set of standard SoapUI path parameters.

Limitiations

  1. the reflection binding does not work with path, port and host settings (use simple binding)
  2. searching for the local maven repo for cached artefact bindings is rather crude
  3. need to improve exception handing, especially with the rule
  4. not enough tests and examples

Versions

Version
0.0.3
0.0.2