|Group / Artifact / Version
||au.com.dius / pact-jvm-server_2.11 / 3.5.0-rc.1
The pact server is a stand-alone interactions recorder and verifier, aimed at clients that are non-JVM or non-Ruby based.
The pact client for that platform will need to be implemented, but it only be responsible for generating the `JSON`
interactions, running the tests and communicating with the server.
The server implements a `JSON` `REST` Admin API with the following endpoints.
/ -> For diagnostics, currently returns a list of ports of the running mock servers.
/create -> For initialising a test server and submitting the JSON interactions. It returns a port
/complete -> For finalising and verifying the interactions with the server. It writes the `JSON` pact file to disk.
## Running the server
### Versions 2.2.6+
Pact server takes the following parameters:
Usage: pact-jvm-server [options] [port]
port to run on (defaults to 29999)
prints this usage text
-h | --host
host to bind to (defaults to localhost)
-l | --mock-port-lower
lower bound to allocate mock ports (defaults to 20000)
-u | --mock-port-upper
upper bound to allocate mock ports (defaults to 40000)
-d | --daemon
run as a daemon process
-v | --pact-version
pact version to generate for (2 or 3)
-k | --keystore-path
Path to keystore
-p | --keystore-password
-s | --ssl-port
Ssl port the mock server should run on. lower and upper bounds are ignored
run with debug logging
### Using trust store 3.4.0+
Trust store can be used. However, it is limited to a single port for the time being.
### Prior to version 2.2.6
Pact server takes one optional parameter, the port number to listen on. If not provided, it will listen on 29999.
It requires an active console to run.
### Using a distribution archive
You can download a [distribution from maven central](http://search.maven.org/remotecontent?filepath=au/com/dius/pact-jvm-server_2.11/2.2.4/).
There is both a ZIP and TAR archive. Unpack it to a directory of choice and then run the script in the bin directory.
### Building a distribution bundle
You can build an application bundle with gradle by running (for 2.11 version):
$ ./gradlew :pact-jvm-server_2.11:installdist
This will create an app bundle in `build/2.11/install/pact-jvm-server_2.11`. You can then execute it with:
$ java -jar pact-jvm-server/build/2.10/install/pact-jvm-server_2.11/lib/pact-jvm-server_2.11-3.2.11.jar
or with the generated bundle script file:
By default will run on port `29999` but a port number can be optionally supplied.
### Running it with docker
You can use a docker image to execute the mock server as a docker container.
$ docker run -d -p 8080:8080 -p 20000-20010:20000-20010 uglyog/pact-jvm-server
This will run the main server on port 8080, and each created mock server on ports 20000-20010. You can map the ports to
any you require.
## Life cycle
The following actions are expected to occur
* The client calls `/create` to initialise a server with the expected `JSON` interactions and state
* The admin server will start a mock server on a random port and return the port number in the response
* The client will execute its interaction tests against the mock server with the supplied port
* Once finished, the client will call `/complete' on the Admin API, posting the port number
* The pact server will verify the interactions and write the `JSON` `pact` file to disk under `/target`
* The mock server running on the supplied port will be shutdown.
The client will need `POST` to `/create` the generated `JSON` interactions, also providing a state as a query parameter.
|Last modified||2017-05-25 03:49:04 UTC|
|Effective POM File
<dependency org="au.com.dius" name="pact-jvm-server_2.11" rev="3.5.0-rc.1" />
@Grapes(@Grab(group='au.com.dius', module='pact-jvm-server_2.11', version='3.5.0-rc.1'))
libraryDependencies += "au.com.dius" % "pact-jvm-server_2.11" % "3.5.0-rc.1"