Gradle

Setup

There are two requirements that must be satisfied for this framework.

The first requirement is that a repose-test.properties file is on the classpath when tests are run.
The repose-test.properties file tells that framework what version of Repose, directories, host, and ports to use.
It should be in the Java properties file format like the following example:

Not all properties are strictly required.
In fact, most properties have reasonable defaults.
However, any property which takes an absolute path should be given a value.

The absolute path of the root directory to run tests under.
The user running the tests must have permission to read and write in this directory.
It is advised that this be the build directory of the build tool being used to run the tests (e.g., buildDir in Gradle).
Doing so enables the build tool to handle cleanup of any test resources.

2

The absolute path of the home directory which will contain Repose artifacts, and possibly other Repose test structures.

3

The absolute path of the directory which contains the configuration file templates.

4

The absolute path to the Repose JAR file.

5

The absolute path of the WAR file containing mock services.

6

The version of Repose.

7

The servlet container to run Repose in.
A value of valve will run a standalone instance of Repose using an embedded container.

8

The path of the directory relative to the test.root.directory or repose.home directory which will contain Repose configuration files.

9

The Repose log file path relative to the test.root.directory or repose.home directory.

10

The log filename path pattern relative to the test.root.directory or repose.home directory.

11

The target hostname (usually localhost).

12

The port number to start at when scanning for open ports.

13

The max port number which can be used when scanning for open ports.

14

The step size between workers when scanning for open ports.

15

The name of a System property the value of which will be used as the worker ID.

The second requirement is that the Repose artifacts (e.g., JARs and EARs) must be placed in the directory specified by the repose.home property.
If they are located elsewhere, the ReposeValveTest specification will not work.
However, other utilities provided by the framework may still be used.

Usage

Spock

To make the most of this framework, tests should be written for the Spock testing framework.
The Repose functional test framework provides a base Spock Specification in the form of the ReposeValveTest class.
The ReposeValveTest specification provide utilities to populate configuration file templates, start Repose, and search the Repose log.

The following simple example demonstrates how a Spock test can be written utilizing the Repose functional test framework.

Creates a Deproxy endpoint that will act as the origin service for Repose.

3

Retrieves a map of the test properties that will be used in templated configuration files.

4

Copies configuration files into the test directory being used by the test instance of Repose.
Any variables in the configuration files will be substituted.
The variable name will be matched to a key in the params map, and the corresponding value will replace the key in the configuration file.

5

Starts Repose.

6

Waits for Repose to finish starting, which is assumed to be when a non-500 status code response is returned.