Adds one header to match on as a Header object where the header values list can be a list of strings or regular expressions
(for more details of the supported regex syntax see http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html)
The body match rules on such as using one of the Body subclasses as follows:
exact string match:
- exact("this is an exact string body");
or
- new StringBody("this is an exact string body")
regular expression match:
- regex("username[a-z]{4}");
or
- new RegexBody("username[a-z]{4}");
json match:
- json("{username: 'foo', password: 'bar'}");
or
- json("{username: 'foo', password: 'bar'}", MatchType.STRICT);
or
- new JsonBody("{username: 'foo', password: 'bar'}");
json schema match:
- jsonSchema("{type: 'object', properties: { 'username': { 'type': 'string' }, 'password': { 'type': 'string' } }, 'required': ['username', 'password']}");
or
- jsonSchemaFromResource("org/mockserver/model/loginSchema.json");
or
- new JsonSchemaBody("{type: 'object', properties: { 'username': { 'type': 'string' }, 'password': { 'type': 'string' } }, 'required': ['username', 'password']}");
xpath match:
- xpath("/element[key = 'some_key' and value = 'some_value']");
or
- new XPathBody("/element[key = 'some_key' and value = 'some_value']");
body parameter match:
- params(
param("name_one", "value_one_one", "value_one_two")
param("name_two", "value_two")
);
or
- new ParameterBody(
new Parameter("name_one", "value_one_one", "value_one_two")
new Parameter("name_two", "value_two")
);
binary match:
- binary(IOUtils.readFully(getClass().getClassLoader().getResourceAsStream("example.pdf"), 1024));
or
- new BinaryBody(IOUtils.readFully(getClass().getClassLoader().getResourceAsStream("example.pdf"), 1024));
for more details of the supported regular expression syntax see http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html
for more details of the supported json syntax see http://jsonassert.skyscreamer.org
for more details of the supported json schema syntax see http://json-schema.org/
for more detail of XPath syntax see http://saxon.sourceforge.net/saxon6.5.3/expressions.html
The class to callback as a fully qualified class name
This calls must:
- implement org.mockserver.mock.action.ExpectationCallback
- have a zero argument constructor
- be available in the classpath of the MockServer
Override whether the socket is closed after a response is sent:
if true the socket will always be closed,
if false the socket will never be closed,
if not set the socket will be closed unless the request received is HTTP 1.1 and contains a "Connection" header with a value of "keep-alive"
The connection options for override the default connection behaviour, this allows full control of headers such
as "Connection" or "Content-Length" or controlling whether the socket is closed after the response has been sent
Override the "Content-Length" header with the specified amount, if not set the "Content-Length"
header will have a value determined by the length of the body
Adds one cookie to match on as a Cookie object where the cookie values list can be a list of strings or regular expressions
(for more details of the supported regex syntax see http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html)
Adds one cookie to match on, which can specified using either plain strings or regular expressions
(for more details of the supported regex syntax see http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html)
Adds one cookie to match on or to not match on using the NottableString, each NottableString can either be a positive matching value,
such as string("match"), or a value to not match on, such as not("do not match"), the string values passed to the NottableString
can be a plain string or a regex (for more details of the supported regex syntax see
http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html)
The cookies to match on as a list of Cookie objects where the values or keys of each cookie can be either a string or a regex
(for more details of the supported regex syntax see http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html)
The cookies to match on as a varags Cookie objects where the values or keys of each cookie can be either a string or a regex
(for more details of the supported regex syntax see http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html)
Adds one header to match on as a Header object where the header values list can be a list of strings or regular expressions
(for more details of the supported regex syntax see http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html)
Adds one header to match which can specified using plain strings or regular expressions
(for more details of the supported regex syntax see http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html)
Adds one header to match on or to not match on using the NottableString, each NottableString can either be a positive matching value,
such as string("match"), or a value to not match on, such as not("do not match"), the string values passed to the NottableString
can also be a plain string or a regex (for more details of the supported regex syntax
see http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html)
The headers to match on as a list of Header objects where the values or keys of each header can be either a string or a regex
(for more details of the supported regex syntax see http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html)
The headers to match on as a varags of Header objects where the values or keys of each header can be either a string or a regex
(for more details of the supported regex syntax see http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html)
Override the "Connection" header:
if true the "Connection" header is specified with a value of "keep-alive"
if false the "Connection" header is specified with a value of "close"
if not set the "Connection" header will have a a value of "close" unless the request received is HTTP 1.1 and contains a "Connection" header with a value of "keep-alive"
The path to match on such as "/some_mocked_path" any servlet context path is ignored for matching and should not be specified here
regex values are also supported such as ".*_path", see http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html
for full details of the supported regex syntax
The path to not match on for example not("/some_mocked_path") with match any path not equal to "/some_mocked_path",
the servlet context path is ignored for matching and should not be specified here
regex values are also supported such as not(".*_path"), see
http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html for full details of the supported regex syntax
Adds one query string parameter to match on as a Parameter object where the parameter values list can be a list of strings or regular expressions
(for more details of the supported regex syntax see http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html)
Adds one query string parameter to match which can specified using plain strings or regular expressions
(for more details of the supported regex syntax see http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html)
Adds one query string parameter to match on or to not match on using the NottableString, each NottableString can either be a positive matching
value, such as string("match"), or a value to not match on, such as not("do not match"), the string values passed to the NottableString
can also be a plain string or a regex (for more details of the supported regex syntax
see http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html)
The query string parameters to match on as a list of Parameter objects where the values or keys of each parameter can be either a string or a regex
(for more details of the supported regex syntax see http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html)
The query string parameters to match on as a varags Parameter objects where the values or keys of each parameter can be either a string or a regex
(for more details of the supported regex syntax see http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html)
The query string parameters to match on as a Map> where the values or keys of each parameter can be either a string or a regex
(for more details of the supported regex syntax see http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html)
The status code to return, such as 200, 404, the status code specified
here will result in the default status message for this status code for
example for 200 the status message "OK" is used