Getting Started Mocking

The typical sequence for using MockServer is as follows:
- Start MockServer
- Setup Expectations
- Run Your Test Scenarios
- Verify Requests

For example code see the code examples folder in the git repository.
On this page
Most of MockServer's power is in step 1, Setup Expectations. Rather than scrolling, jump straight to the capability you need — match the request, choose an action, and (optionally) drive stateful scenarios:
| Match requests | Respond with actions | Sequencing & scenarios |
|---|---|---|
|
Workflow: 0. Start MockServer · 1. Setup Expectations · 3. Verify Requests | Reference: Next Steps · Spring Boot · Upgrading · HTTP/2 Proxy Limitations · Single Port Architecture
0. Start MockServer
The fastest way to run MockServer is a single command — pick whichever fits your environment. Every option below starts a server that mocks and proxies HTTP and HTTPS on one port (default 1080):
# Docker — no Java required
docker run -p 1080:1080 mockserver/mockserver
# Node — no Java and no Docker (downloads a self-contained bundle)
npx -p mockserver-node mockserver run -p 1080
# Homebrew (macOS / Linux)
brew install mockserver && mockserver run -p 1080
Confirm it is up (the status endpoint returns 200 once MockServer is ready):
curl -i -X PUT http://localhost:1080/mockserver/status
MockServer is flexible and support numerous usage patterns.
MockServer can be run:
- programmatically via a Java API in an @Before or @After method
- using a JUnit 4 @Rule via a @Rule annotated field in a JUnit 4 test
- using a JUnit 5 Test Extension via a @ExtendWith annotated JUnit 5 class
- using a Spring Test Execution Listener via a @MockServerTest annotated test class
- as a Docker container in any Docker enabled environment
- via a Helm chart in any Kubernetes environment
- from the command line as a stand-alone process in a test environment
- via a Maven Plugin as part of a Maven build cycle
- as a Node.js (npm) module from any Node.js code
- as a Grunt plugin as part of a Grunt build cycle
- as a deployable WAR to an existing application server
- via a client library binary launcher (Node, Python, Ruby, Go, .NET, Rust) — downloads a cross-platform, JVM-less binary bundle automatically
- as a throwaway Testcontainers container started and stopped automatically by your test run
- as a shared, centralised deployment across multiple teams or CI pipelines — another good option when several projects share one running MockServer
To simplify configuration all versions (except the deployable WAR) use a single port to support the control plane and data plane in HTTP, HTTPS or SOCKS.
MockServer is available in the following formats:
- java dependency
- Docker container
- Helm chart for Kubernetes
- executable jar
- Homebrew package
- maven plugin
- npm plugin
- Grunt plugin
- deployable WAR that runs on JEE web servers
- client library binary bundle — a self-contained, cross-platform binary (no Java required) downloaded automatically by the Node, Python, Ruby, Go, .NET, and Rust clients
It is also possible to build and run MockServer directly from source code
1. Setup Expectations
An expectation can also run extra webhooks or callbacks before or after its response — see Before & After Actions for mirroring, fan-out, shadow, and gating patterns.
Please Note: There are over 100 more detailed code examples in Java, JavaScript, Python, Ruby, Go, .NET, Rust, PHP and the REST API below.
new MockServerClient("localhost", 1080)
.when(
request()
.withMethod("POST")
.withPath("/login")
.withBody("{username: 'foo', password: 'bar'}")
)
.respond(
response()
.withStatusCode(302)
.withCookie(
"sessionId", "2By8LOhBmaW5nZXJwcmludCIlMDAzMW"
)
.withHeader(
"Location", "https://www.mock-server.com"
)
);
Please Note: There are over 100 more detailed code examples in Java, JavaScript, Python, Ruby, Go, .NET, Rust, PHP and the REST API below.
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"method": "POST",
"path": "/login",
"body": {
"username": "foo",
"password": "bar"
}
},
"httpResponse": {
"statusCode": 302,
"headers": {
"Location": [
"https://www.mock-server.com"
]
},
"cookies": {
"sessionId": "2By8LOhBmaW5nZXJwcmludCIlMDAzMW"
}
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
from mockserver import MockServerClient, HttpRequest, HttpResponse
client = MockServerClient("localhost", 1080)
client.when(
HttpRequest(
method="POST",
path="/login",
body="{username: 'foo', password: 'bar'}"
)
).respond(
HttpResponse(
status_code=302,
headers={"Location": ["https://www.mock-server.com"]}
)
)
require 'mockserver-client'
include MockServer
client = MockServer::Client.new('localhost', 1080)
client.when(
HttpRequest.new(
method: 'POST',
path: '/login',
body: "{username: 'foo', password: 'bar'}"
)
).respond(
HttpResponse.new(
status_code: 302,
headers: { 'Location' => ['https://www.mock-server.com'] }
)
)
import mockserver "github.com/mock-server/mockserver-monorepo/mockserver-client-go"
client := mockserver.New("localhost", 1080)
client.When(
mockserver.Request().
Method("POST").
Path("/login").
Body("{username: 'foo', password: 'bar'}"),
).Respond(
mockserver.Response().
StatusCode(302).
Header("Location", "https://www.mock-server.com"),
)
using MockServer.Client;
using MockServer.Client.Models;
using var client = new MockServerClient("localhost", 1080);
client.When(
HttpRequest.Request()
.WithMethod("POST")
.WithPath("/login")
.WithBody("{username: 'foo', password: 'bar'}")
).Respond(
HttpResponse.Response()
.WithStatusCode(302)
.WithHeader("Location", "https://www.mock-server.com")
);
use mockserver_client::{ClientBuilder, HttpRequest, HttpResponse};
let client = ClientBuilder::new("localhost", 1080).build().unwrap();
client.when(
HttpRequest::new()
.method("POST")
.path("/login")
.body("{username: 'foo', password: 'bar'}"),
).respond(
HttpResponse::new()
.status_code(302)
.header("Location", "https://www.mock-server.com"),
).unwrap();
use MockServer\MockServerClient;
use MockServer\HttpRequest;
use MockServer\HttpResponse;
$client = new MockServerClient('localhost', 1080);
$client->when(
HttpRequest::request()
->method('POST')
->path('/login')
->body("{username: 'foo', password: 'bar'}")
)->respond(
HttpResponse::response()
->statusCode(302)
->header('Location', 'https://www.mock-server.com')
);
To use the Java client add the org.mock-server:mockserver-client-java-no-dependencies:7.1.0 dependency. The -no-dependencies artifact bundles all dependencies with relocated packages, so it declares zero transitive dependencies — this avoids classpath conflicts and CVE scanning noise from unused transitive dependencies.
For more details about the different dependency versions see the page on Maven Central
for example in maven:
<dependency>
<groupId>org.mock-server</groupId>
<artifactId>mockserver-client-java-no-dependencies</artifactId>
<version>7.1.0</version>
</dependency>
A request matcher expectation may contain:
- request matcher - used to match which requests this expectation should be applied to
- action - what action to take, actions include response, forward, forward with fallback, callback and error
- times (optional) - how many times the action should be taken
- timeToLive (optional) - how long the expectation should stay active
- priority (optional) - matching is ordered by priority (highest first) then creation (earliest first)
- id (optional) - used for updating an existing expectation (i.e. when the id matches)
- scenario (optional) - used for stateful multi-step API flows where the response changes based on prior interactions
- httpResponses (optional) - an array of responses to cycle through sequentially or randomly on each match
open api expectations are also supported using an OpenAPI v3 specifications to generate request matcher expectations for each operation, see the section on open api expectations for details.
Matching Order
MockServer will match (or play) active expectations in the exact order they are added (if their priority is identical). For example, if an expectation A is added with Times.exactly(3) then expectation B is added with Times.exactly(2) with the same request matcher they will be applied in the following order A, A, A, B, B. Priority can be used to alter the order that expectations are matched; matching is ordered by priority (highest first) then creation (earliest first).
Priority can be used to configure a default expectation or response by specifying a negative value for priority and a very lax request matcher; the lax request matcher ensures the default expectation is always matched, but the low priority ensure it is matched last after all other expectations.
Probabilistic Matching (Percentage)
An expectation can be configured with a percentage (0-100) to enable probabilistic matching. When set, the expectation will only match the specified percentage of requests that structurally match the request matcher. This is useful for simulating intermittent failures, flaky services, or A/B testing scenarios.
For example, setting percentage to 50 means approximately half of matching requests will be handled by this expectation, while the other half will fall through to the next matching expectation or the default behavior.
If percentage is not set or set to 100, the expectation matches all structurally matching requests (the default behavior). A value of 0 means the expectation never matches.
Stateful Scenarios
Stateful scenarios let you model multi-step API conversations where MockServer's response changes based on prior interactions. Each scenario is an independent named state machine that starts in the "Started" state.
An expectation can participate in a scenario by specifying:
- scenarioName - the name of the scenario this expectation belongs to
- scenarioState - the state the scenario must be in for this expectation to match
- newScenarioState - the state the scenario transitions to after this expectation matches
If scenarioName is not set, the expectation behaves normally without any scenario filtering. The default initial state for all scenarios is "Started".
Example - Login Flow: First call returns a token, subsequent calls using that token get a different response.
// Step 1: Login returns a token (scenario starts in "Started" state)
{
"httpRequest": {
"method": "POST",
"path": "/login"
},
"httpResponse": {
"statusCode": 200,
"body": "{\"token\": \"abc123\"}"
},
"scenarioName": "LoginFlow",
"scenarioState": "Started",
"newScenarioState": "LoggedIn",
"times": { "remainingTimes": 1 }
}
// Step 2: After login, GET /profile returns user data
{
"httpRequest": {
"method": "GET",
"path": "/profile"
},
"httpResponse": {
"statusCode": 200,
"body": "{\"name\": \"Alice\", \"email\": \"alice@example.com\"}"
},
"scenarioName": "LoginFlow",
"scenarioState": "LoggedIn"
}
// Step 3: Before login, GET /profile returns 401
{
"httpRequest": {
"method": "GET",
"path": "/profile"
},
"httpResponse": {
"statusCode": 401,
"body": "{\"error\": \"Not authenticated\"}"
},
"scenarioName": "LoginFlow",
"scenarioState": "Started"
}
Example - Pagination: Successive calls to the same endpoint return different pages of data.
// Page 1 (initial state)
{
"httpRequest": {
"method": "GET",
"path": "/items"
},
"httpResponse": {
"statusCode": 200,
"body": "{\"items\": [\"a\", \"b\"], \"page\": 1, \"hasMore\": true}"
},
"scenarioName": "Pagination",
"scenarioState": "Started",
"newScenarioState": "Page2",
"times": { "remainingTimes": 1 }
}
// Page 2
{
"httpRequest": {
"method": "GET",
"path": "/items"
},
"httpResponse": {
"statusCode": 200,
"body": "{\"items\": [\"c\", \"d\"], \"page\": 2, \"hasMore\": true}"
},
"scenarioName": "Pagination",
"scenarioState": "Page2",
"newScenarioState": "Page3",
"times": { "remainingTimes": 1 }
}
// Page 3 (last page)
{
"httpRequest": {
"method": "GET",
"path": "/items"
},
"httpResponse": {
"statusCode": 200,
"body": "{\"items\": [\"e\"], \"page\": 3, \"hasMore\": false}"
},
"scenarioName": "Pagination",
"scenarioState": "Page3"
}
Example - Retry Testing: First two calls return 503, third call succeeds.
// First call: 503
{
"httpRequest": { "path": "/api/data" },
"httpResponse": { "statusCode": 503, "body": "{\"error\": \"Service Unavailable\"}" },
"scenarioName": "RetryTest",
"scenarioState": "Started",
"newScenarioState": "Attempt2",
"times": { "remainingTimes": 1 }
}
// Second call: 503
{
"httpRequest": { "path": "/api/data" },
"httpResponse": { "statusCode": 503, "body": "{\"error\": \"Service Unavailable\"}" },
"scenarioName": "RetryTest",
"scenarioState": "Attempt2",
"newScenarioState": "Ready",
"times": { "remainingTimes": 1 }
}
// Third call onwards: 200
{
"httpRequest": { "path": "/api/data" },
"httpResponse": { "statusCode": 200, "body": "{\"data\": \"success\"}" },
"scenarioName": "RetryTest",
"scenarioState": "Ready"
}
Example - Order State Machine: Model an order lifecycle with state transitions.
// Create order
{
"httpRequest": { "method": "POST", "path": "/orders" },
"httpResponse": { "statusCode": 201, "body": "{\"id\": 1, \"status\": \"CREATED\"}" },
"scenarioName": "OrderLifecycle",
"scenarioState": "Started",
"newScenarioState": "OrderCreated",
"times": { "remainingTimes": 1 }
}
// Pay for order (only available after creation)
{
"httpRequest": { "method": "PUT", "path": "/orders/1/pay" },
"httpResponse": { "statusCode": 200, "body": "{\"id\": 1, \"status\": \"PAID\"}" },
"scenarioName": "OrderLifecycle",
"scenarioState": "OrderCreated",
"newScenarioState": "OrderPaid",
"times": { "remainingTimes": 1 }
}
// Get order - returns CREATED status
{
"httpRequest": { "method": "GET", "path": "/orders/1" },
"httpResponse": { "statusCode": 200, "body": "{\"id\": 1, \"status\": \"CREATED\"}" },
"scenarioName": "OrderLifecycle",
"scenarioState": "OrderCreated"
}
// Get order - returns PAID status
{
"httpRequest": { "method": "GET", "path": "/orders/1" },
"httpResponse": { "statusCode": 200, "body": "{\"id\": 1, \"status\": \"PAID\"}" },
"scenarioName": "OrderLifecycle",
"scenarioState": "OrderPaid"
}
Example - Rate Limiting: Allow a fixed number of calls, then return 429.
// First 3 calls succeed
{
"httpRequest": { "path": "/api/resource" },
"httpResponse": { "statusCode": 200, "body": "{\"data\": \"ok\"}" },
"scenarioName": "RateLimit",
"scenarioState": "Started",
"newScenarioState": "Call2",
"times": { "remainingTimes": 1 }
}
{
"httpRequest": { "path": "/api/resource" },
"httpResponse": { "statusCode": 200, "body": "{\"data\": \"ok\"}" },
"scenarioName": "RateLimit",
"scenarioState": "Call2",
"newScenarioState": "Call3",
"times": { "remainingTimes": 1 }
}
{
"httpRequest": { "path": "/api/resource" },
"httpResponse": { "statusCode": 200, "body": "{\"data\": \"ok\"}" },
"scenarioName": "RateLimit",
"scenarioState": "Call3",
"newScenarioState": "RateLimited",
"times": { "remainingTimes": 1 }
}
// Subsequent calls: 429 Too Many Requests
{
"httpRequest": { "path": "/api/resource" },
"httpResponse": { "statusCode": 429, "body": "{\"error\": \"Rate limit exceeded\"}" },
"scenarioName": "RateLimit",
"scenarioState": "RateLimited"
}
Example - Multi-Turn LLM Conversation: Script a two-turn agent loop where the model first calls a tool, then answers after receiving the tool result. Each turn advances the scenario state automatically. Use isolateBy so concurrent sessions (identified by a header, query parameter, or cookie) maintain independent state.
import static org.mockserver.client.LlmConversationBuilder.conversation;
import static org.mockserver.model.Completion.completion;
import static org.mockserver.model.ToolUse.toolUse;
import static org.mockserver.llm.IsolationSource.header;
conversation()
.withPath("/v1/messages")
.withProvider(Provider.ANTHROPIC)
.withModel("claude-sonnet-4")
.isolateBy(header("x-session-id"))
.turn()
.whenTurnIndex(0)
.respondingWith(
completion()
.withToolCall(toolUse("search").withArguments("{\"query\":\"weather\"}"))
.withStopReason("tool_use"))
.andThen()
.turn()
.whenContainsToolResultFor("search")
.respondingWith(
completion()
.withText("Based on the search results, it will be sunny.")
.withStopReason("end_turn"))
.applyTo(mockServerClient);
JSON equivalent (two expectations sharing a scenario):
// Turn 1: tool call
{
"httpRequest": { "method": "POST", "path": "/v1/messages" },
"httpLlmResponse": {
"provider": "ANTHROPIC",
"model": "claude-sonnet-4",
"completion": {
"toolCalls": [{ "name": "search", "arguments": "{\"query\":\"weather\"}" }],
"stopReason": "tool_use"
},
"conversationPredicates": { "turnIndex": 0 }
},
"scenarioName": "__llm_conv_example",
"scenarioState": "Started",
"newScenarioState": "turn_1"
}
// Turn 2: final answer after tool result
{
"httpRequest": { "method": "POST", "path": "/v1/messages" },
"httpLlmResponse": {
"provider": "ANTHROPIC",
"model": "claude-sonnet-4",
"completion": {
"text": "Based on the search results, it will be sunny.",
"stopReason": "end_turn"
},
"conversationPredicates": { "containsToolResultFor": "search" }
},
"scenarioName": "__llm_conv_example",
"scenarioState": "turn_1",
"newScenarioState": "__done"
}
Scenarios are independent of each other — different scenario names maintain separate state. All scenario states are reset when MockServer is reset.
Timed and Triggered Scenario Flows
Beyond expectation-driven state transitions, MockServer supports timed auto-transitions and external triggers via REST endpoints. These let you model scenarios where state changes happen after a time delay (e.g. a background process completing) or are driven externally by a test harness.
Get current state:
# Returns {"scenarioName": "DeployFlow", "currentState": "Started"}
curl -X GET http://localhost:1080/mockserver/scenario/DeployFlow
Set state immediately:
# Set the scenario to "Deploying" state
curl -X PUT http://localhost:1080/mockserver/scenario/DeployFlow \
-H "Content-Type: application/json" \
-d '{"state": "Deploying"}'
Set state with timed auto-transition: The scenario enters "Deploying" immediately, then automatically transitions to "Deployed" after 5 seconds (if still in "Deploying").
curl -X PUT http://localhost:1080/mockserver/scenario/DeployFlow \
-H "Content-Type: application/json" \
-d '{"state": "Deploying", "transitionAfterMs": 5000, "nextState": "Deployed"}'
External trigger: Advance the scenario to a specific state from your test harness or CI pipeline.
# Jump directly to "Failed" state
curl -X PUT http://localhost:1080/mockserver/scenario/DeployFlow/trigger \
-H "Content-Type: application/json" \
-d '{"newState": "Failed"}'
Example - Deployment Pipeline Flow: Combine expectation-based matching with timed transitions to model a deployment that takes time to complete.
// Step 1: Register expectations for each state
// When Deploying, GET /status returns "in progress"
{
"httpRequest": { "method": "GET", "path": "/status" },
"httpResponse": { "statusCode": 200, "body": "{\"status\": \"deploying\"}" },
"scenarioName": "DeployFlow",
"scenarioState": "Deploying"
}
// When Deployed, GET /status returns "complete"
{
"httpRequest": { "method": "GET", "path": "/status" },
"httpResponse": { "statusCode": 200, "body": "{\"status\": \"complete\"}" },
"scenarioName": "DeployFlow",
"scenarioState": "Deployed"
}
// Step 2: Start the flow with a timed transition
// PUT /mockserver/scenario/DeployFlow
// Body: {"state": "Deploying", "transitionAfterMs": 3000, "nextState": "Deployed"}
//
// Now: GET /status returns "deploying"
// After 3 seconds: GET /status returns "complete"
Timed transitions are guarded: the transition only fires if the scenario is still in the expected currentState when the timer expires. If the scenario has already moved to a different state (e.g. via an external trigger or expectation match), the timed transition becomes a no-op. Scheduling a new transition for the same scenario cancels any pending one.
Cross-Protocol Scenario Correlation
Scenario state transitions are not limited to HTTP request matches. A DNS query, WebSocket connection, gRPC request, or HTTP request can drive a scenario forward via a cross-protocol trigger. This lets you model multi-protocol test flows — for example: "when a WebSocket connects, advance scenario X so the next HTTP expectation for that state becomes active."
Add a crossProtocolScenarios array to an expectation. Each entry specifies:
- trigger — the protocol event that fires the transition: DNS_QUERY, WEBSOCKET_CONNECT, GRPC_REQUEST, or HTTP_REQUEST
- matchPattern — optional substring filter on the event identifier (DNS query name, gRPC service name, HTTP path, or WebSocket URL); if omitted, all events of that type match
- scenarioName — the name of the scenario to advance
- targetState — the state to transition the scenario to
Example — WebSocket connect advances an HTTP scenario: When any WebSocket connection is established, the "ConnectionFlow" scenario transitions to "WsConnected", activating the HTTP expectation that requires that state.
// Expectation 1: dummy WebSocket endpoint that fires the cross-protocol transition
{
"httpRequest": {
"method": "GET",
"path": "/ws/events"
},
"httpResponse": {
"statusCode": 101
},
"crossProtocolScenarios": [
{
"trigger": "WEBSOCKET_CONNECT",
"scenarioName": "ConnectionFlow",
"targetState": "WsConnected"
}
]
}
// Expectation 2: only active after the WebSocket has connected
{
"httpRequest": {
"method": "GET",
"path": "/api/status"
},
"httpResponse": {
"statusCode": 200,
"body": "{\"status\": \"connected\"}"
},
"scenarioName": "ConnectionFlow",
"scenarioState": "WsConnected"
}
Example — DNS query activates a downstream-failure scenario: When a DNS query for payments.svc is observed, advance the scenario to "DnsObserved" so a chaos-injecting HTTP expectation becomes active.
{
"httpRequest": { "method": "GET", "path": "/_internal/dns-trigger" },
"httpResponse": { "statusCode": 200 },
"crossProtocolScenarios": [
{
"trigger": "DNS_QUERY",
"matchPattern": "payments.svc",
"scenarioName": "PaymentsFlow",
"targetState": "DnsObserved"
}
]
}
The matchPattern is a substring match against the event identifier. For DNS_QUERY it is the query name; for GRPC_REQUEST it is the gRPC service name; for HTTP_REQUEST it is the request path; for WEBSOCKET_CONNECT it is the WebSocket URL. When matchPattern is omitted, all events of that trigger type match. Multiple entries in crossProtocolScenarios are evaluated independently — a single event can advance several scenarios in one fire.
Sequential / Cycling Responses
A single expectation can return multiple different responses by providing an array of responses in the httpResponses field. Each time the expectation matches, the next response in the list is returned. After the last response, it cycles back to the first.
The responseMode field controls how responses are selected:
- SEQUENTIAL (default) - responses are returned in order, cycling back to the first after the last
- RANDOM - a random response is selected from the list for each request
Note: Use httpResponses instead of httpResponse (singular) when you want multiple responses. If both are set, httpResponses takes priority.
Example - Sequential Responses: Cycle through different status codes.
{
"httpRequest": {
"path": "/api/status"
},
"httpResponses": [
{ "statusCode": 200, "body": "{\"status\": \"ok\"}" },
{ "statusCode": 503, "body": "{\"status\": \"degraded\"}" },
{ "statusCode": 200, "body": "{\"status\": \"ok\"}" }
]
}
The first request returns 200, the second returns 503, the third returns 200, then it cycles back to the first response.
Example - Random Responses: Simulate unpredictable service behavior.
{
"httpRequest": {
"path": "/api/unstable"
},
"httpResponses": [
{ "statusCode": 200, "body": "{\"result\": \"success\"}" },
{ "statusCode": 500, "body": "{\"error\": \"Internal Server Error\"}" },
{ "statusCode": 429, "body": "{\"error\": \"Too Many Requests\"}" }
],
"responseMode": "RANDOM"
}
Example - Java Client:
import static org.mockserver.model.HttpRequest.request;
import static org.mockserver.model.HttpResponse.response;
new MockServerClient("localhost", 1080)
.when(request().withPath("/api/status"))
.respond(
java.util.Arrays.asList(
response().withStatusCode(200).withBody("{\"status\": \"ok\"}"),
response().withStatusCode(503).withBody("{\"status\": \"degraded\"}")
)
);
Updating Expectations
If an expectation is added and the id field matches an existing expectation the existing expectation will be updated (i.e. replaced). A UUID will be used assigned to each expectation if no value for id is specified.
Request Matchers
There are two types of request matcher:
- request properties matcher - that match requests using HTTP properties such as method, path or body
- open api request matcher - that match requests using an OpenAPI definition
A request properties matcher matches requests using one or more of the following properties:
- method - property matcher
- path - property matcher
- path parameters - key to multiple values matcher
- query string parameters - key to multiple values matcher
- headers - key to multiple values matcher
- cookies - key to single value matcher
- body - body matchers
- secure - boolean value, true for HTTPS
Matching for properties can be done using:
- string value
- use for: method, path, path parameter keys, path parameters values, query parameter keys, query parameters values, header keys, header values, cookie keys, cookie values or bodies
- examples: method, path, path parameters, query parameters, headers, cookies
- regex value
- use for: method, path, path parameter keys, path parameters values, query parameter keys, query parameters values, header keys, header values, cookie keys, cookie values or bodies
- examples: method, path, path parameters, query parameters, headers
- for syntax see Java regex syntax
- json schema
- use for: method, path, path parameters values, query parameters values, header values, cookie values or bodies
- not supported for: path parameter keys, query parameter keys, header keys or cookie keys
- examples: path parameters, query parameters, headers , cookies
- for syntax see JSON Schema documentation
- optional value
- use for: method, path, path parameters values, query parameter keys, query parameters values, header keys, header values, cookie keys, cookie values or bodies
- not supported for: path parameter keys
- examples: query parameters, headers, cookies
- negated value
Note: path values containing { or } characters (such as /api/{id}) are interpreted as regex patterns, not literal strings. This is a common source of unexpected matching behaviour when path templates are used. To match literal curly braces in a path, use one of the following approaches:
- Use an explicit regex matcher and escape the braces: withPath(regex("/api/\\{id\\}"))
- Use an exact string matcher: withPath(exact("/api/{id}"))
Matching for key to multiple values supports multiple values for each key for headers, query parameters and path parameters
- Keys support all property matcher except json schema
- Values support all property matcher except optional values
- Matching supports two modes:
- sub set (default) - matches if the request property contains a matching sub set (considering optional keys), therefore there is at least one matching value for each non-optional key or optional key if present
- matching key - matches if the request property contains only matching values (considering optional keys), therefore all values must match for each non-optional key or optional key if present
Note: for query parameters, the default sub set matching mode means that extra query parameters not specified in the matcher are allowed and do not cause a match failure. To enforce strict matching where only the specified query parameters are allowed (and any additional parameters cause a mismatch), use KeyMatchStyle.MATCHING_KEY on the request matcher. For example:
request()
.withPath("/some/path")
.withQueryStringParameters(
new Parameters(
param("key", "value")
).withKeyMatchStyle(KeyMatchStyle.MATCHING_KEY)
)
Matching for key to single value supports a single value for each key for cookies
- Keys support all property matcher except json schema
- Values support all property matcher except optional values
Important: when matching JSON bodies, there is a significant difference between plain string matching and semantic JSON matching:
- withBody("{\"key\": \"value\"}") performs a character-by-character string comparison. This means whitespace, key ordering, and formatting must match exactly. For example, {"key":"value"} would not match {"key": "value"} because of the missing space.
- withBody(json("{\"key\": \"value\"}")) performs a semantic JSON comparison. This ignores whitespace and (with ONLY_MATCHING_FIELDS) allows additional fields. Use this for matching JSON payloads.
If your expectations are not matching JSON requests as expected, ensure you are using json() rather than passing the JSON string directly.
Matching for bodies can be done using:
- plain text (i.e. exact match)
- regular expression - see Java regex syntax
- JSON - supports:
- matchType to control which fields get matched:
- STRICT matches all fields, order of arrays and no additional fields allowed
- ONLY_MATCHING_FIELDS only matches fields provided in the request matcher
- matchNumbersAsStrings (optional, default false) if true, numeric values are compared by numeric value regardless of type, so 1, 1.0 and 1.00 are all considered equal. This is useful when different languages or serializers produce different numeric representations for the same value (e.g. Java sends 1.0 while Groovy sends 1).
- JSONUnit placeholders to allow fields or values to be ignored or matched by type or pattern, for example:
- ${json-unit.ignore-element} ignore a field
- ${json-unit.any-boolean} match a field as any boolean
- ${json-unit.any-string} match a field as any string
- ${json-unit.any-number} match a field as any number
- ${json-unit.regex}pattern match a field by regex, e.g. ${json-unit.regex}[a-z]+
- ${json-unit.matches:name} match a field with a user-registered custom matcher (e.g. ${json-unit.matches:largerThan}); register the matcher by setting the mockserver.customJsonUnitMatchersClass configuration property to a class implementing CustomJsonUnitMatcherProvider
- matchType to control which fields get matched:
- JSON Schema - see JSON Schema documentation
- JsonPath - matches if at least one value is returned by the expression, see JsonPath documentation
- XML - supports:
- XMLUnit placeholders to allow fields or elements to be ignored or matched by type for example:
- ${xmlunit.ignore} ignore an element
- ${xmlunit.isNumber} match an element or attribute as a number
- XMLUnit placeholders to allow fields or elements to be ignored or matched by type for example:
- XML Schema - see XML Schema documentation
- XPath - matches if at least one value returned by expression, see XPath specification
- form fields (i.e. body parameters)
- binary
- GraphQL - whitespace-insensitive matching of GraphQL queries, mutations, and subscriptions
- negated matcher
GraphQL Body Matching
MockServer supports whitespace-insensitive matching of GraphQL over HTTP JSON request bodies. This allows expectations to match GraphQL queries, mutations, and subscriptions regardless of whitespace, formatting, or comment differences. The request body must be a JSON object with a query field (the standard GraphQL over HTTP format).
A GraphQL body matcher can specify:
- query (required) - the GraphQL query string. Whitespace is normalized before comparison, so { user { name } } matches {\n user {\n name\n }\n}
- operationName (optional) - match the operation name exactly, or using a regex pattern (e.g. Get.*)
- variablesSchema (optional) - a JSON Schema to validate the variables field
- selectionSetMatchType (optional) - controls how the selection set (fields) is compared. Values:
- NORMALISED_STRING (default) - whitespace-normalised string comparison of the full query
- AST_EXACT - matches operation type, name, and the exact set of top-level field names (ignores whitespace, nested fields, and argument differences)
- AST_SUBSET - matches when the expected top-level fields are a subset of the actual request's fields (useful when the request may contain additional fields)
- fields (optional) - explicit list of top-level field names to match in AST modes. If not specified, fields are extracted from the query string
Example - match a GraphQL query:
{
"httpRequest": {
"method": "POST",
"path": "/graphql",
"body": {
"type": "GRAPHQL",
"query": "{ user(id: 1) { name email } }"
}
},
"httpResponse": {
"statusCode": 200,
"body": "{\"data\": {\"user\": {\"name\": \"Alice\", \"email\": \"alice@example.com\"}}}"
}
}
Example - match with operation name and variables schema:
{
"httpRequest": {
"method": "POST",
"path": "/graphql",
"body": {
"type": "GRAPHQL",
"query": "query GetUser($id: ID!) { user(id: $id) { name email } }",
"operationName": "GetUser",
"variablesSchema": "{\"type\": \"object\", \"properties\": {\"id\": {\"type\": \"string\"}}, \"required\": [\"id\"]}"
}
},
"httpResponse": {
"statusCode": 200,
"body": "{\"data\": {\"user\": {\"name\": \"Alice\", \"email\": \"alice@example.com\"}}}"
}
}
Example - match a mutation:
{
"httpRequest": {
"method": "POST",
"path": "/graphql",
"body": {
"type": "GRAPHQL",
"query": "mutation CreateUser($input: CreateUserInput!) { createUser(input: $input) { id name } }",
"operationName": "CreateUser"
}
},
"httpResponse": {
"statusCode": 200,
"body": "{\"data\": {\"createUser\": {\"id\": \"123\", \"name\": \"Alice\"}}}"
}
}
Example - AST subset matching (match any query containing a "users" field):
{
"httpRequest": {
"method": "POST",
"path": "/graphql",
"body": {
"type": "GRAPHQL",
"query": "query { users { id } }",
"selectionSetMatchType": "AST_SUBSET",
"fields": ["users"]
}
},
"httpResponse": {
"statusCode": 200,
"body": "{\"data\": {\"users\": [{\"id\": \"1\", \"name\": \"Alice\"}]}}"
}
}
Example - AST exact matching (match a query with exactly these top-level fields):
{
"httpRequest": {
"method": "POST",
"path": "/graphql",
"body": {
"type": "GRAPHQL",
"query": "query GetDashboard { user profile settings }",
"selectionSetMatchType": "AST_EXACT"
}
},
"httpResponse": {
"statusCode": 200,
"body": "{\"data\": {\"user\": {}, \"profile\": {}, \"settings\": {}}}"
}
}
GraphQL Subscriptions over WebSocket
MockServer supports mocking GraphQL subscriptions over WebSocket using the graphql-transport-ws protocol (also accepts the legacy graphql-ws subprotocol). This allows testing GraphQL subscription clients without a real GraphQL server.
The protocol flow is:
- Client opens a WebSocket connection with Sec-WebSocket-Protocol: graphql-transport-ws
- Client sends connection_init, MockServer replies connection_ack
- Client sends subscribe with a GraphQL query; MockServer AST-matches the query against the configured filter
- On match: MockServer pushes a sequence of next messages (with optional delays), then complete
- On no match: MockServer sends an error message
- Client can send complete to cancel a subscription
- ping/pong keepalive is supported
To configure a GraphQL subscription mock, use an httpWebSocketResponse with:
- subprotocol - set to graphql-transport-ws (or graphql-ws)
- graphqlSubscriptionFilter - a GraphQL body filter specifying the subscription query to match. Supports the same selectionSetMatchType options as GraphQL body matching
- messages - the sequence of payloads to push as next events. Each message's text is wrapped in the protocol envelope {"id":"...","type":"next","payload":{"data":...}}
Example - mock a GraphQL subscription that pushes two events:
{
"httpRequest": {
"method": "GET",
"path": "/graphql"
},
"httpWebSocketResponse": {
"subprotocol": "graphql-transport-ws",
"graphqlSubscriptionFilter": {
"query": "subscription { userUpdated { id name } }",
"selectionSetMatchType": "AST_SUBSET"
},
"messages": [
{"text": "{\"id\": \"1\", \"name\": \"Alice\"}"},
{"text": "{\"id\": \"2\", \"name\": \"Bob\"}", "delay": {"timeUnit": "MILLISECONDS", "value": 500}}
]
}
}
Example - Java API:
mockServerClient.when(
request()
.withMethod("GET")
.withPath("/graphql")
).respondWithWebSocket(
webSocketResponse()
.withSubprotocol("graphql-transport-ws")
.withGraphqlSubscriptionFilter(
GraphQLBody.graphQL("subscription { userUpdated { id name } }")
.withSelectionSetMatchType(SelectionSetMatchType.AST_SUBSET)
)
.withMessage(webSocketMessage("{\"id\": \"1\", \"name\": \"Alice\"}"))
.withMessage(webSocketMessage("{\"id\": \"2\", \"name\": \"Bob\"}"))
);
When a client connects and sends:
{"type": "connection_init"}
// MockServer replies: {"type": "connection_ack"}
{"id": "1", "type": "subscribe", "payload": {"query": "subscription { userUpdated { id name } }"}}
// MockServer replies:
// {"id": "1", "type": "next", "payload": {"data": {"id": "1", "name": "Alice"}}}
// {"id": "1", "type": "next", "payload": {"data": {"id": "2", "name": "Bob"}}}
// {"id": "1", "type": "complete"}
Note: The legacy graphql-ws subprotocol (used by the older subscriptions-transport-ws library) is also accepted. Both use the same message format in MockServer's implementation.
The following code examples show how to match against different elements of a request using different matchers. For more examples see the code examples folder in the git repository.
For brevity static imports have not been included in the Java code examples so please add the following static imports if copying this code
import static org.mockserver.model.HttpRequest.request;
import static org.mockserver.model.HttpResponse.response;
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path"),
Times.once(),
TimeToLive.exactly(TimeUnit.SECONDS, 60L),
10
)
.respond(
response()
.withBody("some_response_body")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"path": "/some/path"
},
"httpResponse": {
"body": "some_response_body"
},
"times": {
"remainingTimes": 1,
"unlimited": false
},
"timeToLive": {
"timeUnit": "SECONDS",
"timeToLive": 60,
"unlimited": false
},
"priority" : 10
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import HttpRequest, HttpResponse
client = MockServerClient("localhost", 1080)
client.when(
HttpRequest.request("/some/path")
).respond(
HttpResponse.response(body="some_response_body")
)
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.when(
MockServer::HttpRequest.new(path: '/some/path')
).respond(
MockServer::HttpResponse.new(body: 'some_response_body')
)
import mockserver "github.com/mock-server/mockserver-monorepo/mockserver-client-go"
client := mockserver.New("localhost", 1080)
client.When(
mockserver.Request().Path("/some/path"),
).Respond(
mockserver.Response().Body("some_response_body"),
)
using MockServer.Client;
using MockServer.Client.Models;
using var client = new MockServerClient("localhost", 1080);
client.When(
HttpRequest.Request().WithPath("/some/path")
).Respond(
HttpResponse.Response().WithBody("some_response_body")
);
use mockserver_client::{ClientBuilder, HttpRequest, HttpResponse};
let client = ClientBuilder::new("localhost", 1080).build().unwrap();
client.when(HttpRequest::new().path("/some/path"))
.respond(HttpResponse::new().body("some_response_body"))
.unwrap();
use MockServer\MockServerClient;
use MockServer\HttpRequest;
use MockServer\HttpResponse;
use MockServer\Times;
$client = new MockServerClient('localhost', 1080);
$client->when(
HttpRequest::request()
->path('/some/path'), Times::exactly(1)
)->respond(
HttpResponse::response()
->body('some_response_body')
);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest" : {
"path" : "/some/path"
},
"httpResponse" : {
"body" : "some_response_body"
},
"times" : {
"remainingTimes" : 1,
"unlimited" : false
},
"timeToLive" : {
"timeUnit" : "SECONDS",
"timeToLive" : 60,
"unlimited" : false
},
"priority" : 10
}'
See REST API for full JSON specification
A negative priority can be used to specify a default expectation or response.
new MockServerClient("localhost", 1080)
.when(
request(),
Times.once(),
TimeToLive.exactly(TimeUnit.SECONDS, 60L),
-10
)
.respond(
response()
.withBody("some_default_response_body")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {},
"httpResponse": {
"body": "some_default_response_body"
},
"times": {
"remainingTimes": 1,
"unlimited": false
},
"timeToLive": {
"timeUnit": "SECONDS",
"timeToLive": 60,
"unlimited": false
},
"priority" : -10
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import HttpRequest, HttpResponse
client = MockServerClient("localhost", 1080)
client.when(
HttpRequest.request()
).respond(
HttpResponse.response(body="some_default_response_body")
)
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.when(
MockServer::HttpRequest.new
).respond(
MockServer::HttpResponse.new(body: 'some_default_response_body')
)
import mockserver "github.com/mock-server/mockserver-monorepo/mockserver-client-go"
client := mockserver.New("localhost", 1080)
client.When(
mockserver.Request(),
).Respond(
mockserver.Response().Body("some_default_response_body"),
)
using MockServer.Client;
using MockServer.Client.Models;
using var client = new MockServerClient("localhost", 1080);
client.When(
HttpRequest.Request()
).Respond(
HttpResponse.Response().WithBody("some_default_response_body")
);
use mockserver_client::{ClientBuilder, HttpRequest, HttpResponse};
let client = ClientBuilder::new("localhost", 1080).build().unwrap();
client.when(HttpRequest::new())
.respond(HttpResponse::new().body("some_default_response_body"))
.unwrap();
use MockServer\MockServerClient;
use MockServer\HttpRequest;
use MockServer\HttpResponse;
use MockServer\Times;
$client = new MockServerClient('localhost', 1080);
$client->when(
HttpRequest::request(), Times::exactly(1)
)->respond(
HttpResponse::response()
->body('some_default_response_body')
);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest" : {},
"httpResponse" : {
"body" : "some_default_response_body"
},
"times" : {
"remainingTimes" : 1,
"unlimited" : false
},
"timeToLive" : {
"timeUnit" : "SECONDS",
"timeToLive" : 60,
"unlimited" : false
},
"priority" : -10
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path")
)
.respond(
response()
.withBody("some_response_body")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"path": "/some/path"
},
"httpResponse": {
"body": "some_response_body"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import HttpRequest, HttpResponse
client = MockServerClient("localhost", 1080)
client.when(
HttpRequest.request("/some/path")
).respond(
HttpResponse.response(body="some_response_body")
)
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.when(
MockServer::HttpRequest.new(path: '/some/path')
).respond(
MockServer::HttpResponse.new(body: 'some_response_body')
)
import mockserver "github.com/mock-server/mockserver-monorepo/mockserver-client-go"
client := mockserver.New("localhost", 1080)
client.When(
mockserver.Request().Path("/some/path"),
).Respond(
mockserver.Response().Body("some_response_body"),
)
using MockServer.Client;
using MockServer.Client.Models;
using var client = new MockServerClient("localhost", 1080);
client.When(
HttpRequest.Request().WithPath("/some/path")
).Respond(
HttpResponse.Response().WithBody("some_response_body")
);
use mockserver_client::{ClientBuilder, HttpRequest, HttpResponse};
let client = ClientBuilder::new("localhost", 1080).build().unwrap();
client.when(HttpRequest::new().path("/some/path"))
.respond(HttpResponse::new().body("some_response_body"))
.unwrap();
use MockServer\MockServerClient;
use MockServer\HttpRequest;
use MockServer\HttpResponse;
$client = new MockServerClient('localhost', 1080);
$client->when(
HttpRequest::request()
->path('/some/path')
)->respond(
HttpResponse::response()
->body('some_response_body')
);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest" : {
"path" : "/some/path"
},
"httpResponse" : {
"body" : "some_response_body"
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path"),
Times.exactly(2)
)
.respond(
response()
.withBody("some_response_body")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"path": "/some/path"
},
"httpResponse": {
"body": "some_response_body"
},
"times": {
"remainingTimes": 2
},
"timeToLive": {
"unlimited": true
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import HttpRequest, HttpResponse
client = MockServerClient("localhost", 1080)
client.when(
HttpRequest.request("/some/path")
).respond(
HttpResponse.response(body="some_response_body")
)
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.when(
MockServer::HttpRequest.new(path: '/some/path')
).respond(
MockServer::HttpResponse.new(body: 'some_response_body')
)
import mockserver "github.com/mock-server/mockserver-monorepo/mockserver-client-go"
client := mockserver.New("localhost", 1080)
client.When(
mockserver.Request().Path("/some/path"),
).Respond(
mockserver.Response().Body("some_response_body"),
)
using MockServer.Client;
using MockServer.Client.Models;
using var client = new MockServerClient("localhost", 1080);
client.When(
HttpRequest.Request().WithPath("/some/path")
).Respond(
HttpResponse.Response().WithBody("some_response_body")
);
use mockserver_client::{ClientBuilder, HttpRequest, HttpResponse};
let client = ClientBuilder::new("localhost", 1080).build().unwrap();
client.when(HttpRequest::new().path("/some/path"))
.respond(HttpResponse::new().body("some_response_body"))
.unwrap();
use MockServer\MockServerClient;
use MockServer\HttpRequest;
use MockServer\HttpResponse;
use MockServer\Times;
$client = new MockServerClient('localhost', 1080);
$client->when(
HttpRequest::request()
->path('/some/path'), Times::exactly(2)
)->respond(
HttpResponse::response()
->body('some_response_body')
);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest" : {
"path" : "/some/path"
},
"httpResponse" : {
"body" : "some_response_body"
},
"times" : {
"remainingTimes" : 2,
"unlimited" : false
},
"timeToLive" : {
"unlimited" : true
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path"),
Times.once(),
TimeToLive.exactly(TimeUnit.SECONDS, 60L)
)
.respond(
response()
.withBody("some_response_body")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"path": "/some/path"
},
"httpResponse": {
"body": "some_response_body"
},
"times": {
"remainingTimes": 1,
"unlimited": false
},
"timeToLive": {
"timeUnit": "SECONDS",
"timeToLive": 60,
"unlimited": false
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import HttpRequest, HttpResponse
client = MockServerClient("localhost", 1080)
client.when(
HttpRequest.request("/some/path")
).respond(
HttpResponse.response(body="some_response_body")
)
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.when(
MockServer::HttpRequest.new(path: '/some/path')
).respond(
MockServer::HttpResponse.new(body: 'some_response_body')
)
import mockserver "github.com/mock-server/mockserver-monorepo/mockserver-client-go"
client := mockserver.New("localhost", 1080)
client.When(
mockserver.Request().Path("/some/path"),
).Respond(
mockserver.Response().Body("some_response_body"),
)
using MockServer.Client;
using MockServer.Client.Models;
using var client = new MockServerClient("localhost", 1080);
client.When(
HttpRequest.Request().WithPath("/some/path")
).Respond(
HttpResponse.Response().WithBody("some_response_body")
);
use mockserver_client::{ClientBuilder, HttpRequest, HttpResponse};
let client = ClientBuilder::new("localhost", 1080).build().unwrap();
client.when(HttpRequest::new().path("/some/path"))
.respond(HttpResponse::new().body("some_response_body"))
.unwrap();
use MockServer\MockServerClient;
use MockServer\HttpRequest;
use MockServer\HttpResponse;
use MockServer\Times;
$client = new MockServerClient('localhost', 1080);
$client->when(
HttpRequest::request()
->path('/some/path'), Times::exactly(1)
)->respond(
HttpResponse::response()
->body('some_response_body')
);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest" : {
"path" : "/some/path"
},
"httpResponse" : {
"body" : "some_response_body"
},
"times" : {
"remainingTimes" : 1,
"unlimited" : false
},
"timeToLive" : {
"timeUnit" : "SECONDS",
"timeToLive" : 60,
"unlimited" : false
}
}'
See REST API for full JSON specification
For details of the full regex syntax supported please see the JDK documentation.
new MockServerClient("localhost", 1080)
.when(
request()
// matches any requests those path starts with "/some"
.withPath("/some.*")
)
.respond(
response()
.withBody("some_response_body")
);
var mockServerClient = require('mockserver-client').mockServerClient;
// matches any requests those path starts with "/some"
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"path": "/some.*"
},
"httpResponse": {
"body": "some_response_body"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import HttpRequest, HttpResponse
client = MockServerClient("localhost", 1080)
client.when(
HttpRequest.request("/some.*")
).respond(
HttpResponse.response(body="some_response_body")
)
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.when(
MockServer::HttpRequest.new(path: '/some.*')
).respond(
MockServer::HttpResponse.new(body: 'some_response_body')
)
import mockserver "github.com/mock-server/mockserver-monorepo/mockserver-client-go"
client := mockserver.New("localhost", 1080)
client.When(
mockserver.Request().Path("/some.*"),
).Respond(
mockserver.Response().Body("some_response_body"),
)
using MockServer.Client;
using MockServer.Client.Models;
using var client = new MockServerClient("localhost", 1080);
client.When(
HttpRequest.Request().WithPath("/some.*")
).Respond(
HttpResponse.Response().WithBody("some_response_body")
);
use mockserver_client::{ClientBuilder, HttpRequest, HttpResponse};
let client = ClientBuilder::new("localhost", 1080).build().unwrap();
client.when(HttpRequest::new().path("/some.*"))
.respond(HttpResponse::new().body("some_response_body"))
.unwrap();
use MockServer\MockServerClient;
use MockServer\HttpRequest;
use MockServer\HttpResponse;
$client = new MockServerClient('localhost', 1080);
$client->when(
HttpRequest::request()
->path('/some.*')
)->respond(
HttpResponse::response()
->body('some_response_body')
);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest" : {
"path" : "/some.*"
},
"httpResponse" : {
"body" : "some_response_body"
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.when(
request()
// matches any requests those path does NOT start with "/some"
.withPath(not("/some.*"))
)
.respond(
response()
.withBody("some_response_body")
);
var mockServerClient = require('mockserver-client').mockServerClient;
// matches any requests those path does NOT start with "/some"
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"path": "!/some.*"
},
"httpResponse": {
"body": "some_response_body"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import HttpRequest, HttpResponse
client = MockServerClient("localhost", 1080)
client.when(
HttpRequest.request("!/some.*")
).respond(
HttpResponse.response(body="some_response_body")
)
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.when(
MockServer::HttpRequest.new(path: '!/some.*')
).respond(
MockServer::HttpResponse.new(body: 'some_response_body')
)
import mockserver "github.com/mock-server/mockserver-monorepo/mockserver-client-go"
client := mockserver.New("localhost", 1080)
client.When(
mockserver.Request().Path("!/some.*"),
).Respond(
mockserver.Response().Body("some_response_body"),
)
using MockServer.Client;
using MockServer.Client.Models;
using var client = new MockServerClient("localhost", 1080);
client.When(
HttpRequest.Request().WithPath("!/some.*")
).Respond(
HttpResponse.Response().WithBody("some_response_body")
);
use mockserver_client::{ClientBuilder, HttpRequest, HttpResponse};
let client = ClientBuilder::new("localhost", 1080).build().unwrap();
client.when(HttpRequest::new().path("!/some.*"))
.respond(HttpResponse::new().body("some_response_body"))
.unwrap();
use MockServer\MockServerClient;
use MockServer\HttpRequest;
use MockServer\HttpResponse;
$client = new MockServerClient('localhost', 1080);
$client->when(
HttpRequest::request()
->path('!/some.*')
)->respond(
HttpResponse::response()
->body('some_response_body')
);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest" : {
"path" : "!/some.*"
},
"httpResponse" : {
"body" : "some_response_body"
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path")
.withPathParameters(
param("cartId", "055CA455-1DF7-45BB-8535-4F83E7266092")
)
.withQueryStringParameters(
param("type", "[A-Z0-9\\-]+")
)
)
.respond(
response()
.withBody("some_response_body")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"path": "/some/path/{cartId}",
"pathParameters": {
"cartId": ["055CA455-1DF7-45BB-8535-4F83E7266092"]
},
"queryStringParameters": {
"type": ["[A-Z0-9\\-]+"]
}
},
"httpResponse": {
"body": "some_response_body"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest": {
"path": "/some/path/{cartId}",
"pathParameters": {
"cartId": ["055CA455-1DF7-45BB-8535-4F83E7266092"]
},
"queryStringParameters": {
"type": ["[A-Z0-9\\-]+"]
}
},
"httpResponse": {
"body": "some_response_body"
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest": {
"path": "/some/path/{cartId}",
"pathParameters": {
"cartId": ["055CA455-1DF7-45BB-8535-4F83E7266092"]
},
"queryStringParameters": {
"type": ["[A-Z0-9\\-]+"]
}
},
"httpResponse": {
"body": "some_response_body"
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest": {
"path": "/some/path/{cartId}",
"pathParameters": {
"cartId": ["055CA455-1DF7-45BB-8535-4F83E7266092"]
},
"queryStringParameters": {
"type": ["[A-Z0-9\\-]+"]
}
},
"httpResponse": {
"body": "some_response_body"
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"": {
""path"": ""/some/path/{cartId}"",
""pathParameters"": {
""cartId"": [""055CA455-1DF7-45BB-8535-4F83E7266092""]
},
""queryStringParameters"": {
""type"": [""[A-Z0-9\\-]+""]
}
},
""httpResponse"": {
""body"": ""some_response_body""
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest": {
"path": "/some/path/{cartId}",
"pathParameters": {
"cartId": ["055CA455-1DF7-45BB-8535-4F83E7266092"]
},
"queryStringParameters": {
"type": ["[A-Z0-9\\-]+"]
}
},
"httpResponse": {
"body": "some_response_body"
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest": {
"path": "/some/path/{cartId}",
"pathParameters": {
"cartId": ["055CA455-1DF7-45BB-8535-4F83E7266092"]
},
"queryStringParameters": {
"type": ["[A-Z0-9\\-]+"]
}
},
"httpResponse": {
"body": "some_response_body"
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"path": "/some/path/{cartId}",
"pathParameters": {
"cartId": ["055CA455-1DF7-45BB-8535-4F83E7266092"]
},
"queryStringParameters": {
"type": ["[A-Z0-9\\-]+"]
}
},
"httpResponse": {
"body": "some_response_body"
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path/{cartId}")
.withPathParameters(
param("cartId", "[A-Z0-9\\-]+")
)
)
.respond(
response()
.withBody("some_response_body")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"path": "/some/path/{cartId}",
"pathParameters": {
"cartId": ["[A-Z0-9\\-]+"]
}
},
"httpResponse": {
"body": "some_response_body"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest": {
"path": "/some/path/{cartId}",
"pathParameters": {
"cartId": ["[A-Z0-9\\-]+"]
}
},
"httpResponse": {
"body": "some_response_body"
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest": {
"path": "/some/path/{cartId}",
"pathParameters": {
"cartId": ["[A-Z0-9\\-]+"]
}
},
"httpResponse": {
"body": "some_response_body"
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest": {
"path": "/some/path/{cartId}",
"pathParameters": {
"cartId": ["[A-Z0-9\\-]+"]
}
},
"httpResponse": {
"body": "some_response_body"
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"": {
""path"": ""/some/path/{cartId}"",
""pathParameters"": {
""cartId"": [""[A-Z0-9\\-]+""]
}
},
""httpResponse"": {
""body"": ""some_response_body""
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest": {
"path": "/some/path/{cartId}",
"pathParameters": {
"cartId": ["[A-Z0-9\\-]+"]
}
},
"httpResponse": {
"body": "some_response_body"
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest": {
"path": "/some/path/{cartId}",
"pathParameters": {
"cartId": ["[A-Z0-9\\-]+"]
}
},
"httpResponse": {
"body": "some_response_body"
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"path": "/some/path/{cartId}",
"pathParameters": {
"cartId": ["[A-Z0-9\\-]+"]
}
},
"httpResponse": {
"body": "some_response_body"
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path/{cartId}/{maxItemCount}")
.withPathParameters(
schemaParam("cartId", "{\"type\": \"string\", \"pattern\": \"^[A-Z0-9\\-]+$\"}"),
param(string("maxItemCount"), schemaString("{ \"type\": \"integer\" }"))
)
)
.respond(
response()
.withBody("some_response_body")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"path": "/some/path/{cartId}/{maxItemCount}",
"pathParameters": {
"cartId": [{
"schema": {
"type": "string",
"pattern": "^[A-Z0-9-]+$"
}
}],
"maxItemCount": [{
"schema": {
"type": "integer"
}
}]
}
},
"httpResponse": {
"body": "some_response_body"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest": {
"path": "/some/path/{cartId}/{maxItemCount}",
"pathParameters": {
"cartId": [{
"schema": {
"type": "string",
"pattern": "^[A-Z0-9-]+$"
}
}],
"maxItemCount": [{
"schema": {
"type": "integer"
}
}]
}
},
"httpResponse": {
"body": "some_response_body"
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest": {
"path": "/some/path/{cartId}/{maxItemCount}",
"pathParameters": {
"cartId": [{
"schema": {
"type": "string",
"pattern": "^[A-Z0-9-]+$"
}
}],
"maxItemCount": [{
"schema": {
"type": "integer"
}
}]
}
},
"httpResponse": {
"body": "some_response_body"
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest": {
"path": "/some/path/{cartId}/{maxItemCount}",
"pathParameters": {
"cartId": [{
"schema": {
"type": "string",
"pattern": "^[A-Z0-9-]+$"
}
}],
"maxItemCount": [{
"schema": {
"type": "integer"
}
}]
}
},
"httpResponse": {
"body": "some_response_body"
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"": {
""path"": ""/some/path/{cartId}/{maxItemCount}"",
""pathParameters"": {
""cartId"": [{
""schema"": {
""type"": ""string"",
""pattern"": ""^[A-Z0-9-]+$""
}
}],
""maxItemCount"": [{
""schema"": {
""type"": ""integer""
}
}]
}
},
""httpResponse"": {
""body"": ""some_response_body""
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest": {
"path": "/some/path/{cartId}/{maxItemCount}",
"pathParameters": {
"cartId": [{
"schema": {
"type": "string",
"pattern": "^[A-Z0-9-]+$"
}
}],
"maxItemCount": [{
"schema": {
"type": "integer"
}
}]
}
},
"httpResponse": {
"body": "some_response_body"
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest": {
"path": "/some/path/{cartId}/{maxItemCount}",
"pathParameters": {
"cartId": [{
"schema": {
"type": "string",
"pattern": "^[A-Z0-9-]+$"
}
}],
"maxItemCount": [{
"schema": {
"type": "integer"
}
}]
}
},
"httpResponse": {
"body": "some_response_body"
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"path": "/some/path/{cartId}/{maxItemCount}",
"pathParameters": {
"cartId": [{
"schema": {
"type": "string",
"pattern": "^[A-Z0-9-]+$"
}
}],
"maxItemCount": [{
"schema": {
"type": "integer"
}
}]
}
},
"httpResponse": {
"body": "some_response_body"
}
}'
See REST API for full JSON specification
To match a path segment containing multiple values separated by delimiters (e.g. /2024-01-15/report), use a single path parameter with a regex value to match the entire compound segment.
new MockServerClient("localhost", 1080)
.when(
request()
// matches paths like /2024-01-15/report or /val1-val2-val3/report
.withPath("/{compound}/report")
.withPathParameters(
param("compound", "[^/]+-[^/]+-[^/]+")
)
)
.respond(
response()
.withBody("some_response_body")
);
var mockServerClient = require('mockserver-client').mockServerClient;
// matches paths like /2024-01-15/report or /val1-val2-val3/report
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"path": "/{compound}/report",
"pathParameters": {
"compound": ["[^/]+-[^/]+-[^/]+"]
}
},
"httpResponse": {
"body": "some_response_body"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest": {
"path": "/{compound}/report",
"pathParameters": {
"compound": ["[^/]+-[^/]+-[^/]+"]
}
},
"httpResponse": {
"body": "some_response_body"
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest": {
"path": "/{compound}/report",
"pathParameters": {
"compound": ["[^/]+-[^/]+-[^/]+"]
}
},
"httpResponse": {
"body": "some_response_body"
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest": {
"path": "/{compound}/report",
"pathParameters": {
"compound": ["[^/]+-[^/]+-[^/]+"]
}
},
"httpResponse": {
"body": "some_response_body"
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"": {
""path"": ""/{compound}/report"",
""pathParameters"": {
""compound"": [""[^/]+-[^/]+-[^/]+""]
}
},
""httpResponse"": {
""body"": ""some_response_body""
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest": {
"path": "/{compound}/report",
"pathParameters": {
"compound": ["[^/]+-[^/]+-[^/]+"]
}
},
"httpResponse": {
"body": "some_response_body"
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest": {
"path": "/{compound}/report",
"pathParameters": {
"compound": ["[^/]+-[^/]+-[^/]+"]
}
},
"httpResponse": {
"body": "some_response_body"
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"path": "/{compound}/report",
"pathParameters": {
"compound": ["[^/]+-[^/]+-[^/]+"]
}
},
"httpResponse": {
"body": "some_response_body"
}
}'
See REST API for full JSON specification
For details of the full regex syntax supported please see the JDK documentation.
new MockServerClient("localhost", 1080)
.when(
request()
// matches any requests that does NOT have a "GET" method
.withMethod(not("P.*{2,3}"))
)
.respond(
response()
.withBody("some_response_body")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"method": "P.*{2,3}"
},
"httpResponse": {
"body": "some_response_body"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import HttpRequest, HttpResponse
client = MockServerClient("localhost", 1080)
client.when(
HttpRequest.request()
.with_method("P.*{2,3}")
).respond(
HttpResponse.response(body="some_response_body")
)
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.when(
MockServer::HttpRequest.new(method: 'P.*{2,3}')
).respond(
MockServer::HttpResponse.new(body: 'some_response_body')
)
import mockserver "github.com/mock-server/mockserver-monorepo/mockserver-client-go"
client := mockserver.New("localhost", 1080)
client.When(
mockserver.Request().Method("P.*{2,3}"),
).Respond(
mockserver.Response().Body("some_response_body"),
)
using MockServer.Client;
using MockServer.Client.Models;
using var client = new MockServerClient("localhost", 1080);
client.When(
HttpRequest.Request().WithMethod("P.*{2,3}")
).Respond(
HttpResponse.Response().WithBody("some_response_body")
);
use mockserver_client::{ClientBuilder, HttpRequest, HttpResponse};
let client = ClientBuilder::new("localhost", 1080).build().unwrap();
client.when(HttpRequest::new().method("P.*{2,3}"))
.respond(HttpResponse::new().body("some_response_body"))
.unwrap();
use MockServer\MockServerClient;
use MockServer\HttpRequest;
use MockServer\HttpResponse;
$client = new MockServerClient('localhost', 1080);
$client->when(
HttpRequest::request()
->method('P.*{2,3}')
)->respond(
HttpResponse::response()
->body('some_response_body')
);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest" : {
"method" : "P.*{2,3}"
},
"httpResponse" : {
"body" : "some_response_body"
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.when(
request()
// matches any requests that does NOT have a "GET" method
.withMethod(not("GET"))
)
.respond(
response()
.withBody("some_response_body")
);
var mockServerClient = require('mockserver-client').mockServerClient;
// matches any requests that does NOT have a "GET" method
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"method": "!GET"
},
"httpResponse": {
"body": "some_response_body"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import HttpRequest, HttpResponse
client = MockServerClient("localhost", 1080)
client.when(
HttpRequest.request()
.with_method("!GET")
).respond(
HttpResponse.response(body="some_response_body")
)
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.when(
MockServer::HttpRequest.new(method: '!GET')
).respond(
MockServer::HttpResponse.new(body: 'some_response_body')
)
import mockserver "github.com/mock-server/mockserver-monorepo/mockserver-client-go"
client := mockserver.New("localhost", 1080)
client.When(
mockserver.Request().Method("!GET"),
).Respond(
mockserver.Response().Body("some_response_body"),
)
using MockServer.Client;
using MockServer.Client.Models;
using var client = new MockServerClient("localhost", 1080);
client.When(
HttpRequest.Request().WithMethod("!GET")
).Respond(
HttpResponse.Response().WithBody("some_response_body")
);
use mockserver_client::{ClientBuilder, HttpRequest, HttpResponse};
let client = ClientBuilder::new("localhost", 1080).build().unwrap();
client.when(HttpRequest::new().method("!GET"))
.respond(HttpResponse::new().body("some_response_body"))
.unwrap();
use MockServer\MockServerClient;
use MockServer\HttpRequest;
use MockServer\HttpResponse;
$client = new MockServerClient('localhost', 1080);
$client->when(
HttpRequest::request()
->method('!GET')
)->respond(
HttpResponse::response()
->body('some_response_body')
);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest" : {
"method" : "!GET"
},
"httpResponse" : {
"body" : "some_response_body"
}
}'
See REST API for full JSON specification
For details of the full regex syntax supported please see the JDK documentation.
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path")
.withQueryStringParameters(
param("[A-z]{0,10}", "055CA455-1DF7-45BB-8535-4F83E7266092")
)
)
.respond(
response()
.withBody("some_response_body")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"path": "/some/path",
"queryStringParameters": {
"[A-z]{0,10}": ["055CA455-1DF7-45BB-8535-4F83E7266092"]
}
},
"httpResponse": {
"body": "some_response_body"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import HttpRequest, HttpResponse
client = MockServerClient("localhost", 1080)
client.when(
HttpRequest.request("/some/path")
.with_query_param("[A-z]{0,10}", "055CA455-1DF7-45BB-8535-4F83E7266092")
).respond(
HttpResponse.response(body="some_response_body")
)
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.when(
MockServer::HttpRequest.new(path: '/some/path')
).respond(
MockServer::HttpResponse.new(body: 'some_response_body')
)
import mockserver "github.com/mock-server/mockserver-monorepo/mockserver-client-go"
client := mockserver.New("localhost", 1080)
client.When(
mockserver.Request().Path("/some/path").QueryStringParameter("[A-z]{0,10}", "055CA455-1DF7-45BB-8535-4F83E7266092"),
).Respond(
mockserver.Response().Body("some_response_body"),
)
using MockServer.Client;
using MockServer.Client.Models;
using var client = new MockServerClient("localhost", 1080);
client.When(
HttpRequest.Request().WithPath("/some/path").WithQueryStringParameter("[A-z]{0,10}", "055CA455-1DF7-45BB-8535-4F83E7266092")
).Respond(
HttpResponse.Response().WithBody("some_response_body")
);
use mockserver_client::{ClientBuilder, HttpRequest, HttpResponse};
let client = ClientBuilder::new("localhost", 1080).build().unwrap();
client.when(HttpRequest::new().path("/some/path").query_param("[A-z]{0,10}", "055CA455-1DF7-45BB-8535-4F83E7266092"))
.respond(HttpResponse::new().body("some_response_body"))
.unwrap();
use MockServer\MockServerClient;
use MockServer\HttpRequest;
use MockServer\HttpResponse;
$client = new MockServerClient('localhost', 1080);
$client->when(
HttpRequest::request()
->path('/some/path')
->queryStringParameter('[A-z]{0,10}', '055CA455-1DF7-45BB-8535-4F83E7266092')
)->respond(
HttpResponse::response()
->body('some_response_body')
);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"path": "/some/path",
"queryStringParameters": {
"[A-z]{0,10}": ["055CA455-1DF7-45BB-8535-4F83E7266092"]
}
},
"httpResponse": {
"body": "some_response_body"
}
}'
See REST API for full JSON specification
For details of the full regex syntax supported please see the JDK documentation.
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path")
.withQueryStringParameters(
param("cartId", "[A-Z0-9\\-]+")
)
)
.respond(
response()
.withBody("some_response_body")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"path": "/some/path",
"queryStringParameters": {
"cartId": ["[A-Z0-9\\-]+"]
}
},
"httpResponse": {
"body": "some_response_body"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import HttpRequest, HttpResponse
client = MockServerClient("localhost", 1080)
client.when(
HttpRequest.request("/some/path")
.with_query_param("cartId", "[A-Z0-9\-]+")
).respond(
HttpResponse.response(body="some_response_body")
)
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.when(
MockServer::HttpRequest.new(path: '/some/path')
).respond(
MockServer::HttpResponse.new(body: 'some_response_body')
)
import mockserver "github.com/mock-server/mockserver-monorepo/mockserver-client-go"
client := mockserver.New("localhost", 1080)
client.When(
mockserver.Request().Path("/some/path").QueryStringParameter("cartId", "[A-Z0-9\-]+"),
).Respond(
mockserver.Response().Body("some_response_body"),
)
using MockServer.Client;
using MockServer.Client.Models;
using var client = new MockServerClient("localhost", 1080);
client.When(
HttpRequest.Request().WithPath("/some/path").WithQueryStringParameter("cartId", "[A-Z0-9\-]+")
).Respond(
HttpResponse.Response().WithBody("some_response_body")
);
use mockserver_client::{ClientBuilder, HttpRequest, HttpResponse};
let client = ClientBuilder::new("localhost", 1080).build().unwrap();
client.when(HttpRequest::new().path("/some/path").query_param("cartId", "[A-Z0-9\-]+"))
.respond(HttpResponse::new().body("some_response_body"))
.unwrap();
use MockServer\MockServerClient;
use MockServer\HttpRequest;
use MockServer\HttpResponse;
$client = new MockServerClient('localhost', 1080);
$client->when(
HttpRequest::request()
->path('/some/path')
->queryStringParameter('cartId', '[A-Z0-9\-]+')
)->respond(
HttpResponse::response()
->body('some_response_body')
);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"path": "/some/path",
"queryStringParameters": {
"cartId": ["[A-Z0-9\\-]+"]
}
},
"httpResponse": {
"body": "some_response_body"
}
}'
See REST API for full JSON specification
This example shows the two ways a JSON Schema can be specified to match a query parameter value, either using the schemaParam static builder for parameters or the schemaString for static builder strings.
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path")
.withQueryStringParameters(
schemaParam("cartId", "{\"type\": \"string\", \"pattern\": \"^[A-Z0-9\\-]+$\"}"),
param(string("maxItemCount"), schemaString("{ \"type\": \"integer\" }"))
)
)
.respond(
response()
.withBody("some_response_body")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"path": "/some/path",
"queryStringParameters": {
"cartId": [{
"schema": {
"type": "string",
"pattern": "^[A-Z0-9-]+$"
}
}],
"maxItemCount": [{
"schema": {
"type": "integer"
}
}]
}
},
"httpResponse": {
"body": "some_response_body"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest": {
"path": "/some/path",
"queryStringParameters": {
"cartId": [{
"schema": {
"type": "string",
"pattern": "^[A-Z0-9-]+$"
}
}],
"maxItemCount": [{
"schema": {
"type": "integer"
}
}]
}
},
"httpResponse": {
"body": "some_response_body"
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest": {
"path": "/some/path",
"queryStringParameters": {
"cartId": [{
"schema": {
"type": "string",
"pattern": "^[A-Z0-9-]+$"
}
}],
"maxItemCount": [{
"schema": {
"type": "integer"
}
}]
}
},
"httpResponse": {
"body": "some_response_body"
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest": {
"path": "/some/path",
"queryStringParameters": {
"cartId": [{
"schema": {
"type": "string",
"pattern": "^[A-Z0-9-]+$"
}
}],
"maxItemCount": [{
"schema": {
"type": "integer"
}
}]
}
},
"httpResponse": {
"body": "some_response_body"
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"": {
""path"": ""/some/path"",
""queryStringParameters"": {
""cartId"": [{
""schema"": {
""type"": ""string"",
""pattern"": ""^[A-Z0-9-]+$""
}
}],
""maxItemCount"": [{
""schema"": {
""type"": ""integer""
}
}]
}
},
""httpResponse"": {
""body"": ""some_response_body""
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest": {
"path": "/some/path",
"queryStringParameters": {
"cartId": [{
"schema": {
"type": "string",
"pattern": "^[A-Z0-9-]+$"
}
}],
"maxItemCount": [{
"schema": {
"type": "integer"
}
}]
}
},
"httpResponse": {
"body": "some_response_body"
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest": {
"path": "/some/path",
"queryStringParameters": {
"cartId": [{
"schema": {
"type": "string",
"pattern": "^[A-Z0-9-]+$"
}
}],
"maxItemCount": [{
"schema": {
"type": "integer"
}
}]
}
},
"httpResponse": {
"body": "some_response_body"
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"path": "/some/path",
"queryStringParameters": {
"cartId": [{
"schema": {
"type": "string",
"pattern": "^[A-Z0-9-]+$"
}
}],
"maxItemCount": [{
"schema": {
"type": "integer"
}
}]
}
},
"httpResponse": {
"body": "some_response_body"
}
}'
See REST API for full JSON specification
This example shows the two ways to specify an optional query parameter value, either using the optionalParam static builder for parameters or the optionalString for static builder strings.
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path")
.withQueryStringParameters(
optionalParam("cartId", "[A-Z0-9\\-]+"),
param(optionalString("maxItemCount"), schemaString("{ \"type\": \"integer\" }")),
schemaParam(optionalString("userId"), "{ \"type\": \"string\", \"format\": \"uuid\" }")
)
)
.respond(
response()
.withBody("some_response_body")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"path": "/some/path",
"queryStringParameters": {
"?cartId": ["[A-Z0-9\\-]+"],
"?maxItemCount": [{
"schema": {
"type": "integer"
}
}],
"?userId": [{
"schema": {
"type": "string",
"format": "uuid"
}
}]
}
},
"httpResponse": {
"body": "some_response_body"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest": {
"path": "/some/path",
"queryStringParameters": {
"?cartId": ["[A-Z0-9\\-]+"],
"?maxItemCount": [{
"schema": {
"type": "integer"
}
}],
"?userId": [{
"schema": {
"type": "string",
"format": "uuid"
}
}]
}
},
"httpResponse": {
"body": "some_response_body"
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest": {
"path": "/some/path",
"queryStringParameters": {
"?cartId": ["[A-Z0-9\\-]+"],
"?maxItemCount": [{
"schema": {
"type": "integer"
}
}],
"?userId": [{
"schema": {
"type": "string",
"format": "uuid"
}
}]
}
},
"httpResponse": {
"body": "some_response_body"
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest": {
"path": "/some/path",
"queryStringParameters": {
"?cartId": ["[A-Z0-9\\-]+"],
"?maxItemCount": [{
"schema": {
"type": "integer"
}
}],
"?userId": [{
"schema": {
"type": "string",
"format": "uuid"
}
}]
}
},
"httpResponse": {
"body": "some_response_body"
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"": {
""path"": ""/some/path"",
""queryStringParameters"": {
""?cartId"": [""[A-Z0-9\\-]+""],
""?maxItemCount"": [{
""schema"": {
""type"": ""integer""
}
}],
""?userId"": [{
""schema"": {
""type"": ""string"",
""format"": ""uuid""
}
}]
}
},
""httpResponse"": {
""body"": ""some_response_body""
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest": {
"path": "/some/path",
"queryStringParameters": {
"?cartId": ["[A-Z0-9\\-]+"],
"?maxItemCount": [{
"schema": {
"type": "integer"
}
}],
"?userId": [{
"schema": {
"type": "string",
"format": "uuid"
}
}]
}
},
"httpResponse": {
"body": "some_response_body"
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest": {
"path": "/some/path",
"queryStringParameters": {
"?cartId": ["[A-Z0-9\\-]+"],
"?maxItemCount": [{
"schema": {
"type": "integer"
}
}],
"?userId": [{
"schema": {
"type": "string",
"format": "uuid"
}
}]
}
},
"httpResponse": {
"body": "some_response_body"
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"path": "/some/path",
"queryStringParameters": {
"?cartId": ["[A-Z0-9\\-]+"],
"?maxItemCount": [{
"schema": {
"type": "integer"
}
}],
"?userId": [{
"schema": {
"type": "string",
"format": "uuid"
}
}]
}
},
"httpResponse": {
"body": "some_response_body"
}
}'
See REST API for full JSON specification
Matching by keys to multiple-values by SUB_SET is the default mode this ensures at least one value with the same key matches, but MATCHING_KEY is also supported which ensures all values with the same key match.
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path")
.withQueryStringParameters(new Parameters(
schemaParam("multiValuedParameter", "{\"type\": \"string\", \"pattern\": \"^[A-Z0-9\\-]+$\"}"),
param(string("maxItemCount"), schemaString("{ \"type\": \"integer\" }"))
).withKeyMatchStyle(KeyMatchStyle.SUB_SET))
)
.respond(
response()
.withBody("some_response_body")
);
Matching by SUB_SET is the default mode so nothing needs to be specified for this key match style.
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest" : {
"path" : "/some/path",
"queryStringParameters" : {
"multiValuedParameter" : [ {
"schema" : {
"type" : "string",
"pattern" : "^[A-Z0-9-]+$"
}
} ],
"maxItemCount" : [ {
"schema" : {
"type" : "integer"
}
} ]
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest" : {
"path" : "/some/path",
"queryStringParameters" : {
"multiValuedParameter" : [ {
"schema" : {
"type" : "string",
"pattern" : "^[A-Z0-9-]+$"
}
} ],
"maxItemCount" : [ {
"schema" : {
"type" : "integer"
}
} ]
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest" : {
"path" : "/some/path",
"queryStringParameters" : {
"multiValuedParameter" : [ {
"schema" : {
"type" : "string",
"pattern" : "^[A-Z0-9-]+$"
}
} ],
"maxItemCount" : [ {
"schema" : {
"type" : "integer"
}
} ]
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest" : {
"path" : "/some/path",
"queryStringParameters" : {
"multiValuedParameter" : [ {
"schema" : {
"type" : "string",
"pattern" : "^[A-Z0-9-]+$"
}
} ],
"maxItemCount" : [ {
"schema" : {
"type" : "integer"
}
} ]
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"" : {
""path"" : ""/some/path"",
""queryStringParameters"" : {
""multiValuedParameter"" : [ {
""schema"" : {
""type"" : ""string"",
""pattern"" : ""^[A-Z0-9-]+$""
}
} ],
""maxItemCount"" : [ {
""schema"" : {
""type"" : ""integer""
}
} ]
}
},
""httpResponse"" : {
""body"" : ""some_response_body""
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest" : {
"path" : "/some/path",
"queryStringParameters" : {
"multiValuedParameter" : [ {
"schema" : {
"type" : "string",
"pattern" : "^[A-Z0-9-]+$"
}
} ],
"maxItemCount" : [ {
"schema" : {
"type" : "integer"
}
} ]
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest" : {
"path" : "/some/path",
"queryStringParameters" : {
"multiValuedParameter" : [ {
"schema" : {
"type" : "string",
"pattern" : "^[A-Z0-9-]+$"
}
} ],
"maxItemCount" : [ {
"schema" : {
"type" : "integer"
}
} ]
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
Matching by SUB_SET is the default mode so nothing needs to be specified for this key match style.
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest" : {
"path" : "/some/path",
"queryStringParameters" : {
"multiValuedParameter" : [ {
"schema" : {
"type" : "string",
"pattern" : "^[A-Z0-9-]+$"
}
} ],
"maxItemCount" : [ {
"schema" : {
"type" : "integer"
}
} ]
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}'
See REST API for full JSON specification
Matching by keys to multiple-values by SUB_SET is the default mode this ensures at least one value with the same key matches, but MATCHING_KEY is also supported which ensures all values with the same key match.
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path")
.withQueryStringParameters(new Parameters(
schemaParam("multiValuedParameter", "{\"type\": \"string\", \"pattern\": \"^[A-Z0-9\\-]+$\"}"),
param(string("maxItemCount"), schemaString("{ \"type\": \"integer\" }"))
).withKeyMatchStyle(KeyMatchStyle.MATCHING_KEY))
)
.respond(
response()
.withBody("some_response_body")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest" : {
"path" : "/some/path",
"queryStringParameters" : {
"keyMatchStyle" : "MATCHING_KEY",
"multiValuedParameter" : [ {
"schema" : {
"type" : "string",
"pattern" : "^[A-Z0-9-]+$"
}
} ],
"maxItemCount" : [ {
"schema" : {
"type" : "integer"
}
} ]
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest" : {
"path" : "/some/path",
"queryStringParameters" : {
"keyMatchStyle" : "MATCHING_KEY",
"multiValuedParameter" : [ {
"schema" : {
"type" : "string",
"pattern" : "^[A-Z0-9-]+$"
}
} ],
"maxItemCount" : [ {
"schema" : {
"type" : "integer"
}
} ]
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest" : {
"path" : "/some/path",
"queryStringParameters" : {
"keyMatchStyle" : "MATCHING_KEY",
"multiValuedParameter" : [ {
"schema" : {
"type" : "string",
"pattern" : "^[A-Z0-9-]+$"
}
} ],
"maxItemCount" : [ {
"schema" : {
"type" : "integer"
}
} ]
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest" : {
"path" : "/some/path",
"queryStringParameters" : {
"keyMatchStyle" : "MATCHING_KEY",
"multiValuedParameter" : [ {
"schema" : {
"type" : "string",
"pattern" : "^[A-Z0-9-]+$"
}
} ],
"maxItemCount" : [ {
"schema" : {
"type" : "integer"
}
} ]
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"" : {
""path"" : ""/some/path"",
""queryStringParameters"" : {
""keyMatchStyle"" : ""MATCHING_KEY"",
""multiValuedParameter"" : [ {
""schema"" : {
""type"" : ""string"",
""pattern"" : ""^[A-Z0-9-]+$""
}
} ],
""maxItemCount"" : [ {
""schema"" : {
""type"" : ""integer""
}
} ]
}
},
""httpResponse"" : {
""body"" : ""some_response_body""
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest" : {
"path" : "/some/path",
"queryStringParameters" : {
"keyMatchStyle" : "MATCHING_KEY",
"multiValuedParameter" : [ {
"schema" : {
"type" : "string",
"pattern" : "^[A-Z0-9-]+$"
}
} ],
"maxItemCount" : [ {
"schema" : {
"type" : "integer"
}
} ]
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest" : {
"path" : "/some/path",
"queryStringParameters" : {
"keyMatchStyle" : "MATCHING_KEY",
"multiValuedParameter" : [ {
"schema" : {
"type" : "string",
"pattern" : "^[A-Z0-9-]+$"
}
} ],
"maxItemCount" : [ {
"schema" : {
"type" : "integer"
}
} ]
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest" : {
"path" : "/some/path",
"queryStringParameters" : {
"keyMatchStyle" : "MATCHING_KEY",
"multiValuedParameter" : [ {
"schema" : {
"type" : "string",
"pattern" : "^[A-Z0-9-]+$"
}
} ],
"maxItemCount" : [ {
"schema" : {
"type" : "integer"
}
} ]
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.when(
request()
.withMethod("GET")
.withPath("/some/path")
.withHeaders(
header("Accept", "application/json"),
header("Accept-Encoding", "gzip, deflate, br")
)
)
.respond(
response()
.withBody("some_response_body")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"method": "GET",
"path": "/some/path",
"headers": {
"Accept": ["application/json"],
"Accept-Encoding": ["gzip, deflate, br"]
}
},
"httpResponse": {
"body": "some_response_body"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import HttpRequest, HttpResponse
client = MockServerClient("localhost", 1080)
client.when(
HttpRequest.request("/some/path")
.with_method("GET")
.with_header("Accept", "application/json")
.with_header("Accept-Encoding", "gzip, deflate, br")
).respond(
HttpResponse.response(body="some_response_body")
)
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.when(
MockServer::HttpRequest.new(path: '/some/path', method: 'GET')
).respond(
MockServer::HttpResponse.new(body: 'some_response_body')
)
import mockserver "github.com/mock-server/mockserver-monorepo/mockserver-client-go"
client := mockserver.New("localhost", 1080)
client.When(
mockserver.Request().Path("/some/path").Method("GET").Header("Accept", "application/json").Header("Accept-Encoding", "gzip, deflate, br"),
).Respond(
mockserver.Response().Body("some_response_body"),
)
using MockServer.Client;
using MockServer.Client.Models;
using var client = new MockServerClient("localhost", 1080);
client.When(
HttpRequest.Request().WithPath("/some/path").WithMethod("GET").WithHeader("Accept", "application/json").WithHeader("Accept-Encoding", "gzip, deflate, br")
).Respond(
HttpResponse.Response().WithBody("some_response_body")
);
use mockserver_client::{ClientBuilder, HttpRequest, HttpResponse};
let client = ClientBuilder::new("localhost", 1080).build().unwrap();
client.when(HttpRequest::new().method("GET").path("/some/path").header("Accept", "application/json").header("Accept-Encoding", "gzip, deflate, br"))
.respond(HttpResponse::new().body("some_response_body"))
.unwrap();
use MockServer\MockServerClient;
use MockServer\HttpRequest;
use MockServer\HttpResponse;
$client = new MockServerClient('localhost', 1080);
$client->when(
HttpRequest::request()
->method('GET')
->path('/some/path')
->header('Accept', 'application/json')
->header('Accept-Encoding', 'gzip, deflate, br')
)->respond(
HttpResponse::response()
->body('some_response_body')
);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest" : {
"method" : "GET",
"path" : "/some/path",
"headers" : {
"Accept" : [ "application/json" ],
"Accept-Encoding" : [ "gzip, deflate, br" ]
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}'
See REST API for full JSON specification
For details of the full regex syntax supported please see the JDK documentation.
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path")
.withHeader(
header("Accept.*")
)
)
.respond(
response()
.withBody("some_response_body")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"path": "/some/path",
"headers": {
// matches requests that have any header starting with the name Accept
"Accept.*": [ "" ]
}
},
"httpResponse": {
"body": "some_response_body"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import HttpRequest, HttpResponse
client = MockServerClient("localhost", 1080)
client.when(
HttpRequest.request("/some/path")
.with_header("Accept.*", "")
).respond(
HttpResponse.response(body="some_response_body")
)
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.when(
MockServer::HttpRequest.new(path: '/some/path')
).respond(
MockServer::HttpResponse.new(body: 'some_response_body')
)
import mockserver "github.com/mock-server/mockserver-monorepo/mockserver-client-go"
client := mockserver.New("localhost", 1080)
client.When(
mockserver.Request().Path("/some/path").Header("Accept.*", ""),
).Respond(
mockserver.Response().Body("some_response_body"),
)
using MockServer.Client;
using MockServer.Client.Models;
using var client = new MockServerClient("localhost", 1080);
client.When(
HttpRequest.Request().WithPath("/some/path").WithHeader("Accept.*", "")
).Respond(
HttpResponse.Response().WithBody("some_response_body")
);
use mockserver_client::{ClientBuilder, HttpRequest, HttpResponse};
let client = ClientBuilder::new("localhost", 1080).build().unwrap();
client.when(HttpRequest::new().path("/some/path").header("Accept.*", ""))
.respond(HttpResponse::new().body("some_response_body"))
.unwrap();
use MockServer\MockServerClient;
use MockServer\HttpRequest;
use MockServer\HttpResponse;
$client = new MockServerClient('localhost', 1080);
$client->when(
HttpRequest::request()
->path('/some/path')
->header('Accept.*', '')
)->respond(
HttpResponse::response()
->body('some_response_body')
);
// matches requests that have any header starting with the name Accept
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"path": "/some/path",
"headers": {
"Accept.*": [ "" ]
}
},
"httpResponse": {
"body": "some_response_body"
}
}'
See REST API for full JSON specification
For details of the full regex syntax supported please see the JDK documentation.
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path")
.withHeader(
header("Accept.*", ".*gzip.*")
)
)
.respond(
response()
.withBody("some_response_body")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"path": "/some/path",
"headers": {
// matches requests that have a header with a name starting with Accept and a value containing gzip
"Accept.*": [".*gzip.*"]
}
},
"httpResponse": {
"body": "some_response_body"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import HttpRequest, HttpResponse
client = MockServerClient("localhost", 1080)
client.when(
HttpRequest.request("/some/path")
.with_header("Accept.*", ".*gzip.*")
).respond(
HttpResponse.response(body="some_response_body")
)
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.when(
MockServer::HttpRequest.new(path: '/some/path')
).respond(
MockServer::HttpResponse.new(body: 'some_response_body')
)
import mockserver "github.com/mock-server/mockserver-monorepo/mockserver-client-go"
client := mockserver.New("localhost", 1080)
client.When(
mockserver.Request().Path("/some/path").Header("Accept.*", ".*gzip.*"),
).Respond(
mockserver.Response().Body("some_response_body"),
)
using MockServer.Client;
using MockServer.Client.Models;
using var client = new MockServerClient("localhost", 1080);
client.When(
HttpRequest.Request().WithPath("/some/path").WithHeader("Accept.*", ".*gzip.*")
).Respond(
HttpResponse.Response().WithBody("some_response_body")
);
use mockserver_client::{ClientBuilder, HttpRequest, HttpResponse};
let client = ClientBuilder::new("localhost", 1080).build().unwrap();
client.when(HttpRequest::new().path("/some/path").header("Accept.*", ".*gzip.*"))
.respond(HttpResponse::new().body("some_response_body"))
.unwrap();
use MockServer\MockServerClient;
use MockServer\HttpRequest;
use MockServer\HttpResponse;
$client = new MockServerClient('localhost', 1080);
$client->when(
HttpRequest::request()
->path('/some/path')
->header('Accept.*', '.*gzip.*')
)->respond(
HttpResponse::response()
->body('some_response_body')
);
// matches requests that have a header with a name starting with Accept and a value containing gzip
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"path": "/some/path",
"headers": {
"Accept.*": [".*gzip.*"]
}
},
"httpResponse": {
"body": "some_response_body"
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path")
.withHeaders(
// matches requests that have an Accept header without the value "application/json"
header(string("Accept"), not("application/json")),
// matches requests that have an Accept-Encoding without the substring "gzip"
header(string("Accept-Encoding"), not(".*gzip.*"))
)
)
.respond(
response()
.withBody("some_response_body")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"path": "/some/path",
"headers": {
// matches requests that have an Accept header without the value "application/json"
"Accept": ["!application/json"],
// matches requests that have an Accept-Encoding without the substring "gzip"
"Accept-Encoding": ["!.*gzip.*"]
}
},
"httpResponse": {
"body": "some_response_body"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest" : {
"path" : "/some/path",
"headers" : {
"Accept" : [ "!application/json" ],
"Accept-Encoding" : [ "!.*gzip.*" ]
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest" : {
"path" : "/some/path",
"headers" : {
"Accept" : [ "!application/json" ],
"Accept-Encoding" : [ "!.*gzip.*" ]
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest" : {
"path" : "/some/path",
"headers" : {
"Accept" : [ "!application/json" ],
"Accept-Encoding" : [ "!.*gzip.*" ]
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"" : {
""path"" : ""/some/path"",
""headers"" : {
""Accept"" : [ ""!application/json"" ],
""Accept-Encoding"" : [ ""!.*gzip.*"" ]
}
},
""httpResponse"" : {
""body"" : ""some_response_body""
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest" : {
"path" : "/some/path",
"headers" : {
"Accept" : [ "!application/json" ],
"Accept-Encoding" : [ "!.*gzip.*" ]
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest" : {
"path" : "/some/path",
"headers" : {
"Accept" : [ "!application/json" ],
"Accept-Encoding" : [ "!.*gzip.*" ]
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest" : {
"path" : "/some/path",
"headers" : {
"Accept" : [ "!application/json" ],
"Accept-Encoding" : [ "!.*gzip.*" ]
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path")
.withHeaders(
// matches requests that do not have either an Accept or an Accept-Encoding header
header(not("Accept")),
header(not("Accept-Encoding"))
)
)
.respond(
response()
.withBody("some_response_body")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"path": "/some/path",
"headers": {
// matches requests that do not have either an Accept or an Accept-Encoding header
"!Accept": [".*"],
"!Accept-Encoding": [".*"]
}
},
"httpResponse": {
"body": "some_response_body"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest" : {
"path" : "/some/path",
"headers" : {
"!Accept" : [ ".*" ],
"!Accept-Encoding" : [ ".*" ]
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest" : {
"path" : "/some/path",
"headers" : {
"!Accept" : [ ".*" ],
"!Accept-Encoding" : [ ".*" ]
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest" : {
"path" : "/some/path",
"headers" : {
"!Accept" : [ ".*" ],
"!Accept-Encoding" : [ ".*" ]
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"" : {
""path"" : ""/some/path"",
""headers"" : {
""!Accept"" : [ "".*"" ],
""!Accept-Encoding"" : [ "".*"" ]
}
},
""httpResponse"" : {
""body"" : ""some_response_body""
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest" : {
"path" : "/some/path",
"headers" : {
"!Accept" : [ ".*" ],
"!Accept-Encoding" : [ ".*" ]
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest" : {
"path" : "/some/path",
"headers" : {
"!Accept" : [ ".*" ],
"!Accept-Encoding" : [ ".*" ]
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest" : {
"path" : "/some/path",
"headers" : {
"!Accept" : [ ".*" ],
"!Accept-Encoding" : [ ".*" ]
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path")
.withHeader(
schemaHeader("Accept.*", "{\"type\": \"string\", \"pattern\": \"^.*gzip.*$\"}")
)
)
.respond(
response()
.withBody("some_response_body")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"path": "/some/path",
"headers": {
"Accept.*": [{
"schema": {
"type": "string",
"pattern": "^.*gzip.*$"
}
}]
}
},
"httpResponse": {
"body": "some_response_body"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest": {
"path": "/some/path",
"headers": {
"Accept.*": [{
"schema": {
"type": "string",
"pattern": "^.*gzip.*$"
}
}]
}
},
"httpResponse": {
"body": "some_response_body"
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest": {
"path": "/some/path",
"headers": {
"Accept.*": [{
"schema": {
"type": "string",
"pattern": "^.*gzip.*$"
}
}]
}
},
"httpResponse": {
"body": "some_response_body"
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest": {
"path": "/some/path",
"headers": {
"Accept.*": [{
"schema": {
"type": "string",
"pattern": "^.*gzip.*$"
}
}]
}
},
"httpResponse": {
"body": "some_response_body"
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"": {
""path"": ""/some/path"",
""headers"": {
""Accept.*"": [{
""schema"": {
""type"": ""string"",
""pattern"": ""^.*gzip.*$""
}
}]
}
},
""httpResponse"": {
""body"": ""some_response_body""
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest": {
"path": "/some/path",
"headers": {
"Accept.*": [{
"schema": {
"type": "string",
"pattern": "^.*gzip.*$"
}
}]
}
},
"httpResponse": {
"body": "some_response_body"
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest": {
"path": "/some/path",
"headers": {
"Accept.*": [{
"schema": {
"type": "string",
"pattern": "^.*gzip.*$"
}
}]
}
},
"httpResponse": {
"body": "some_response_body"
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"path": "/some/path",
"headers": {
"Accept.*": [{
"schema": {
"type": "string",
"pattern": "^.*gzip.*$"
}
}]
}
},
"httpResponse": {
"body": "some_response_body"
}
}'
See REST API for full JSON specification
This example shows how to match by either one value (in this case a header) or another value or both.
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path")
.withHeaders(
header("headerOne|headerTwo", ".*"),
optionalHeader("headerOne", "headerOneValue"),
optionalHeader("headerTwo", "headerTwoValue")
)
)
.respond(
response()
.withBody("some_response_body")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"path": "/some/path",
"headers": {
"headerOne|headerTwo": [".*"],
"?headerOne": ["headerOneValue"],
"?headerTwo": ["headerTwoValue"]
}
},
"httpResponse": {
"body": "some_response_body"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import HttpRequest, HttpResponse
client = MockServerClient("localhost", 1080)
client.when(
HttpRequest.request("/some/path")
.with_header("headerOne|headerTwo", ".*")
.with_header("?headerOne", "headerOneValue")
.with_header("?headerTwo", "headerTwoValue")
).respond(
HttpResponse.response(body="some_response_body")
)
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.when(
MockServer::HttpRequest.new(path: '/some/path')
).respond(
MockServer::HttpResponse.new(body: 'some_response_body')
)
import mockserver "github.com/mock-server/mockserver-monorepo/mockserver-client-go"
client := mockserver.New("localhost", 1080)
client.When(
mockserver.Request().Path("/some/path").Header("headerOne|headerTwo", ".*").Header("?headerOne", "headerOneValue").Header("?headerTwo", "headerTwoValue"),
).Respond(
mockserver.Response().Body("some_response_body"),
)
using MockServer.Client;
using MockServer.Client.Models;
using var client = new MockServerClient("localhost", 1080);
client.When(
HttpRequest.Request().WithPath("/some/path").WithHeader("headerOne|headerTwo", ".*").WithHeader("?headerOne", "headerOneValue").WithHeader("?headerTwo", "headerTwoValue")
).Respond(
HttpResponse.Response().WithBody("some_response_body")
);
use mockserver_client::{ClientBuilder, HttpRequest, HttpResponse};
let client = ClientBuilder::new("localhost", 1080).build().unwrap();
client.when(HttpRequest::new().path("/some/path").header("headerOne|headerTwo", ".*").header("?headerOne", "headerOneValue").header("?headerTwo", "headerTwoValue"))
.respond(HttpResponse::new().body("some_response_body"))
.unwrap();
use MockServer\MockServerClient;
use MockServer\HttpRequest;
use MockServer\HttpResponse;
$client = new MockServerClient('localhost', 1080);
$client->when(
HttpRequest::request()
->path('/some/path')
->header('headerOne|headerTwo', '.*')
->header('?headerOne', 'headerOneValue')
->header('?headerTwo', 'headerTwoValue')
)->respond(
HttpResponse::response()
->body('some_response_body')
);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"path": "/some/path",
"headers": {
"headerOne|headerTwo": [".*"],
"?headerOne": ["headerOneValue"],
"?headerTwo": ["headerTwoValue"]
}
},
"httpResponse": {
"body": "some_response_body"
}
}'
See REST API for full JSON specification
Matching by keys to multiple-values by SUB_SET is the default mode this ensures at least one value with the same key matches, but MATCHING_KEY is also supported which ensures all values with the same key match.
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path")
.withHeaders(new Headers(
header("multiValuedHeader", "value.*"),
header("headerTwo", "headerTwoValue")
).withKeyMatchStyle(KeyMatchStyle.MATCHING_KEY))
)
.respond(
response()
.withBody("some_response_body")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest" : {
"path" : "/some/path",
"headers" : {
"keyMatchStyle" : "MATCHING_KEY",
"multiValuedHeader" : [ "value.*" ],
"headerTwo" : [ "headerTwoValue" ]
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import HttpRequest, HttpResponse
client = MockServerClient("localhost", 1080)
client.when(
HttpRequest.request("/some/path")
.with_header("keyMatchStyle", "M", "A", "T", "C", "H", "I", "N", "G", "_", "K", "E", "Y")
.with_header("multiValuedHeader", "value.*")
.with_header("headerTwo", "headerTwoValue")
).respond(
HttpResponse.response(body="some_response_body")
)
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.when(
MockServer::HttpRequest.new(path: '/some/path')
).respond(
MockServer::HttpResponse.new(body: 'some_response_body')
)
import mockserver "github.com/mock-server/mockserver-monorepo/mockserver-client-go"
client := mockserver.New("localhost", 1080)
client.When(
mockserver.Request().Path("/some/path").Header("keyMatchStyle", "M", "A", "T", "C", "H", "I", "N", "G", "_", "K", "E", "Y").Header("multiValuedHeader", "value.*").Header("headerTwo", "headerTwoValue"),
).Respond(
mockserver.Response().Body("some_response_body"),
)
using MockServer.Client;
using MockServer.Client.Models;
using var client = new MockServerClient("localhost", 1080);
client.When(
HttpRequest.Request().WithPath("/some/path").WithHeader("keyMatchStyle", "M", "A", "T", "C", "H", "I", "N", "G", "_", "K", "E", "Y").WithHeader("multiValuedHeader", "value.*").WithHeader("headerTwo", "headerTwoValue")
).Respond(
HttpResponse.Response().WithBody("some_response_body")
);
use mockserver_client::{ClientBuilder, HttpRequest, HttpResponse};
let client = ClientBuilder::new("localhost", 1080).build().unwrap();
client.when(HttpRequest::new().path("/some/path").header("keyMatchStyle", "M").header("keyMatchStyle", "A").header("keyMatchStyle", "T").header("keyMatchStyle", "C").header("keyMatchStyle", "H").header("keyMatchStyle", "I").header("keyMatchStyle", "N").header("keyMatchStyle", "G").header("keyMatchStyle", "_").header("keyMatchStyle", "K").header("keyMatchStyle", "E").header("keyMatchStyle", "Y").header("multiValuedHeader", "value.*").header("headerTwo", "headerTwoValue"))
.respond(HttpResponse::new().body("some_response_body"))
.unwrap();
use MockServer\MockServerClient;
use MockServer\HttpRequest;
use MockServer\HttpResponse;
$client = new MockServerClient('localhost', 1080);
$client->when(
HttpRequest::request()
->path('/some/path')
->header('keyMatchStyle', 'MATCHING_KEY')
->header('multiValuedHeader', 'value.*')
->header('headerTwo', 'headerTwoValue')
)->respond(
HttpResponse::response()
->body('some_response_body')
);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest" : {
"path" : "/some/path",
"headers" : {
"keyMatchStyle" : "MATCHING_KEY",
"multiValuedHeader" : [ "value.*" ],
"headerTwo" : [ "headerTwoValue" ]
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.when(
request()
.withMethod("GET")
.withPath("/view/cart")
.withCookies(
cookie("session", "4930456C-C718-476F-971F-CB8E047AB349")
)
.withQueryStringParameters(
param("cartId", "055CA455-1DF7-45BB-8535-4F83E7266092")
)
)
.respond(
response()
.withBody("some_response_body")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"method": "GET",
"path": "/view/cart",
"queryStringParameters": {
"cartId": ["055CA455-1DF7-45BB-8535-4F83E7266092"]
},
"cookies": {
"session": "4930456C-C718-476F-971F-CB8E047AB349"
}
},
"httpResponse": {
"body": "some_response_body"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import HttpRequest, HttpResponse
client = MockServerClient("localhost", 1080)
client.when(
HttpRequest.request("/view/cart")
.with_method("GET")
.with_query_param("cartId", "055CA455-1DF7-45BB-8535-4F83E7266092")
.with_cookie("session", "4930456C-C718-476F-971F-CB8E047AB349")
).respond(
HttpResponse.response(body="some_response_body")
)
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.when(
MockServer::HttpRequest.new(path: '/view/cart', method: 'GET')
).respond(
MockServer::HttpResponse.new(body: 'some_response_body')
)
import mockserver "github.com/mock-server/mockserver-monorepo/mockserver-client-go"
client := mockserver.New("localhost", 1080)
client.When(
mockserver.Request().Path("/view/cart").Method("GET").QueryStringParameter("cartId", "055CA455-1DF7-45BB-8535-4F83E7266092").Cookie("session", "4930456C-C718-476F-971F-CB8E047AB349"),
).Respond(
mockserver.Response().Body("some_response_body"),
)
using MockServer.Client;
using MockServer.Client.Models;
using var client = new MockServerClient("localhost", 1080);
client.When(
HttpRequest.Request().WithPath("/view/cart").WithMethod("GET").WithQueryStringParameter("cartId", "055CA455-1DF7-45BB-8535-4F83E7266092")
).Respond(
HttpResponse.Response().WithBody("some_response_body")
);
use mockserver_client::{ClientBuilder, HttpRequest, HttpResponse};
let client = ClientBuilder::new("localhost", 1080).build().unwrap();
client.when(HttpRequest::new().method("GET").path("/view/cart").query_param("cartId", "055CA455-1DF7-45BB-8535-4F83E7266092"))
.respond(HttpResponse::new().body("some_response_body"))
.unwrap();
use MockServer\MockServerClient;
use MockServer\HttpRequest;
use MockServer\HttpResponse;
$client = new MockServerClient('localhost', 1080);
$client->when(
HttpRequest::request()
->method('GET')
->path('/view/cart')
->queryStringParameter('cartId', '055CA455-1DF7-45BB-8535-4F83E7266092')
->cookie('session', '4930456C-C718-476F-971F-CB8E047AB349')
)->respond(
HttpResponse::response()
->body('some_response_body')
);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest" : {
"method" : "GET",
"path" : "/view/cart",
"queryStringParameters" : {
"cartId" : [ "055CA455-1DF7-45BB-8535-4F83E7266092" ]
},
"cookies" : {
"session" : "4930456C-C718-476F-971F-CB8E047AB349"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.when(
request()
.withMethod("GET")
.withPath("/view/cart")
.withQueryStringParameters(
schemaParam("cartId", "{ \"type\": \"string\", \"format\": \"uuid\" }")
)
.withCookies(
schemaCookie("session", "{ \"type\": \"string\", \"format\": \"uuid\" }")
)
)
.respond(
response()
.withBody("some_response_body")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"method": "GET",
"path": "/view/cart",
"queryStringParameters": {
"cartId": [{
"schema": {
"type": "string",
"format": "uuid"
}
}]
},
"cookies": {
"session": {
"schema": {
"type": "string",
"format": "uuid"
}
}
}
},
"httpResponse": {
"body": "some_response_body"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import HttpRequest, HttpResponse
client = MockServerClient("localhost", 1080)
client.when(
HttpRequest.request("/view/cart")
.with_method("GET")
.with_query_param("cartId", "055CA455-1DF7-45BB-8535-4F83E7266092")
.with_cookie("session", "4930456C-C718-476F-971F-CB8E047AB349")
).respond(
HttpResponse.response(body="some_response_body")
)
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.when(
MockServer::HttpRequest.new(path: '/view/cart', method: 'GET')
).respond(
MockServer::HttpResponse.new(body: 'some_response_body')
)
import mockserver "github.com/mock-server/mockserver-monorepo/mockserver-client-go"
client := mockserver.New("localhost", 1080)
client.When(
mockserver.Request().Path("/view/cart").Method("GET").QueryStringParameter("cartId", "055CA455-1DF7-45BB-8535-4F83E7266092").Cookie("session", "4930456C-C718-476F-971F-CB8E047AB349"),
).Respond(
mockserver.Response().Body("some_response_body"),
)
using MockServer.Client;
using MockServer.Client.Models;
using var client = new MockServerClient("localhost", 1080);
client.When(
HttpRequest.Request().WithPath("/view/cart").WithMethod("GET").WithQueryStringParameter("cartId", "055CA455-1DF7-45BB-8535-4F83E7266092")
).Respond(
HttpResponse.Response().WithBody("some_response_body")
);
use mockserver_client::{ClientBuilder, HttpRequest, HttpResponse};
let client = ClientBuilder::new("localhost", 1080).build().unwrap();
client.when(HttpRequest::new().method("GET").path("/view/cart").query_param("cartId", "055CA455-1DF7-45BB-8535-4F83E7266092"))
.respond(HttpResponse::new().body("some_response_body"))
.unwrap();
use MockServer\MockServerClient;
use MockServer\HttpRequest;
use MockServer\HttpResponse;
$client = new MockServerClient('localhost', 1080);
$client->when(
HttpRequest::request()
->method('GET')
->path('/view/cart')
->queryStringParameter('cartId', '055CA455-1DF7-45BB-8535-4F83E7266092')
->cookie('session', '4930456C-C718-476F-971F-CB8E047AB349')
)->respond(
HttpResponse::response()
->body('some_response_body')
);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest" : {
"method" : "GET",
"path" : "/view/cart",
"queryStringParameters" : {
"cartId" : [ "055CA455-1DF7-45BB-8535-4F83E7266092" ]
},
"cookies" : {
"session" : "4930456C-C718-476F-971F-CB8E047AB349"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/view/cart")
.withCookies(
optionalCookie("session", schemaString("{ \"type\": \"string\", \"format\": \"uuid\" }"))
)
.withQueryStringParameters(
schemaParam("cartId", "{ \"type\": \"string\", \"format\": \"uuid\" }")
)
)
.respond(
response()
.withBody("some_response_body")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"path": "/view/cart",
"queryStringParameters": {
"cartId": [{
"schema": {
"type": "string",
"format": "uuid"
}
}]
},
"cookies": {
"?session": {
"schema": {
"type": "string",
"format": "uuid"
}
}
}
},
"httpResponse": {
"body": "some_response_body"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest": {
"path": "/view/cart",
"queryStringParameters": {
"cartId": [{
"schema": {
"type": "string",
"format": "uuid"
}
}]
},
"cookies": {
"?session": {
"schema": {
"type": "string",
"format": "uuid"
}
}
}
},
"httpResponse": {
"body": "some_response_body"
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest": {
"path": "/view/cart",
"queryStringParameters": {
"cartId": [{
"schema": {
"type": "string",
"format": "uuid"
}
}]
},
"cookies": {
"?session": {
"schema": {
"type": "string",
"format": "uuid"
}
}
}
},
"httpResponse": {
"body": "some_response_body"
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest": {
"path": "/view/cart",
"queryStringParameters": {
"cartId": [{
"schema": {
"type": "string",
"format": "uuid"
}
}]
},
"cookies": {
"?session": {
"schema": {
"type": "string",
"format": "uuid"
}
}
}
},
"httpResponse": {
"body": "some_response_body"
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"": {
""path"": ""/view/cart"",
""queryStringParameters"": {
""cartId"": [{
""schema"": {
""type"": ""string"",
""format"": ""uuid""
}
}]
},
""cookies"": {
""?session"": {
""schema"": {
""type"": ""string"",
""format"": ""uuid""
}
}
}
},
""httpResponse"": {
""body"": ""some_response_body""
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest": {
"path": "/view/cart",
"queryStringParameters": {
"cartId": [{
"schema": {
"type": "string",
"format": "uuid"
}
}]
},
"cookies": {
"?session": {
"schema": {
"type": "string",
"format": "uuid"
}
}
}
},
"httpResponse": {
"body": "some_response_body"
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest": {
"path": "/view/cart",
"queryStringParameters": {
"cartId": [{
"schema": {
"type": "string",
"format": "uuid"
}
}]
},
"cookies": {
"?session": {
"schema": {
"type": "string",
"format": "uuid"
}
}
}
},
"httpResponse": {
"body": "some_response_body"
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"path": "/view/cart",
"queryStringParameters": {
"cartId": [{
"schema": {
"type": "string",
"format": "uuid"
}
}]
},
"cookies": {
"?session": {
"schema": {
"type": "string",
"format": "uuid"
}
}
}
},
"httpResponse": {
"body": "some_response_body"
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.when(
request()
.withBody(subString("some_string"))
)
.respond(
response()
.withBody("some_response_body")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"body": {
"type": "STRING",
"string": "some_string",
"subString": true
}
},
"httpResponse": {
"body": "some_response_body"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest" : {
"body" : {
"type": "STRING",
"string": "some_string",
"subString": True
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest" : {
"body" : {
"type": "STRING",
"string": "some_string",
"subString": true
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest" : {
"body" : {
"type": "STRING",
"string": "some_string",
"subString": true
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"" : {
""body"" : {
""type"": ""STRING"",
""string"": ""some_string"",
""subString"": true
}
},
""httpResponse"" : {
""body"" : ""some_response_body""
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest" : {
"body" : {
"type": "STRING",
"string": "some_string",
"subString": true
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest" : {
"body" : {
"type": "STRING",
"string": "some_string",
"subString": true
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest" : {
"body" : {
"type": "STRING",
"string": "some_string",
"subString": true
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.when(
request()
.withBody(exact("我说中国话", Charsets.UTF_16))
)
.respond(
response()
.withBody("some_response_body")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"body": {
"type": "STRING",
"string": "我说中国话",
"contentType": "text/plain; charset=utf-16"
}
},
"httpResponse": {
"body": "some_response_body"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest" : {
"body" : {
"type" : "STRING",
"string" : "我说中国话",
"contentType" : "text/plain; charset=utf-16"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest" : {
"body" : {
"type" : "STRING",
"string" : "我说中国话",
"contentType" : "text/plain; charset=utf-16"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest" : {
"body" : {
"type" : "STRING",
"string" : "我说中国话",
"contentType" : "text/plain; charset=utf-16"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"" : {
""body"" : {
""type"" : ""STRING"",
""string"" : ""我说中国话"",
""contentType"" : ""text/plain; charset=utf-16""
}
},
""httpResponse"" : {
""body"" : ""some_response_body""
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest" : {
"body" : {
"type" : "STRING",
"string" : "我说中国话",
"contentType" : "text/plain; charset=utf-16"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest" : {
"body" : {
"type" : "STRING",
"string" : "我说中国话",
"contentType" : "text/plain; charset=utf-16"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest" : {
"body" : {
"type" : "STRING",
"string" : "我说中国话",
"contentType" : "text/plain; charset=utf-16"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}'
See REST API for full JSON specification
For details of the full regex syntax supported please see the JDK documentation.
new MockServerClient("localhost", 1080)
.when(
request()
.withBody(regex("starts_with_.*"))
)
.respond(
response()
.withBody("some_response_body")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"body": {
"type": "REGEX",
"regex": "starts_with_.*"
}
},
"httpResponse": {
"body": "some_response_body"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest": {
"body": {
"type": "REGEX",
"regex": "starts_with_.*"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest": {
"body": {
"type": "REGEX",
"regex": "starts_with_.*"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest": {
"body": {
"type": "REGEX",
"regex": "starts_with_.*"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"": {
""body"": {
""type"": ""REGEX"",
""regex"": ""starts_with_.*""
}
},
""httpResponse"" : {
""body"" : ""some_response_body""
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest": {
"body": {
"type": "REGEX",
"regex": "starts_with_.*"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest": {
"body": {
"type": "REGEX",
"regex": "starts_with_.*"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"body": {
"type": "REGEX",
"regex": "starts_with_.*"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.when(
request()
.withMethod("POST")
.withHeaders(
header("Content-Type", "application/x-www-form-urlencoded")
)
.withBody(
params(
param("email", "joe.blogs@gmail.com"),
param("password", "secure_Password123")
)
)
)
.respond(
response()
.withBody("some_response_body")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"method": "POST",
"headers": {
"Content-Type": ["application/x-www-form-urlencoded"]
},
"body": {
"type": "PARAMETERS",
"parameters": {
"email": ["joe.blogs@gmail.com"],
"password": ["secure_Password123"]
}
}
},
"httpResponse": {
"body": "some_response_body"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest" : {
"method" : "POST",
"headers" : {
"Content-Type" : [ "application/x-www-form-urlencoded" ]
},
"body" : {
"type" : "PARAMETERS",
"parameters" : {
"email" : [ "joe.blogs@gmail.com" ],
"password" : [ "secure_Password123" ]
}
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest" : {
"method" : "POST",
"headers" : {
"Content-Type" : [ "application/x-www-form-urlencoded" ]
},
"body" : {
"type" : "PARAMETERS",
"parameters" : {
"email" : [ "joe.blogs@gmail.com" ],
"password" : [ "secure_Password123" ]
}
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest" : {
"method" : "POST",
"headers" : {
"Content-Type" : [ "application/x-www-form-urlencoded" ]
},
"body" : {
"type" : "PARAMETERS",
"parameters" : {
"email" : [ "joe.blogs@gmail.com" ],
"password" : [ "secure_Password123" ]
}
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"" : {
""method"" : ""POST"",
""headers"" : {
""Content-Type"" : [ ""application/x-www-form-urlencoded"" ]
},
""body"" : {
""type"" : ""PARAMETERS"",
""parameters"" : {
""email"" : [ ""joe.blogs@gmail.com"" ],
""password"" : [ ""secure_Password123"" ]
}
}
},
""httpResponse"" : {
""body"" : ""some_response_body""
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest" : {
"method" : "POST",
"headers" : {
"Content-Type" : [ "application/x-www-form-urlencoded" ]
},
"body" : {
"type" : "PARAMETERS",
"parameters" : {
"email" : [ "joe.blogs@gmail.com" ],
"password" : [ "secure_Password123" ]
}
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest" : {
"method" : "POST",
"headers" : {
"Content-Type" : [ "application/x-www-form-urlencoded" ]
},
"body" : {
"type" : "PARAMETERS",
"parameters" : {
"email" : [ "joe.blogs@gmail.com" ],
"password" : [ "secure_Password123" ]
}
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest" : {
"method" : "POST",
"headers" : {
"Content-Type" : [ "application/x-www-form-urlencoded" ]
},
"body" : {
"type" : "PARAMETERS",
"parameters" : {
"email" : [ "joe.blogs@gmail.com" ],
"password" : [ "secure_Password123" ]
}
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}'
See REST API for full JSON specification
Matches if at least one value is returned by the JsonPath expression
For a quick summary the XPath syntax please see w3schools, for details of the full XPath syntax please see www.w3.org
new MockServerClient("localhost", 1080)
.when(
request()
// matches any request with an XML body that contains
// one or more elements that match the XPath expression
.withBody(
xpath("/bookstore/book[price>30]/price")
)
)
.respond(
response()
.withBody("some_response_body")
);
// matches a request with the following body:
/*
<?xml version="1.0" encoding="ISO-8859-1"?>
<bookstore>
<book category="COOKING">
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
<book category="CHILDREN">
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
<book category="WEB">
<title lang="en">Learning XML</title>
<author>Erik T. Ray</author>
<year>2003</year>
<price>31.95</price>
</book>
</bookstore>
*/
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"body": {
// matches any request with an XML body that contains
// one or more elements that match the XPath expression
"type": "XPATH",
"xpath": "/bookstore/book[price>30]/price"
}
},
"httpResponse": {
"body": "some_response_body"
}
});
// matches a request with the following body:
/*
<?xml version="1.0" encoding="ISO-8859-1"?>
<bookstore>
<book category="COOKING">
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
<book category="CHILDREN">
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
<book category="WEB">
<title lang="en">Learning XML</title>
<author>Erik T. Ray</author>
<year>2003</year>
<price>31.95</price>
</book>
</bookstore>
*/
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest" : {
"body" : {
"type" : "XPATH",
"xpath" : "/bookstore/book[price>30]/price"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest" : {
"body" : {
"type" : "XPATH",
"xpath" : "/bookstore/book[price>30]/price"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest" : {
"body" : {
"type" : "XPATH",
"xpath" : "/bookstore/book[price>30]/price"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"" : {
""body"" : {
""type"" : ""XPATH"",
""xpath"" : ""/bookstore/book[price>30]/price""
}
},
""httpResponse"" : {
""body"" : ""some_response_body""
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest" : {
"body" : {
"type" : "XPATH",
"xpath" : "/bookstore/book[price>30]/price"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest" : {
"body" : {
"type" : "XPATH",
"xpath" : "/bookstore/book[price>30]/price"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest" : {
"body" : {
"type" : "XPATH",
"xpath" : "/bookstore/book[price>30]/price"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}'
See REST API for full JSON specification
Matches if at least one value is returned by the JsonPath expression
For a quick summary the XPath syntax please see w3schools, for details of the full XPath syntax please see www.w3.org
new MockServerClient("localhost", 1080)
.when(
request()
.withBody(
// matches any request with an XML body that does NOT
// contain one or more elements that match the XPath expression
not(xpath("/bookstore/book[price>30]/price"))
)
)
.respond(
response()
.withBody("some_response_body")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"body": {
// matches any request with an XML body that does NOT
// contain one or more elements that match the XPath expression
"not": true,
"type": "XPATH",
"xpath": "/bookstore/book[price>30]/price"
}
},
"httpResponse": {
"body": "some_response_body"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest" : {
"body" : {
"not" : True,
"type" : "XPATH",
"xpath" : "/bookstore/book[price>30]/price"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest" : {
"body" : {
"not" : true,
"type" : "XPATH",
"xpath" : "/bookstore/book[price>30]/price"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest" : {
"body" : {
"not" : true,
"type" : "XPATH",
"xpath" : "/bookstore/book[price>30]/price"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"" : {
""body"" : {
""not"" : true,
""type"" : ""XPATH"",
""xpath"" : ""/bookstore/book[price>30]/price""
}
},
""httpResponse"" : {
""body"" : ""some_response_body""
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest" : {
"body" : {
"not" : true,
"type" : "XPATH",
"xpath" : "/bookstore/book[price>30]/price"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest" : {
"body" : {
"not" : true,
"type" : "XPATH",
"xpath" : "/bookstore/book[price>30]/price"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest" : {
"body" : {
"not" : true,
"type" : "XPATH",
"xpath" : "/bookstore/book[price>30]/price"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.when(
request()
.withBody(
xml("<bookstore>" + System.lineSeparator() +
" <book nationality=\"ITALIAN\" category=\"COOKING\">" + System.lineSeparator() +
" <title lang=\"en\">Everyday Italian</title>" + System.lineSeparator() +
" <author>Giada De Laurentiis</author>" + System.lineSeparator() +
" <year>2005</year>" + System.lineSeparator() +
" <price>30.00</price>" + System.lineSeparator() +
" </book>" + System.lineSeparator() +
"</bookstore>")
)
)
.respond(
response()
.withBody("some_response_body")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"body": {
"type": "XML",
"xml": "<bookstore>\n" +
" <book nationality=\"ITALIAN\" category=\"COOKING\">\n" +
" <title lang=\"en\">Everyday Italian</title>\n" +
" <author>Giada De Laurentiis</author>\n" +
" <year>2005</year>\n" +
" <price>30.00</price>\n" +
" </book>\n" +
"</bookstore>"
}
},
"httpResponse": {
"body": "some_response_body"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest" : {
"body" : {
"type" : "XML",
"xml" : "<bookstore> <book nationality=\"ITALIAN\" category=\"COOKING\"><title lang=\"en\">Everyday Italian</title><author>Giada De Laurentiis</author><year>2005</year><price>30.00</price></book> </bookstore>"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest" : {
"body" : {
"type" : "XML",
"xml" : "<bookstore> <book nationality=\"ITALIAN\" category=\"COOKING\"><title lang=\"en\">Everyday Italian</title><author>Giada De Laurentiis</author><year>2005</year><price>30.00</price></book> </bookstore>"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest" : {
"body" : {
"type" : "XML",
"xml" : "<bookstore> <book nationality=\"ITALIAN\" category=\"COOKING\"><title lang=\"en\">Everyday Italian</title><author>Giada De Laurentiis</author><year>2005</year><price>30.00</price></book> </bookstore>"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
"httpRequest" : {
"body" : {
"type" : "XML",
"xml" : "<bookstore> <book nationality=\"ITALIAN\" category=\"COOKING\"><title lang=\"en\">Everyday Italian</title><author>Giada De Laurentiis</author><year>2005</year><price>30.00</price></book> </bookstore>"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest" : {
"body" : {
"type" : "XML",
"xml" : "<bookstore> <book nationality=\"ITALIAN\" category=\"COOKING\"><title lang=\"en\">Everyday Italian</title><author>Giada De Laurentiis</author><year>2005</year><price>30.00</price></book> </bookstore>"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest" : {
"body" : {
"type" : "XML",
"xml" : "<bookstore> <book nationality=\"ITALIAN\" category=\"COOKING\"><title lang=\"en\">Everyday Italian</title><author>Giada De Laurentiis</author><year>2005</year><price>30.00</price></book> </bookstore>"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest" : {
"body" : {
"type" : "XML",
"xml" : "<bookstore> <book nationality=\"ITALIAN\" category=\"COOKING\"><title lang=\"en\">Everyday Italian</title><author>Giada De Laurentiis</author><year>2005</year><price>30.00</price></book> </bookstore>"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}'
See REST API for full JSON specification
See XMLUnit documentation for full details of supported placeholders.
new MockServerClient("localhost", 1080)
.when(
request()
.withBody(
xml("<bookstore>" + System.lineSeparator() +
" <book nationality=\"ITALIAN\" category=\"COOKING\">" + System.lineSeparator() +
" <title lang=\"en\">Everyday Italian</title>" + System.lineSeparator() +
" <author>${xmlunit.ignore}</author>" + System.lineSeparator() +
" <year>${xmlunit.isNumber}</year>" + System.lineSeparator() +
" <price>30.00</price>" + System.lineSeparator() +
" </book>" + System.lineSeparator() +
"</bookstore>")
)
)
.respond(
response()
.withBody("some_response_body")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest" : {
"body" : {
"type" : "XML",
"xml" : "<bookstore>\n" +
" <book nationality=\"ITALIAN\" category=\"COOKING\">\n" +
" <title lang=\"en\">Everyday Italian</title>\n" +
" <author>${xmlunit.ignore}</author>\n" +
" <year>${xmlunit.isNumber}</year>\n" +
" <price>30.00</price>\n" +
" </book>\n" +
"</bookstore>"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest" : {
"body" : {
"type" : "XML",
"xml" : "<bookstore>\n <book nationality=\"ITALIAN\" category=\"COOKING\">\n <title lang=\"en\">Everyday Italian</title>\n <author>${xmlunit.ignore}</author>\n <year>${xmlunit.isNumber}</year>\n <price>30.00</price>\n </book>\n</bookstore>"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest" : {
"body" : {
"type" : "XML",
"xml" : "<bookstore>\n <book nationality=\"ITALIAN\" category=\"COOKING\">\n <title lang=\"en\">Everyday Italian</title>\n <author>${xmlunit.ignore}</author>\n <year>${xmlunit.isNumber}</year>\n <price>30.00</price>\n </book>\n</bookstore>"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest" : {
"body" : {
"type" : "XML",
"xml" : "<bookstore>\n <book nationality=\"ITALIAN\" category=\"COOKING\">\n <title lang=\"en\">Everyday Italian</title>\n <author>${xmlunit.ignore}</author>\n <year>${xmlunit.isNumber}</year>\n <price>30.00</price>\n </book>\n</bookstore>"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"" : {
""body"" : {
""type"" : ""XML"",
""xml"" : ""<bookstore>\n <book nationality=\""ITALIAN\"" category=\""COOKING\"">\n <title lang=\""en\"">Everyday Italian</title>\n <author>${xmlunit.ignore}</author>\n <year>${xmlunit.isNumber}</year>\n <price>30.00</price>\n </book>\n</bookstore>""
}
},
""httpResponse"" : {
""body"" : ""some_response_body""
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest" : {
"body" : {
"type" : "XML",
"xml" : "<bookstore>\n <book nationality=\"ITALIAN\" category=\"COOKING\">\n <title lang=\"en\">Everyday Italian</title>\n <author>${xmlunit.ignore}</author>\n <year>${xmlunit.isNumber}</year>\n <price>30.00</price>\n </book>\n</bookstore>"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest" : {
"body" : {
"type" : "XML",
"xml" : "<bookstore>\n <book nationality=\"ITALIAN\" category=\"COOKING\">\n <title lang=\"en\">Everyday Italian</title>\n <author>${xmlunit.ignore}</author>\n <year>${xmlunit.isNumber}</year>\n <price>30.00</price>\n </book>\n</bookstore>"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest" : {
"body" : {
"type" : "XML",
"xml" : "<bookstore>\n <book nationality=\"ITALIAN\" category=\"COOKING\">\n <title lang=\"en\">Everyday Italian</title>\n <author>${xmlunit.ignore}</author>\n <year>${xmlunit.isNumber}</year>\n <price>30.00</price>\n </book>\n</bookstore>"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.when(
request()
.withBody(
xmlSchema("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + System.lineSeparator() +
"<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" elementFormDefault=\"qualified\" attributeFormDefault=\"unqualified\">" + System.lineSeparator() +
" <!-- XML Schema Generated from XML Document on Wed Jun 28 2017 21:52:45 GMT+0100 (BST) -->" + System.lineSeparator() +
" <!-- with XmlGrid.net Free Online Service http://xmlgrid.net -->" + System.lineSeparator() +
" <xs:element name=\"notes\">" + System.lineSeparator() +
" <xs:complexType>" + System.lineSeparator() +
" <xs:sequence>" + System.lineSeparator() +
" <xs:element name=\"note\" maxOccurs=\"unbounded\">" + System.lineSeparator() +
" <xs:complexType>" + System.lineSeparator() +
" <xs:sequence>" + System.lineSeparator() +
" <xs:element name=\"to\" minOccurs=\"1\" maxOccurs=\"1\" type=\"xs:string\"></xs:element>" + System.lineSeparator() +
" <xs:element name=\"from\" minOccurs=\"1\" maxOccurs=\"1\" type=\"xs:string\"></xs:element>" + System.lineSeparator() +
" <xs:element name=\"heading\" minOccurs=\"1\" maxOccurs=\"1\" type=\"xs:string\"></xs:element>" + System.lineSeparator() +
" <xs:element name=\"body\" minOccurs=\"1\" maxOccurs=\"1\" type=\"xs:string\"></xs:element>" + System.lineSeparator() +
" </xs:sequence>" + System.lineSeparator() +
" </xs:complexType>" + System.lineSeparator() +
" </xs:element>" + System.lineSeparator() +
" </xs:sequence>" + System.lineSeparator() +
" </xs:complexType>" + System.lineSeparator() +
" </xs:element>" + System.lineSeparator() +
"</xs:schema>")
)
)
.respond(
response()
.withBody("some_response_body")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"body": {
"type": "XML_SCHEMA",
"xmlSchema": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" elementFormDefault=\"qualified\" attributeFormDefault=\"unqualified\">\n" +
" <!-- XML Schema Generated from XML Document on Wed Jun 28 2017 21:52:45 GMT+0100 (BST) -->\n" +
" <!-- with XmlGrid.net Free Online Service http://xmlgrid.net -->\n" +
" <xs:element name=\"notes\">\n" +
" <xs:complexType>\n" +
" <xs:sequence>\n" +
" <xs:element name=\"note\" maxOccurs=\"unbounded\">\n" +
" <xs:complexType>\n" +
" <xs:sequence>\n" +
" <xs:element name=\"to\" minOccurs=\"1\" maxOccurs=\"1\" type=\"xs:string\"></xs:element>\n" +
" <xs:element name=\"from\" minOccurs=\"1\" maxOccurs=\"1\" type=\"xs:string\"></xs:element>\n" +
" <xs:element name=\"heading\" minOccurs=\"1\" maxOccurs=\"1\" type=\"xs:string\"></xs:element>\n" +
" <xs:element name=\"body\" minOccurs=\"1\" maxOccurs=\"1\" type=\"xs:string\"></xs:element>\n" +
" </xs:sequence>\n" +
" </xs:complexType>\n" +
" </xs:element>\n" +
" </xs:sequence>\n" +
" </xs:complexType>\n" +
" </xs:element>\n</xs:schema>"
}
},
"httpResponse": {
"body": "some_response_body"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest" : {
"body" : {
"type" : "XML_SCHEMA",
"xmlSchema" : "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" elementFormDefault=\"qualified\" attributeFormDefault=\"unqualified\"> <xs:element name=\"notes\"> <xs:complexType> <xs:sequence> <xs:element name=\"note\" maxOccurs=\"unbounded\"> <xs:complexType> <xs:sequence> <xs:element name=\"to\" minOccurs=\"1\" maxOccurs=\"1\" type=\"xs:string\"></xs:element> <xs:element name=\"from\" minOccurs=\"1\" maxOccurs=\"1\" type=\"xs:string\"></xs:element> <xs:element name=\"heading\" minOccurs=\"1\" maxOccurs=\"1\" type=\"xs:string\"></xs:element> <xs:element name=\"body\" minOccurs=\"1\" maxOccurs=\"1\" type=\"xs:string\"></xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest" : {
"body" : {
"type" : "XML_SCHEMA",
"xmlSchema" : "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" elementFormDefault=\"qualified\" attributeFormDefault=\"unqualified\"> <xs:element name=\"notes\"> <xs:complexType> <xs:sequence> <xs:element name=\"note\" maxOccurs=\"unbounded\"> <xs:complexType> <xs:sequence> <xs:element name=\"to\" minOccurs=\"1\" maxOccurs=\"1\" type=\"xs:string\"></xs:element> <xs:element name=\"from\" minOccurs=\"1\" maxOccurs=\"1\" type=\"xs:string\"></xs:element> <xs:element name=\"heading\" minOccurs=\"1\" maxOccurs=\"1\" type=\"xs:string\"></xs:element> <xs:element name=\"body\" minOccurs=\"1\" maxOccurs=\"1\" type=\"xs:string\"></xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest" : {
"body" : {
"type" : "XML_SCHEMA",
"xmlSchema" : "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" elementFormDefault=\"qualified\" attributeFormDefault=\"unqualified\"> <xs:element name=\"notes\"> <xs:complexType> <xs:sequence> <xs:element name=\"note\" maxOccurs=\"unbounded\"> <xs:complexType> <xs:sequence> <xs:element name=\"to\" minOccurs=\"1\" maxOccurs=\"1\" type=\"xs:string\"></xs:element> <xs:element name=\"from\" minOccurs=\"1\" maxOccurs=\"1\" type=\"xs:string\"></xs:element> <xs:element name=\"heading\" minOccurs=\"1\" maxOccurs=\"1\" type=\"xs:string\"></xs:element> <xs:element name=\"body\" minOccurs=\"1\" maxOccurs=\"1\" type=\"xs:string\"></xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
"httpRequest" : {
"body" : {
"type" : "XML_SCHEMA",
"xmlSchema" : "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" elementFormDefault=\"qualified\" attributeFormDefault=\"unqualified\"> <xs:element name=\"notes\"> <xs:complexType> <xs:sequence> <xs:element name=\"note\" maxOccurs=\"unbounded\"> <xs:complexType> <xs:sequence> <xs:element name=\"to\" minOccurs=\"1\" maxOccurs=\"1\" type=\"xs:string\"></xs:element> <xs:element name=\"from\" minOccurs=\"1\" maxOccurs=\"1\" type=\"xs:string\"></xs:element> <xs:element name=\"heading\" minOccurs=\"1\" maxOccurs=\"1\" type=\"xs:string\"></xs:element> <xs:element name=\"body\" minOccurs=\"1\" maxOccurs=\"1\" type=\"xs:string\"></xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest" : {
"body" : {
"type" : "XML_SCHEMA",
"xmlSchema" : "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" elementFormDefault=\"qualified\" attributeFormDefault=\"unqualified\"> <xs:element name=\"notes\"> <xs:complexType> <xs:sequence> <xs:element name=\"note\" maxOccurs=\"unbounded\"> <xs:complexType> <xs:sequence> <xs:element name=\"to\" minOccurs=\"1\" maxOccurs=\"1\" type=\"xs:string\"></xs:element> <xs:element name=\"from\" minOccurs=\"1\" maxOccurs=\"1\" type=\"xs:string\"></xs:element> <xs:element name=\"heading\" minOccurs=\"1\" maxOccurs=\"1\" type=\"xs:string\"></xs:element> <xs:element name=\"body\" minOccurs=\"1\" maxOccurs=\"1\" type=\"xs:string\"></xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest" : {
"body" : {
"type" : "XML_SCHEMA",
"xmlSchema" : "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" elementFormDefault=\"qualified\" attributeFormDefault=\"unqualified\"> <xs:element name=\"notes\"> <xs:complexType> <xs:sequence> <xs:element name=\"note\" maxOccurs=\"unbounded\"> <xs:complexType> <xs:sequence> <xs:element name=\"to\" minOccurs=\"1\" maxOccurs=\"1\" type=\"xs:string\"></xs:element> <xs:element name=\"from\" minOccurs=\"1\" maxOccurs=\"1\" type=\"xs:string\"></xs:element> <xs:element name=\"heading\" minOccurs=\"1\" maxOccurs=\"1\" type=\"xs:string\"></xs:element> <xs:element name=\"body\" minOccurs=\"1\" maxOccurs=\"1\" type=\"xs:string\"></xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest" : {
"body" : {
"type" : "XML_SCHEMA",
"xmlSchema" : "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" elementFormDefault=\"qualified\" attributeFormDefault=\"unqualified\"> <xs:element name=\"notes\"> <xs:complexType> <xs:sequence> <xs:element name=\"note\" maxOccurs=\"unbounded\"> <xs:complexType> <xs:sequence> <xs:element name=\"to\" minOccurs=\"1\" maxOccurs=\"1\" type=\"xs:string\"></xs:element> <xs:element name=\"from\" minOccurs=\"1\" maxOccurs=\"1\" type=\"xs:string\"></xs:element> <xs:element name=\"heading\" minOccurs=\"1\" maxOccurs=\"1\" type=\"xs:string\"></xs:element> <xs:element name=\"body\" minOccurs=\"1\" maxOccurs=\"1\" type=\"xs:string\"></xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.when(
request()
.withBody(
xmlSchemaFromResource("org/mockserver/examples/mockserver/testXmlSchema.xsd")
)
)
.respond(
response()
.withBody("some_response_body")
);
JSON body matcher supports two mode STRICT which matches all fields, order of arrays and no additional fields allowed, and ONLY_MATCHING_FIELDS which only matches fields provided in the request matcher.
When matching JSON arrays the number of elements in the array must always match, however if ONLY_MATCHING_FIELDS mode is specified only the fields in the each array element in the matcher will be matched against each corresponding object in the array.
new MockServerClient("localhost", 1080)
.when(
request()
.withBody(
json("{" + System.lineSeparator() +
" \"id\": 1," + System.lineSeparator() +
" \"name\": \"A green door\"," + System.lineSeparator() +
" \"price\": 12.50," + System.lineSeparator() +
" \"tags\": [\"home\", \"green\"]" + System.lineSeparator() +
"}",
MatchType.STRICT
)
)
)
.respond(
response()
.withStatusCode(HttpStatusCode.ACCEPTED_202.code())
.withBody("some_response_body")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"body": {
"type": "JSON",
"json": {
"id": 1,
"name": "A green door",
"price": 12.50,
"tags": ["home", "green"]
},
"matchType": "STRICT"
}
},
"httpResponse": {
"statusCode": 202,
"body": "some_response_body"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest": {
"body": {
"type": "JSON",
"json": {
"id": 1,
"name": "A green door",
"price": 12.50,
"tags": ["home", "green"]
},
"matchType": "STRICT"
}
},
"httpResponse": {
"statusCode": 202,
"body": "some_response_body"
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest": {
"body": {
"type": "JSON",
"json": {
"id": 1,
"name": "A green door",
"price": 12.50,
"tags": ["home", "green"]
},
"matchType": "STRICT"
}
},
"httpResponse": {
"statusCode": 202,
"body": "some_response_body"
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest": {
"body": {
"type": "JSON",
"json": {
"id": 1,
"name": "A green door",
"price": 12.50,
"tags": ["home", "green"]
},
"matchType": "STRICT"
}
},
"httpResponse": {
"statusCode": 202,
"body": "some_response_body"
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"": {
""body"": {
""type"": ""JSON"",
""json"": {
""id"": 1,
""name"": ""A green door"",
""price"": 12.50,
""tags"": [""home"", ""green""]
},
""matchType"": ""STRICT""
}
},
""httpResponse"": {
""statusCode"": 202,
""body"": ""some_response_body""
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest": {
"body": {
"type": "JSON",
"json": {
"id": 1,
"name": "A green door",
"price": 12.50,
"tags": ["home", "green"]
},
"matchType": "STRICT"
}
},
"httpResponse": {
"statusCode": 202,
"body": "some_response_body"
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest": {
"body": {
"type": "JSON",
"json": {
"id": 1,
"name": "A green door",
"price": 12.50,
"tags": ["home", "green"]
},
"matchType": "STRICT"
}
},
"httpResponse": {
"statusCode": 202,
"body": "some_response_body"
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"body": {
"type": "JSON",
"json": {
"id": 1,
"name": "A green door",
"price": 12.50,
"tags": ["home", "green"]
},
"matchType": "STRICT"
}
},
"httpResponse": {
"statusCode": 202,
"body": "some_response_body"
}
}'
See REST API for full JSON specification
JSON body matcher supports two mode STRICT which matches all fields, order of arrays and no additional fields allowed, and ONLY_MATCHING_FIELDS which only matches fields provided in the request matcher.
When matching JSON arrays the number of elements in the array must always match, however if ONLY_MATCHING_FIELDS mode is specified only the fields in the each array element in the matcher will be matched against each corresponding object in the array.
new MockServerClient("localhost", 1080)
.when(
request()
.withBody(
json("{" + System.lineSeparator() +
" \"id\": 1," + System.lineSeparator() +
" \"name\": \"A green door\"," + System.lineSeparator() +
" \"price\": 12.50," + System.lineSeparator() +
" \"tags\": [\"home\", \"green\"]" + System.lineSeparator() +
"}",
MatchType.ONLY_MATCHING_FIELDS
)
)
)
.respond(
response()
.withStatusCode(HttpStatusCode.ACCEPTED_202.code())
.withBody("some_response_body")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"body": {
"id": 1,
"name": "A green door",
"price": 12.50,
"tags": ["home", "green"]
}
},
"httpResponse": {
"statusCode": 202,
"body": "some_response_body"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest": {
"body": {
"id": 1,
"name": "A green door",
"price": 12.50,
"tags": ["home", "green"]
}
},
"httpResponse": {
"statusCode": 202,
"body": "some_response_body"
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest": {
"body": {
"id": 1,
"name": "A green door",
"price": 12.50,
"tags": ["home", "green"]
}
},
"httpResponse": {
"statusCode": 202,
"body": "some_response_body"
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest": {
"body": {
"id": 1,
"name": "A green door",
"price": 12.50,
"tags": ["home", "green"]
}
},
"httpResponse": {
"statusCode": 202,
"body": "some_response_body"
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"": {
""body"": {
""id"": 1,
""name"": ""A green door"",
""price"": 12.50,
""tags"": [""home"", ""green""]
}
},
""httpResponse"": {
""statusCode"": 202,
""body"": ""some_response_body""
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest": {
"body": {
"id": 1,
"name": "A green door",
"price": 12.50,
"tags": ["home", "green"]
}
},
"httpResponse": {
"statusCode": 202,
"body": "some_response_body"
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest": {
"body": {
"id": 1,
"name": "A green door",
"price": 12.50,
"tags": ["home", "green"]
}
},
"httpResponse": {
"statusCode": 202,
"body": "some_response_body"
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"body": {
"id": 1,
"name": "A green door",
"price": 12.50,
"tags": ["home", "green"]
}
},
"httpResponse": {
"statusCode": 202,
"body": "some_response_body"
}
}'
See REST API for full JSON specification
JSON body matcher supports two mode STRICT which matches all fields, order of arrays and no additional fields allowed, and ONLY_MATCHING_FIELDS which only matches fields provided in the request matcher.
When matching JSON arrays the number of elements in the array must always match, however if ONLY_MATCHING_FIELDS mode is specified only the fields in the each array element in the matcher will be matched against each corresponding object in the array.
new MockServerClient("localhost", 1080)
.when(
request()
.withBody(
json(
"{\"context\": [{\"source\": \"DECISION_REQUEST\"},{\"source\": \"DECISION_REQUEST\"},{\"source\": \"DECISION_REQUEST\"}]}",
MatchType.ONLY_MATCHING_FIELDS
)
)
)
.respond(
response()
.withStatusCode(HttpStatusCode.ACCEPTED_202.code())
.withBody("some_response_body")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"method": "POST",
"path": "/json",
"body": {
"type": "JSON",
"json": {
"context": [
{
"source": "DECISION_REQUEST"
},
{
"source": "DECISION_REQUEST"
},
{
"source": "DECISION_REQUEST"
}
]
},
"matchType": "ONLY_MATCHING_FIELDS"
}
},
"httpResponse": {
"statusCode": 200,
"body": "some response"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest": {
"method": "POST",
"path": "/json",
"body": {
"type": "JSON",
"json": {
"context": [
{
"source": "DECISION_REQUEST"
},
{
"source": "DECISION_REQUEST"
},
{
"source": "DECISION_REQUEST"
}
]
},
"matchType": "ONLY_MATCHING_FIELDS"
}
},
"httpResponse": {
"statusCode": 200,
"body": "some response"
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest": {
"method": "POST",
"path": "/json",
"body": {
"type": "JSON",
"json": {
"context": [
{
"source": "DECISION_REQUEST"
},
{
"source": "DECISION_REQUEST"
},
{
"source": "DECISION_REQUEST"
}
]
},
"matchType": "ONLY_MATCHING_FIELDS"
}
},
"httpResponse": {
"statusCode": 200,
"body": "some response"
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest": {
"method": "POST",
"path": "/json",
"body": {
"type": "JSON",
"json": {
"context": [
{
"source": "DECISION_REQUEST"
},
{
"source": "DECISION_REQUEST"
},
{
"source": "DECISION_REQUEST"
}
]
},
"matchType": "ONLY_MATCHING_FIELDS"
}
},
"httpResponse": {
"statusCode": 200,
"body": "some response"
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"": {
""method"": ""POST"",
""path"": ""/json"",
""body"": {
""type"": ""JSON"",
""json"": {
""context"": [
{
""source"": ""DECISION_REQUEST""
},
{
""source"": ""DECISION_REQUEST""
},
{
""source"": ""DECISION_REQUEST""
}
]
},
""matchType"": ""ONLY_MATCHING_FIELDS""
}
},
""httpResponse"": {
""statusCode"": 200,
""body"": ""some response""
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest": {
"method": "POST",
"path": "/json",
"body": {
"type": "JSON",
"json": {
"context": [
{
"source": "DECISION_REQUEST"
},
{
"source": "DECISION_REQUEST"
},
{
"source": "DECISION_REQUEST"
}
]
},
"matchType": "ONLY_MATCHING_FIELDS"
}
},
"httpResponse": {
"statusCode": 200,
"body": "some response"
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest": {
"method": "POST",
"path": "/json",
"body": {
"type": "JSON",
"json": {
"context": [
{
"source": "DECISION_REQUEST"
},
{
"source": "DECISION_REQUEST"
},
{
"source": "DECISION_REQUEST"
}
]
},
"matchType": "ONLY_MATCHING_FIELDS"
}
},
"httpResponse": {
"statusCode": 200,
"body": "some response"
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"method": "POST",
"path": "/json",
"body": {
"type": "JSON",
"json": {
"context": [
{
"source": "DECISION_REQUEST"
},
{
"source": "DECISION_REQUEST"
},
{
"source": "DECISION_REQUEST"
}
]
},
"matchType": "ONLY_MATCHING_FIELDS"
}
},
"httpResponse": {
"statusCode": 200,
"body": "some response"
}
}'
See REST API for full JSON specification
See JSONUnit documentation for full details of supported placeholders.
new MockServerClient("localhost", 1080)
.when(
request()
.withBody(
json("{" + System.lineSeparator() +
" \"id\": 1," + System.lineSeparator() +
" \"name\": \"A green door\"," + System.lineSeparator() +
" \"price\": \"${json-unit.ignore-element}\"," + System.lineSeparator() +
" \"enabled\": \"${json-unit.any-boolean}\"," + System.lineSeparator() +
" \"tags\": [\"home\", \"green\"]" + System.lineSeparator() +
"}",
MatchType.ONLY_MATCHING_FIELDS
)
)
)
.respond(
response()
.withStatusCode(HttpStatusCode.ACCEPTED_202.code())
.withBody("some_response_body")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest" : {
"body" : {
"type" : "JSON",
"json" : {
"id" : 1,
"name" : "A green door",
"price" : "${json-unit.ignore-element}",
"enabled" : "${json-unit.any-boolean}",
"tags" : [ "home", "green" ]
}
}
},
"httpResponse" : {
"statusCode" : 202,
"body" : "some_response_body"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest" : {
"body" : {
"type" : "JSON",
"json" : {
"id" : 1,
"name" : "A green door",
"price" : "${json-unit.ignore-element}",
"enabled" : "${json-unit.any-boolean}",
"tags" : [ "home", "green" ]
}
}
},
"httpResponse" : {
"statusCode" : 202,
"body" : "some_response_body"
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest" : {
"body" : {
"type" : "JSON",
"json" : {
"id" : 1,
"name" : "A green door",
"price" : "${json-unit.ignore-element}",
"enabled" : "${json-unit.any-boolean}",
"tags" : [ "home", "green" ]
}
}
},
"httpResponse" : {
"statusCode" : 202,
"body" : "some_response_body"
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest" : {
"body" : {
"type" : "JSON",
"json" : {
"id" : 1,
"name" : "A green door",
"price" : "${json-unit.ignore-element}",
"enabled" : "${json-unit.any-boolean}",
"tags" : [ "home", "green" ]
}
}
},
"httpResponse" : {
"statusCode" : 202,
"body" : "some_response_body"
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"" : {
""body"" : {
""type"" : ""JSON"",
""json"" : {
""id"" : 1,
""name"" : ""A green door"",
""price"" : ""${json-unit.ignore-element}"",
""enabled"" : ""${json-unit.any-boolean}"",
""tags"" : [ ""home"", ""green"" ]
}
}
},
""httpResponse"" : {
""statusCode"" : 202,
""body"" : ""some_response_body""
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest" : {
"body" : {
"type" : "JSON",
"json" : {
"id" : 1,
"name" : "A green door",
"price" : "${json-unit.ignore-element}",
"enabled" : "${json-unit.any-boolean}",
"tags" : [ "home", "green" ]
}
}
},
"httpResponse" : {
"statusCode" : 202,
"body" : "some_response_body"
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest" : {
"body" : {
"type" : "JSON",
"json" : {
"id" : 1,
"name" : "A green door",
"price" : "${json-unit.ignore-element}",
"enabled" : "${json-unit.any-boolean}",
"tags" : [ "home", "green" ]
}
}
},
"httpResponse" : {
"statusCode" : 202,
"body" : "some_response_body"
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest" : {
"body" : {
"type" : "JSON",
"json" : {
"id" : 1,
"name" : "A green door",
"price" : "${json-unit.ignore-element}",
"enabled" : "${json-unit.any-boolean}",
"tags" : [ "home", "green" ]
}
}
},
"httpResponse" : {
"statusCode" : 202,
"body" : "some_response_body"
}
}'
See REST API for full JSON specification
By default, JSON body matching treats 1 and 1.0 as different values because they have different numeric types (integer vs double). When matchNumbersAsStrings is set to true, numbers are compared by numeric value so 1, 1.0 and 1.00 are all considered equal. This is useful when different languages or serializers produce different numeric representations for the same value.
new MockServerClient("localhost", 1080)
.when(
request()
.withBody(
json("{" + System.lineSeparator() +
" \"id\": 1," + System.lineSeparator() +
" \"price\": 12.5" + System.lineSeparator() +
"}",
MatchType.ONLY_MATCHING_FIELDS,
true // matchNumbersAsStrings
)
)
)
.respond(
response()
.withStatusCode(HttpStatusCode.ACCEPTED_202.code())
.withBody("some_response_body")
);
This expectation will match requests containing {"id": 1.0, "price": 12.50} as well as {"id": 1, "price": 12.5}.
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest": {
"body": {
"type": "JSON",
"json": {
"id": 1,
"price": 12.5
},
"matchNumbersAsStrings": True
}
},
"httpResponse": {
"statusCode": 202,
"body": "some_response_body"
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest": {
"body": {
"type": "JSON",
"json": {
"id": 1,
"price": 12.5
},
"matchNumbersAsStrings": true
}
},
"httpResponse": {
"statusCode": 202,
"body": "some_response_body"
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest": {
"body": {
"type": "JSON",
"json": {
"id": 1,
"price": 12.5
},
"matchNumbersAsStrings": true
}
},
"httpResponse": {
"statusCode": 202,
"body": "some_response_body"
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"": {
""body"": {
""type"": ""JSON"",
""json"": {
""id"": 1,
""price"": 12.5
},
""matchNumbersAsStrings"": true
}
},
""httpResponse"": {
""statusCode"": 202,
""body"": ""some_response_body""
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest": {
"body": {
"type": "JSON",
"json": {
"id": 1,
"price": 12.5
},
"matchNumbersAsStrings": true
}
},
"httpResponse": {
"statusCode": 202,
"body": "some_response_body"
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest": {
"body": {
"type": "JSON",
"json": {
"id": 1,
"price": 12.5
},
"matchNumbersAsStrings": true
}
},
"httpResponse": {
"statusCode": 202,
"body": "some_response_body"
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"body": {
"type": "JSON",
"json": {
"id": 1,
"price": 12.5
},
"matchNumbersAsStrings": true
}
},
"httpResponse": {
"statusCode": 202,
"body": "some_response_body"
}
}'
See REST API for full JSON specification
For details of the full json schema supported please see json-schema.org.
new MockServerClient("localhost", 1080)
.when(
request()
.withBody(
jsonSchema("{" + System.lineSeparator() +
" \"$schema\": \"https://json-schema.org/draft-04/schema#\"," + System.lineSeparator() +
" \"title\": \"Product\"," + System.lineSeparator() +
" \"description\": \"A product from Acme catalog\"," + System.lineSeparator() +
" \"type\": \"object\"," + System.lineSeparator() +
" \"properties\": {" + System.lineSeparator() +
" \"id\": {" + System.lineSeparator() +
" \"description\": \"The unique identifier for a product\"," + System.lineSeparator() +
" \"type\": \"integer\"" + System.lineSeparator() +
" }," + System.lineSeparator() +
" \"name\": {" + System.lineSeparator() +
" \"description\": \"Name of the product\"," + System.lineSeparator() +
" \"type\": \"string\"" + System.lineSeparator() +
" }," + System.lineSeparator() +
" \"price\": {" + System.lineSeparator() +
" \"type\": \"number\"," + System.lineSeparator() +
" \"minimum\": 0," + System.lineSeparator() +
" \"exclusiveMinimum\": true" + System.lineSeparator() +
" }," + System.lineSeparator() +
" \"tags\": {" + System.lineSeparator() +
" \"type\": \"array\"," + System.lineSeparator() +
" \"items\": {" + System.lineSeparator() +
" \"type\": \"string\"" + System.lineSeparator() +
" }," + System.lineSeparator() +
" \"minItems\": 1," + System.lineSeparator() +
" \"uniqueItems\": true" + System.lineSeparator() +
" }" + System.lineSeparator() +
" }," + System.lineSeparator() +
" \"required\": [\"id\", \"name\", \"price\"]" + System.lineSeparator() +
"}"))
)
.respond(
response()
.withBody("some_response_body")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"body": {
"type": "JSON_SCHEMA",
"jsonSchema": {
"$schema": "https://json-schema.org/draft-04/schema#",
"title": "Product",
"description": "A product from Acme catalog",
"type": "object",
"properties": {
"id": {
"description": "The unique identifier for a product",
"type": "integer"
},
"name": {
"description": "Name of the product",
"type": "string"
},
"price": {
"type": "number",
"minimum": 0,
"exclusiveMinimum": true
},
"tags": {
"type": "array",
"items": {
"type": "string"
},
"minItems": 1,
"uniqueItems": true
}
},
"required": [
"id",
"name",
"price"
]
}
}
},
"httpResponse": {
"body": "some_response_body"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest": {
"body": {
"type": "JSON_SCHEMA",
"jsonSchema": {
"$schema": "https://json-schema.org/draft-04/schema#",
"title": "Product",
"description": "A product from Acme catalog",
"type": "object",
"properties": {
"id": {
"description": "The unique identifier for a product",
"type": "integer"
},
"name": {
"description": "Name of the product",
"type": "string"
},
"price": {
"type": "number",
"minimum": 0,
"exclusiveMinimum": True
},
"tags": {
"type": "array",
"items": {
"type": "string"
},
"minItems": 1,
"uniqueItems": True
}
},
"required": [
"id",
"name",
"price"
]
}
}
},
"httpResponse": {
"body": "some_response_body"
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest": {
"body": {
"type": "JSON_SCHEMA",
"jsonSchema": {
"$schema": "https://json-schema.org/draft-04/schema#",
"title": "Product",
"description": "A product from Acme catalog",
"type": "object",
"properties": {
"id": {
"description": "The unique identifier for a product",
"type": "integer"
},
"name": {
"description": "Name of the product",
"type": "string"
},
"price": {
"type": "number",
"minimum": 0,
"exclusiveMinimum": true
},
"tags": {
"type": "array",
"items": {
"type": "string"
},
"minItems": 1,
"uniqueItems": true
}
},
"required": [
"id",
"name",
"price"
]
}
}
},
"httpResponse": {
"body": "some_response_body"
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest": {
"body": {
"type": "JSON_SCHEMA",
"jsonSchema": {
"$schema": "https://json-schema.org/draft-04/schema#",
"title": "Product",
"description": "A product from Acme catalog",
"type": "object",
"properties": {
"id": {
"description": "The unique identifier for a product",
"type": "integer"
},
"name": {
"description": "Name of the product",
"type": "string"
},
"price": {
"type": "number",
"minimum": 0,
"exclusiveMinimum": true
},
"tags": {
"type": "array",
"items": {
"type": "string"
},
"minItems": 1,
"uniqueItems": true
}
},
"required": [
"id",
"name",
"price"
]
}
}
},
"httpResponse": {
"body": "some_response_body"
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"": {
""body"": {
""type"": ""JSON_SCHEMA"",
""jsonSchema"": {
""$schema"": ""https://json-schema.org/draft-04/schema#"",
""title"": ""Product"",
""description"": ""A product from Acme catalog"",
""type"": ""object"",
""properties"": {
""id"": {
""description"": ""The unique identifier for a product"",
""type"": ""integer""
},
""name"": {
""description"": ""Name of the product"",
""type"": ""string""
},
""price"": {
""type"": ""number"",
""minimum"": 0,
""exclusiveMinimum"": true
},
""tags"": {
""type"": ""array"",
""items"": {
""type"": ""string""
},
""minItems"": 1,
""uniqueItems"": true
}
},
""required"": [
""id"",
""name"",
""price""
]
}
}
},
""httpResponse"": {
""body"": ""some_response_body""
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest": {
"body": {
"type": "JSON_SCHEMA",
"jsonSchema": {
"$schema": "https://json-schema.org/draft-04/schema#",
"title": "Product",
"description": "A product from Acme catalog",
"type": "object",
"properties": {
"id": {
"description": "The unique identifier for a product",
"type": "integer"
},
"name": {
"description": "Name of the product",
"type": "string"
},
"price": {
"type": "number",
"minimum": 0,
"exclusiveMinimum": true
},
"tags": {
"type": "array",
"items": {
"type": "string"
},
"minItems": 1,
"uniqueItems": true
}
},
"required": [
"id",
"name",
"price"
]
}
}
},
"httpResponse": {
"body": "some_response_body"
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest": {
"body": {
"type": "JSON_SCHEMA",
"jsonSchema": {
"$schema": "https://json-schema.org/draft-04/schema#",
"title": "Product",
"description": "A product from Acme catalog",
"type": "object",
"properties": {
"id": {
"description": "The unique identifier for a product",
"type": "integer"
},
"name": {
"description": "Name of the product",
"type": "string"
},
"price": {
"type": "number",
"minimum": 0,
"exclusiveMinimum": true
},
"tags": {
"type": "array",
"items": {
"type": "string"
},
"minItems": 1,
"uniqueItems": true
}
},
"required": [
"id",
"name",
"price"
]
}
}
},
"httpResponse": {
"body": "some_response_body"
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"body": {
"type": "JSON_SCHEMA",
"jsonSchema": {
"$schema": "https://json-schema.org/draft-04/schema#",
"title": "Product",
"description": "A product from Acme catalog",
"type": "object",
"properties": {
"id": {
"description": "The unique identifier for a product",
"type": "integer"
},
"name": {
"description": "Name of the product",
"type": "string"
},
"price": {
"type": "number",
"minimum": 0,
"exclusiveMinimum": true
},
"tags": {
"type": "array",
"items": {
"type": "string"
},
"minItems": 1,
"uniqueItems": true
}
},
"required": [
"id",
"name",
"price"
]
}
}
},
"httpResponse": {
"body": "some_response_body"
}
}'
See REST API for full JSON specification
Matches if at least one value is returned by the JsonPath expression. For details of the full JsonPath supported please see github.com/json-path/JsonPath.
new MockServerClient("localhost", 1080)
.when(
request()
.withBody(
// matches any request with an JSON body that contain
// one or more fields that match the JsonPath expression
jsonPath("$.store.book[?(@.price < 10)]")
)
)
.respond(
response()
.withBody("some_response_body")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"body": {
// matches any request with an JSON body that contain
// one or more fields that match the JsonPath expression
"type": "JSON_PATH",
"jsonPath": "$.store.book[?(@.price < 10)]"
}
},
"httpResponse": {
"body": "some_response_body"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest" : {
"body" : {
"type": "JSON_PATH",
"jsonPath": "$.store.book[?(@.price < 10)]"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest" : {
"body" : {
"type": "JSON_PATH",
"jsonPath": "$.store.book[?(@.price < 10)]"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest" : {
"body" : {
"type": "JSON_PATH",
"jsonPath": "$.store.book[?(@.price < 10)]"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"" : {
""body"" : {
""type"": ""JSON_PATH"",
""jsonPath"": ""$.store.book[?(@.price < 10)]""
}
},
""httpResponse"" : {
""body"" : ""some_response_body""
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest" : {
"body" : {
"type": "JSON_PATH",
"jsonPath": "$.store.book[?(@.price < 10)]"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest" : {
"body" : {
"type": "JSON_PATH",
"jsonPath": "$.store.book[?(@.price < 10)]"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest" : {
"body" : {
"type": "JSON_PATH",
"jsonPath": "$.store.book[?(@.price < 10)]"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}'
See REST API for full JSON specification
Matches if at least one value is returned by the JsonPath expression. For details of the full JsonPath supported please see github.com/json-path/JsonPath.
new MockServerClient("localhost", 1080)
.when(
request()
.withBody(
// matches any request with an JSON body that does NOT contain
// one or more fields that match the JsonPath expression
not(jsonPath("$.store.book[?(@.price < 10)]"))
)
)
.respond(
response()
.withBody("some_response_body")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"body": {
// matches any request with an JSON body that does NOT contain
// one or more fields that match the JsonPath expression
"not": true,
"type": "JSON_PATH",
"jsonPath": "$.store.book[?(@.price < 10)]"
}
},
"httpResponse": {
"body": "some_response_body"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest" : {
"body" : {
"not": True,
"type": "JSON_PATH",
"jsonPath": "$.store.book[?(@.price < 10)]"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest" : {
"body" : {
"not": true,
"type": "JSON_PATH",
"jsonPath": "$.store.book[?(@.price < 10)]"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest" : {
"body" : {
"not": true,
"type": "JSON_PATH",
"jsonPath": "$.store.book[?(@.price < 10)]"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"" : {
""body"" : {
""not"": true,
""type"": ""JSON_PATH"",
""jsonPath"": ""$.store.book[?(@.price < 10)]""
}
},
""httpResponse"" : {
""body"" : ""some_response_body""
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest" : {
"body" : {
"not": true,
"type": "JSON_PATH",
"jsonPath": "$.store.book[?(@.price < 10)]"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest" : {
"body" : {
"not": true,
"type": "JSON_PATH",
"jsonPath": "$.store.book[?(@.price < 10)]"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest" : {
"body" : {
"not": true,
"type": "JSON_PATH",
"jsonPath": "$.store.book[?(@.price < 10)]"
}
},
"httpResponse" : {
"body" : "some_response_body"
}
}'
See REST API for full JSON specification
byte[] pngBytes = IOUtils.toByteArray(getClass().getClassLoader().getResourceAsStream("org/mockserver/examples/mockserver/test.png"));
new MockServerClient("localhost", 1080)
.when(
request()
.withMethod("POST")
.withHeaders(
header("content-type", "image/png"),
header("content-disposition", "form-data; name=\"test.png\"; filename=\"test.png\"")
)
.withBody(binary(pngBytes))
)
.respond(
response()
.withBody("png_saved_response")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"method": "POST"
"headers": {
"content-type": ["image/png"],
"content-disposition": ["form-data; name=\"test.png\"; filename=\"test.png\""]
},
"body": {
"type": "BINARY",
"base64Bytes": "iVBORw0KGgoAAAANSUhEUgAAAqwAAAApCAIAAAB/QuwlAAAK+GlDQ1BJQ0MgUHJvZmlsZQAASA2tl3dcU8kWx+fe9EYLICAl9CZ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then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest": {
"method": "POST"
"headers": {
"content-type": ["image/png"],
"content-disposition": ["form-data; name=\"test.png\"; filename=\"test.png\""]
},
"body": {
"type": "BINARY",
"base64Bytes": "iVBORw0KGgoAAAANSUhEUgAAAqwAAAApCAIAAAB/QuwlAAAK+GlDQ1BJQ0MgUHJvZmlsZQAASA2tl3dcU8kWx+fe9EYLICAl9CZIr9JrAAXpYCMkgYQSYgoCVpTFFVwLKiKgrugiiIJrAWQtiAULoljAvkEWFXVdLIiKypvAEvfzPm//e5PP3Pne35w598zcmXzOBYBGZQmFWagKANkCiSg6xJ+RmJTMIDwGWKAF8EAf2LHYYqFfVFQE+NfyoRcg8s5bNnJf/2r2vztUOVwxGwAkCnancsTsbMjHYH3PFookAGDqoG68RCKUcxdkdREMELJMzumT/F7OqROMJU7YxEYHAIDVBYBIZbFE6QBQLaDOyGWnQz/UUMh2Ag5fADkPsjebx+JAboU8Izs7R85/QLZI/Yef9H8wi5Wq8MlipSt4ci5wJHxwIF8szGLlT9z8Py/ZWVK4XhPFEF6pPFFoNGwT4ZpVZ+aEK1iQOidySufDGU0xTxoaN8VscQBcy8mxHFZg+BRLM+P8ppglgvS3DV/CjJ1iUU60wr8ga458f0zEwOMyFcwVB8VM6Wn8YOYUF/BiE6Y4lx8/Z4rFmTGKGAp4AQpdJI1WxJwmClbMMVsMR/79XDbr+7MkvFj5O56Ih8MNDJpiriBOEY9Q4q/wI8ya2N8T9tysEIUuzo1RjJWIYhV6BitMvl8n7IWSKMWagEDAB2IgBFmABfIBAyyB9xLAg5QGcoAIsAEXcOBdNAgB/rDNhioHagxgAYLgaCasDKjlQk0Ef/yJXksJNw/uWwACcoT5In46T8LwgyeNy2AK2LYzGA529k4wGHhu5TYAvLs7cR4RTeJ3bYcDAEFVcI9w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3BbHsTdDAztG0WAIkARoAhQBO52BKgTcLePMO0fRYAiQBGgCFAE3CBAnQA3wNBiigBFgCJAEaAI3O0IUCfgbh9h2j+KAEWAIkARoAi4QYA6AW6AocUUAYoARYAiQBG42xGgTsDdPsK0fxQBigBFgCJAEXCDAHUC3ABDiykCFAGKAEWAInC3I0CdgLt9hGn/KAIUAYoARYAi4AYB6gS4AYYWUwQoAhQBigBF4G5HgDoBd/sI0/5RBCgCFAGKAEXADQL/D4BaqFLDMQVOAAAAAElFTkSuQmCC"
}
},
"httpResponse" : {
"body" : "png_saved_response"
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest": {
"method": "POST"
"headers": {
"content-type": ["image/png"],
"content-disposition": ["form-data; name=\"test.png\"; filename=\"test.png\""]
},
"body": {
"type": "BINARY",
"base64Bytes": "iVBORw0KGgoAAAANSUhEUgAAAqwAAAApCAIAAAB/QuwlAAAK+GlDQ1BJQ0MgUHJvZmlsZQAASA2tl3dcU8kWx+fe9EYLICAl9CZIr9JrAAXpYCMkgYQSYgoCVpTFFVwLKiKgrugiiIJrAWQtiAULoljAvkEWFXVdLIiKypvAEvfzPm//e5PP3Pne35w598zcmXzOBYBGZQmFWagKANkCiSg6xJ+RmJTMIDwGWKAF8EAf2LHYYqFfVFQE+NfyoRcg8s5bNnJf/2r2vztUOVwxGwAkCnancsTsbMjHYH3PFookAGDqoG68RCKUcxdkdREMELJMzumT/F7OqROMJU7YxEYHAIDVBYBIZbFE6QBQLaDOyGWnQz/UUMh2Ag5fADkPsjebx+JAboU8Izs7R85/QLZI/Yef9H8wi5Wq8MlipSt4ci5wJHxwIF8szGLlT9z8Py/ZWVK4XhPFEF6pPFFoNGwT4ZpVZ+aEK1iQOidySufDGU0xTxoaN8VscQBcy8mxHFZg+BRLM+P8ppglgvS3DV/CjJ1iUU60wr8ga458f0zEwOMyFcwVB8VM6Wn8YOYUF/BiE6Y4lx8/Z4rFmTG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8D4gpMQ/34YHAPz9P/zwQySHpr5G4Nem5gvXrI9ETfxHyuMjwJ39180mQ2PgrPHR0xxOXHvWrM9jC4NH9G+t/clUfd78y0ivCEXIB5uenzWKe1O9Z1IoFUWAIkAR6AME/mWpvVDf+dB9yg/m/ft0dLLZdv264eqAxxSPBN/nyUMzrIp07PhnZvVvvXa95nx7g8HmHxEQ8x9PJakm0EMAkZH6ta7q+2teMx5//auchEektxXlRx8HiOBMqygCFAGKAEWAInA3I3BbHsTdDAztG0WAIkARoAhQBO52BKgTcLePMO0fRYAiQBGgCFAE3CBAnQA3wNBiigBFgCJAEaAI3O0IUCfgbh9h2j+KAEWAIkARoAi4QYA6AW6AocUUAYoARYAiQBG42xGgTsDdPsK0fxQBigBFgCJAEXCDAHUC3ABDiykCFAGKAEWAInC3I0CdgLt9hGn/KAIUAYoARYAi4AYB6gS4AYYWUwQoAhQBigBF4G5HgDoBd/sI0/5RBCgCFAGKAEXADQL/D4BaqFLDMQVOAAAAAElFTkSuQmCC"
}
},
"httpResponse" : {
"body" : "png_saved_response"
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest": {
"method": "POST"
"headers": {
"content-type": ["image/png"],
"content-disposition": ["form-data; name=\"test.png\"; filename=\"test.png\""]
},
"body": {
"type": "BINARY",
"base64Bytes": "iVBORw0KGgoAAAANSUhEUgAAAqwAAAApCAIAAAB/QuwlAAAK+GlDQ1BJQ0MgUHJvZmlsZQAASA2tl3dcU8kWx+fe9EYLICAl9CZIr9JrAAXpYCMkgYQSYgoCVpTFFVwLKiKgrugiiIJrAWQtiAULoljAvkEWFXVdLIiKypvAEvfzPm//e5PP3Pne35w598zcmXzOBYBGZQmFWagKANkCiSg6xJ+RmJTMIDwGWKAF8EAf2LHYYqFfVFQE+NfyoRcg8s5bNnJf/2r2vztUOVwxGwAkCnancsTsbMjHYH3PFookAGDqoG68RCKUcxdkdREMELJMzumT/F7OqROMJU7YxEYHAIDVBYBIZbFE6QBQLa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XmGeWK1Yu3AM8N44X7jgueJWhll5XKV4kLsR8lDoXU8O/wQXfmZj119Gx6Yx8JNBKwUv1nrad7qDeIpYT+nPb/v6z5+h9/4gWAyhbGPa4RMGzvPkOyX8jyMvZlxpejV8A8QNtn/fgt64YXw+XyGj4+c5nJSDIkARuD0E2i4vCs3BqxAzwIsckPVmZcNKeMs/Cd76ek1+QvbUFL+IEGvx92jZDHoj+lnqAbgfJf0W+dSl8D4gpMQ/34YHAPz9P/zwQySHpr5G4Nem5gvXrI9ETfxHyuMjwJ39180mQ2PgrPHR0xxOXHvWrM9jC4NH9G+t/clUfd78y0ivCEXIB5uenzWKe1O9Z1IoFUWAIkAR6AME/mWpvVDf+dB9yg/m/ft0dLLZdv264eqAxxSPBN/nyUMzrIp07PhnZvVvvXa95nx7g8HmHxEQ8x9PJakm0EMAkZH6ta7q+2teMx5//auchEektxXlRx8HiOBMqygCFAGKAEWAInA3I3BbHsTdDAztG0WAIkARoAhQBO52BKgTcLePMO0fRYAiQBGgCFAE3CBAnQA3wNBiigBFgCJAEaAI3O0IUCfgbh9h2j+KAEWAIkARoAi4QYA6AW6AocUUAYoARYAiQBG42xGgTsDdPsK0fxQBigBFgCJAEXCDAHUC3ABDiykCFAGKAEWAInC3I0CdgLt9hGn/KAIUAYoARYAi4AYB6gS4AYYWUwQoAhQBigBF4G5HgDoBd/sI0/5RBCgCFAGKAEXADQL/D4BaqFLDMQVOAAAAAElFTkSuQmCC"
}
},
"httpResponse" : {
"body" : "png_saved_response"
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"": {
""method"": ""POST""
""headers"": {
""content-type"": [""image/png""],
""content-disposition"": [""form-data; name=\""test.png\""; filename=\""test.png\""""]
},
""body"": {
""type"": ""BINARY"",
""base64Bytes"": ""iVBORw0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G5HgDoBd/sI0/5RBCgCFAGKAEXADQL/D4BaqFLDMQVOAAAAAElFTkSuQmCC""
}
},
""httpResponse"" : {
""body"" : ""png_saved_response""
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest": {
"method": "POST"
"headers": {
"content-type": ["image/png"],
"content-disposition": ["form-data; name=\"test.png\"; filename=\"test.png\""]
},
"body": {
"type": "BINARY",
"base64Bytes": "iVBORw0KGgoAAAANSUhEUgAAAqwAAAApCAIAAAB/QuwlAAAK+GlDQ1BJQ0MgUHJvZmlsZQAASA2tl3dcU8kWx+fe9EYLICAl9CZIr9JrAAXpYCMkgYQSYgoCVpTFFVwLKiKgrugiiIJrAWQtiAULoljAvkEWFXVdLIiKypvAEvfzPm//e5PP3Pne35w598zcmXzOBYBGZQmFWagKANkCiSg6xJ+RmJTMIDwGWKAF8EAf2LHYYqFfVFQE+NfyoRcg8s5bNnJf/2r2vztUOVwxGwAkCnancsTsbMjHYH3PFookAGDqoG68RCKUcxdkdREMELJMzumT/F7OqROMJU7YxEYHAIDVBYBIZbFE6QBQLaDOyGWnQz/UUMh2Ag5fADkPsjebx+JAboU8Izs7R85/QLZI/Yef9H8wi5Wq8MlipSt4ci5wJHxwIF8szGLlT9z8Py/ZWVK4XhPFEF6pPFFoNGwT4ZpVZ+aEK1iQOidySufDGU0xTxoaN8VscQBcy8mxHFZg+BRLM+P8ppglgvS3DV/CjJ1iUU60wr8ga458f0zEwOMyFcwVB8VM6Wn8YOYUF/BiE6Y4lx8/Z4rFmTGKGAp4AQpdJI1WxJwmClbMMVsMR/79XDbr+7MkvFj5O56Ih8MNDJpiriBOEY9Q4q/wI8ya2N8T9tysEIUuzo1RjJWIYhV6BitMvl8n7IWSKMWagEDAB2IgBFmABfIBAyyB9xLAg5QGcoAIsAEXcOBdNAgB/rDNhioHagxgAYLgaCasDKjlQk0Ef/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vvXa95nx7g8HmHxEQ8x9PJakm0EMAkZH6ta7q+2teMx5//auchEektxXlRx8HiOBMqygCFAGKAEWAInA3I3BbHsTdDAztG0WAIkARoAhQBO52BKgTcLePMO0fRYAiQBGgCFAE3CBAnQA3wNBiigBFgCJAEaAI3O0IUCfgbh9h2j+KAEWAIkARoAi4QYA6AW6AocUUAYoARYAiQBG42xGgTsDdPsK0fxQBigBFgCJAEXCDAHUC3ABDiykCFAGKAEWAInC3I0CdgLt9hGn/KAIUAYoARYAi4AYB6gS4AYYWUwQoAhQBigBF4G5HgDoBd/sI0/5RBCgCFAGKAEXADQL/D4BaqFLDMQVOAAAAAElFTkSuQmCC"
}
},
"httpResponse" : {
"body" : "png_saved_response"
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest": {
"method": "POST"
"headers": {
"content-type": ["image/png"],
"content-disposition": ["form-data; name=\"test.png\"; filename=\"test.png\""]
},
"body": {
"type": "BINARY",
"base64Bytes": "iVBORw0KGgoAAAANSUhEUgAAAqwAAAApCAIAAAB/QuwlAAAK+GlDQ1BJQ0MgUHJvZmlsZQAASA2tl3dcU8kWx+fe9EYLICAl9CZIr9JrAAXpYCMkgYQSYgoCVpTFFVwLKiKgrugiiIJrAWQtiAULoljAvkEWFXVdLIiKypvAEvfzPm//e5PP3Pne35w598zcmXzOBYBGZQmFWagKANkCiSg6xJ+RmJTMIDwGWKAF8EAf2LHYYqFfVFQE+NfyoRcg8s5bNnJf/2r2vztUOVwxGwAkCnancsTsbMjHYH3PFookAGDqoG68RCKUcxdkdREMELJMzumT/F7OqROMJU7YxEYHAIDVBYBIZbFE6QBQLaDOyGWnQz/UUMh2Ag5fADkPsjebx+JAboU8Izs7R85/QLZI/Yef9H8wi5Wq8MlipSt4ci5wJHxwIF8szGLlT9z8Py/ZWVK4XhPFEF6pPFFoNGwT4ZpVZ+aEK1iQOidySufDGU0xTxoa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64YXw+XyGj4+c5nJSDIkARuD0E2i4vCs3BqxAzwIsckPVmZcNKeMs/Cd76ek1+QvbUFL+IEGvx92jZDHoj+lnqAbgfJf0W+dSl8D4gpMQ/34YHAPz9P/zwQySHpr5G4Nem5gvXrI9ETfxHyuMjwJ39180mQ2PgrPHR0xxOXHvWrM9jC4NH9G+t/clUfd78y0ivCEXIB5uenzWKe1O9Z1IoFUWAIkAR6AME/mWpvVDf+dB9yg/m/ft0dLLZdv264eqAxxSPBN/nyUMzrIp07PhnZvVvvXa95nx7g8HmHxEQ8x9PJakm0EMAkZH6ta7q+2teMx5//auchEektxXlRx8HiOBMqygCFAGKAEWAInA3I3BbHsTdDAztG0WAIkARoAhQBO52BKgTcLePMO0fRYAiQBGgCFAE3CBAnQA3wNBiigBFgCJAEaAI3O0IUCfgbh9h2j+KAEWAIkARoAi4QYA6AW6AocUUAYoARYAiQBG42xGgTsDdPsK0fxQBigBFgCJAEXCDAHUC3ABDiykCFAGKAEWAInC3I0CdgLt9hGn/KAIUAYoARYAi4AYB6gS4AYYWUwQoAhQBigBF4G5HgDoBd/sI0/5RBCgCFAGKAEXADQL/D4BaqFLDMQVOAAAAAElFTkSuQmCC"
}
},
"httpResponse" : {
"body" : "png_saved_response"
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"method": "POST"
"headers": {
"content-type": ["image/png"],
"content-disposition": ["form-data; name=\"test.png\"; filename=\"test.png\""]
},
"body": {
"type": "BINARY",
"base64Bytes": "iVBORw0KGgoAAAANSUhEUgAAAqwAAAApCAIAAAB/QuwlAAAK+GlDQ1BJQ0MgUHJvZmlsZQAASA2t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se" : {
"body" : "png_saved_response"
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.upsert(
new Expectation(
request().withPath("/some/path"),
Times.once(),
TimeToLive.exactly(TimeUnit.SECONDS, 60L),
100
)
.withId("some_unique_id")
.thenRespond(response().withBody("some_response_body"))
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"id": "some_unique_id",
"httpRequest": {
"path": "/some/path"
},
"httpResponse": {
"body": "some_response_body"
},
"times": {
"remainingTimes": 1,
"unlimited": false
},
"timeToLive": {
"timeUnit": "SECONDS",
"timeToLive": 60,
"unlimited": false
},
"priority" : 100
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"id": "some_unique_id",
"httpRequest" : {
"path" : "/some/path"
},
"httpResponse" : {
"body" : "some_response_body"
},
"times" : {
"remainingTimes" : 1,
"unlimited" : False
},
"timeToLive" : {
"timeUnit" : "SECONDS",
"timeToLive" : 60,
"unlimited" : False
},
"priority" : 100
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"id": "some_unique_id",
"httpRequest" : {
"path" : "/some/path"
},
"httpResponse" : {
"body" : "some_response_body"
},
"times" : {
"remainingTimes" : 1,
"unlimited" : false
},
"timeToLive" : {
"timeUnit" : "SECONDS",
"timeToLive" : 60,
"unlimited" : false
},
"priority" : 100
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"id": "some_unique_id",
"httpRequest" : {
"path" : "/some/path"
},
"httpResponse" : {
"body" : "some_response_body"
},
"times" : {
"remainingTimes" : 1,
"unlimited" : false
},
"timeToLive" : {
"timeUnit" : "SECONDS",
"timeToLive" : 60,
"unlimited" : false
},
"priority" : 100
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""id"": ""some_unique_id"",
""httpRequest"" : {
""path"" : ""/some/path""
},
""httpResponse"" : {
""body"" : ""some_response_body""
},
""times"" : {
""remainingTimes"" : 1,
""unlimited"" : false
},
""timeToLive"" : {
""timeUnit"" : ""SECONDS"",
""timeToLive"" : 60,
""unlimited"" : false
},
""priority"" : 100
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"id": "some_unique_id",
"httpRequest" : {
"path" : "/some/path"
},
"httpResponse" : {
"body" : "some_response_body"
},
"times" : {
"remainingTimes" : 1,
"unlimited" : false
},
"timeToLive" : {
"timeUnit" : "SECONDS",
"timeToLive" : 60,
"unlimited" : false
},
"priority" : 100
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"id": "some_unique_id",
"httpRequest" : {
"path" : "/some/path"
},
"httpResponse" : {
"body" : "some_response_body"
},
"times" : {
"remainingTimes" : 1,
"unlimited" : false
},
"timeToLive" : {
"timeUnit" : "SECONDS",
"timeToLive" : 60,
"unlimited" : false
},
"priority" : 100
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"id": "some_unique_id",
"httpRequest" : {
"path" : "/some/path"
},
"httpResponse" : {
"body" : "some_response_body"
},
"times" : {
"remainingTimes" : 1,
"unlimited" : false
},
"timeToLive" : {
"timeUnit" : "SECONDS",
"timeToLive" : 60,
"unlimited" : false
},
"priority" : 100
}'
See REST API for full JSON specification
An open api request matcher can contain any of the following fields:
- specUrlOrPayload - mandatory value containing an OpenAPI v3 specifications in either JSON or YAML format as an:
- HTTP/HTTPS URL
- File URL
- classpath location (without the classpath: scheme)
- inline JSON object
- inline escaped YAML string
- operationId - optional value that specifies which operation to match against, if empty or null all operations are matched against
MockServer creates a set of request properties matchers for each open api request matcher, to ensures control-plane logic such as clearing expectations or retrieving expectations work consistently between the two types of request matchers, this can be viewed in the MockServer UI active expectations section.
The following code examples show how to match request using an Open API specification. For more examples see the code examples folder in the git repository.
For brevity static imports have not been included in the Java code examples so please add the following static imports if copying this code
import static org.mockserver.model.HttpRequest.request;
import static org.mockserver.model.HttpResponse.response;
new MockServerClient("localhost", 1080)
.when(
openAPI(
"https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json"
)
)
.respond(
response()
.withBody("some_response_body")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"specUrlOrPayload": "https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json"
},
"httpResponse": {
"body": "some_response_body"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest": {
"specUrlOrPayload": "https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json"
},
"httpResponse": {
"body": "some_response_body"
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest": {
"specUrlOrPayload": "https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json"
},
"httpResponse": {
"body": "some_response_body"
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest": {
"specUrlOrPayload": "https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json"
},
"httpResponse": {
"body": "some_response_body"
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"": {
""specUrlOrPayload"": ""https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json""
},
""httpResponse"": {
""body"": ""some_response_body""
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest": {
"specUrlOrPayload": "https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json"
},
"httpResponse": {
"body": "some_response_body"
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
// OpenAPI matchers are not supported in the PHP client;
// use the REST API directly
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => json_encode([[
'httpRequest' => [
'specUrlOrPayload' => 'https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json',
],
'httpResponse' => ['body' => 'some_response_body'],
]]),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"specUrlOrPayload": "https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json"
},
"httpResponse": {
"body": "some_response_body"
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.when(
openAPI(
"https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json",
"showPetById"
)
)
.respond(
response()
.withBody("some_response_body")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"specUrlOrPayload": "https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json",
"operationId": "showPetById"
},
"httpResponse": {
"body": "some_response_body"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest": {
"specUrlOrPayload": "https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json",
"operationId": "showPetById"
},
"httpResponse": {
"body": "some_response_body"
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest": {
"specUrlOrPayload": "https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json",
"operationId": "showPetById"
},
"httpResponse": {
"body": "some_response_body"
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest": {
"specUrlOrPayload": "https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json",
"operationId": "showPetById"
},
"httpResponse": {
"body": "some_response_body"
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"": {
""specUrlOrPayload"": ""https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json"",
""operationId"": ""showPetById""
},
""httpResponse"": {
""body"": ""some_response_body""
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest": {
"specUrlOrPayload": "https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json",
"operationId": "showPetById"
},
"httpResponse": {
"body": "some_response_body"
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
// OpenAPI matchers are not supported in the PHP client;
// use the REST API directly
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => json_encode([[
'httpRequest' => [
'specUrlOrPayload' => 'https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json',
'operationId' => 'showPetById',
],
'httpResponse' => ['body' => 'some_response_body'],
]]),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"specUrlOrPayload": "https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json",
"operationId": "showPetById"
},
"httpResponse": {
"body": "some_response_body"
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.when(
openAPI(
"file:/Users/jamesbloom/git/mockserver/mockserver/mockserver-core/target/test-classes/org/mockserver/openapi/openapi_petstore_example.json"
)
)
.respond(
response()
.withBody("some_response_body")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"specUrlOrPayload": "file:/Users/jamesbloom/git/mockserver/mockserver/mockserver-core/target/test-classes/org/mockserver/openapi/openapi_petstore_example.json"
},
"httpResponse": {
"body": "some_response_body"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest": {
"specUrlOrPayload": "file:/Users/jamesbloom/git/mockserver/mockserver/mockserver-core/target/test-classes/org/mockserver/openapi/openapi_petstore_example.json"
},
"httpResponse": {
"body": "some_response_body"
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest": {
"specUrlOrPayload": "file:/Users/jamesbloom/git/mockserver/mockserver/mockserver-core/target/test-classes/org/mockserver/openapi/openapi_petstore_example.json"
},
"httpResponse": {
"body": "some_response_body"
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest": {
"specUrlOrPayload": "file:/Users/jamesbloom/git/mockserver/mockserver/mockserver-core/target/test-classes/org/mockserver/openapi/openapi_petstore_example.json"
},
"httpResponse": {
"body": "some_response_body"
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"": {
""specUrlOrPayload"": ""file:/Users/jamesbloom/git/mockserver/mockserver/mockserver-core/target/test-classes/org/mockserver/openapi/openapi_petstore_example.json""
},
""httpResponse"": {
""body"": ""some_response_body""
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest": {
"specUrlOrPayload": "file:/Users/jamesbloom/git/mockserver/mockserver/mockserver-core/target/test-classes/org/mockserver/openapi/openapi_petstore_example.json"
},
"httpResponse": {
"body": "some_response_body"
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
// OpenAPI matchers are not supported in the PHP client;
// use the REST API directly
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => json_encode([[
'httpRequest' => [
'specUrlOrPayload' => 'file:/Users/jamesbloom/git/mockserver/mockserver/mockserver-core/target/test-classes/org/mockserver/openapi/openapi_petstore_example.json',
],
'httpResponse' => ['body' => 'some_response_body'],
]]),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"specUrlOrPayload": "file:/Users/jamesbloom/git/mockserver/mockserver/mockserver-core/target/test-classes/org/mockserver/openapi/openapi_petstore_example.json"
},
"httpResponse": {
"body": "some_response_body"
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.when(
openAPI(
"org/mockserver/openapi/openapi_petstore_example.json"
)
)
.respond(
response()
.withBody("some_response_body")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"specUrlOrPayload": "org/mockserver/openapi/openapi_petstore_example.json"
},
"httpResponse": {
"body": "some_response_body"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest": {
"specUrlOrPayload": "org/mockserver/openapi/openapi_petstore_example.json"
},
"httpResponse": {
"body": "some_response_body"
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest": {
"specUrlOrPayload": "org/mockserver/openapi/openapi_petstore_example.json"
},
"httpResponse": {
"body": "some_response_body"
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest": {
"specUrlOrPayload": "org/mockserver/openapi/openapi_petstore_example.json"
},
"httpResponse": {
"body": "some_response_body"
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"": {
""specUrlOrPayload"": ""org/mockserver/openapi/openapi_petstore_example.json""
},
""httpResponse"": {
""body"": ""some_response_body""
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest": {
"specUrlOrPayload": "org/mockserver/openapi/openapi_petstore_example.json"
},
"httpResponse": {
"body": "some_response_body"
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
// OpenAPI matchers are not supported in the PHP client;
// use the REST API directly
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => json_encode([[
'httpRequest' => [
'specUrlOrPayload' => 'org/mockserver/openapi/openapi_petstore_example.json',
],
'httpResponse' => ['body' => 'some_response_body'],
]]),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"specUrlOrPayload": "org/mockserver/openapi/openapi_petstore_example.json"
},
"httpResponse": {
"body": "some_response_body"
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.when(
new OpenAPIDefinition()
.withSpecUrlOrPayload(
FileReader.readFileFromClassPathOrPath("/Users/jamesbloom/git/mockserver/mockserver/mockserver-core/target/test-classes/org/mockserver/openapi/openapi_petstore_example.json")
)
.withOperationId("listPets")
)
.respond(
response()
.withBody("some_response_body")
);
var fs = require('fs');
try {
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"specUrlOrPayload": fs.readFileSync("/Users/jamesbloom/git/mockserver/mockserver/mockserver-core/target/test-classes/org/mockserver/openapi/openapi_petstore_example.json", "utf8"),
"operationId": "showPetById"
},
"httpResponse": {
"body": "some_response_body"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
} catch(e) {
console.log('Error:', e.stack);
}
See REST API for full JSON specification
import json
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
with open("/path/to/openapi_petstore_example.json") as f:
spec = json.load(f)
client.upsert(Expectation.from_dict({
"httpRequest": {
"specUrlOrPayload": spec,
"operationId": "listPets"
},
"httpResponse": {
"body": "some_response_body"
}
}))
require 'mockserver-client'
require 'json'
client = MockServer::Client.new('localhost', 1080)
spec = JSON.parse(File.read('/path/to/openapi_petstore_example.json'))
client.upsert(MockServer::Expectation.from_hash({
"httpRequest": {
"specUrlOrPayload": spec,
"operationId": "showPetById"
},
"httpResponse": {
"body": "some_response_body"
}
}))
package main
import (
"bytes"
"fmt"
"net/http"
"os"
)
func main() {
spec, _ := os.ReadFile("/path/to/openapi_petstore_example.json")
body := []byte(fmt.Sprintf(`{
"httpRequest": {
"specUrlOrPayload": %s,
"operationId": "listPets"
},
"httpResponse": {
"body": "some_response_body"
}
}`, string(spec)))
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.IO;
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var spec = File.ReadAllText("/path/to/openapi_petstore_example.json");
var json = $@"{{
""httpRequest"": {{
""specUrlOrPayload"": {spec},
""operationId"": ""listPets""
}},
""httpResponse"": {{
""body"": ""some_response_body""
}}
}}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
use std::fs;
let client = Client::new();
let spec = fs::read_to_string("/path/to/openapi_petstore_example.json").unwrap();
let body = format!(r#"{{
"httpRequest": {{
"specUrlOrPayload": {},
"operationId": "listPets"
}},
"httpResponse": {{
"body": "some_response_body"
}}
}}"#, spec);
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body)
.send()
.unwrap();
// OpenAPI matchers are not supported in the PHP client;
// use the REST API directly
$specJson = file_get_contents('/path/to/openapi_petstore_example.json');
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => json_encode([[
'httpRequest' => [
'specUrlOrPayload' => json_decode($specJson, true),
'operationId' => 'listPets',
],
'httpResponse' => ['body' => 'some_response_body'],
]]),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d "{
\"httpRequest\": {
\"specUrlOrPayload\": `cat /Users/jamesbloom/git/mockserver/mockserver/mockserver-core/target/test-classes/org/mockserver/openapi/openapi_petstore_example.json`
},
\"httpResponse\": {
\"body\": \"some_response_body\"
}
}"
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest" : {
"specUrlOrPayload" : {
"openapi" : "3.0.0",
"info" : {
"version" : "1.0.0",
"title" : "Swagger Petstore",
"license" : {
"name" : "MIT"
}
},
"servers" : [ {
"url" : "http://petstore.swagger.io/v1"
} ],
"paths" : {
"/pets" : {
"get" : {
"summary" : "List all pets",
"operationId" : "listPets",
"tags" : [ "pets" ],
"parameters" : [ {
"name" : "limit",
"in" : "query",
"description" : "How many items to return at one time (max 100)",
"required" : false,
"schema" : {
"type" : "integer",
"format" : "int32"
}
} ],
"responses" : {
"200" : {
"description" : "A paged array of pets",
"headers" : {
"x-next" : {
"description" : "A link to the next page of responses",
"schema" : {
"type" : "string"
}
}
},
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/Pets"
}
}
}
},
"500" : {
"description" : "unexpected error",
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/Error"
}
}
}
},
"default" : {
"description" : "unexpected error",
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/Error"
}
}
}
}
}
},
"post" : {
"summary" : "Create a pet",
"operationId" : "createPets",
"tags" : [ "pets" ],
"requestBody" : {
"description" : "a pet",
"required" : true,
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/Pet"
}
},
"*/*" : {
"schema" : {
"$ref" : "#/components/schemas/Pet"
}
}
}
},
"responses" : {
"201" : {
"description" : "Null response"
},
"400" : {
"description" : "unexpected error",
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/Error"
}
}
}
},
"500" : {
"description" : "unexpected error",
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/Error"
}
}
}
},
"default" : {
"description" : "unexpected error",
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/Error"
}
}
}
}
}
}
},
"/pets/{petId}" : {
"get" : {
"summary" : "Info for a specific pet",
"operationId" : "showPetById",
"tags" : [ "pets" ],
"parameters" : [ {
"name" : "petId",
"in" : "path",
"required" : true,
"description" : "The id of the pet to retrieve",
"schema" : {
"type" : "string"
}
}, {
"in" : "header",
"name" : "X-Request-ID",
"schema" : {
"type" : "string",
"format" : "uuid"
},
"required" : true
} ],
"responses" : {
"200" : {
"description" : "Expected response to a valid request",
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/Pet"
}
}
}
},
"400" : {
"description" : "unexpected error",
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/Error"
}
}
}
},
"500" : {
"description" : "unexpected error",
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/Error"
}
}
}
},
"default" : {
"description" : "unexpected error",
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/Error"
}
}
}
}
}
}
},
"/some/path" : {
"get" : {
"summary" : "Additional request with extra matchers",
"operationId" : "somePath",
"tags" : [ "pets" ],
"parameters" : [ {
"name" : "limit",
"in" : "query",
"description" : "How many items to return at one time (max 100)",
"required" : false,
"schema" : {
"type" : "integer",
"format" : "int32"
}
}, {
"in" : "header",
"name" : "X-Request-ID",
"schema" : {
"type" : "string",
"format" : "uuid"
},
"required" : true
} ],
"responses" : {
"200" : {
"description" : "Expected response to a valid request",
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/Pet"
}
}
}
},
"default" : {
"description" : "unexpected error",
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/Error"
}
}
}
}
}
}
}
},
"components" : {
"schemas" : {
"Pet" : {
"type" : "object",
"required" : [ "id", "name" ],
"properties" : {
"id" : {
"type" : "integer",
"format" : "int64"
},
"name" : {
"type" : "string"
},
"tag" : {
"type" : "string"
}
}
},
"Pets" : {
"type" : "array",
"items" : {
"$ref" : "#/components/schemas/Pet"
}
},
"Error" : {
"type" : "object",
"required" : [ "code", "message" ],
"properties" : {
"code" : {
"type" : "integer",
"format" : "int32"
},
"message" : {
"type" : "string"
}
}
}
}
}
},
"operationId" : "listPets"
},
"httpResponse" : {
"body" : "some_response_body"
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.when(
new OpenAPIDefinition()
.withSpecUrlOrPayload(
"\nopenapi: 3.0.0\ninfo:\n version: 1.0.0\n title: Swagger Petstore\n license:\n name: MIT\nservers:\n - url: http://petstore.swagger.io/v1\npaths:\n /pets:\n get:\n summary: List all pets\n operationId: listPets\n tags:\n - pets\n parameters:\n - name: limit\n in: query\n description: How many items to return at one time (max 100)\n required: false\n schema:\n type: integer\n format: int32\n responses:\n '200':\n description: A paged array of pets\n headers:\n x-next:\n description: A link to the next page of responses\n schema:\n type: string\n examples:\n two:\n value: \"/pets?query=752cd724e0d7&page=2\"\n end:\n value: \"\"\n content:\n application/json:\n schema:\n $ref: '#/components/schemas/Pets'\n '500':\n description: unexpected error\n headers:\n x-code:\n description: The error code\n schema:\n type: integer\n format: int32\n example: 90\n content:\n application/json:\n schema:\n $ref: '#/components/schemas/Error'\n default:\n description: unexpected error\n content:\n application/json:\n schema:\n $ref: '#/components/schemas/Error'\n post:\n summary: Create a pet\n operationId: createPets\n tags:\n - pets\n requestBody:\n description: a pet\n required: true\n content:\n application/json:\n schema:\n $ref: '#/components/schemas/Pet'\n '*/*':\n schema:\n $ref: '#/components/schemas/Pet'\n responses:\n '201':\n description: Null response\n '400':\n description: unexpected error\n content:\n application/json:\n schema:\n $ref: '#/components/schemas/Error'\n '500':\n description: unexpected error\n content:\n application/json:\n schema:\n $ref: '#/components/schemas/Error'\n default:\n description: unexpected error\n content:\n application/json:\n schema:\n $ref: '#/components/schemas/Error'\n /pets/{petId}:\n get:\n summary: Info for a specific pet\n operationId: showPetById\n tags:\n - pets\n parameters:\n - name: petId\n in: path\n required: true\n description: The id of the pet to retrieve\n schema:\n type: string\n - in: header\n name: X-Request-ID\n schema:\n type: string\n format: uuid\n required: true\n responses:\n '200':\n description: Expected response to a valid request\n content:\n application/json:\n schema:\n $ref: '#/components/schemas/Pet'\n examples:\n Crumble:\n value:\n id: 2\n name: Crumble\n tag: dog\n Boots:\n value:\n id: 3\n name: Boots\n tag: cat\n '500':\n description: unexpected error\n content:\n application/json:\n schema:\n $ref: '#/components/schemas/Error'\n default:\n description: unexpected error\n content:\n application/json:\n schema:\n $ref: '#/components/schemas/Error'\ncomponents:\n schemas:\n Pet:\n type: object\n required:\n - id\n - name\n properties:\n id:\n type: integer\n format: int64\n name:\n type: string\n tag:\n type: string\n example:\n id: 1\n name: Scruffles\n tag: dog\n Pets:\n type: array\n items:\n $ref: '#/components/schemas/Pet'\n Error:\n type: object\n required:\n - code\n - message\n properties:\n code:\n type: integer\n format: int32\n message:\n type: string\n",
"operationId" : "listPets"
},
"times" : {
"unlimited" : true
},
"timeToLive" : {
"unlimited" : true
},
"httpResponse" : {
"body" : "some_response_body"
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.when(
new OpenAPIDefinition()
.withSpecUrlOrPayload(
FileReader.readFileFromClassPathOrPath("/Users/jamesbloom/git/mockserver/mockserver/mockserver-core/target/test-classes/org/mockserver/openapi/openapi_petstore_example.json")
)
.withOperationId("listPets"),
Times.exactly(2)
)
.respond(
response()
.withBody("some_response_body")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest":{
"specUrlOrPayload": "https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json",
"operationId": "showPetById"
},
"httpResponse":{
"statusCode": 200,
"body": "some_body"
},
"times": {
"remainingTimes": 2
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest": {
"specUrlOrPayload": "https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json",
"operationId": "showPetById"
},
"httpResponse": {
"statusCode": 200,
"body": "some_body"
},
"times": {
"remainingTimes": 2
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest": {
"specUrlOrPayload": "https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json",
"operationId": "showPetById"
},
"httpResponse": {
"statusCode": 200,
"body": "some_body"
},
"times": {
"remainingTimes": 2
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest":{
"specUrlOrPayload": "https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json",
"operationId": "showPetById"
},
"httpResponse":{
"statusCode": 200,
"body": "some_body"
},
"times": {
"remainingTimes": 2
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"":{
""specUrlOrPayload"": ""https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json"",
""operationId"": ""showPetById""
},
""httpResponse"":{
""statusCode"": 200,
""body"": ""some_body""
},
""times"": {
""remainingTimes"": 2
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest":{
"specUrlOrPayload": "https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json",
"operationId": "showPetById"
},
"httpResponse":{
"statusCode": 200,
"body": "some_body"
},
"times": {
"remainingTimes": 2
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
// OpenAPI matchers are not supported in the PHP client;
// use the REST API directly
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => json_encode([[
'httpRequest' => [
'specUrlOrPayload' => 'https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json',
'operationId' => 'showPetById',
],
'httpResponse' => ['statusCode' => 200, 'body' => 'some_body'],
'times' => ['remainingTimes' => 2],
]]),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest":{
"specUrlOrPayload": "https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json",
"operationId": "showPetById"
},
"httpResponse":{
"statusCode": 200,
"body": "some_body"
},
"times": {
"remainingTimes": 2
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.upsert(
new Expectation(
openAPI(
"org/mockserver/openapi/openapi_petstore_example.json",
"showPetById"
),
Times.once(),
TimeToLive.exactly(TimeUnit.SECONDS, 60L),
100
)
.withId("630a6e5b-9d61-4668-a18f-a0d3df558583")
.thenRespond(response().withBody("some_response_body"))
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"id": "630a6e5b-9d61-4668-a18f-a0d3df558583",
"priority": 0,
"httpRequest":{
"specUrlOrPayload": "https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json",
"operationId": "showPetById"
},
"httpResponse":{
"statusCode": 200,
"body": "some_response_body"
},
"times":{
"unlimited": true
},
"timeToLive":{
"unlimited": true
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"id": "630a6e5b-9d61-4668-a18f-a0d3df558583",
"priority": 0,
"httpRequest": {
"specUrlOrPayload": "https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json",
"operationId": "showPetById"
},
"httpResponse": {
"statusCode": 200,
"body": "some_response_body"
},
"times": {
"unlimited": True
},
"timeToLive": {
"unlimited": True
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"id": "630a6e5b-9d61-4668-a18f-a0d3df558583",
"priority": 0,
"httpRequest": {
"specUrlOrPayload": "https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json",
"operationId": "showPetById"
},
"httpResponse": {
"statusCode": 200,
"body": "some_response_body"
},
"times": {
"unlimited": true
},
"timeToLive": {
"unlimited": true
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"id": "630a6e5b-9d61-4668-a18f-a0d3df558583",
"priority": 0,
"httpRequest":{
"specUrlOrPayload": "https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json",
"operationId": "showPetById"
},
"httpResponse":{
"statusCode": 200,
"body": "some_response_body"
},
"times":{
"unlimited": true
},
"timeToLive":{
"unlimited": true
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""id"": ""630a6e5b-9d61-4668-a18f-a0d3df558583"",
""priority"": 0,
""httpRequest"":{
""specUrlOrPayload"": ""https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json"",
""operationId"": ""showPetById""
},
""httpResponse"":{
""statusCode"": 200,
""body"": ""some_response_body""
},
""times"":{
""unlimited"": true
},
""timeToLive"":{
""unlimited"": true
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"id": "630a6e5b-9d61-4668-a18f-a0d3df558583",
"priority": 0,
"httpRequest":{
"specUrlOrPayload": "https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json",
"operationId": "showPetById"
},
"httpResponse":{
"statusCode": 200,
"body": "some_response_body"
},
"times":{
"unlimited": true
},
"timeToLive":{
"unlimited": true
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
// OpenAPI matchers are not supported in the PHP client;
// use the REST API directly
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => json_encode([[
'id' => '630a6e5b-9d61-4668-a18f-a0d3df558583',
'priority' => 0,
'httpRequest' => [
'specUrlOrPayload' => 'https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json',
'operationId' => 'showPetById',
],
'httpResponse' => ['statusCode' => 200, 'body' => 'some_response_body'],
'times' => ['unlimited' => true],
'timeToLive' => ['unlimited' => true],
]]),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"id": "630a6e5b-9d61-4668-a18f-a0d3df558583",
"priority": 0,
"httpRequest":{
"specUrlOrPayload": "https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json",
"operationId": "showPetById"
},
"httpResponse":{
"statusCode": 200,
"body": "some_response_body"
},
"times":{
"unlimited": true
},
"timeToLive":{
"unlimited": true
}
}'
See REST API for full JSON specification
Actions
Actions can be one of the following types:
- response - returns a response defined by using
- a literal
- a javascript template
- a velocity template
- a class callback (must be present in classpath)
- a method / closure callback (via WebSocket)
- forward - forwards modified requests and returns modified response by using
- the exact request and response received
- an static overridden request and / or response
- a dynamically modified request and / or response
- a javascript template (request only)
- a velocity template (request only)
- a class callback for request and / or response (must be present in classpath)
- a method / closure callback for request and / or response (via WebSocket)
- error - returns an invalid response as a sequence of bytes or closes the connection
- LLM response - returns a provider-correct LLM completion (Anthropic, OpenAI, etc.) from a high-level description of text, tool calls, and usage
If no action is present for a request because no request matcher was matched then:
- if MockServer is being used as a proxy the request is proxied to its destination un-modified
- if the request host header does not match the hostname or IP the request automatically proxied to the host header
A response action can be:
-
either a response literal containing any of the following:
- status code
- reason phrase
- body
- headers
- cookies
- delay (including distribution-based delays for realistic latency simulation)
- connectionOptions that can be used to suppress headers, override headers, close the socket connection, or deliver the response in chunks with delays (dribble delay)
-
or a templated response using javascript or velocity with a delay
-
or a callback used to dynamically generate a response based on the request:
-
as a server side callback implemented as a java class that has a default constructor, implements org.mockserver.mock.action.ExpectationResponseCallback and is available on the classpath
-
as a client side callback implemented as a closure using the java or javascript clients
-
The following code examples show how to create different response actions.
new MockServerClient("localhost", 1080)
// this request matcher matches every request
.when(
request()
)
.respond(
response()
.withBody("some_response_body")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
// if no request matcher is specified then every request matched
"httpResponse": {
"body": "some_response_body"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import HttpRequest, HttpResponse
client = MockServerClient("localhost", 1080)
# this request matcher matches every request
client.when(
HttpRequest.request()
).respond(
HttpResponse.response(body="some_response_body")
)
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
# this request matcher matches every request
client.when(
MockServer::HttpRequest.new
).respond(
MockServer::HttpResponse.new(body: 'some_response_body')
)
import mockserver "github.com/mock-server/mockserver-monorepo/mockserver-client-go"
client := mockserver.New("localhost", 1080)
// this request matcher matches every request
client.When(
mockserver.Request(),
).Respond(
mockserver.Response().Body("some_response_body"),
)
using MockServer.Client;
using MockServer.Client.Models;
using var client = new MockServerClient("localhost", 1080);
// this request matcher matches every request
client.When(
HttpRequest.Request()
).Respond(
HttpResponse.Response().WithBody("some_response_body")
);
use mockserver_client::{ClientBuilder, HttpRequest, HttpResponse};
let client = ClientBuilder::new("localhost", 1080).build().unwrap();
// this request matcher matches every request
client.when(HttpRequest::new())
.respond(HttpResponse::new().body("some_response_body"))
.unwrap();
use MockServer\MockServerClient;
use MockServer\HttpRequest;
use MockServer\HttpResponse;
$client = new MockServerClient('localhost', 1080);
$client->when(
HttpRequest::request()
)->respond(
HttpResponse::response()
->body('some_response_body')
);
# if no request matcher is specified then every request matched
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpResponse": {
"body": "some_response_body"
}
}'
See REST API for full JSON specification
FileBody loads the response content from a file at response time, rather than embedding the content directly in the expectation. This is useful when the response payload is large (e.g. sample JSON or XML files), generated externally, or shared across multiple expectations. The file path can be absolute or relative to the working directory.
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/api/data")
)
.respond(
response()
.withBodyFromFile("/path/to/response.json")
);
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/api/data")
)
.respond(
response()
.withBodyFromFile("/path/to/response.json", MediaType.APPLICATION_JSON)
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"path": "/api/data"
},
"httpResponse": {
"body": {
"type": "FILE",
"filePath": "/path/to/response.json",
"contentType": "application/json"
}
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest": {
"path": "/api/data"
},
"httpResponse": {
"body": {
"type": "FILE",
"filePath": "/path/to/response.json",
"contentType": "application/json"
}
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest": {
"path": "/api/data"
},
"httpResponse": {
"body": {
"type": "FILE",
"filePath": "/path/to/response.json",
"contentType": "application/json"
}
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest": {
"path": "/api/data"
},
"httpResponse": {
"body": {
"type": "FILE",
"filePath": "/path/to/response.json",
"contentType": "application/json"
}
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"": {
""path"": ""/api/data""
},
""httpResponse"": {
""body"": {
""type"": ""FILE"",
""filePath"": ""/path/to/response.json"",
""contentType"": ""application/json""
}
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest": {
"path": "/api/data"
},
"httpResponse": {
"body": {
"type": "FILE",
"filePath": "/path/to/response.json",
"contentType": "application/json"
}
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest": {
"path": "/api/data"
},
"httpResponse": {
"body": {
"type": "FILE",
"filePath": "/path/to/response.json",
"contentType": "application/json"
}
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"path": "/api/data"
},
"httpResponse": {
"body": {
"type": "FILE",
"filePath": "/path/to/response.json",
"contentType": "application/json"
}
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
// this request matcher matches every request
.when(
request()
)
.respond(
response()
.withHeader(
CONTENT_TYPE.toString(),
MediaType.create("text", "plain").withCharset(Charsets.UTF_16).toString()
)
.withBody("我说中国话".getBytes(Charsets.UTF_16))
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
// if no request matcher is specified then every request matched
"httpResponse": {
"headers": {
"content-type": ["text/plain; charset=utf-16"]
},
"body": {
"type": "BINARY",
"base64Bytes": "/v9iEYv0Ti1W/Yvd"
}
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpResponse": {
"headers": {
"content-type": ["text/plain; charset=utf-16"]
},
"body": {
"type": "BINARY",
"base64Bytes": "/v9iEYv0Ti1W/Yvd"
}
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpResponse": {
"headers": {
"content-type": ["text/plain; charset=utf-16"]
},
"body": {
"type": "BINARY",
"base64Bytes": "/v9iEYv0Ti1W/Yvd"
}
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpResponse": {
"headers": {
"content-type": ["text/plain; charset=utf-16"]
},
"body": {
"type": "BINARY",
"base64Bytes": "/v9iEYv0Ti1W/Yvd"
}
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpResponse"": {
""headers"": {
""content-type"": [""text/plain; charset=utf-16""]
},
""body"": {
""type"": ""BINARY"",
""base64Bytes"": ""/v9iEYv0Ti1W/Yvd""
}
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpResponse": {
"headers": {
"content-type": ["text/plain; charset=utf-16"]
},
"body": {
"type": "BINARY",
"base64Bytes": "/v9iEYv0Ti1W/Yvd"
}
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpResponse": {
"headers": {
"content-type": ["text/plain; charset=utf-16"]
},
"body": {
"type": "BINARY",
"base64Bytes": "/v9iEYv0Ti1W/Yvd"
}
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
# if no request matcher is specified then every request matched
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpResponse": {
"headers": {
"content-type": ["text/plain; charset=utf-16"]
},
"body": {
"type": "BINARY",
"base64Bytes": "/v9iEYv0Ti1W/Yvd"
}
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.when(
request()
.withMethod("GET")
.withPath("/farsi_body")
)
.respond(
response()
.withBody(json("سلام", MediaType.APPLICATION_JSON_UTF_8))
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"method": "GET",
"path": "/simple"
},
"httpResponse": {
"body": {
"type": "STRING",
"string": "سلام",
"contentType": "text/plain; charset=utf-8"
}
},
"times": {
"unlimited": true
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest": {
"method": "GET",
"path": "/simple"
},
"httpResponse": {
"body": {
"type": "STRING",
"string": "\u0633\u0644\u0627\u0645",
"contentType": "text/plain; charset=utf-8"
}
},
"times": {
"unlimited": true
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest": {
"method": "GET",
"path": "/simple"
},
"httpResponse": {
"body": {
"type": "STRING",
"string": "\u0633\u0644\u0627\u0645",
"contentType": "text/plain; charset=utf-8"
}
},
"times": {
"unlimited": true
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest": {
"method": "GET",
"path": "/simple"
},
"httpResponse": {
"body": {
"type": "STRING",
"string": "\u0633\u0644\u0627\u0645",
"contentType": "text/plain; charset=utf-8"
}
},
"times": {
"unlimited": true
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"": {
""method"": ""GET"",
""path"": ""/simple""
},
""httpResponse"": {
""body"": {
""type"": ""STRING"",
""string"": ""\u0633\u0644\u0627\u0645"",
""contentType"": ""text/plain; charset=utf-8""
}
},
""times"": {
""unlimited"": true
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest": {
"method": "GET",
"path": "/simple"
},
"httpResponse": {
"body": {
"type": "STRING",
"string": "\u0633\u0644\u0627\u0645",
"contentType": "text/plain; charset=utf-8"
}
},
"times": {
"unlimited": true
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest": {
"method": "GET",
"path": "/simple"
},
"httpResponse": {
"body": {
"type": "STRING",
"string": "سلام",
"contentType": "text/plain; charset=utf-8"
}
},
"times": {
"unlimited": true
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT http://localhost:1080/mockserver/expectation -H "Content-Type: application/json; charset=utf-8" --data '{
"httpRequest": {
"method": "GET",
"path": "/simple"
},
"httpResponse": {
"body": {
"type": "STRING",
"string": "سلام",
"contentType": "text/plain; charset=utf-8"
}
},
"times": {
"unlimited": true
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
// this request matcher matches every request
.when(
request()
)
.respond(
response()
.withBody("some_response_body")
.withHeader("Content-Type", "plain/text")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
// if no request matcher is specified then every request matched
"httpResponse": {
"headers": {
"Content-Type": ["plain/text"]
},
"body": "some_response_body"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import HttpRequest, HttpResponse
client = MockServerClient("localhost", 1080)
# this request matcher matches every request
client.when(
HttpRequest.request()
).respond(
HttpResponse.response(body="some_response_body")
.with_header("Content-Type", "plain/text")
)
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
# this request matcher matches every request
client.when(
MockServer::HttpRequest.new
).respond(
MockServer::HttpResponse.new(
body: 'some_response_body',
headers: [MockServer::KeyToMultiValue.new(
name: 'Content-Type', values: ['plain/text']
)]
)
)
import mockserver "github.com/mock-server/mockserver-monorepo/mockserver-client-go"
client := mockserver.New("localhost", 1080)
// this request matcher matches every request
client.When(
mockserver.Request(),
).Respond(
mockserver.Response().
Body("some_response_body").
Header("Content-Type", "plain/text"),
)
using MockServer.Client;
using MockServer.Client.Models;
using var client = new MockServerClient("localhost", 1080);
// this request matcher matches every request
client.When(
HttpRequest.Request()
).Respond(
HttpResponse.Response()
.WithBody("some_response_body")
.WithHeader("Content-Type", "plain/text")
);
use mockserver_client::{ClientBuilder, HttpRequest, HttpResponse};
let client = ClientBuilder::new("localhost", 1080).build().unwrap();
// this request matcher matches every request
client.when(HttpRequest::new())
.respond(
HttpResponse::new()
.body("some_response_body")
.header("Content-Type", "plain/text")
)
.unwrap();
use MockServer\MockServerClient;
use MockServer\HttpRequest;
use MockServer\HttpResponse;
$client = new MockServerClient('localhost', 1080);
$client->when(
HttpRequest::request()
)->respond(
HttpResponse::response()
->header('Content-Type', 'plain/text')
->body('some_response_body')
);
curl -v -X PUT http://localhost:1080/mockserver/expectation -H "Content-Type: application/json; charset=utf-8" --data '{
"httpResponse": {
"headers": {
"Content-Type": ["plain/text"]
},
"body": "some_response_body"
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
// this request matcher matches every request
.when(
request()
)
.respond(
response()
.withBody("some_response_body")
.withHeader("Content-Type", "plain/text")
.withCookie("Session", "97d43b1e-fe03-4855-926a-f448eddac32f")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
// if no request matcher is specified then every request matched
"httpResponse": {
"headers": {
"Content-Type": ["plain/text"]
},
"cookies": {
"Session": "97d43b1e-fe03-4855-926a-f448eddac32f"
},
"body": "some_response_body"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import HttpRequest, HttpResponse
client = MockServerClient("localhost", 1080)
# this request matcher matches every request
client.when(
HttpRequest.request()
).respond(
HttpResponse.response(body="some_response_body")
.with_header("Content-Type", "plain/text")
.with_cookie("Session", "97d43b1e-fe03-4855-926a-f448eddac32f")
)
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
# this request matcher matches every request
client.when(
MockServer::HttpRequest.new
).respond(
MockServer::HttpResponse.new(
body: 'some_response_body',
headers: [MockServer::KeyToMultiValue.new(
name: 'Content-Type', values: ['plain/text']
)],
cookies: [MockServer::KeyToMultiValue.new(
name: 'Session', values: ['97d43b1e-fe03-4855-926a-f448eddac32f']
)]
)
)
import mockserver "github.com/mock-server/mockserver-monorepo/mockserver-client-go"
client := mockserver.New("localhost", 1080)
// this request matcher matches every request
client.When(
mockserver.Request(),
).Respond(
mockserver.Response().
Body("some_response_body").
Header("Content-Type", "plain/text").
Cookie("Session", "97d43b1e-fe03-4855-926a-f448eddac32f"),
)
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpResponse"": {
""headers"": {
""Content-Type"": [""plain/text""]
},
""cookies"": {
""Session"": ""97d43b1e-fe03-4855-926a-f448eddac32f""
},
""body"": ""some_response_body""
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpResponse": {
"headers": {
"Content-Type": ["plain/text"]
},
"cookies": {
"Session": "97d43b1e-fe03-4855-926a-f448eddac32f"
},
"body": "some_response_body"
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
use MockServer\MockServerClient;
use MockServer\HttpRequest;
use MockServer\HttpResponse;
$client = new MockServerClient('localhost', 1080);
$client->when(
HttpRequest::request()
)->respond(
HttpResponse::response()
->header('Content-Type', 'plain/text')
->cookie('Session', '97d43b1e-fe03-4855-926a-f448eddac32f')
->body('some_response_body')
);
curl -v -X PUT http://localhost:1080/mockserver/expectation -H "Content-Type: application/json; charset=utf-8" --data '{
"httpResponse": {
"headers": {
"Content-Type": ["plain/text"]
},
"cookies": {
"Session": "97d43b1e-fe03-4855-926a-f448eddac32f"
},
"body": "some_response_body"
}
}'
See REST API for full JSON specification
Note for WAR deployments: Jakarta Servlet 6 (Tomcat 11+, Jetty 12+, WildFly 32+) removed support for custom HTTP reason phrases via HttpServletResponse.setStatus(int, String), so when MockServer is deployed as a WAR in a Servlet 6 container only the status code is sent on the wire and the reason phrase is silently dropped. The reason phrase still works in MockServer's standalone, Docker, and Netty deployments.
new MockServerClient("localhost", 1080)
.when(
request()
.withMethod("POST")
.withPath("/some/path")
)
.respond(
response()
.withStatusCode(418)
.withReasonPhrase("I'm a teapot")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"method": "POST",
"path": "/some/path"
},
"httpResponse": {
"statusCode": 418,
"reasonPhrase": "I'm a teapot"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import HttpRequest, HttpResponse
client = MockServerClient("localhost", 1080)
client.when(
HttpRequest.request(path="/some/path").with_method("POST")
).respond(
HttpResponse.response()
.with_status_code(418)
.with_reason_phrase("I'm a teapot")
)
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.when(
MockServer::HttpRequest.new(method: 'POST', path: '/some/path')
).respond(
MockServer::HttpResponse.new(
status_code: 418,
reason_phrase: "I'm a teapot"
)
)
import mockserver "github.com/mock-server/mockserver-monorepo/mockserver-client-go"
client := mockserver.New("localhost", 1080)
client.When(
mockserver.Request().Method("POST").Path("/some/path"),
).Respond(
mockserver.Response().
StatusCode(418).
ReasonPhrase("I'm a teapot"),
)
using MockServer.Client;
using MockServer.Client.Models;
using var client = new MockServerClient("localhost", 1080);
client.When(
HttpRequest.Request().WithMethod("POST").WithPath("/some/path")
).Respond(
HttpResponse.Response()
.WithStatusCode(418)
.WithReasonPhrase("I'm a teapot")
);
use mockserver_client::{ClientBuilder, HttpRequest, HttpResponse};
let client = ClientBuilder::new("localhost", 1080).build().unwrap();
client.when(
HttpRequest::new().method("POST").path("/some/path")
).respond(
HttpResponse::new().status_code(418)
).unwrap();
// Note: the Rust client does not expose reason_phrase;
// use a raw PUT /mockserver/expectation request for that field
use MockServer\MockServerClient;
use MockServer\HttpRequest;
use MockServer\HttpResponse;
$client = new MockServerClient('localhost', 1080);
$client->when(
HttpRequest::request()
->method('POST')
->path('/some/path')
)->respond(
HttpResponse::response()
->statusCode(418)
->reasonPhrase('I\'m a teapot')
);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"method": "POST",
"path": "/some/path"
},
"httpResponse": {
"statusCode": 418,
"reasonPhrase": "I'm a teapot"
}
}'
See REST API for full JSON specification
byte[] pngBytes = IOUtils.toByteArray(getClass().getClassLoader().getResourceAsStream("org/mockserver/examples/mockserver/test.png"));
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/ws/rest/user/[0-9]+/icon/[0-9]+\\.png")
)
.respond(
response()
.withStatusCode(HttpStatusCode.OK_200.code())
.withHeaders(
header(CONTENT_TYPE.toString(), MediaType.PNG.toString()),
header(CONTENT_DISPOSITION.toString(), "form-data; name=\"test.png\"; filename=\"test.png\"")
)
.withBody(binary(pngBytes))
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"path": "/ws/rest/user/[0-9]+/icon/[0-9]+\\.png"
},
"httpResponse": {
"statusCode": 200,
"headers": {
"content-type": ["image/png"],
"content-disposition": ["form-data; name=\"test.png\"; filename=\"test.png\""]
},
"body": {
"type": "BINARY",
"base64Bytes": "iVBORw0KGgoAAAANSUhEUgAAAqwAAAApCAIAAAB/QuwlAAAK+GlDQ1BJQ0MgUHJvZmlsZQAASA2tl3dcU8kWx+fe9EYLICAl9CZIr9JrAAXpYCMkgYQSYgoCVpTFFVwLKiKgrugiiIJrAWQtiAULoljAvkEWFXVdLIiKypvAEvfzPm//e5PP3Pne35w598zcmXzOBYBGZQmFWagKANkCiSg6xJ+RmJTMIDwGWKAF8EAf2LHYYqFfVFQE+NfyoRcg8s5bNnJf/2r2vztUOVwxGwAkCnancsTsbMjHYH3PFookAGDqoG68RCKUcxdkdREMELJMzumT/F7OqROMJU7YxEYHAIDVBYBIZbFE6QBQLaDOyGWnQz/UUMh2Ag5fADkPsjebx+JAboU8Izs7R85/QLZI/Yef9H8wi5Wq8MlipSt4ci5wJHxwIF8szGLlT9z8Py/ZWVK4XhPFEF6pPFFoNGwT4ZpVZ+aEK1iQOidySufDGU0xTxoaN8VscQBcy8mxHFZg+BRLM+P8ppglgvS3DV/CjJ1iUU60wr8ga458f0zEwOMyFcwVB8VM6Wn8YOYUF/BiE6Y4lx8/Z4rFmTGKGAp4AQpdJI1WxJwmClbMMVsMR/79XDbr+7MkvFj5O56Ih8MNDJpiriBOEY9Q4q/wI8ya2N8T9tysEIUuzo1RjJWIYhV6BitMvl8n7IWSKMWagEDAB2Ig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FUWAIkAR6AME/mWpvVDf+dB9yg/m/ft0dLLZdv264eqAxxSPBN/nyUMzrIp07PhnZvVvvXa95nx7g8HmHxEQ8x9PJakm0EMAkZH6ta7q+2teMx5//auchEektxXlRx8HiOBMqygCFAGKAEWAInA3I3BbHsTdDAztG0WAIkARoAhQBO52BKgTcLePMO0fRYAiQBGgCFAE3CBAnQA3wNBiigBFgCJAEaAI3O0IUCfgbh9h2j+KAEWAIkARoAi4QYA6AW6AocUUAYoARYAiQBG42xGgTsDdPsK0fxQBigBFgCJAEXCDAHUC3ABDiykCFAGKAEWAInC3I0CdgLt9hGn/KAIUAYoARYAi4AYB6gS4AYYWUwQoAhQBigBF4G5HgDoBd/sI0/5RBCgCFAGKAEXADQL/D4BaqFLDMQVOAAAAAElFTkSuQmCC"
}
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest": {
"path": "/ws/rest/user/[0-9]+/icon/[0-9]+\\.png"
},
"httpResponse": {
"statusCode": 200,
"headers": {
"content-type": ["image/png"],
"content-disposition": ["form-data; name=\"test.png\"; filename=\"test.png\""]
},
"body": {
"type": "BINARY",
"base64Bytes": "iVBORw0KGgoAAAANSUhEUgAAAqwAAAAp..."
}
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest": {
"path": "/ws/rest/user/[0-9]+/icon/[0-9]+\\.png"
},
"httpResponse": {
"statusCode": 200,
"headers": {
"content-type": ["image/png"],
"content-disposition": ["form-data; name=\"test.png\"; filename=\"test.png\""]
},
"body": {
"type": "BINARY",
"base64Bytes": "iVBORw0KGgoAAAANSUhEUgAAAqwAAAAp..."
}
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest": {
"path": "/ws/rest/user/[0-9]+/icon/[0-9]+\\.png"
},
"httpResponse": {
"statusCode": 200,
"headers": {
"content-type": ["image/png"],
"content-disposition": ["form-data; name=\"test.png\"; filename=\"test.png\""]
},
"body": {
"type": "BINARY",
"base64Bytes": "iVBORw0KGgoAAAANSUhEUgAAAqwAAAAp..."
}
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"": {
""path"": ""/ws/rest/user/[0-9]+/icon/[0-9]+\\.png""
},
""httpResponse"": {
""statusCode"": 200,
""headers"": {
""content-type"": [""image/png""],
""content-disposition"": [""form-data; name=\""test.png\""; filename=\""test.png\""""]
},
""body"": {
""type"": ""BINARY"",
""base64Bytes"": ""iVBORw0KGgoAAAANSUhEUgAAAqwAAAAp...""
}
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest": {
"path": "/ws/rest/user/[0-9]+/icon/[0-9]+\\.png"
},
"httpResponse": {
"statusCode": 200,
"headers": {
"content-type": ["image/png"],
"content-disposition": ["form-data; name=\"test.png\"; filename=\"test.png\""]
},
"body": {
"type": "BINARY",
"base64Bytes": "iVBORw0KGgoAAAANSUhEUgAAAqwAAAAp..."
}
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest": {
"path": "/ws/rest/user/[0-9]+/icon/[0-9]+\\.png"
},
"httpResponse": {
"statusCode": 200,
"headers": {
"content-type": ["image/png"],
"content-disposition": ["form-data; name=\"test.png\"; filename=\"test.png\""]
},
"body": {
"type": "BINARY",
"base64Bytes": "iVBORw0KGgoAAAANSUhEUgAAAqwAAAApCAIAAAB/QuwlAAAK+GlDQ1BJQ0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SuQmCC"
}
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"path": "/ws/rest/user/[0-9]+/icon/[0-9]+\\.png"
},
"httpResponse": {
"statusCode": 200,
"headers": {
"content-type": ["image/png"],
"content-disposition": ["form-data; name=\"test.png\"; filename=\"test.png\""]
},
"body": {
"type": "BINARY",
"base64Bytes": "iVBORw0KGgoAAAANSUhEUgAAAqwAAAApCAIAAAB/QuwlAAAK+GlDQ1BJQ0MgUHJvZmlsZQAASA2tl3dcU8kWx+fe9EYLICAl9CZIr9JrAAXpYCMkgYQSYgoCVpTFFVwLKiKgrugiiIJrAWQtiAULoljAvkEWFXVdLIiKypvAEvfzPm//e5PP3Pne35w598zcmXzOBYBGZQmFWagKANkCiSg6xJ+RmJTMIDwGWKAF8EAf2LHYYqFfVFQE+NfyoRcg8s5bNnJf/2r2vztUOVwxGwAkCnancsTsbMjHYH3PFookAGDqoG68RCKUcxdkdREMELJMzumT/F7OqROMJU7YxEYHAIDVBYBIZbFE6QBQLaDOyGWnQz/UUMh2Ag5fADkPsjebx+JAboU8Izs7R85/QLZI/Yef9H8wi5Wq8MlipSt4ci5wJHxwIF8szGLlT9z8Py/ZWVK4XhPFEF6pPFFoNGwT4ZpVZ+aEK1iQOidySufDGU0xTxoaN8VscQBcy8mxHFZg+BRLM+P8ppglgvS3DV/CjJ1iUU60wr8ga458f0zEwOMyFcwVB8VM6Wn8YOYUF/BiE6Y4lx8/Z4rFmTGKGAp4AQpdJI1WxJwmClbMMVsMR/79XDbr+7MkvFj5O56Ih8MNDJpiriBOEY9Q4q/wI8ya2N8T9tysEIUuzo1RjJWIYhV6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ivCEXIB5uenzWKe1O9Z1IoFUWAIkAR6AME/mWpvVDf+dB9yg/m/ft0dLLZdv264eqAxxSPBN/nyUMzrIp07PhnZvVvvXa95nx7g8HmHxEQ8x9PJakm0EMAkZH6ta7q+2teMx5//auchEektxXlRx8HiOBMqygCFAGKAEWAInA3I3BbHsTdDAztG0WAIkARoAhQBO52BKgTcLePMO0fRYAiQBGgCFAE3CBAnQA3wNBiigBFgCJAEaAI3O0IUCfgbh9h2j+KAEWAIkARoAi4QYA6AW6AocUUAYoARYAiQBG42xGgTsDdPsK0fxQBigBFgCJAEXCDAHUC3ABDiykCFAGKAEWAInC3I0CdgLt9hGn/KAIUAYoARYAi4AYB6gS4AYYWUwQoAhQBigBF4G5HgDoBd/sI0/5RBCgCFAGKAEXADQL/D4BaqFLDMQVOAAAAAElFTkSuQmCC"
}
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path")
)
.respond(
response()
.withBody("some_response_body")
.withDelay(TimeUnit.SECONDS, 10)
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"path": "/some/path"
},
"httpResponse": {
"body": "some_response_body",
"delay": {
"timeUnit": "SECONDS",
"value": 10
}
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Delay, HttpRequest, HttpResponse
client = MockServerClient("localhost", 1080)
client.when(
HttpRequest.request(path="/some/path")
).respond_with_delay(
HttpResponse.response(body="some_response_body"),
Delay(time_unit="SECONDS", value=10)
)
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.when(
MockServer::HttpRequest.new(path: '/some/path')
).respond_with_delay(
MockServer::HttpResponse.new(body: 'some_response_body'),
MockServer::Delay.new(time_unit: 'SECONDS', value: 10)
)
import mockserver "github.com/mock-server/mockserver-monorepo/mockserver-client-go"
client := mockserver.New("localhost", 1080)
client.When(
mockserver.Request().Path("/some/path"),
).Respond(
mockserver.Response().
Body("some_response_body").
WithDelay("SECONDS", 10),
)
using MockServer.Client;
using MockServer.Client.Models;
using var client = new MockServerClient("localhost", 1080);
client.When(
HttpRequest.Request().WithPath("/some/path")
).Respond(
HttpResponse.Response()
.WithBody("some_response_body")
.WithDelay(TimeUnit.SECONDS, 10)
);
use mockserver_client::{ClientBuilder, Delay, HttpRequest, HttpResponse};
let client = ClientBuilder::new("localhost", 1080).build().unwrap();
client.when(
HttpRequest::new().path("/some/path")
).respond(
HttpResponse::new()
.body("some_response_body")
.delay(Delay::seconds(10))
).unwrap();
use MockServer\MockServerClient;
use MockServer\HttpRequest;
use MockServer\HttpResponse;
use MockServer\Delay;
$client = new MockServerClient('localhost', 1080);
$client->when(
HttpRequest::request()
->path('/some/path')
)->respond(
HttpResponse::response()
->body('some_response_body')
->delay(new Delay('SECONDS', 10))
);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"path": "/some/path"
},
"httpResponse": {
"body": "some_response_body",
"delay": {
"timeUnit": "SECONDS",
"value": 10
}
}
}'
See REST API for full JSON specification
Distribution-based delays add realistic variability to response times. Each request samples a new random delay from the chosen distribution. Three distribution types are supported:
- UNIFORM — equal probability across a min/max range; use for simple random variation
- LOG_NORMAL — most values near the median with a long tail of slower responses; best for realistic network/API latency simulation. Specified via median and p99 (99th percentile)
- GAUSSIAN — bell curve centered on the mean; use when you know the average latency and expected spread (standard deviation)
Distribution-based delays are supported on all action types including response, forward, error, template, and callback actions.
Sampled values are clamped to a minimum of 0 and a maximum of 86,400,000 milliseconds (24 hours). Validation constraints: UNIFORM requires min >= 0 and max >= min; LOG_NORMAL requires median > 0 and p99 >= median; GAUSSIAN requires mean >= 0 and stdDev >= 0.
// uniform random delay between 100ms and 500ms
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path")
)
.respond(
response()
.withBody("some_response_body")
.withDelay(Delay.uniform(TimeUnit.MILLISECONDS, 100, 500))
);
// log-normal delay (realistic latency distribution) with median 200ms and p99 of 800ms
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path")
)
.respond(
response()
.withBody("some_response_body")
.withDelay(Delay.logNormal(TimeUnit.MILLISECONDS, 200, 800))
);
// gaussian delay with mean 200ms and standard deviation of 50ms
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path")
)
.respond(
response()
.withBody("some_response_body")
.withDelay(Delay.gaussian(TimeUnit.MILLISECONDS, 200, 50))
);
var mockServerClient = require('mockserver-client').mockServerClient;
// uniform random delay between 100ms and 500ms
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"path": "/some/path"
},
"httpResponse": {
"body": "some_response_body",
"delay": {
"timeUnit": "MILLISECONDS",
"distribution": {
"type": "UNIFORM",
"min": 100,
"max": 500
}
}
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
// log-normal delay with median 200ms and p99 of 800ms
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"path": "/some/path"
},
"httpResponse": {
"body": "some_response_body",
"delay": {
"timeUnit": "MILLISECONDS",
"distribution": {
"type": "LOG_NORMAL",
"median": 200,
"p99": 800
}
}
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
// gaussian delay with mean 200ms and standard deviation of 50ms
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"path": "/some/path"
},
"httpResponse": {
"body": "some_response_body",
"delay": {
"timeUnit": "MILLISECONDS",
"distribution": {
"type": "GAUSSIAN",
"mean": 200,
"stdDev": 50
}
}
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest": {
"path": "/some/path"
},
"httpResponse": {
"body": "some_response_body",
"delay": {
"timeUnit": "MILLISECONDS",
"distribution": {
"type": "UNIFORM",
"min": 100,
"max": 500
}
}
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest": {
"path": "/some/path"
},
"httpResponse": {
"body": "some_response_body",
"delay": {
"timeUnit": "MILLISECONDS",
"distribution": {
"type": "UNIFORM",
"min": 100,
"max": 500
}
}
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest": {
"path": "/some/path"
},
"httpResponse": {
"body": "some_response_body",
"delay": {
"timeUnit": "MILLISECONDS",
"distribution": {
"type": "UNIFORM",
"min": 100,
"max": 500
}
}
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"": {
""path"": ""/some/path""
},
""httpResponse"": {
""body"": ""some_response_body"",
""delay"": {
""timeUnit"": ""MILLISECONDS"",
""distribution"": {
""type"": ""UNIFORM"",
""min"": 100,
""max"": 500
}
}
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest": {
"path": "/some/path"
},
"httpResponse": {
"body": "some_response_body",
"delay": {
"timeUnit": "MILLISECONDS",
"distribution": {
"type": "UNIFORM",
"min": 100,
"max": 500
}
}
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json1 = <<<'JSON'
{
"httpRequest": {
"path": "/some/path"
},
"httpResponse": {
"body": "some_response_body",
"delay": {
"timeUnit": "MILLISECONDS",
"distribution": {
"type": "UNIFORM",
"min": 100,
"max": 500
}
}
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json1,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
$json2 = <<<'JSON'
{
"httpRequest": {
"path": "/some/path"
},
"httpResponse": {
"body": "some_response_body",
"delay": {
"timeUnit": "MILLISECONDS",
"distribution": {
"type": "LOG_NORMAL",
"median": 200,
"p99": 800
}
}
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json2,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
$json3 = <<<'JSON'
{
"httpRequest": {
"path": "/some/path"
},
"httpResponse": {
"body": "some_response_body",
"delay": {
"timeUnit": "MILLISECONDS",
"distribution": {
"type": "GAUSSIAN",
"mean": 200,
"stdDev": 50
}
}
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json3,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
# uniform random delay between 100ms and 500ms
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"path": "/some/path"
},
"httpResponse": {
"body": "some_response_body",
"delay": {
"timeUnit": "MILLISECONDS",
"distribution": {
"type": "UNIFORM",
"min": 100,
"max": 500
}
}
}
}'
# log-normal delay with median 200ms and p99 of 800ms
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"path": "/some/path"
},
"httpResponse": {
"body": "some_response_body",
"delay": {
"timeUnit": "MILLISECONDS",
"distribution": {
"type": "LOG_NORMAL",
"median": 200,
"p99": 800
}
}
}
}'
# gaussian delay with mean 200ms and standard deviation of 50ms
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"path": "/some/path"
},
"httpResponse": {
"body": "some_response_body",
"delay": {
"timeUnit": "MILLISECONDS",
"distribution": {
"type": "GAUSSIAN",
"mean": 200,
"stdDev": 50
}
}
}
}'
See REST API for full JSON specification
MockServerClient mockServerClient = new MockServerClient("localhost", 1080);
// respond once with 200, then respond twice with 204, then
// respond with 404 as no remaining active expectations
mockServerClient
.when(
request()
.withPath("/some/path"),
Times.exactly(1)
)
.respond(
response()
.withStatusCode(200)
);
mockServerClient
.when(
request()
.withPath("/some/path"),
Times.exactly(2)
)
.respond(
response()
.withStatusCode(204)
);
var client = require('mockserver-client').mockServerClient("localhost", 1080);
// respond once with 200, then respond twice with 204, then
// respond with 404 as no remaining active expectations
client.mockAnyResponse({
"httpRequest": {
"path": "/some/path"
},
"httpResponse": {
"statusCode": 200
},
"times": {
"remainingTimes": 1,
"unlimited": false
}
}).then(
function () {
console.log("first expectation created");
client.mockAnyResponse({
"httpRequest": {
"path": "/some/path"
},
"httpResponse": {
"statusCode": 204
},
"times": {
"remainingTimes": 2,
"unlimited": false
}
}).then(
function () {
console.log("second expectation created");
},
function (error) {
console.log(error);
}
);
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import HttpRequest, HttpResponse, Times
client = MockServerClient("localhost", 1080)
# respond once with 200, then respond twice with 204, then
# respond with 404 as no remaining active expectations
client.when(
HttpRequest.request(path="/some/path"),
times=Times.exactly(1)
).respond(
HttpResponse.response(status_code=200)
)
client.when(
HttpRequest.request(path="/some/path"),
times=Times.exactly(2)
).respond(
HttpResponse.response(status_code=204)
)
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
# respond once with 200, then respond twice with 204, then
# respond with 404 as no remaining active expectations
client.when(
MockServer::HttpRequest.new(path: '/some/path'),
times: MockServer::Times.exactly(1)
).respond(
MockServer::HttpResponse.new(status_code: 200)
)
client.when(
MockServer::HttpRequest.new(path: '/some/path'),
times: MockServer::Times.exactly(2)
).respond(
MockServer::HttpResponse.new(status_code: 204)
)
import mockserver "github.com/mock-server/mockserver-monorepo/mockserver-client-go"
client := mockserver.New("localhost", 1080)
// respond once with 200, then respond twice with 204, then
// respond with 404 as no remaining active expectations
client.When(
mockserver.Request().Path("/some/path"),
mockserver.WithTimes(mockserver.Exactly(1)),
).Respond(
mockserver.Response().StatusCode(200),
)
client.When(
mockserver.Request().Path("/some/path"),
mockserver.WithTimes(mockserver.Exactly(2)),
).Respond(
mockserver.Response().StatusCode(204),
)
using MockServer.Client;
using MockServer.Client.Models;
using var client = new MockServerClient("localhost", 1080);
// respond once with 200, then respond twice with 204, then
// respond with 404 as no remaining active expectations
client.When(
HttpRequest.Request().WithPath("/some/path"),
times: Times.Exactly(1)
).Respond(
HttpResponse.Response().WithStatusCode(200)
);
client.When(
HttpRequest.Request().WithPath("/some/path"),
times: Times.Exactly(2)
).Respond(
HttpResponse.Response().WithStatusCode(204)
);
use mockserver_client::{ClientBuilder, HttpRequest, HttpResponse, Times};
let client = ClientBuilder::new("localhost", 1080).build().unwrap();
// respond once with 200, then respond twice with 204, then
// respond with 404 as no remaining active expectations
client.when(HttpRequest::new().path("/some/path"))
.times(Times::once())
.respond(HttpResponse::new().status_code(200))
.unwrap();
client.when(HttpRequest::new().path("/some/path"))
.times(Times::exactly(2))
.respond(HttpResponse::new().status_code(204))
.unwrap();
use MockServer\MockServerClient;
use MockServer\HttpRequest;
use MockServer\HttpResponse;
use MockServer\Times;
$client = new MockServerClient('localhost', 1080);
// respond once with 200, then respond twice with 204, then
// respond with 404 as no remaining active expectations
$client->when(
HttpRequest::request()
->path('/some/path'), Times::exactly(1)
)->respond(
HttpResponse::response()
->statusCode(200)
);
$client->when(
HttpRequest::request()
->path('/some/path'), Times::exactly(2)
)->respond(
HttpResponse::response()
->statusCode(204)
);
# respond once with 200, then respond twice with 204, then
# respond with 404 as no remaining active expectations
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"path": "/some/path"
},
"httpResponse": {
"statusCode": 200
},
"times": {
"remainingTimes": 1,
"unlimited": false
}
}'
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"path": "/some/path"
},
"httpResponse": {
"statusCode": 204
},
"times": {
"remainingTimes": 2,
"unlimited": false
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path")
)
.respond(
response()
.withBody("some_response_body")
.withConnectionOptions(
connectionOptions()
.withSuppressConnectionHeader(true)
.withSuppressContentLengthHeader(true)
)
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest" : {
"path" : "/some/path"
},
"httpResponse" : {
"body" : "some_response_body",
"connectionOptions" : {
"suppressContentLengthHeader" : true,
"suppressConnectionHeader" : true
}
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest" : {
"path" : "/some/path"
},
"httpResponse" : {
"body" : "some_response_body",
"connectionOptions" : {
"suppressContentLengthHeader" : true,
"suppressConnectionHeader" : true
}
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest" : {
"path" : "/some/path"
},
"httpResponse" : {
"body" : "some_response_body",
"connectionOptions" : {
"suppressContentLengthHeader" : true,
"suppressConnectionHeader" : true
}
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest" : {
"path" : "/some/path"
},
"httpResponse" : {
"body" : "some_response_body",
"connectionOptions" : {
"suppressContentLengthHeader" : true,
"suppressConnectionHeader" : true
}
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"" : {
""path"" : ""/some/path""
},
""httpResponse"" : {
""body"" : ""some_response_body"",
""connectionOptions"" : {
""suppressContentLengthHeader"" : true,
""suppressConnectionHeader"" : true
}
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest" : {
"path" : "/some/path"
},
"httpResponse" : {
"body" : "some_response_body",
"connectionOptions" : {
"suppressContentLengthHeader" : true,
"suppressConnectionHeader" : true
}
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest" : {
"path" : "/some/path"
},
"httpResponse" : {
"body" : "some_response_body",
"connectionOptions" : {
"suppressContentLengthHeader" : true,
"suppressConnectionHeader" : true
}
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest" : {
"path" : "/some/path"
},
"httpResponse" : {
"body" : "some_response_body",
"connectionOptions" : {
"suppressContentLengthHeader" : true,
"suppressConnectionHeader" : true
}
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path")
)
.respond(
response()
.withBody("some_response_body")
.withConnectionOptions(
connectionOptions()
.withKeepAliveOverride(false)
.withContentLengthHeaderOverride(10)
)
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest" : {
"path" : "/some/path"
},
"httpResponse" : {
"body" : "some_response_body",
"connectionOptions" : {
"contentLengthHeaderOverride" : 10,
"keepAliveOverride" : false
}
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest" : {
"path" : "/some/path"
},
"httpResponse" : {
"body" : "some_response_body",
"connectionOptions" : {
"contentLengthHeaderOverride" : 10,
"keepAliveOverride" : false
}
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest" : {
"path" : "/some/path"
},
"httpResponse" : {
"body" : "some_response_body",
"connectionOptions" : {
"contentLengthHeaderOverride" : 10,
"keepAliveOverride" : false
}
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest" : {
"path" : "/some/path"
},
"httpResponse" : {
"body" : "some_response_body",
"connectionOptions" : {
"contentLengthHeaderOverride" : 10,
"keepAliveOverride" : false
}
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"" : {
""path"" : ""/some/path""
},
""httpResponse"" : {
""body"" : ""some_response_body"",
""connectionOptions"" : {
""contentLengthHeaderOverride"" : 10,
""keepAliveOverride"" : false
}
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest" : {
"path" : "/some/path"
},
"httpResponse" : {
"body" : "some_response_body",
"connectionOptions" : {
"contentLengthHeaderOverride" : 10,
"keepAliveOverride" : false
}
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest" : {
"path" : "/some/path"
},
"httpResponse" : {
"body" : "some_response_body",
"connectionOptions" : {
"contentLengthHeaderOverride" : 10,
"keepAliveOverride" : false
}
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest" : {
"path" : "/some/path"
},
"httpResponse" : {
"body" : "some_response_body",
"connectionOptions" : {
"contentLengthHeaderOverride" : 10,
"keepAliveOverride" : false
}
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path")
)
.respond(
response()
.withBody("some_response_body")
.withConnectionOptions(
connectionOptions()
.withCloseSocket(true)
)
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest" : {
"path" : "/some/path"
},
"httpResponse" : {
"body" : "some_response_body",
"connectionOptions" : {
"closeSocket" : true
}
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest" : {
"path" : "/some/path"
},
"httpResponse" : {
"body" : "some_response_body",
"connectionOptions" : {
"closeSocket" : true
}
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest" : {
"path" : "/some/path"
},
"httpResponse" : {
"body" : "some_response_body",
"connectionOptions" : {
"closeSocket" : true
}
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest" : {
"path" : "/some/path"
},
"httpResponse" : {
"body" : "some_response_body",
"connectionOptions" : {
"closeSocket" : true
}
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"" : {
""path"" : ""/some/path""
},
""httpResponse"" : {
""body"" : ""some_response_body"",
""connectionOptions"" : {
""closeSocket"" : true
}
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest" : {
"path" : "/some/path"
},
"httpResponse" : {
"body" : "some_response_body",
"connectionOptions" : {
"closeSocket" : true
}
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest" : {
"path" : "/some/path"
},
"httpResponse" : {
"body" : "some_response_body",
"connectionOptions" : {
"closeSocket" : true
}
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest" : {
"path" : "/some/path"
},
"httpResponse" : {
"body" : "some_response_body",
"connectionOptions" : {
"closeSocket" : true
}
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path")
)
.respond(
response()
.withBody("some_response_body")
.withConnectionOptions(
connectionOptions()
.withCloseSocket(true)
.withCloseSocketDelay(new Delay(MILLISECONDS, 500))
)
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest" : {
"path" : "/some/path"
},
"httpResponse" : {
"body" : "some_response_body",
"connectionOptions" : {
"closeSocket" : true,
"closeSocketDelay" : {
"timeUnit" : "MILLISECONDS",
"value" : 500
}
}
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest" : {
"path" : "/some/path"
},
"httpResponse" : {
"body" : "some_response_body",
"connectionOptions" : {
"closeSocket" : true,
"closeSocketDelay" : {
"timeUnit" : "MILLISECONDS",
"value" : 500
}
}
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest" : {
"path" : "/some/path"
},
"httpResponse" : {
"body" : "some_response_body",
"connectionOptions" : {
"closeSocket" : true,
"closeSocketDelay" : {
"timeUnit" : "MILLISECONDS",
"value" : 500
}
}
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest" : {
"path" : "/some/path"
},
"httpResponse" : {
"body" : "some_response_body",
"connectionOptions" : {
"closeSocket" : true,
"closeSocketDelay" : {
"timeUnit" : "MILLISECONDS",
"value" : 500
}
}
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"" : {
""path"" : ""/some/path""
},
""httpResponse"" : {
""body"" : ""some_response_body"",
""connectionOptions"" : {
""closeSocket"" : true,
""closeSocketDelay"" : {
""timeUnit"" : ""MILLISECONDS"",
""value"" : 500
}
}
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest" : {
"path" : "/some/path"
},
"httpResponse" : {
"body" : "some_response_body",
"connectionOptions" : {
"closeSocket" : true,
"closeSocketDelay" : {
"timeUnit" : "MILLISECONDS",
"value" : 500
}
}
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest" : {
"path" : "/some/path"
},
"httpResponse" : {
"body" : "some_response_body",
"connectionOptions" : {
"closeSocket" : true,
"closeSocketDelay" : {
"timeUnit" : "MILLISECONDS",
"value" : 500
}
}
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest" : {
"path" : "/some/path"
},
"httpResponse" : {
"body" : "some_response_body",
"connectionOptions" : {
"closeSocket" : true,
"closeSocketDelay" : {
"timeUnit" : "MILLISECONDS",
"value" : 500
}
}
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path")
)
.respond(
response()
.withBody("some_long_response_body_delivered_in_chunks")
.withConnectionOptions(
connectionOptions()
.withChunkSize(10)
.withChunkDelay(new Delay(MILLISECONDS, 500))
)
);
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest" : {
"path" : "/some/path"
},
"httpResponse" : {
"body" : "some_long_response_body_delivered_in_chunks",
"connectionOptions" : {
"chunkSize" : 10,
"chunkDelay" : {
"timeUnit" : "MILLISECONDS",
"value" : 500
}
}
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest" : {
"path" : "/some/path"
},
"httpResponse" : {
"body" : "some_long_response_body_delivered_in_chunks",
"connectionOptions" : {
"chunkSize" : 10,
"chunkDelay" : {
"timeUnit" : "MILLISECONDS",
"value" : 500
}
}
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest" : {
"path" : "/some/path"
},
"httpResponse" : {
"body" : "some_long_response_body_delivered_in_chunks",
"connectionOptions" : {
"chunkSize" : 10,
"chunkDelay" : {
"timeUnit" : "MILLISECONDS",
"value" : 500
}
}
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"" : {
""path"" : ""/some/path""
},
""httpResponse"" : {
""body"" : ""some_long_response_body_delivered_in_chunks"",
""connectionOptions"" : {
""chunkSize"" : 10,
""chunkDelay"" : {
""timeUnit"" : ""MILLISECONDS"",
""value"" : 500
}
}
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest" : {
"path" : "/some/path"
},
"httpResponse" : {
"body" : "some_long_response_body_delivered_in_chunks",
"connectionOptions" : {
"chunkSize" : 10,
"chunkDelay" : {
"timeUnit" : "MILLISECONDS",
"value" : 500
}
}
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest" : {
"path" : "/some/path"
},
"httpResponse" : {
"body" : "some_long_response_body_delivered_in_chunks",
"connectionOptions" : {
"chunkSize" : 10,
"chunkDelay" : {
"timeUnit" : "MILLISECONDS",
"value" : 500
}
}
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest" : {
"path" : "/some/path"
},
"httpResponse" : {
"body" : "some_long_response_body_delivered_in_chunks",
"connectionOptions" : {
"chunkSize" : 10,
"chunkDelay" : {
"timeUnit" : "MILLISECONDS",
"value" : 500
}
}
}
}'
See REST API for full JSON specification
// $!request.headers['Session-Id'] returns an array of values because headers and queryStringParameters have multiple values
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path")
)
.respond(
template(
HttpTemplate.TemplateType.JAVASCRIPT,
"return {\n" +
" 'statusCode': 200,\n" +
" 'cookies': {\n" +
" 'session' : request.headers['Session-Id'][0]\n" +
" },\n" +
" 'headers': {\n" +
" 'Date' : Date()\n" +
" },\n" +
" 'body': JSON.stringify(\n" +
" {\n" +
" method: request.method,\n" +
" path: request.path,\n" +
" body: request.body\n" +
" }\n" +
" )\n" +
"};"
)
);
var mockServerClient = require('mockserver-client').mockServerClient;
// $!request.headers['Session-Id'] returns an array of values because headers and queryStringParameters have multiple values
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"path": "/some/path"
},
"httpResponseTemplate": {
"template": "return { statusCode: 200, cookies: { session: request.headers[\"Session-Id\"] && request.headers[\"Session-Id\"][0] }, headers: { Date: [ Date() ] }, body: JSON.stringify({method: request.method, path: request.path, body: request.body}) };",
"templateType": "JAVASCRIPT"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest": {
"path": "/some/path"
},
"httpResponseTemplate": {
"template": "return { statusCode: 200, cookies: { session: request.headers[\"Session-Id\"] && request.headers[\"Session-Id\"][0] }, headers: { Date: [ Date() ] }, body: JSON.stringify({method: request.method, path: request.path, body: request.body}) };",
"templateType": "JAVASCRIPT"
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest": {
"path": "/some/path"
},
"httpResponseTemplate": {
"template": "return { statusCode: 200, cookies: { session: request.headers[\"Session-Id\"] && request.headers[\"Session-Id\"][0] }, headers: { Date: [ Date() ] }, body: JSON.stringify({method: request.method, path: request.path, body: request.body}) };",
"templateType": "JAVASCRIPT"
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest": {
"path": "/some/path"
},
"httpResponseTemplate": {
"template": "return { statusCode: 200, cookies: { session: request.headers[\"Session-Id\"] && request.headers[\"Session-Id\"][0] }, headers: { Date: [ Date() ] }, body: JSON.stringify({method: request.method, path: request.path, body: request.body}) };",
"templateType": "JAVASCRIPT"
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"": {
""path"": ""/some/path""
},
""httpResponseTemplate"": {
""template"": ""return { statusCode: 200, cookies: { session: request.headers[\""Session-Id\""] && request.headers[\""Session-Id\""][0] }, headers: { Date: [ Date() ] }, body: JSON.stringify({method: request.method, path: request.path, body: request.body}) };"",
""templateType"": ""JAVASCRIPT""
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest": {
"path": "/some/path"
},
"httpResponseTemplate": {
"template": "return { statusCode: 200, cookies: { session: request.headers[\"Session-Id\"] && request.headers[\"Session-Id\"][0] }, headers: { Date: [ Date() ] }, body: JSON.stringify({method: request.method, path: request.path, body: request.body}) };",
"templateType": "JAVASCRIPT"
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest": {
"path": "/some/path"
},
"httpResponseTemplate": {
"template": "return { statusCode: 200, cookies: { session: request.headers[\"Session-Id\"] && request.headers[\"Session-Id\"][0] }, headers: { Date: [ Date() ] }, body: JSON.stringify({method: request.method, path: request.path, body: request.body}) };",
"templateType": "JAVASCRIPT"
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"path": "/some/path"
},
"httpResponseTemplate": {
"template": "return { statusCode: 200, cookies: { session: request.headers[\"Session-Id\"] && request.headers[\"Session-Id\"][0] }, headers: { Date: [ Date() ] }, body: JSON.stringify({method: request.method, path: request.path, body: request.body}) };",
"templateType": "JAVASCRIPT"
}
}'
See REST API for full JSON specification
To simplify handling different types of bodies, JavaScript and Velocity templates, have access to both an object request.body field and a string request.bodyAsString field which can be used as shown in the examples below.
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path")
)
.respond(
template(
HttpTemplate.TemplateType.JAVASCRIPT,
"return { statusCode: 200, headers: { Date: [ Date() ] }, body: JSON.stringify({is_active: JSON.parse(request.bodyAsString).is_active, id: \"1234\", name: \"taras\"}) };"
)
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"path": "/some/path"
},
"httpResponseTemplate": {
"template": "return { statusCode: 200, headers: { Date: [ Date() ] }, body: JSON.stringify({is_active: JSON.parse(request.bodyAsString).is_active, id: \"1234\", name: \"taras\"}) };",
"templateType": "JAVASCRIPT"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest": {
"path": "/some/path"
},
"httpResponseTemplate": {
"template": "return { statusCode: 200, headers: { Date: [ Date() ] }, body: JSON.stringify({is_active: JSON.parse(request.bodyAsString).is_active, id: \"1234\", name: \"taras\"}) };",
"templateType": "JAVASCRIPT"
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest": {
"path": "/some/path"
},
"httpResponseTemplate": {
"template": "return { statusCode: 200, headers: { Date: [ Date() ] }, body: JSON.stringify({is_active: JSON.parse(request.bodyAsString).is_active, id: \"1234\", name: \"taras\"}) };",
"templateType": "JAVASCRIPT"
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest": {
"path": "/some/path"
},
"httpResponseTemplate": {
"template": "return { statusCode: 200, headers: { Date: [ Date() ] }, body: JSON.stringify({is_active: JSON.parse(request.bodyAsString).is_active, id: \"1234\", name: \"taras\"}) };",
"templateType": "JAVASCRIPT"
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"": {
""path"": ""/some/path""
},
""httpResponseTemplate"": {
""template"": ""return { statusCode: 200, headers: { Date: [ Date() ] }, body: JSON.stringify({is_active: JSON.parse(request.bodyAsString).is_active, id: \""1234\"", name: \""taras\""}) };"",
""templateType"": ""JAVASCRIPT""
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest": {
"path": "/some/path"
},
"httpResponseTemplate": {
"template": "return { statusCode: 200, headers: { Date: [ Date() ] }, body: JSON.stringify({is_active: JSON.parse(request.bodyAsString).is_active, id: \"1234\", name: \"taras\"}) };",
"templateType": "JAVASCRIPT"
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest": {
"path": "/some/path"
},
"httpResponseTemplate": {
"template": "return { statusCode: 200, headers: { Date: [ Date() ] }, body: JSON.stringify({is_active: JSON.parse(request.bodyAsString).is_active, id: \"1234\", name: \"taras\"}) };",
"templateType": "JAVASCRIPT"
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"path": "/some/path"
},
"httpResponseTemplate": {
"template": "return { statusCode: 200, headers: { Date: [ Date() ] }, body: JSON.stringify({is_active: JSON.parse(request.bodyAsString).is_active, id: \"1234\", name: \"taras\"}) };",
"templateType": "JAVASCRIPT"
}
}'
See REST API for full JSON specification
String template = "" +
"if (request.method === 'POST' && request.path === '/somePath') {\n" +
" return {\n" +
" 'statusCode': 200,\n" +
" 'body': JSON.stringify({name: 'value'})\n" +
" };\n" +
"} else {\n" +
" return {\n" +
" 'statusCode': 406,\n" +
" 'body': request.body\n" +
" };\n" +
"}";
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path")
)
.respond(
template(HttpTemplate.TemplateType.JAVASCRIPT)
.withTemplate(template)
.withDelay(TimeUnit.MINUTES, 2)
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {"path": "/some/path"},
"httpResponseTemplate": {
"template": "if (request.method === \"POST\" && request.path === \"/some/path\") { return { statusCode: 200, body: JSON.stringify({name: \"value\"}) }; } else { return { statusCode: 406, body: request.body }; }",
"templateType": "JAVASCRIPT",
"delay": {"timeUnit": "MINUTES", "value": 2}
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest": {"path": "/some/path"},
"httpResponseTemplate": {
"template": "if (request.method === \"POST\" && request.path === \"/some/path\") { return { statusCode: 200, body: JSON.stringify({name: \"value\"}) }; } else { return { statusCode: 406, body: request.body }; }",
"templateType": "JAVASCRIPT",
"delay": {"timeUnit": "MINUTES", "value": 2}
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest": {"path": "/some/path"},
"httpResponseTemplate": {
"template": "if (request.method === \"POST\" && request.path === \"/some/path\") { return { statusCode: 200, body: JSON.stringify({name: \"value\"}) }; } else { return { statusCode: 406, body: request.body }; }",
"templateType": "JAVASCRIPT",
"delay": {"timeUnit": "MINUTES", "value": 2}
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest": {"path": "/some/path"},
"httpResponseTemplate": {
"template": "if (request.method === \"POST\" && request.path === \"/some/path\") { return { statusCode: 200, body: JSON.stringify({name: \"value\"}) }; } else { return { statusCode: 406, body: request.body }; }",
"templateType": "JAVASCRIPT",
"delay": {"timeUnit": "MINUTES", "value": 2}
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"": {""path"": ""/some/path""},
""httpResponseTemplate"": {
""template"": ""if (request.method === \""POST\"" && request.path === \""/some/path\"") { return { statusCode: 200, body: JSON.stringify({name: \""value\""}) }; } else { return { statusCode: 406, body: request.body }; }"",
""templateType"": ""JAVASCRIPT"",
""delay"": {""timeUnit"": ""MINUTES"", ""value"": 2}
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest": {"path": "/some/path"},
"httpResponseTemplate": {
"template": "if (request.method === \"POST\" && request.path === \"/some/path\") { return { statusCode: 200, body: JSON.stringify({name: \"value\"}) }; } else { return { statusCode: 406, body: request.body }; }",
"templateType": "JAVASCRIPT",
"delay": {"timeUnit": "MINUTES", "value": 2}
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest": {"path": "/some/path"},
"httpResponseTemplate": {
"template": "if (request.method === \"POST\" && request.path === \"/some/path\") { return { statusCode: 200, body: JSON.stringify({name: \"value\"}) }; } else { return { statusCode: 406, body: request.body }; }",
"templateType": "JAVASCRIPT",
"delay": {"timeUnit": "MINUTES", "value": 2}
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {"path": "/some/path"},
"httpResponseTemplate": {
"template": "if (request.method === \"POST\" && request.path === \"/some/path\") { return { statusCode: 200, body: JSON.stringify({name: \"value\"}) }; } else { return { statusCode: 406, body: request.body }; }",
"templateType": "JAVASCRIPT",
"delay": {"timeUnit": "MINUTES", "value": 2}
}
}'
See REST API for full JSON specification
// $!request.headers['Session-Id'] and $!request.headers['User-Agent'] both returns an
// array of values because headers and queryStringParameters have multiple values
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path")
)
.respond(
template(
HttpTemplate.TemplateType.VELOCITY,
"{\n" +
" \"statusCode\": 200,\n" +
" \"cookies\": { \n" +
" \"session\": \"$!request.headers['Session-Id'][0]\"\n" +
" },\n" +
" \"headers\": {\n" +
" \"Client-User-Agent\": [ \"$!request.headers['User-Agent'][0]\" ]\n" +
" },\n" +
" \"body\": $!request.body\n" +
"}"
)
);
var mockServerClient = require('mockserver-client').mockServerClient;
// $!request.headers['Session-Id'] and $!request.headers['User-Agent'] both returns an
// array of values because headers and queryStringParameters have multiple values
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"path": "/some/path"
},
"httpResponseTemplate": {
"template": "{ \"statusCode\": 200, \"cookies\": { \"session\": \"$!request.headers[\"Session-Id\"][0]\" }, \"headers\": { \"Client-User-Agent\": [ \"$!request.headers[\"User-Agent\"][0]\" ] }, \"body\": \"$!request.body\" }",
"templateType": "VELOCITY"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest": {
"path": "/some/path"
},
"httpResponseTemplate": {
"template": "{ \"statusCode\": 200, \"cookies\": { \"session\": \"$!request.headers[\"Session-Id\"][0]\" }, \"headers\": { \"Client-User-Agent\": [ \"$!request.headers[\"User-Agent\"][0]\" ] }, \"body\": \"$!request.body\" }",
"templateType": "VELOCITY"
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest": {
"path": "/some/path"
},
"httpResponseTemplate": {
"template": "{ \"statusCode\": 200, \"cookies\": { \"session\": \"$!request.headers[\"Session-Id\"][0]\" }, \"headers\": { \"Client-User-Agent\": [ \"$!request.headers[\"User-Agent\"][0]\" ] }, \"body\": \"$!request.body\" }",
"templateType": "VELOCITY"
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest": {
"path": "/some/path"
},
"httpResponseTemplate": {
"template": "{ \"statusCode\": 200, \"cookies\": { \"session\": \"$!request.headers[\"Session-Id\"][0]\" }, \"headers\": { \"Client-User-Agent\": [ \"$!request.headers[\"User-Agent\"][0]\" ] }, \"body\": \"$!request.body\" }",
"templateType": "VELOCITY"
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"": {
""path"": ""/some/path""
},
""httpResponseTemplate"": {
""template"": ""{ \""statusCode\"": 200, \""cookies\"": { \""session\"": \""$!request.headers[\""Session-Id\""][0]\"" }, \""headers\"": { \""Client-User-Agent\"": [ \""$!request.headers[\""User-Agent\""][0]\"" ] }, \""body\"": \""$!request.body\"" }"",
""templateType"": ""VELOCITY""
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest": {
"path": "/some/path"
},
"httpResponseTemplate": {
"template": "{ \"statusCode\": 200, \"cookies\": { \"session\": \"$!request.headers[\"Session-Id\"][0]\" }, \"headers\": { \"Client-User-Agent\": [ \"$!request.headers[\"User-Agent\"][0]\" ] }, \"body\": \"$!request.body\" }",
"templateType": "VELOCITY"
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest": {
"path": "/some/path"
},
"httpResponseTemplate": {
"template": "{ \"statusCode\": 200, \"cookies\": { \"session\": \"$!request.headers[\"Session-Id\"][0]\" }, \"headers\": { \"Client-User-Agent\": [ \"$!request.headers[\"User-Agent\"][0]\" ] }, \"body\": \"$!request.body\" }",
"templateType": "VELOCITY"
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"path": "/some/path"
},
"httpResponseTemplate": {
"template": "{ \"statusCode\": 200, \"cookies\": { \"session\": \"$!request.headers[\"Session-Id\"][0]\" }, \"headers\": { \"Client-User-Agent\": [ \"$!request.headers[\"User-Agent\"][0]\" ] }, \"body\": \"$!request.body\" }",
"templateType": "VELOCITY"
}
}'
See REST API for full JSON specification
public class CallbackActionExamples {
public void responseClassCallback() {
new ClientAndServer(1080)
.when(
request()
.withPath("/some.*")
)
.respond(
callback()
.withCallbackClass(TestExpectationResponseCallback.class)
);
}
public static class TestExpectationResponseCallback implements ExpectationResponseCallback {
@Override
public HttpResponse handle(HttpRequest httpRequest) {
if (httpRequest.getPath().getValue().endsWith("/path")) {
return response()
.withStatusCode(HttpStatusCode.ACCEPTED_202.code())
.withHeaders(
header("x-callback", "test_callback_header"),
header("Content-Length", "a_callback_response".getBytes(UTF_8).length),
header("Connection", "keep-alive")
)
.withBody("a_callback_response");
} else {
return notFoundResponse();
}
}
}
}
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"path": "/some.*"
},
"httpResponseClassCallback": {
"callbackClass": "org.mockserver.examples.mockserver.CallbackActionExamples$TestExpectationResponseCallback"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest" : {
"path" : "/some.*"
},
"httpResponseClassCallback" : {
"callbackClass" : "org.mockserver.examples.mockserver.CallbackActionExamples$TestExpectationResponseCallback"
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest" : {
"path" : "/some.*"
},
"httpResponseClassCallback" : {
"callbackClass" : "org.mockserver.examples.mockserver.CallbackActionExamples$TestExpectationResponseCallback"
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest" : {
"path" : "/some.*"
},
"httpResponseClassCallback" : {
"callbackClass" : "org.mockserver.examples.mockserver.CallbackActionExamples$TestExpectationResponseCallback"
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"" : {
""path"" : ""/some.*""
},
""httpResponseClassCallback"" : {
""callbackClass"" : ""org.mockserver.examples.mockserver.CallbackActionExamples$TestExpectationResponseCallback""
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest" : {
"path" : "/some.*"
},
"httpResponseClassCallback" : {
"callbackClass" : "org.mockserver.examples.mockserver.CallbackActionExamples$TestExpectationResponseCallback"
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest" : {
"path" : "/some.*"
},
"httpResponseClassCallback" : {
"callbackClass" : "org.mockserver.examples.mockserver.CallbackActionExamples$TestExpectationResponseCallback"
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest" : {
"path" : "/some.*"
},
"httpResponseClassCallback" : {
"callbackClass" : "org.mockserver.examples.mockserver.CallbackActionExamples$TestExpectationResponseCallback"
}
}'
To use a class callback MockServer must be able to load the class from the classpath.
The callback class must:
- implement
- org.mockserver.mock.action.ExpectationResponseCallback to dynamically override the response
- have a zero argument constructor
- be available in the classpath of the MockServer
If MockServer is started using the the JUnit 4 @Rule, the JUnit 5 Test Extension, ClientAndServer or directly using org.mockserver.netty.MockServer then any class present in the main or test classpaths will be visible to MockServer.
If MockServer is started using the maven plugin only the non-forked goals (such as runAndWait and start) will be able to load classes from the main and test classpaths. It is possible to use classes from a separate maven dependency, however, this dependency must be specified in the plugin configuration dependencies section. Any dependency added to the plugin configuration dependencies section will then be visible to MockServer run using both forked and non-forked goals.
The following configuration shows how to use classes from a separate maven dependency in callback actions.
<plugin>
<groupId>org.mock-server</groupId>
<artifactId>mockserver-maven-plugin</artifactId>
<version>7.1.0</version>
<configuration>
<serverPort>1080</serverPort>
<logLevel>DEBUG</logLevel>
<pipeLogToConsole>true</pipeLogToConsole>
</configuration>
<executions>
<execution>
<id>pre-integration-test</id>
<phase>pre-integration-test</phase>
<goals>
<goal>runForked</goal>
</goals>
</execution>
<execution>
<id>post-integration-test</id>
<phase>post-integration-test</phase>
<goals>
<goal>stopForked</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.my-domain</groupId>
<artifactId>my-callback-dependency</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
</plugin>
If MockServer is started using the command line then the callback classes must be added to the JVM using the classpath command line switch (cp or classpath). The classpath switch is ignored by the JVM if the jar switch is used. So to run the MockServer from the command line directly (with mockserver-netty-7.1.0-no-dependencies.jar) you must specify the org.mockserver.cli.Main main class specifically and not use the jar switch as follows.
java -Dfile.encoding=UTF-8 -cp mockserver-netty-7.1.0-no-dependencies.jar:my-callback-dependency.jar org.mockserver.cli.Main -serverPort 1080
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path")
)
.respond(
new ExpectationResponseCallback() {
@Override
public HttpResponse handle(HttpRequest httpRequest) {
if (httpRequest.getMethod().getValue().equals("POST")) {
return response()
.withStatusCode(ACCEPTED_202.code())
.withHeaders(
header("x-object-callback", "test_object_callback_header")
)
.withBody("an_object_callback_response");
} else {
return notFoundResponse();
}
}
}
);
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path")
)
.respond(
request -> {
if (request.getMethod().getValue().equals("POST")) {
return response()
.withStatusCode(ACCEPTED_202.code())
.withHeaders(
header("x-object-callback", "test_object_callback_header")
)
.withBody("an_object_callback_response");
} else {
return notFoundResponse();
}
}
);
var mockServerClient = require('mockserver-client').mockServerClient;
var callback = function (request) {
if (request.method === 'POST') {
return {
'statusCode': 201,
'header': {
"x-object-callback": ["test_object_callback_header"]
},
'body': "an_object_callback_response"
};
} else {
return {
'statusCode': 404
};
}
};
mockServerClient("localhost", 1080)
.mockWithCallback(
{
'path': '/some/path'
},
callback
)
.then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
When using org.mockserver.client.MockServerClient each method / closure callback has a separate web socket client. To ensure the number of total threads does not grow too large for large numbers of method / closure callback expectations the default event loop thread pool for the web socket client is kept fairly low. However, if an extremely large load is matched against a single method / closure callback expectation the event loop thread pool may not be large enough for its web socket client.
The number of threads for the event loop thread pool for each web socket client (i.e. for each expectation with a method / closure callback) can be configured and is described in the configuration section.
MockServer provides an in-memory file store that can be used with the FileBody type. Files stored via the file store API can be referenced in expectations by name. The file store is cleared when MockServer is reset.
# Store a file
curl -v -X PUT "http://localhost:1080/mockserver/files/store?name=sample.json" \
-H "Content-Type: application/json" \
-d '{"id": 1, "name": "example"}'
# Retrieve a file
curl -v -X PUT "http://localhost:1080/mockserver/files/retrieve" \
-H "Content-Type: application/json" \
-d '{"name": "sample.json"}'
# List all stored files
curl -v -X PUT "http://localhost:1080/mockserver/files/list"
# Delete a file
curl -v -X PUT "http://localhost:1080/mockserver/files/delete" \
-H "Content-Type: application/json" \
-d '{"name": "sample.json"}'
MockServerClient mockServerClient = new MockServerClient("localhost", 1080);
// Store a file, then reference it in an expectation using FileBody
mockServerClient
.when(
request()
.withPath("/api/data")
)
.respond(
response()
.withBodyFromFile("sample.json", MediaType.APPLICATION_JSON)
);
Endpoints:
- PUT /mockserver/files/store?name=<filename> — stores a file with the given name; the request body is the file content
- PUT /mockserver/files/retrieve — retrieves a stored file; the request body is a JSON object with a
"name"field - PUT /mockserver/files/list — lists all stored file names
- PUT /mockserver/files/delete — deletes a stored file; the request body is a JSON object with a
"name"field
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path")
)
.respond(
new ExpectationResponseCallback() {
@Override
public HttpResponse handle(HttpRequest httpRequest) throws Exception {
if (httpRequest.getMethod().getValue().equals("POST")) {
mockServerClient
.when(
request()
.withPath("/some/otherPath")
)
.respond(
response()
.withBody(httpRequest.getBodyAsString())
);
return response()
.withStatusCode(ACCEPTED_202.code())
.withBody("request processed");
} else {
return notFoundResponse();
}
}
}
);
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path")
)
.respond(
httpRequest -> {
if (httpRequest.getMethod().getValue().equals("POST")) {
mockServerClient
.when(
request()
.withPath("/some/otherPath")
)
.respond(
response()
.withBody(httpRequest.getBodyAsString())
);
return response()
.withStatusCode(ACCEPTED_202.code())
.withBody("request processed");
} else {
return notFoundResponse();
}
}
);
var mockServerClient = require('mockserver-client').mockServerClient;
var callback = function (request) {
if (request.method === 'POST') {
mockServerClient("localhost", 1080)
.mockAnyResponse({
"httpRequest": {
"path": "/some/otherPath"
},
"httpResponse": {
"body": request.body.string
}
})
.then(
function () {
console.log("chained expectation created");
},
function (error) {
console.log(error);
}
);
return {
'statusCode': 202,
'body': "request processed"
};
} else {
return {
'statusCode': 404
};
}
};
mockServerClient("localhost", 1080)
.mockWithCallback(
{
'path': '/some/path'
},
callback
)
.then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
When using org.mockserver.client.MockServerClient each method / closure callback has a separate web socket client. To ensure the number of total threads does not grow too large for large numbers of method / closure callback expectations the default event loop thread pool for the web socket client is kept fairly low. However, if an extremely large load is matched against a single method / closure callback expectation the event loop thread pool may not be large enough for its web socket client.
The number of threads for the event loop thread pool for each web socket client (i.e. for each expectation with a method / closure callback) can be configured and is described in the configuration section.
A forward action can be:
-
either an exact forwarder, that forwards requests exactly as it receives them, containing the following:
- host
- port
- scheme
-
or an overridden request (or overridden response), with a delay (including distribution-based delays), that allows any part of a forwarded request or response to be replaced or certain fields (path, headers, cookies or query parameters) to be modified
-
or a templated forwarder using javascript or velocity, with a delay, that allows requests to be modified or completely re-written before they are forwarded
-
or a callback used to dynamically generate the request to forward based on the request received by MockServer:
-
as a server side callback implemented as a java class that has a default constructor, implements org.mockserver.mock.action.ExpectationForwardCallback or org.mockserver.mock.action.ExpectationForwardAndResponseCallback and is available on the classpath
-
as a client side callback implemented as a closure using the java or javascript clients
-
The following code examples show how to create different forward actions.
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path")
)
.forward(
forward()
.withHost("mock-server.com")
.withPort(80)
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"path": "/some/path"
},
"httpForward": {
"host": "mock-server.com",
"port": 80,
"scheme": "HTTP"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import HttpForward, HttpRequest
client = MockServerClient("localhost", 1080)
client.when(
HttpRequest.request("/some/path")
).forward(
HttpForward(host="mock-server.com", port=80, scheme="HTTP")
)
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.when(
MockServer::HttpRequest.new(path: '/some/path')
).forward(
MockServer::HttpForward.new(host: 'mock-server.com', port: 80, scheme: 'HTTP')
)
import mockserver "github.com/mock-server/mockserver-monorepo/mockserver-client-go"
client := mockserver.New("localhost", 1080)
client.When(
mockserver.Request().Path("/some/path"),
).Forward(
mockserver.Forward().Host("mock-server.com").Port(80).Scheme("HTTP"),
)
using MockServer.Client;
using MockServer.Client.Models;
using var client = new MockServerClient("localhost", 1080);
client.When(
HttpRequest.Request().WithPath("/some/path")
).Forward(
HttpForward.Forward().WithHost("mock-server.com").WithPort(80).WithScheme("HTTP")
);
use mockserver_client::{ClientBuilder, HttpRequest, HttpForward};
let client = ClientBuilder::new("localhost", 1080).build().unwrap();
client.when(HttpRequest::new().path("/some/path"))
.forward(HttpForward::new("mock-server.com", 80).scheme("HTTP"))
.unwrap();
use MockServer\MockServerClient;
use MockServer\HttpRequest;
use MockServer\HttpForward;
$client = new MockServerClient('localhost', 1080);
$client->when(
HttpRequest::request()
->path('/some/path')
)->forward(
HttpForward::forward()
->host('mock-server.com')
->port(80)
->scheme('HTTP')
);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"path": "/some/path"
},
"httpForward": {
"host": "mock-server.com",
"port": 80,
"scheme": "HTTP"
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path")
)
.forward(
forward()
.withHost("mock-server.com")
.withPort(443)
.withScheme(HttpForward.Scheme.HTTPS)
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"path": "/some/path"
},
"httpForward": {
"host": "mock-server.com",
"port": 443,
"scheme": "HTTPS"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import HttpForward, HttpRequest
client = MockServerClient("localhost", 1080)
client.when(
HttpRequest.request("/some/path")
).forward(
HttpForward(host="mock-server.com", port=443, scheme="HTTPS")
)
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.when(
MockServer::HttpRequest.new(path: '/some/path')
).forward(
MockServer::HttpForward.new(host: 'mock-server.com', port: 443, scheme: 'HTTPS')
)
import mockserver "github.com/mock-server/mockserver-monorepo/mockserver-client-go"
client := mockserver.New("localhost", 1080)
client.When(
mockserver.Request().Path("/some/path"),
).Forward(
mockserver.Forward().Host("mock-server.com").Port(443).Scheme("HTTPS"),
)
using MockServer.Client;
using MockServer.Client.Models;
using var client = new MockServerClient("localhost", 1080);
client.When(
HttpRequest.Request().WithPath("/some/path")
).Forward(
HttpForward.Forward().WithHost("mock-server.com").WithPort(443).WithScheme("HTTPS")
);
use mockserver_client::{ClientBuilder, HttpRequest, HttpForward};
let client = ClientBuilder::new("localhost", 1080).build().unwrap();
client.when(HttpRequest::new().path("/some/path"))
.forward(HttpForward::new("mock-server.com", 443).scheme("HTTPS"))
.unwrap();
use MockServer\MockServerClient;
use MockServer\HttpRequest;
use MockServer\HttpForward;
$client = new MockServerClient('localhost', 1080);
$client->when(
HttpRequest::request()
->path('/some/path')
)->forward(
HttpForward::forward()
->host('mock-server.com')
->port(443)
->scheme('HTTPS')
);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"path": "/some/path"
},
"httpForward": {
"host": "mock-server.com",
"port": 443,
"scheme": "HTTPS"
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path")
)
.forward(
forwardOverriddenRequest(
request()
.withPath("/some/other/path")
.withHeader("Host", "target.host.com")
)
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"httpRequest": {
"path": "/some/other/path",
"headers": {
"Host": ["target.host.com"]
}
}
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"httpRequest": {
"path": "/some/other/path",
"headers": {
"Host": ["target.host.com"]
}
}
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"httpRequest": {
"path": "/some/other/path",
"headers": {
"Host": ["target.host.com"]
}
}
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"httpRequest": {
"path": "/some/other/path",
"headers": {
"Host": ["target.host.com"]
}
}
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"": {
""path"": ""/some/path""
},
""httpOverrideForwardedRequest"": {
""httpRequest"": {
""path"": ""/some/other/path"",
""headers"": {
""Host"": [""target.host.com""]
}
}
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"httpRequest": {
"path": "/some/other/path",
"headers": {
"Host": ["target.host.com"]
}
}
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"httpRequest": {
"path": "/some/other/path",
"headers": {
"Host": ["target.host.com"]
}
}
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"httpRequest": {
"path": "/some/other/path",
"headers": {
"Host": ["target.host.com"]
}
}
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path")
)
.forward(
forwardOverriddenRequest(
request()
.withPath("/some/other/path")
.withHeader("Host", "target.host.com"),
response()
.withBody("some_overridden_body")
)
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"httpRequest": {
"path": "/some/other/path",
"headers": {
"Host": ["target.host.com"]
}
},
"httpResponse": {
"body": "some_overridden_body"
}
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"httpRequest": {
"path": "/some/other/path",
"headers": {
"Host": ["target.host.com"]
}
},
"httpResponse": {
"body": "some_overridden_body"
}
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"httpRequest": {
"path": "/some/other/path",
"headers": {
"Host": ["target.host.com"]
}
},
"httpResponse": {
"body": "some_overridden_body"
}
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"httpRequest": {
"path": "/some/other/path",
"headers": {
"Host": ["target.host.com"]
}
},
"httpResponse": {
"body": "some_overridden_body"
}
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"": {
""path"": ""/some/path""
},
""httpOverrideForwardedRequest"": {
""httpRequest"": {
""path"": ""/some/other/path"",
""headers"": {
""Host"": [""target.host.com""]
}
},
""httpResponse"": {
""body"": ""some_overridden_body""
}
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"httpRequest": {
"path": "/some/other/path",
"headers": {
"Host": ["target.host.com"]
}
},
"httpResponse": {
"body": "some_overridden_body"
}
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"httpRequest": {
"path": "/some/other/path",
"headers": {
"Host": ["target.host.com"]
}
},
"httpResponse": {
"body": "some_overridden_body"
}
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"httpRequest": {
"path": "/some/other/path",
"headers": {
"Host": ["target.host.com"]
}
},
"httpResponse": {
"body": "some_overridden_body"
}
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path")
)
.forward(
forwardOverriddenRequest(
request()
// this replaces the entire set of headers
.withHeader("Host", "target.host.com")
.withBody("some_overridden_body"),
requestModifier()
.withPath("^/(.+)/(.+)$", "/prefix/$1/infix/$2/postfix")
.withQueryStringParameters(
queryParametersModifier()
.add(
param("parameterToAddOne", "addedValue"),
param("parameterToAddTwo", "addedValue")
)
.replace(
param("overrideParameterToReplace", "replacedValue"),
param("requestParameterToReplace", "replacedValue"),
param("extraParameterToReplace", "shouldBeIgnore")
)
.remove(
"overrideParameterToRemove",
"requestParameterToRemove"
)
)
// this modifies the set of headers
.withHeaders(
headersModifier()
.add(
header("headerToAddOne", "addedValue"),
header("headerToAddTwo", "addedValue")
)
.replace(
header("overrideHeaderToReplace", "replacedValue"),
header("requestHeaderToReplace", "replacedValue"),
header("extraHeaderToReplace", "shouldBeIgnore")
)
.remove(
"overrideHeaderToRemove",
"requestHeaderToRemove"
)
)
.withCookies(
cookiesModifier()
.add(
cookie("cookieToAddOne", "addedValue"),
cookie("cookieToAddTwo", "addedValue")
)
.replace(
cookie("overrideCookieToReplace", "replacedValue"),
cookie("requestCookieToReplace", "replacedValue"),
cookie("extraCookieToReplace", "shouldBeIgnore")
)
.remove(
"overrideCookieToRemove",
"requestCookieToRemove"
)
)
)
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"requestOverride": {
"headers": {
"Host": [
"target.host.com"
]
},
"body": "some_overridden_body"
},
"requestModifier": {
"cookies": {
"add": {
"cookieToAddOne": "addedValue",
"cookieToAddTwo": "addedValue"
},
"remove": [
"overrideCookieToRemove",
"requestCookieToRemove"
],
"replace": {
"overrideCookieToReplace": "replacedValue",
"requestCookieToReplace": "replacedValue",
"extraCookieToReplace": "shouldBeIgnore"
}
},
"headers": {
"add": {
"headerToAddTwo": [
"addedValue"
],
"headerToAddOne": [
"addedValue"
]
},
"remove": [
"overrideHeaderToRemove",
"requestHeaderToRemove"
],
"replace": {
"requestHeaderToReplace": [
"replacedValue"
],
"overrideHeaderToReplace": [
"replacedValue"
],
"extraHeaderToReplace": [
"shouldBeIgnore"
]
}
},
"path": {
"regex": "^/(.+)/(.+)$",
"substitution": "/prefix/$1/infix/$2/postfix"
},
"queryStringParameters": {
"add": {
"parameterToAddTwo": [
"addedValue"
],
"parameterToAddOne": [
"addedValue"
]
},
"remove": [
"overrideParameterToRemove",
"requestParameterToRemove"
],
"replace": {
"requestParameterToReplace": [
"replacedValue"
],
"overrideParameterToReplace": [
"replacedValue"
],
"extraParameterToReplace": [
"shouldBeIgnore"
]
}
}
}
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"requestOverride": {
"headers": {
"Host": [
"target.host.com"
]
},
"body": "some_overridden_body"
},
"requestModifier": {
"cookies": {
"add": {
"cookieToAddOne": "addedValue",
"cookieToAddTwo": "addedValue"
},
"remove": [
"overrideCookieToRemove",
"requestCookieToRemove"
],
"replace": {
"overrideCookieToReplace": "replacedValue",
"requestCookieToReplace": "replacedValue",
"extraCookieToReplace": "shouldBeIgnore"
}
},
"headers": {
"add": {
"headerToAddTwo": [
"addedValue"
],
"headerToAddOne": [
"addedValue"
]
},
"remove": [
"overrideHeaderToRemove",
"requestHeaderToRemove"
],
"replace": {
"requestHeaderToReplace": [
"replacedValue"
],
"overrideHeaderToReplace": [
"replacedValue"
],
"extraHeaderToReplace": [
"shouldBeIgnore"
]
}
},
"path": {
"regex": "^/(.+)/(.+)$",
"substitution": "/prefix/$1/infix/$2/postfix"
},
"queryStringParameters": {
"add": {
"parameterToAddTwo": [
"addedValue"
],
"parameterToAddOne": [
"addedValue"
]
},
"remove": [
"overrideParameterToRemove",
"requestParameterToRemove"
],
"replace": {
"requestParameterToReplace": [
"replacedValue"
],
"overrideParameterToReplace": [
"replacedValue"
],
"extraParameterToReplace": [
"shouldBeIgnore"
]
}
}
}
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"requestOverride": {
"headers": {
"Host": [
"target.host.com"
]
},
"body": "some_overridden_body"
},
"requestModifier": {
"cookies": {
"add": {
"cookieToAddOne": "addedValue",
"cookieToAddTwo": "addedValue"
},
"remove": [
"overrideCookieToRemove",
"requestCookieToRemove"
],
"replace": {
"overrideCookieToReplace": "replacedValue",
"requestCookieToReplace": "replacedValue",
"extraCookieToReplace": "shouldBeIgnore"
}
},
"headers": {
"add": {
"headerToAddTwo": [
"addedValue"
],
"headerToAddOne": [
"addedValue"
]
},
"remove": [
"overrideHeaderToRemove",
"requestHeaderToRemove"
],
"replace": {
"requestHeaderToReplace": [
"replacedValue"
],
"overrideHeaderToReplace": [
"replacedValue"
],
"extraHeaderToReplace": [
"shouldBeIgnore"
]
}
},
"path": {
"regex": "^/(.+)/(.+)$",
"substitution": "/prefix/$1/infix/$2/postfix"
},
"queryStringParameters": {
"add": {
"parameterToAddTwo": [
"addedValue"
],
"parameterToAddOne": [
"addedValue"
]
},
"remove": [
"overrideParameterToRemove",
"requestParameterToRemove"
],
"replace": {
"requestParameterToReplace": [
"replacedValue"
],
"overrideParameterToReplace": [
"replacedValue"
],
"extraParameterToReplace": [
"shouldBeIgnore"
]
}
}
}
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"requestOverride": {
"headers": {
"Host": [
"target.host.com"
]
},
"body": "some_overridden_body"
},
"requestModifier": {
"cookies": {
"add": {
"cookieToAddOne": "addedValue",
"cookieToAddTwo": "addedValue"
},
"remove": [
"overrideCookieToRemove",
"requestCookieToRemove"
],
"replace": {
"overrideCookieToReplace": "replacedValue",
"requestCookieToReplace": "replacedValue",
"extraCookieToReplace": "shouldBeIgnore"
}
},
"headers": {
"add": {
"headerToAddTwo": [
"addedValue"
],
"headerToAddOne": [
"addedValue"
]
},
"remove": [
"overrideHeaderToRemove",
"requestHeaderToRemove"
],
"replace": {
"requestHeaderToReplace": [
"replacedValue"
],
"overrideHeaderToReplace": [
"replacedValue"
],
"extraHeaderToReplace": [
"shouldBeIgnore"
]
}
},
"path": {
"regex": "^/(.+)/(.+)$",
"substitution": "/prefix/$1/infix/$2/postfix"
},
"queryStringParameters": {
"add": {
"parameterToAddTwo": [
"addedValue"
],
"parameterToAddOne": [
"addedValue"
]
},
"remove": [
"overrideParameterToRemove",
"requestParameterToRemove"
],
"replace": {
"requestParameterToReplace": [
"replacedValue"
],
"overrideParameterToReplace": [
"replacedValue"
],
"extraParameterToReplace": [
"shouldBeIgnore"
]
}
}
}
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"": {
""path"": ""/some/path""
},
""httpOverrideForwardedRequest"": {
""requestOverride"": {
""headers"": {
""Host"": [
""target.host.com""
]
},
""body"": ""some_overridden_body""
},
""requestModifier"": {
""cookies"": {
""add"": {
""cookieToAddOne"": ""addedValue"",
""cookieToAddTwo"": ""addedValue""
},
""remove"": [
""overrideCookieToRemove"",
""requestCookieToRemove""
],
""replace"": {
""overrideCookieToReplace"": ""replacedValue"",
""requestCookieToReplace"": ""replacedValue"",
""extraCookieToReplace"": ""shouldBeIgnore""
}
},
""headers"": {
""add"": {
""headerToAddTwo"": [
""addedValue""
],
""headerToAddOne"": [
""addedValue""
]
},
""remove"": [
""overrideHeaderToRemove"",
""requestHeaderToRemove""
],
""replace"": {
""requestHeaderToReplace"": [
""replacedValue""
],
""overrideHeaderToReplace"": [
""replacedValue""
],
""extraHeaderToReplace"": [
""shouldBeIgnore""
]
}
},
""path"": {
""regex"": ""^/(.+)/(.+)$"",
""substitution"": ""/prefix/$1/infix/$2/postfix""
},
""queryStringParameters"": {
""add"": {
""parameterToAddTwo"": [
""addedValue""
],
""parameterToAddOne"": [
""addedValue""
]
},
""remove"": [
""overrideParameterToRemove"",
""requestParameterToRemove""
],
""replace"": {
""requestParameterToReplace"": [
""replacedValue""
],
""overrideParameterToReplace"": [
""replacedValue""
],
""extraParameterToReplace"": [
""shouldBeIgnore""
]
}
}
}
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"requestOverride": {
"headers": {
"Host": [
"target.host.com"
]
},
"body": "some_overridden_body"
},
"requestModifier": {
"cookies": {
"add": {
"cookieToAddOne": "addedValue",
"cookieToAddTwo": "addedValue"
},
"remove": [
"overrideCookieToRemove",
"requestCookieToRemove"
],
"replace": {
"overrideCookieToReplace": "replacedValue",
"requestCookieToReplace": "replacedValue",
"extraCookieToReplace": "shouldBeIgnore"
}
},
"headers": {
"add": {
"headerToAddTwo": [
"addedValue"
],
"headerToAddOne": [
"addedValue"
]
},
"remove": [
"overrideHeaderToRemove",
"requestHeaderToRemove"
],
"replace": {
"requestHeaderToReplace": [
"replacedValue"
],
"overrideHeaderToReplace": [
"replacedValue"
],
"extraHeaderToReplace": [
"shouldBeIgnore"
]
}
},
"path": {
"regex": "^/(.+)/(.+)$",
"substitution": "/prefix/$1/infix/$2/postfix"
},
"queryStringParameters": {
"add": {
"parameterToAddTwo": [
"addedValue"
],
"parameterToAddOne": [
"addedValue"
]
},
"remove": [
"overrideParameterToRemove",
"requestParameterToRemove"
],
"replace": {
"requestParameterToReplace": [
"replacedValue"
],
"overrideParameterToReplace": [
"replacedValue"
],
"extraParameterToReplace": [
"shouldBeIgnore"
]
}
}
}
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"requestOverride": {
"headers": {
"Host": [
"target.host.com"
]
},
"body": "some_overridden_body"
},
"requestModifier": {
"cookies": {
"add": {
"cookieToAddOne": "addedValue",
"cookieToAddTwo": "addedValue"
},
"remove": [
"overrideCookieToRemove",
"requestCookieToRemove"
],
"replace": {
"overrideCookieToReplace": "replacedValue",
"requestCookieToReplace": "replacedValue",
"extraCookieToReplace": "shouldBeIgnore"
}
},
"headers": {
"add": {
"headerToAddTwo": [
"addedValue"
],
"headerToAddOne": [
"addedValue"
]
},
"remove": [
"overrideHeaderToRemove",
"requestHeaderToRemove"
],
"replace": {
"requestHeaderToReplace": [
"replacedValue"
],
"overrideHeaderToReplace": [
"replacedValue"
],
"extraHeaderToReplace": [
"shouldBeIgnore"
]
}
},
"path": {
"regex": "^/(.+)/(.+)$",
"substitution": "/prefix/$1/infix/$2/postfix"
},
"queryStringParameters": {
"add": {
"parameterToAddTwo": [
"addedValue"
],
"parameterToAddOne": [
"addedValue"
]
},
"remove": [
"overrideParameterToRemove",
"requestParameterToRemove"
],
"replace": {
"requestParameterToReplace": [
"replacedValue"
],
"overrideParameterToReplace": [
"replacedValue"
],
"extraParameterToReplace": [
"shouldBeIgnore"
]
}
}
}
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"requestOverride": {
"headers": {
"Host": [
"target.host.com"
]
},
"body": "some_overridden_body"
},
"requestModifier": {
"cookies": {
"add": {
"cookieToAddOne": "addedValue",
"cookieToAddTwo": "addedValue"
},
"remove": [
"overrideCookieToRemove",
"requestCookieToRemove"
],
"replace": {
"overrideCookieToReplace": "replacedValue",
"requestCookieToReplace": "replacedValue",
"extraCookieToReplace": "shouldBeIgnore"
}
},
"headers": {
"add": {
"headerToAddTwo": [
"addedValue"
],
"headerToAddOne": [
"addedValue"
]
},
"remove": [
"overrideHeaderToRemove",
"requestHeaderToRemove"
],
"replace": {
"requestHeaderToReplace": [
"replacedValue"
],
"overrideHeaderToReplace": [
"replacedValue"
],
"extraHeaderToReplace": [
"shouldBeIgnore"
]
}
},
"path": {
"regex": "^/(.+)/(.+)$",
"substitution": "/prefix/$1/infix/$2/postfix"
},
"queryStringParameters": {
"add": {
"parameterToAddTwo": [
"addedValue"
],
"parameterToAddOne": [
"addedValue"
]
},
"remove": [
"overrideParameterToRemove",
"requestParameterToRemove"
],
"replace": {
"requestParameterToReplace": [
"replacedValue"
],
"overrideParameterToReplace": [
"replacedValue"
],
"extraParameterToReplace": [
"shouldBeIgnore"
]
}
}
}
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path")
)
.forward(
forwardOverriddenRequest()
.withRequestOverride(
request()
// this replaces the entire set of headers
.withHeader("Host", "target.host.com")
.withBody("some_overridden_body")
)
.withRequestModifier(
requestModifier()
.withPath("^/(.+)/(.+)$", "/prefix/$1/infix/$2/postfix")
.withQueryStringParameters(
queryParametersModifier()
.add(
param("parameterToAddOne", "addedValue"),
param("parameterToAddTwo", "addedValue")
)
.replace(
param("overrideParameterToReplace", "replacedValue"),
param("requestParameterToReplace", "replacedValue"),
param("extraParameterToReplace", "shouldBeIgnore")
)
.remove(
"overrideParameterToRemove",
"requestParameterToRemove"
)
)
// this modifies the set of headers
.withHeaders(
headersModifier()
.add(
header("headerToAddOne", "addedValue"),
header("headerToAddTwo", "addedValue")
)
.replace(
header("overrideHeaderToReplace", "replacedValue"),
header("requestHeaderToReplace", "replacedValue"),
header("extraHeaderToReplace", "shouldBeIgnore")
)
.remove(
"overrideHeaderToRemove",
"requestHeaderToRemove"
)
)
.withCookies(
cookiesModifier()
.add(
cookie("cookieToAddOne", "addedValue"),
cookie("cookieToAddTwo", "addedValue")
)
.replace(
cookie("overrideCookieToReplace", "replacedValue"),
cookie("requestCookieToReplace", "replacedValue"),
cookie("extraCookieToReplace", "shouldBeIgnore")
)
.remove(
"overrideCookieToRemove",
"requestCookieToRemove"
)
)
)
.withResponseOverride(
response()
.withBody("some_overridden_body")
)
.withResponseModifier(
responseModifier()
.withHeaders(
headersModifier()
.add(
header("headerToAddOne", "addedValue"),
header("headerToAddTwo", "addedValue")
)
.replace(
header("overrideHeaderToReplace", "replacedValue"),
header("requestHeaderToReplace", "replacedValue"),
header("extraHeaderToReplace", "shouldBeIgnore")
)
.remove(
"overrideHeaderToRemove",
"requestHeaderToRemove"
)
)
.withCookies(
cookiesModifier()
.add(
cookie("cookieToAddOne", "addedValue"),
cookie("cookieToAddTwo", "addedValue")
)
.replace(
cookie("overrideCookieToReplace", "replacedValue"),
cookie("requestCookieToReplace", "replacedValue"),
cookie("extraCookieToReplace", "shouldBeIgnore")
)
.remove(
"overrideCookieToRemove",
"requestCookieToRemove"
)
)
)
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"requestOverride": {
"headers": {
"Host": [
"target.host.com"
]
},
"body": "some_overridden_body"
},
"requestModifier": {
"cookies": {
"add": {
"cookieToAddOne": "addedValue",
"cookieToAddTwo": "addedValue"
},
"remove": [
"overrideCookieToRemove",
"requestCookieToRemove"
],
"replace": {
"overrideCookieToReplace": "replacedValue",
"requestCookieToReplace": "replacedValue",
"extraCookieToReplace": "shouldBeIgnore"
}
},
"headers": {
"add": {
"headerToAddTwo": [
"addedValue"
],
"headerToAddOne": [
"addedValue"
]
},
"remove": [
"overrideHeaderToRemove",
"requestHeaderToRemove"
],
"replace": {
"requestHeaderToReplace": [
"replacedValue"
],
"overrideHeaderToReplace": [
"replacedValue"
],
"extraHeaderToReplace": [
"shouldBeIgnore"
]
}
},
"path": {
"regex": "^/(.+)/(.+)$",
"substitution": "/prefix/$1/infix/$2/postfix"
},
"queryStringParameters": {
"add": {
"parameterToAddTwo": [
"addedValue"
],
"parameterToAddOne": [
"addedValue"
]
},
"remove": [
"overrideParameterToRemove",
"requestParameterToRemove"
],
"replace": {
"requestParameterToReplace": [
"replacedValue"
],
"overrideParameterToReplace": [
"replacedValue"
],
"extraParameterToReplace": [
"shouldBeIgnore"
]
}
}
},
"responseOverride": {
"body": "some_overridden_body"
},
"responseModifier": {
"cookies": {
"add": {
"cookieToAddOne": "addedValue",
"cookieToAddTwo": "addedValue"
},
"remove": [
"overrideCookieToRemove",
"requestCookieToRemove"
],
"replace": {
"overrideCookieToReplace": "replacedValue",
"requestCookieToReplace": "replacedValue",
"extraCookieToReplace": "shouldBeIgnore"
}
},
"headers": {
"add": {
"headerToAddTwo": [
"addedValue"
],
"headerToAddOne": [
"addedValue"
]
},
"remove": [
"overrideHeaderToRemove",
"requestHeaderToRemove"
],
"replace": {
"requestHeaderToReplace": [
"replacedValue"
],
"overrideHeaderToReplace": [
"replacedValue"
],
"extraHeaderToReplace": [
"shouldBeIgnore"
]
}
}
}
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"requestOverride": {
"headers": {
"Host": [
"target.host.com"
]
},
"body": "some_overridden_body"
},
"requestModifier": {
"cookies": {
"add": {
"cookieToAddOne": "addedValue",
"cookieToAddTwo": "addedValue"
},
"remove": [
"overrideCookieToRemove",
"requestCookieToRemove"
],
"replace": {
"overrideCookieToReplace": "replacedValue",
"requestCookieToReplace": "replacedValue",
"extraCookieToReplace": "shouldBeIgnore"
}
},
"headers": {
"add": {
"headerToAddTwo": [
"addedValue"
],
"headerToAddOne": [
"addedValue"
]
},
"remove": [
"overrideHeaderToRemove",
"requestHeaderToRemove"
],
"replace": {
"requestHeaderToReplace": [
"replacedValue"
],
"overrideHeaderToReplace": [
"replacedValue"
],
"extraHeaderToReplace": [
"shouldBeIgnore"
]
}
},
"path": {
"regex": "^/(.+)/(.+)$",
"substitution": "/prefix/$1/infix/$2/postfix"
},
"queryStringParameters": {
"add": {
"parameterToAddTwo": [
"addedValue"
],
"parameterToAddOne": [
"addedValue"
]
},
"remove": [
"overrideParameterToRemove",
"requestParameterToRemove"
],
"replace": {
"requestParameterToReplace": [
"replacedValue"
],
"overrideParameterToReplace": [
"replacedValue"
],
"extraParameterToReplace": [
"shouldBeIgnore"
]
}
}
},
"responseOverride": {
"body": "some_overridden_body"
},
"responseModifier": {
"cookies": {
"add": {
"cookieToAddOne": "addedValue",
"cookieToAddTwo": "addedValue"
},
"remove": [
"overrideCookieToRemove",
"requestCookieToRemove"
],
"replace": {))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"requestOverride": {
"headers": {
"Host": [
"target.host.com"
]
},
"body": "some_overridden_body"
},
"requestModifier": {
"cookies": {
"add": {
"cookieToAddOne": "addedValue",
"cookieToAddTwo": "addedValue"
},
"remove": [
"overrideCookieToRemove",
"requestCookieToRemove"
],
"replace": {
"overrideCookieToReplace": "replacedValue",
"requestCookieToReplace": "replacedValue",
"extraCookieToReplace": "shouldBeIgnore"
}
},
"headers": {
"add": {
"headerToAddTwo": [
"addedValue"
],
"headerToAddOne": [
"addedValue"
]
},
"remove": [
"overrideHeaderToRemove",
"requestHeaderToRemove"
],
"replace": {
"requestHeaderToReplace": [
"replacedValue"
],
"overrideHeaderToReplace": [
"replacedValue"
],
"extraHeaderToReplace": [
"shouldBeIgnore"
]
}
},
"path": {
"regex": "^/(.+)/(.+)$",
"substitution": "/prefix/$1/infix/$2/postfix"
},
"queryStringParameters": {
"add": {
"parameterToAddTwo": [
"addedValue"
],
"parameterToAddOne": [
"addedValue"
]
},
"remove": [
"overrideParameterToRemove",
"requestParameterToRemove"
],
"replace": {
"requestParameterToReplace": [
"replacedValue"
],
"overrideParameterToReplace": [
"replacedValue"
],
"extraParameterToReplace": [
"shouldBeIgnore"
]
}
}
},
"responseOverride": {
"body": "some_overridden_body"
},
"responseModifier": {
"cookies": {
"add": {
"cookieToAddOne": "addedValue",
"cookieToAddTwo": "addedValue"
},
"remove": [
"overrideCookieToRemove",
"requestCookieToRemove"
],
"replace": {))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"requestOverride": {
"headers": {
"Host": [
"target.host.com"
]
},
"body": "some_overridden_body"
},
"requestModifier": {
"cookies": {
"add": {
"cookieToAddOne": "addedValue",
"cookieToAddTwo": "addedValue"
},
"remove": [
"overrideCookieToRemove",
"requestCookieToRemove"
],
"replace": {
"overrideCookieToReplace": "replacedValue",
"requestCookieToReplace": "replacedValue",
"extraCookieToReplace": "shouldBeIgnore"
}
},
"headers": {
"add": {
"headerToAddTwo": [
"addedValue"
],
"headerToAddOne": [
"addedValue"
]
},
"remove": [
"overrideHeaderToRemove",
"requestHeaderToRemove"
],
"replace": {
"requestHeaderToReplace": [
"replacedValue"
],
"overrideHeaderToReplace": [
"replacedValue"
],
"extraHeaderToReplace": [
"shouldBeIgnore"
]
}
},
"path": {
"regex": "^/(.+)/(.+)$",
"substitution": "/prefix/$1/infix/$2/postfix"
},
"queryStringParameters": {
"add": {
"parameterToAddTwo": [
"addedValue"
],
"parameterToAddOne": [
"addedValue"
]
},
"remove": [
"overrideParameterToRemove",
"requestParameterToRemove"
],
"replace": {
"requestParameterToReplace": [
"replacedValue"
],
"overrideParameterToReplace": [
"replacedValue"
],
"extraParameterToReplace": [
"shouldBeIgnore"
]
}
}
},
"responseOverride": {
"body": "some_overridden_body"
},
"responseModifier": {
"cookies": {
"add": {
"cookieToAddOne": "addedValue",
"cookieToAddTwo": "addedValue"
},
"remove": [
"overrideCookieToRemove",
"requestCookieToRemove"
],
"replace": {`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"": {
""path"": ""/some/path""
},
""httpOverrideForwardedRequest"": {
""requestOverride"": {
""headers"": {
""Host"": [
""target.host.com""
]
},
""body"": ""some_overridden_body""
},
""requestModifier"": {
""cookies"": {
""add"": {
""cookieToAddOne"": ""addedValue"",
""cookieToAddTwo"": ""addedValue""
},
""remove"": [
""overrideCookieToRemove"",
""requestCookieToRemove""
],
""replace"": {
""overrideCookieToReplace"": ""replacedValue"",
""requestCookieToReplace"": ""replacedValue"",
""extraCookieToReplace"": ""shouldBeIgnore""
}
},
""headers"": {
""add"": {
""headerToAddTwo"": [
""addedValue""
],
""headerToAddOne"": [
""addedValue""
]
},
""remove"": [
""overrideHeaderToRemove"",
""requestHeaderToRemove""
],
""replace"": {
""requestHeaderToReplace"": [
""replacedValue""
],
""overrideHeaderToReplace"": [
""replacedValue""
],
""extraHeaderToReplace"": [
""shouldBeIgnore""
]
}
},
""path"": {
""regex"": ""^/(.+)/(.+)$"",
""substitution"": ""/prefix/$1/infix/$2/postfix""
},
""queryStringParameters"": {
""add"": {
""parameterToAddTwo"": [
""addedValue""
],
""parameterToAddOne"": [
""addedValue""
]
},
""remove"": [
""overrideParameterToRemove"",
""requestParameterToRemove""
],
""replace"": {
""requestParameterToReplace"": [
""replacedValue""
],
""overrideParameterToReplace"": [
""replacedValue""
],
""extraParameterToReplace"": [
""shouldBeIgnore""
]
}
}
},
""responseOverride"": {
""body"": ""some_overridden_body""
},
""responseModifier"": {
""cookies"": {
""add"": {
""cookieToAddOne"": ""addedValue"",
""cookieToAddTwo"": ""addedValue""
},
""remove"": [
""overrideCookieToRemove"",
""requestCookieToRemove""
],
""replace"": {";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"requestOverride": {
"headers": {
"Host": [
"target.host.com"
]
},
"body": "some_overridden_body"
},
"requestModifier": {
"cookies": {
"add": {
"cookieToAddOne": "addedValue",
"cookieToAddTwo": "addedValue"
},
"remove": [
"overrideCookieToRemove",
"requestCookieToRemove"
],
"replace": {
"overrideCookieToReplace": "replacedValue",
"requestCookieToReplace": "replacedValue",
"extraCookieToReplace": "shouldBeIgnore"
}
},
"headers": {
"add": {
"headerToAddTwo": [
"addedValue"
],
"headerToAddOne": [
"addedValue"
]
},
"remove": [
"overrideHeaderToRemove",
"requestHeaderToRemove"
],
"replace": {
"requestHeaderToReplace": [
"replacedValue"
],
"overrideHeaderToReplace": [
"replacedValue"
],
"extraHeaderToReplace": [
"shouldBeIgnore"
]
}
},
"path": {
"regex": "^/(.+)/(.+)$",
"substitution": "/prefix/$1/infix/$2/postfix"
},
"queryStringParameters": {
"add": {
"parameterToAddTwo": [
"addedValue"
],
"parameterToAddOne": [
"addedValue"
]
},
"remove": [
"overrideParameterToRemove",
"requestParameterToRemove"
],
"replace": {
"requestParameterToReplace": [
"replacedValue"
],
"overrideParameterToReplace": [
"replacedValue"
],
"extraParameterToReplace": [
"shouldBeIgnore"
]
}
}
},
"responseOverride": {
"body": "some_overridden_body"
},
"responseModifier": {
"cookies": {
"add": {
"cookieToAddOne": "addedValue",
"cookieToAddTwo": "addedValue"
},
"remove": [
"overrideCookieToRemove",
"requestCookieToRemove"
],
"replace": {"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"requestOverride": {
"headers": {
"Host": [
"target.host.com"
]
},
"body": "some_overridden_body"
},
"requestModifier": {
"cookies": {
"add": {
"cookieToAddOne": "addedValue",
"cookieToAddTwo": "addedValue"
},
"remove": [
"overrideCookieToRemove",
"requestCookieToRemove"
],
"replace": {
"overrideCookieToReplace": "replacedValue",
"requestCookieToReplace": "replacedValue",
"extraCookieToReplace": "shouldBeIgnore"
}
},
"headers": {
"add": {
"headerToAddTwo": [
"addedValue"
],
"headerToAddOne": [
"addedValue"
]
},
"remove": [
"overrideHeaderToRemove",
"requestHeaderToRemove"
],
"replace": {
"requestHeaderToReplace": [
"replacedValue"
],
"overrideHeaderToReplace": [
"replacedValue"
],
"extraHeaderToReplace": [
"shouldBeIgnore"
]
}
},
"path": {
"regex": "^/(.+)/(.+)$",
"substitution": "/prefix/$1/infix/$2/postfix"
},
"queryStringParameters": {
"add": {
"parameterToAddTwo": [
"addedValue"
],
"parameterToAddOne": [
"addedValue"
]
},
"remove": [
"overrideParameterToRemove",
"requestParameterToRemove"
],
"replace": {
"requestParameterToReplace": [
"replacedValue"
],
"overrideParameterToReplace": [
"replacedValue"
],
"extraParameterToReplace": [
"shouldBeIgnore"
]
}
}
},
"responseOverride": {
"body": "some_overridden_body"
},
"responseModifier": {
"cookies": {
"add": {
"cookieToAddOne": "addedValue",
"cookieToAddTwo": "addedValue"
},
"remove": [
"overrideCookieToRemove",
"requestCookieToRemove"
],
"replace": {
"overrideCookieToReplace": "replacedValue",
"requestCookieToReplace": "replacedValue",
"extraCookieToReplace": "shouldBeIgnore"
}
},
"headers": {
"add": {
"headerToAddTwo": [
"addedValue"
],
"headerToAddOne": [
"addedValue"
]
},
"remove": [
"overrideHeaderToRemove",
"requestHeaderToRemove"
],
"replace": {
"requestHeaderToReplace": [
"replacedValue"
],
"overrideHeaderToReplace": [
"replacedValue"
],
"extraHeaderToReplace": [
"shouldBeIgnore"
]
}
}
}
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"requestOverride": {
"headers": {
"Host": [
"target.host.com"
]
},
"body": "some_overridden_body"
},
"requestModifier": {
"cookies": {
"add": {
"cookieToAddOne": "addedValue",
"cookieToAddTwo": "addedValue"
},
"remove": [
"overrideCookieToRemove",
"requestCookieToRemove"
],
"replace": {
"overrideCookieToReplace": "replacedValue",
"requestCookieToReplace": "replacedValue",
"extraCookieToReplace": "shouldBeIgnore"
}
},
"headers": {
"add": {
"headerToAddTwo": [
"addedValue"
],
"headerToAddOne": [
"addedValue"
]
},
"remove": [
"overrideHeaderToRemove",
"requestHeaderToRemove"
],
"replace": {
"requestHeaderToReplace": [
"replacedValue"
],
"overrideHeaderToReplace": [
"replacedValue"
],
"extraHeaderToReplace": [
"shouldBeIgnore"
]
}
},
"path": {
"regex": "^/(.+)/(.+)$",
"substitution": "/prefix/$1/infix/$2/postfix"
},
"queryStringParameters": {
"add": {
"parameterToAddTwo": [
"addedValue"
],
"parameterToAddOne": [
"addedValue"
]
},
"remove": [
"overrideParameterToRemove",
"requestParameterToRemove"
],
"replace": {
"requestParameterToReplace": [
"replacedValue"
],
"overrideParameterToReplace": [
"replacedValue"
],
"extraParameterToReplace": [
"shouldBeIgnore"
]
}
}
},
"responseOverride": {
"body": "some_overridden_body"
},
"responseModifier": {
"cookies": {
"add": {
"cookieToAddOne": "addedValue",
"cookieToAddTwo": "addedValue"
},
"remove": [
"overrideCookieToRemove",
"requestCookieToRemove"
],
"replace": {
"overrideCookieToReplace": "replacedValue",
"requestCookieToReplace": "replacedValue",
"extraCookieToReplace": "shouldBeIgnore"
}
},
"headers": {
"add": {
"headerToAddTwo": [
"addedValue"
],
"headerToAddOne": [
"addedValue"
]
},
"remove": [
"overrideHeaderToRemove",
"requestHeaderToRemove"
],
"replace": {
"requestHeaderToReplace": [
"replacedValue"
],
"overrideHeaderToReplace": [
"replacedValue"
],
"extraHeaderToReplace": [
"shouldBeIgnore"
]
}
}
}
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path")
)
.forward(
forwardOverriddenRequest(
request()
.withPath("/some/other/path")
.withHeader("Host", "any.host.com")
.withSocketAddress("target.host.com", 1234, SocketAddress.Scheme.HTTPS)
)
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"httpRequest": {
"path": "/some/other/path",
"headers": {
"Host": ["any.host.com"]
},
"socketAddress": {
"host": "target.host.com",
"port": 1234,
"scheme": "HTTPS"
}
}
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"httpRequest": {
"path": "/some/other/path",
"headers": {
"Host": ["any.host.com"]
},
"socketAddress": {
"host": "target.host.com",
"port": 1234,
"scheme": "HTTPS"
}
}
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"httpRequest": {
"path": "/some/other/path",
"headers": {
"Host": ["any.host.com"]
},
"socketAddress": {
"host": "target.host.com",
"port": 1234,
"scheme": "HTTPS"
}
}
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"httpRequest": {
"path": "/some/other/path",
"headers": {
"Host": ["any.host.com"]
},
"socketAddress": {
"host": "target.host.com",
"port": 1234,
"scheme": "HTTPS"
}
}
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"": {
""path"": ""/some/path""
},
""httpOverrideForwardedRequest"": {
""httpRequest"": {
""path"": ""/some/other/path"",
""headers"": {
""Host"": [""any.host.com""]
},
""socketAddress"": {
""host"": ""target.host.com"",
""port"": 1234,
""scheme"": ""HTTPS""
}
}
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"httpRequest": {
"path": "/some/other/path",
"headers": {
"Host": ["any.host.com"]
},
"socketAddress": {
"host": "target.host.com",
"port": 1234,
"scheme": "HTTPS"
}
}
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"httpRequest": {
"path": "/some/other/path",
"headers": {
"Host": ["any.host.com"]
},
"socketAddress": {
"host": "target.host.com",
"port": 1234,
"scheme": "HTTPS"
}
}
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"httpRequest": {
"path": "/some/other/path",
"headers": {
"Host": ["any.host.com"]
},
"socketAddress": {
"host": "target.host.com",
"port": 1234,
"scheme": "HTTPS"
}
}
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path")
)
.forward(
forwardOverriddenRequest(
request()
.withHeader("Host", "target.host.com")
.withBody("some_overridden_body")
).withDelay(SECONDS, 10)
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"httpRequest": {
"path": "/some/other/path",
"body": "some_overridden_body",
"headers": {
"Host": ["target.host.com"]
}
},
"delay": {
"timeUnit": "SECONDS",
"value": 10
}
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"httpRequest": {
"path": "/some/other/path",
"body": "some_overridden_body",
"headers": {
"Host": ["target.host.com"]
}
},
"delay": {
"timeUnit": "SECONDS",
"value": 10
}
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"httpRequest": {
"path": "/some/other/path",
"body": "some_overridden_body",
"headers": {
"Host": ["target.host.com"]
}
},
"delay": {
"timeUnit": "SECONDS",
"value": 10
}
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"httpRequest": {
"path": "/some/other/path",
"body": "some_overridden_body",
"headers": {
"Host": ["target.host.com"]
}
},
"delay": {
"timeUnit": "SECONDS",
"value": 10
}
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"": {
""path"": ""/some/path""
},
""httpOverrideForwardedRequest"": {
""httpRequest"": {
""path"": ""/some/other/path"",
""body"": ""some_overridden_body"",
""headers"": {
""Host"": [""target.host.com""]
}
},
""delay"": {
""timeUnit"": ""SECONDS"",
""value"": 10
}
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"httpRequest": {
"path": "/some/other/path",
"body": "some_overridden_body",
"headers": {
"Host": ["target.host.com"]
}
},
"delay": {
"timeUnit": "SECONDS",
"value": 10
}
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"httpRequest": {
"path": "/some/other/path",
"body": "some_overridden_body",
"headers": {
"Host": ["target.host.com"]
}
},
"delay": {
"timeUnit": "SECONDS",
"value": 10
}
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"httpRequest": {
"path": "/some/other/path",
"body": "some_overridden_body",
"headers": {
"Host": ["target.host.com"]
}
},
"delay": {
"timeUnit": "SECONDS",
"value": 10
}
}
}'
See REST API for full JSON specification
Forward actions support the same distribution-based delays as response actions, allowing realistic latency simulation when proxying requests.
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path")
)
.forward(
forwardOverriddenRequest(
request()
.withHeader("Host", "target.host.com")
.withBody("some_overridden_body")
).withDelay(Delay.logNormal(TimeUnit.MILLISECONDS, 200, 800))
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"httpRequest": {
"path": "/some/other/path",
"body": "some_overridden_body",
"headers": {
"Host": ["target.host.com"]
}
},
"delay": {
"timeUnit": "MILLISECONDS",
"distribution": {
"type": "LOG_NORMAL",
"median": 200,
"p99": 800
}
}
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"httpRequest": {
"path": "/some/other/path",
"body": "some_overridden_body",
"headers": {
"Host": ["target.host.com"]
}
},
"delay": {
"timeUnit": "MILLISECONDS",
"distribution": {
"type": "LOG_NORMAL",
"median": 200,
"p99": 800
}
}
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"httpRequest": {
"path": "/some/other/path",
"body": "some_overridden_body",
"headers": {
"Host": ["target.host.com"]
}
},
"delay": {
"timeUnit": "MILLISECONDS",
"distribution": {
"type": "LOG_NORMAL",
"median": 200,
"p99": 800
}
}
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"httpRequest": {
"path": "/some/other/path",
"body": "some_overridden_body",
"headers": {
"Host": ["target.host.com"]
}
},
"delay": {
"timeUnit": "MILLISECONDS",
"distribution": {
"type": "LOG_NORMAL",
"median": 200,
"p99": 800
}
}
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"": {
""path"": ""/some/path""
},
""httpOverrideForwardedRequest"": {
""httpRequest"": {
""path"": ""/some/other/path"",
""body"": ""some_overridden_body"",
""headers"": {
""Host"": [""target.host.com""]
}
},
""delay"": {
""timeUnit"": ""MILLISECONDS"",
""distribution"": {
""type"": ""LOG_NORMAL"",
""median"": 200,
""p99"": 800
}
}
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"httpRequest": {
"path": "/some/other/path",
"body": "some_overridden_body",
"headers": {
"Host": ["target.host.com"]
}
},
"delay": {
"timeUnit": "MILLISECONDS",
"distribution": {
"type": "LOG_NORMAL",
"median": 200,
"p99": 800
}
}
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"httpRequest": {
"path": "/some/other/path",
"body": "some_overridden_body",
"headers": {
"Host": ["target.host.com"]
}
},
"delay": {
"timeUnit": "MILLISECONDS",
"distribution": {
"type": "LOG_NORMAL",
"median": 200,
"p99": 800
}
}
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"httpRequest": {
"path": "/some/other/path",
"body": "some_overridden_body",
"headers": {
"Host": ["target.host.com"]
}
},
"delay": {
"timeUnit": "MILLISECONDS",
"distribution": {
"type": "LOG_NORMAL",
"median": 200,
"p99": 800
}
}
}
}'
See REST API for full JSON specification
// request.queryStringParameters['userId'] returns an array of values because headers and queryStringParameters have multiple values
String template = "return {\n" +
" 'path' : \"/somePath\",\n" +
" 'queryStringParameters' : {\n" +
" 'userId' : request.queryStringParameters && request.queryStringParameters['userId']\n" +
" },\n" +
" 'headers' : {\n" +
" 'Host' : [ \"localhost:1081\" ]\n" +
" },\n" +
" 'body': JSON.stringify({'name': 'value'})\n" +
"};";
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path")
)
.forward(
template(
HttpTemplate.TemplateType.JAVASCRIPT,
template
)
);
var mockServerClient = require('mockserver-client').mockServerClient;
// request.queryStringParameters['userId'] returns an array of values because headers and queryStringParameters have multiple values
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"path": "/some/path"
},
"httpForwardTemplate": {
"template": "return {\n" +
" 'path' : \"/somePath\",\n" +
" 'queryStringParameters' : {\n" +
" 'userId' : request.queryStringParameters && request.queryStringParameters['userId']\n" +
" },\n" +
" 'headers' : {\n" +
" 'Host' : [ \"localhost:1081\" ]\n" +
" },\n" +
" 'body': JSON.stringify({'name': 'value'})\n" +
"};",
"templateType": "JAVASCRIPT"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest": {
"path": "/some/path"
},
"httpForwardTemplate": {
"template": "return {\n" +
" 'path' : \"/somePath\",\n" +
" 'queryStringParameters' : {\n" +
" 'userId' : request.queryStringParameters && request.queryStringParameters['userId']\n" +
" },\n" +
" 'headers' : {\n" +
" 'Host' : [ \"localhost:1081\" ]\n" +
" },\n" +
" 'body': JSON.stringify({'name': 'value'})\n" +
"};",
"templateType": "JAVASCRIPT"
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest": {
"path": "/some/path"
},
"httpForwardTemplate": {
"template": "return {\n" +
" 'path' : \"/somePath\",\n" +
" 'queryStringParameters' : {\n" +
" 'userId' : request.queryStringParameters && request.queryStringParameters['userId']\n" +
" },\n" +
" 'headers' : {\n" +
" 'Host' : [ \"localhost:1081\" ]\n" +
" },\n" +
" 'body': JSON.stringify({'name': 'value'})\n" +
"};",
"templateType": "JAVASCRIPT"
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest": {
"path": "/some/path"
},
"httpForwardTemplate": {
"template": "return {\n" +
" 'path' : \"/somePath\",\n" +
" 'queryStringParameters' : {\n" +
" 'userId' : request.queryStringParameters && request.queryStringParameters['userId']\n" +
" },\n" +
" 'headers' : {\n" +
" 'Host' : [ \"localhost:1081\" ]\n" +
" },\n" +
" 'body': JSON.stringify({'name': 'value'})\n" +
"};",
"templateType": "JAVASCRIPT"
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"": {
""path"": ""/some/path""
},
""httpForwardTemplate"": {
""template"": ""return {\n"" +
"" 'path' : \""/somePath\"",\n"" +
"" 'queryStringParameters' : {\n"" +
"" 'userId' : request.queryStringParameters && request.queryStringParameters['userId']\n"" +
"" },\n"" +
"" 'headers' : {\n"" +
"" 'Host' : [ \""localhost:1081\"" ]\n"" +
"" },\n"" +
"" 'body': JSON.stringify({'name': 'value'})\n"" +
""};"",
""templateType"": ""JAVASCRIPT""
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest": {
"path": "/some/path"
},
"httpForwardTemplate": {
"template": "return {\n" +
" 'path' : \"/somePath\",\n" +
" 'queryStringParameters' : {\n" +
" 'userId' : request.queryStringParameters && request.queryStringParameters['userId']\n" +
" },\n" +
" 'headers' : {\n" +
" 'Host' : [ \"localhost:1081\" ]\n" +
" },\n" +
" 'body': JSON.stringify({'name': 'value'})\n" +
"};",
"templateType": "JAVASCRIPT"
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest": {
"path": "/some/path"
},
"httpForwardTemplate": {
"template": "return {\n" +
" 'path' : \"/somePath\",\n" +
" 'queryStringParameters' : {\n" +
" 'userId' : request.queryStringParameters && request.queryStringParameters['userId']\n" +
" },\n" +
" 'headers' : {\n" +
" 'Host' : [ \"localhost:1081\" ]\n" +
" },\n" +
" 'body': JSON.stringify({'name': 'value'})\n" +
"};",
"templateType": "JAVASCRIPT"
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"path": "/some/path"
},
"httpForwardTemplate": {
"template": "return {\n" +
" 'path' : \"/somePath\",\n" +
" 'queryStringParameters' : {\n" +
" 'userId' : request.queryStringParameters && request.queryStringParameters['userId']\n" +
" },\n" +
" 'headers' : {\n" +
" 'Host' : [ \"localhost:1081\" ]\n" +
" },\n" +
" 'body': JSON.stringify({'name': 'value'})\n" +
"};",
"templateType": "JAVASCRIPT"
}
}'
See REST API for full JSON specification
String template = "return {" + System.getProperty("line.separator") +
" 'path' : request.path.substring(request.path.indexOf('/somePrefix')+'/somePrefix'.length,request.path.length)," + System.getProperty("line.separator") +
" 'headers' : {" + System.getProperty("line.separator") +
" 'Host' : [ \"localhost:1081\" ]" + System.getProperty("line.separator") +
" }," + System.getProperty("line.separator") +
"};";
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/somePrefix*")
)
.forward(
template(
HttpTemplate.TemplateType.JAVASCRIPT,
template
)
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"path": "/somePrefix*"
},
"httpForwardTemplate": {
"template": "return {\n" +
" 'path' : request.path.substring(request.path.indexOf('/somePrefix')+'/somePrefix'.length,request.path.length),\n" +
" 'headers' : {\n" +
" 'Host' : [ \"localhost:1081\" ]\n" +
" }
"};",
"templateType": "JAVASCRIPT"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest": {
"path": "/somePrefix*"
},
"httpForwardTemplate": {
"template": "return {\n" +
" 'path' : request.path.substring(request.path.indexOf('/somePrefix')+'/somePrefix'.length,request.path.length),\n" +
" 'headers' : {\n" +
" 'Host' : [ \"localhost:1081\" ]\n" +
" }\n" +
"};",
"templateType": "JAVASCRIPT"
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest": {
"path": "/somePrefix*"
},
"httpForwardTemplate": {
"template": "return {\n" +
" 'path' : request.path.substring(request.path.indexOf('/somePrefix')+'/somePrefix'.length,request.path.length),\n" +
" 'headers' : {\n" +
" 'Host' : [ \"localhost:1081\" ]\n" +
" }\n" +
"};",
"templateType": "JAVASCRIPT"
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest": {
"path": "/somePrefix*"
},
"httpForwardTemplate": {
"template": "return {\n" +
" 'path' : request.path.substring(request.path.indexOf('/somePrefix')+'/somePrefix'.length,request.path.length),\n" +
" 'headers' : {\n" +
" 'Host' : [ \"localhost:1081\" ]\n" +
" }\n" +
"};",
"templateType": "JAVASCRIPT"
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"": {
""path"": ""/somePrefix*""
},
""httpForwardTemplate"": {
""template"": ""return {\n"" +
"" 'path' : request.path.substring(request.path.indexOf('/somePrefix')+'/somePrefix'.length,request.path.length),\n"" +
"" 'headers' : {\n"" +
"" 'Host' : [ \""localhost:1081\"" ]\n"" +
"" }\n"" +
""};"",
""templateType"": ""JAVASCRIPT""
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest": {
"path": "/somePrefix*"
},
"httpForwardTemplate": {
"template": "return {\n" +
" 'path' : request.path.substring(request.path.indexOf('/somePrefix')+'/somePrefix'.length,request.path.length),\n" +
" 'headers' : {\n" +
" 'Host' : [ \"localhost:1081\" ]\n" +
" }\n" +
"};",
"templateType": "JAVASCRIPT"
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest": {
"path": "/somePrefix*"
},
"httpForwardTemplate": {
"template": "return {\n" +
" 'path' : request.path.substring(request.path.indexOf('/somePrefix')+'/somePrefix'.length,request.path.length),\n" +
" 'headers' : {\n" +
" 'Host' : [ \"localhost:1081\" ]\n" +
" }\n" +
"};",
"templateType": "JAVASCRIPT"
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"path": "/somePrefix*"
},
"httpForwardTemplate": {
"template": "return {\n" +
" 'path' : request.path.substring(request.path.indexOf('/somePrefix')+'/somePrefix'.length,request.path.length),\n" +
" 'headers' : {\n" +
" 'Host' : [ \"localhost:1081\" ]\n" +
" }\n" +
"};",
"templateType": "JAVASCRIPT"
}
}'
See REST API for full JSON specification
// request.cookies['SessionId'] returns a single value because cookies only contain a single value
String template = "return {\n" +
" 'path' : \"/somePath\",\n" +
" 'cookies' : {\n" +
" 'SessionId' : request.cookies && request.cookies['SessionId']\n" +
" },\n" +
" 'headers' : {\n" +
" 'Host' : [ \"localhost:1081\" ]\n" +
" },\n" +
" 'keepAlive' : true,\n" +
" 'secure' : true,\n" +
" 'body' : \"some_body\"\n" +
"};";
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path")
)
.forward(
template(HttpTemplate.TemplateType.JAVASCRIPT)
.withTemplate(template)
.withDelay(TimeUnit.SECONDS, 20)
);
var mockServerClient = require('mockserver-client').mockServerClient;
// request.cookies['SessionId'] returns a single value because cookies only contain a single value
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"path": "/some/path"
},
"httpForwardTemplate": {
"template": "return {\n" +
" 'path' : \"/somePath\",\n" +
" 'cookies' : {\n" +
" 'SessionId' : request.cookies && request.cookies['SessionId']\n" +
" },\n" +
" 'headers' : {\n" +
" 'Host' : [ \"localhost:1081\" ]\n" +
" },\n" +
" 'keepAlive' : true,\n" +
" 'secure' : true,\n" +
" 'body' : \"some_body\"\n" +
"};",
"templateType": "JAVASCRIPT",
"delay": {"timeUnit": "SECONDS", "value": 20}
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest": {
"path": "/some/path"
},
"httpForwardTemplate": {
"template": "return {\n" +
" 'path' : \"/somePath\",\n" +
" 'cookies' : {\n" +
" 'SessionId' : request.cookies && request.cookies['SessionId']\n" +
" },\n" +
" 'headers' : {\n" +
" 'Host' : [ \"localhost:1081\" ]\n" +
" },\n" +
" 'keepAlive' : True,\n" +
" 'secure' : True,\n" +
" 'body' : \"some_body\"\n" +
"};",
"templateType": "JAVASCRIPT",
"delay": {"timeUnit": "SECONDS", "value": 20}
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest": {
"path": "/some/path"
},
"httpForwardTemplate": {
"template": "return {\n" +
" 'path' : \"/somePath\",\n" +
" 'cookies' : {\n" +
" 'SessionId' : request.cookies && request.cookies['SessionId']\n" +
" },\n" +
" 'headers' : {\n" +
" 'Host' : [ \"localhost:1081\" ]\n" +
" },\n" +
" 'keepAlive' : true,\n" +
" 'secure' : true,\n" +
" 'body' : \"some_body\"\n" +
"};",
"templateType": "JAVASCRIPT",
"delay": {"timeUnit": "SECONDS", "value": 20}
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest": {
"path": "/some/path"
},
"httpForwardTemplate": {
"template": "return {\n" +
" 'path' : \"/somePath\",\n" +
" 'cookies' : {\n" +
" 'SessionId' : request.cookies && request.cookies['SessionId']\n" +
" },\n" +
" 'headers' : {\n" +
" 'Host' : [ \"localhost:1081\" ]\n" +
" },\n" +
" 'keepAlive' : true,\n" +
" 'secure' : true,\n" +
" 'body' : \"some_body\"\n" +
"};",
"templateType": "JAVASCRIPT",
"delay": {"timeUnit": "SECONDS", "value": 20}
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"": {
""path"": ""/some/path""
},
""httpForwardTemplate"": {
""template"": ""return {\n"" +
"" 'path' : \""/somePath\"",\n"" +
"" 'cookies' : {\n"" +
"" 'SessionId' : request.cookies && request.cookies['SessionId']\n"" +
"" },\n"" +
"" 'headers' : {\n"" +
"" 'Host' : [ \""localhost:1081\"" ]\n"" +
"" },\n"" +
"" 'keepAlive' : true,\n"" +
"" 'secure' : true,\n"" +
"" 'body' : \""some_body\""\n"" +
""};"",
""templateType"": ""JAVASCRIPT"",
""delay"": {""timeUnit"": ""SECONDS"", ""value"": 20}
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest": {
"path": "/some/path"
},
"httpForwardTemplate": {
"template": "return {\n" +
" 'path' : \"/somePath\",\n" +
" 'cookies' : {\n" +
" 'SessionId' : request.cookies && request.cookies['SessionId']\n" +
" },\n" +
" 'headers' : {\n" +
" 'Host' : [ \"localhost:1081\" ]\n" +
" },\n" +
" 'keepAlive' : true,\n" +
" 'secure' : true,\n" +
" 'body' : \"some_body\"\n" +
"};",
"templateType": "JAVASCRIPT",
"delay": {"timeUnit": "SECONDS", "value": 20}
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest": {
"path": "/some/path"
},
"httpForwardTemplate": {
"template": "return {\n" +
" 'path' : \"/somePath\",\n" +
" 'cookies' : {\n" +
" 'SessionId' : request.cookies && request.cookies['SessionId']\n" +
" },\n" +
" 'headers' : {\n" +
" 'Host' : [ \"localhost:1081\" ]\n" +
" },\n" +
" 'keepAlive' : true,\n" +
" 'secure' : true,\n" +
" 'body' : \"some_body\"\n" +
"};",
"templateType": "JAVASCRIPT",
"delay": {"timeUnit": "SECONDS", "value": 20}
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"path": "/some/path"
},
"httpForwardTemplate": {
"template": "return {\n" +
" 'path' : \"/somePath\",\n" +
" 'cookies' : {\n" +
" 'SessionId' : request.cookies && request.cookies['SessionId']\n" +
" },\n" +
" 'headers' : {\n" +
" 'Host' : [ \"localhost:1081\" ]\n" +
" },\n" +
" 'keepAlive' : true,\n" +
" 'secure' : true,\n" +
" 'body' : \"some_body\"\n" +
"};",
"templateType": "JAVASCRIPT",
"delay": {"timeUnit": "SECONDS", "value": 20}
}
}'
See REST API for full JSON specification
// $!request.queryStringParameters['userId'] returns an array of values because headers and queryStringParameters have multiple values
String template = "{\n" +
" 'path' : \"/somePath\",\n" +
" 'queryStringParameters' : {\n" +
" 'userId' : [ \"$!request.queryStringParameters['userId'][0]\" ]\n" +
" },\n" +
" 'cookies' : {\n" +
" 'SessionId' : \"$!request.cookies['SessionId']\"\n" +
" },\n" +
" 'headers' : {\n" +
" 'Host' : [ \"localhost:1081\" ]\n" +
" },\n" +
" 'body': \"{'name': 'value'}\"\n" +
"}";
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path")
)
.forward(
template(
HttpTemplate.TemplateType.VELOCITY,
template
)
);
var mockServerClient = require('mockserver-client').mockServerClient;
// $!request.queryStringParameters['userId'] returns an array of values because headers and queryStringParameters have multiple values
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"path": "/some/path"
},
"httpForwardTemplate": {
"template": "{\n" +
" 'path' : \"/somePath\",\n" +
" 'queryStringParameters' : {\n" +
" 'userId' : [ \"$!request.queryStringParameters['userId'][0]\" ]\n" +
" },\n" +
" 'cookies' : {\n" +
" 'SessionId' : \"$!request.cookies['SessionId']\"\n" +
" },\n" +
" 'headers' : {\n" +
" 'Host' : [ \"localhost:1081\" ]\n" +
" },\n" +
" 'body': \"{'name': 'value'}\"\n" +
"}",
"templateType": "VELOCITY"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest": {
"path": "/some/path"
},
"httpForwardTemplate": {
"template": "{\n" +
" 'path' : \"/somePath\",\n" +
" 'queryStringParameters' : {\n" +
" 'userId' : [ \"$!request.queryStringParameters['userId'][0]\" ]\n" +
" },\n" +
" 'cookies' : {\n" +
" 'SessionId' : \"$!request.cookies['SessionId']\"\n" +
" },\n" +
" 'headers' : {\n" +
" 'Host' : [ \"localhost:1081\" ]\n" +
" },\n" +
" 'body': \"{'name': 'value'}\"\n" +
"}",
"templateType": "VELOCITY"
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest": {
"path": "/some/path"
},
"httpForwardTemplate": {
"template": "{\n" +
" 'path' : \"/somePath\",\n" +
" 'queryStringParameters' : {\n" +
" 'userId' : [ \"$!request.queryStringParameters['userId'][0]\" ]\n" +
" },\n" +
" 'cookies' : {\n" +
" 'SessionId' : \"$!request.cookies['SessionId']\"\n" +
" },\n" +
" 'headers' : {\n" +
" 'Host' : [ \"localhost:1081\" ]\n" +
" },\n" +
" 'body': \"{'name': 'value'}\"\n" +
"}",
"templateType": "VELOCITY"
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest": {
"path": "/some/path"
},
"httpForwardTemplate": {
"template": "{\n" +
" 'path' : \"/somePath\",\n" +
" 'queryStringParameters' : {\n" +
" 'userId' : [ \"$!request.queryStringParameters['userId'][0]\" ]\n" +
" },\n" +
" 'cookies' : {\n" +
" 'SessionId' : \"$!request.cookies['SessionId']\"\n" +
" },\n" +
" 'headers' : {\n" +
" 'Host' : [ \"localhost:1081\" ]\n" +
" },\n" +
" 'body': \"{'name': 'value'}\"\n" +
"}",
"templateType": "VELOCITY"
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"": {
""path"": ""/some/path""
},
""httpForwardTemplate"": {
""template"": ""{\n"" +
"" 'path' : \""/somePath\"",\n"" +
"" 'queryStringParameters' : {\n"" +
"" 'userId' : [ \""$!request.queryStringParameters['userId'][0]\"" ]\n"" +
"" },\n"" +
"" 'cookies' : {\n"" +
"" 'SessionId' : \""$!request.cookies['SessionId']\""\n"" +
"" },\n"" +
"" 'headers' : {\n"" +
"" 'Host' : [ \""localhost:1081\"" ]\n"" +
"" },\n"" +
"" 'body': \""{'name': 'value'}\""\n"" +
""}"",
""templateType"": ""VELOCITY""
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest": {
"path": "/some/path"
},
"httpForwardTemplate": {
"template": "{\n" +
" 'path' : \"/somePath\",\n" +
" 'queryStringParameters' : {\n" +
" 'userId' : [ \"$!request.queryStringParameters['userId'][0]\" ]\n" +
" },\n" +
" 'cookies' : {\n" +
" 'SessionId' : \"$!request.cookies['SessionId']\"\n" +
" },\n" +
" 'headers' : {\n" +
" 'Host' : [ \"localhost:1081\" ]\n" +
" },\n" +
" 'body': \"{'name': 'value'}\"\n" +
"}",
"templateType": "VELOCITY"
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest": {
"path": "/some/path"
},
"httpForwardTemplate": {
"template": "{\n" +
" 'path' : \"/somePath\",\n" +
" 'queryStringParameters' : {\n" +
" 'userId' : [ \"$!request.queryStringParameters['userId'][0]\" ]\n" +
" },\n" +
" 'cookies' : {\n" +
" 'SessionId' : \"$!request.cookies['SessionId']\"\n" +
" },\n" +
" 'headers' : {\n" +
" 'Host' : [ \"localhost:1081\" ]\n" +
" },\n" +
" 'body': \"{'name': 'value'}\"\n" +
"}",
"templateType": "VELOCITY"
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"path": "/some/path"
},
"httpForwardTemplate": {
"template": "{\n" +
" 'path' : \"/somePath\",\n" +
" 'queryStringParameters' : {\n" +
" 'userId' : [ \"$!request.queryStringParameters['userId'][0]\" ]\n" +
" },\n" +
" 'cookies' : {\n" +
" 'SessionId' : \"$!request.cookies['SessionId']\"\n" +
" },\n" +
" 'headers' : {\n" +
" 'Host' : [ \"localhost:1081\" ]\n" +
" },\n" +
" 'body': \"{'name': 'value'}\"\n" +
"}",
"templateType": "VELOCITY"
}
}'
See REST API for full JSON specification
A response template allows you to transform the response returned from the upstream server using a template that has access to both the original request and the upstream response. This is useful when you need to dynamically modify responses based on request context — for example, injecting request headers into the response body or conditionally changing the status code.
The template receives two objects: request (the original request) and response (the upstream response). The template must return a valid HTTP response JSON object.
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"requestOverride": {
"headers": {
"Host": ["target.host.com"]
}
},
"responseTemplate": {
"templateType": "JAVASCRIPT",
"template": "return { 'statusCode': response.statusCode, 'headers': response.headers, 'body': JSON.stringify({ 'originalBody': response.body, 'requestPath': request.path }) };"
}
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"requestOverride": {
"headers": {
"Host": ["target.host.com"]
}
},
"responseTemplate": {
"templateType": "JAVASCRIPT",
"template": "return { 'statusCode': response.statusCode, 'headers': response.headers, 'body': JSON.stringify({ 'originalBody': response.body, 'requestPath': request.path }) };"
}
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"requestOverride": {
"headers": {
"Host": ["target.host.com"]
}
},
"responseTemplate": {
"templateType": "JAVASCRIPT",
"template": "return { 'statusCode': response.statusCode, 'headers': response.headers, 'body': JSON.stringify({ 'originalBody': response.body, 'requestPath': request.path }) };"
}
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"": {
""path"": ""/some/path""
},
""httpOverrideForwardedRequest"": {
""requestOverride"": {
""headers"": {
""Host"": [""target.host.com""]
}
},
""responseTemplate"": {
""templateType"": ""JAVASCRIPT"",
""template"": ""return { 'statusCode': response.statusCode, 'headers': response.headers, 'body': JSON.stringify({ 'originalBody': response.body, 'requestPath': request.path }) };""
}
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"requestOverride": {
"headers": {
"Host": ["target.host.com"]
}
},
"responseTemplate": {
"templateType": "JAVASCRIPT",
"template": "return { 'statusCode': response.statusCode, 'headers': response.headers, 'body': JSON.stringify({ 'originalBody': response.body, 'requestPath': request.path }) };"
}
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"requestOverride": {
"headers": {
"Host": ["target.host.com"]
}
},
"responseTemplate": {
"templateType": "JAVASCRIPT",
"template": "return { 'statusCode': response.statusCode, 'headers': response.headers, 'body': JSON.stringify({ 'originalBody': response.body, 'requestPath': request.path }) };"
}
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"path": "/some/path"
},
"httpOverrideForwardedRequest": {
"requestOverride": {
"headers": {
"Host": ["target.host.com"]
}
},
"responseTemplate": {
"templateType": "JAVASCRIPT",
"template": "return { 'statusCode': response.statusCode, 'headers': response.headers, 'body': JSON.stringify({ 'originalBody': response.body, 'requestPath': request.path }) };"
}
}
}'
See REST API for full JSON specification
When using a templated forward (JavaScript, Velocity, or Mustache), you can also specify a responseOverride and/or responseModifier to statically modify the response returned from the upstream server — without needing a separate response template.
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest": {
"path": "/some/path"
},
"httpForwardTemplate": {
"templateType": "JAVASCRIPT",
"template": "return { 'path': '/target' + request.path, 'headers': { 'Host': ['target.host.com'] } };",
"responseOverride": {
"headers": {
"x-proxy": ["mockserver"]
}
}
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest": {
"path": "/some/path"
},
"httpForwardTemplate": {
"templateType": "JAVASCRIPT",
"template": "return { 'path': '/target' + request.path, 'headers': { 'Host': ['target.host.com'] } };",
"responseOverride": {
"headers": {
"x-proxy": ["mockserver"]
}
}
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest": {
"path": "/some/path"
},
"httpForwardTemplate": {
"templateType": "JAVASCRIPT",
"template": "return { 'path': '/target' + request.path, 'headers': { 'Host': ['target.host.com'] } };",
"responseOverride": {
"headers": {
"x-proxy": ["mockserver"]
}
}
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"": {
""path"": ""/some/path""
},
""httpForwardTemplate"": {
""templateType"": ""JAVASCRIPT"",
""template"": ""return { 'path': '/target' + request.path, 'headers': { 'Host': ['target.host.com'] } };"",
""responseOverride"": {
""headers"": {
""x-proxy"": [""mockserver""]
}
}
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest": {
"path": "/some/path"
},
"httpForwardTemplate": {
"templateType": "JAVASCRIPT",
"template": "return { 'path': '/target' + request.path, 'headers': { 'Host': ['target.host.com'] } };",
"responseOverride": {
"headers": {
"x-proxy": ["mockserver"]
}
}
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest": {
"path": "/some/path"
},
"httpForwardTemplate": {
"templateType": "JAVASCRIPT",
"template": "return { 'path': '/target' + request.path, 'headers': { 'Host': ['target.host.com'] } };",
"responseOverride": {
"headers": {
"x-proxy": ["mockserver"]
}
}
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"path": "/some/path"
},
"httpForwardTemplate": {
"templateType": "JAVASCRIPT",
"template": "return { 'path': '/target' + request.path, 'headers': { 'Host': ['target.host.com'] } };",
"responseOverride": {
"headers": {
"x-proxy": ["mockserver"]
}
}
}
}'
See REST API for full JSON specification
public class CallbackActionExamples {
public void forwardClassCallback() {
new ClientAndServer(1080)
.when(
request()
.withPath("/some.*")
)
.forward(
callback()
.withCallbackClass(TestExpectationForwardCallback.class)
);
}
public static class TestExpectationForwardCallback implements ExpectationForwardCallback {
@Override
public HttpRequest handle(HttpRequest httpRequest) {
return request()
.withPath(httpRequest.getPath())
.withMethod("POST")
.withHeaders(
header("x-callback", "test_callback_header"),
header("Content-Length", "a_callback_request".getBytes(UTF_8).length),
header("Connection", "keep-alive")
)
.withBody("a_callback_request");
}
}
}
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"path": "/some.*"
},
"httpForwardClassCallback": {
"callbackClass": "org.mockserver.examples.mockserver.CallbackActionExamples$TestExpectationForwardCallback"
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
$json = <<<'JSON'
{
"httpRequest" : {
"path" : "/some.*"
},
"httpForwardClassCallback" : {
"callbackClass" : "org.mockserver.examples.mockserver.CallbackActionExamples$TestExpectationForwardCallback"
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest" : {
"path" : "/some.*"
},
"httpForwardClassCallback" : {
"callbackClass" : "org.mockserver.examples.mockserver.CallbackActionExamples$TestExpectationForwardCallback"
}
}'
To use a class callback MockServer must be able to load the class from the classpath.
The callback class must:
- implement
- org.mockserver.mock.action.ExpectationForwardCallback to dynamically override the request or
- org.mockserver.mock.action.ExpectationForwardAndResponseCallback to dynamically override the request and the response
- have a zero argument constructor
- be available in the classpath of the MockServer
If MockServer is started using the JUnit 4 @Rule, the JUnit 5 Test Extension, ClientAndServer or directly using org.mockserver.netty.MockServer then any class present in the main or test classpaths will be visible to MockServer.
If MockServer is started using the maven plugin only the non-forked goals (such as runAndWait and start) will be able to load classes from the main and test classpaths. It is possible to use classes from a separate maven dependency, however, this dependency must be specified in the plugin configuration dependencies section. Any dependency added to the plugin configuration dependencies section will then be visible to MockServer run using both forked and non-forked goals.
The following configuration shows how to use classes from a separate maven dependency in callback actions.
<plugin>
<groupId>org.mock-server</groupId>
<artifactId>mockserver-maven-plugin</artifactId>
<version>7.1.0</version>
<configuration>
<serverPort>1080</serverPort>
<logLevel>DEBUG</logLevel>
<pipeLogToConsole>true</pipeLogToConsole>
</configuration>
<executions>
<execution>
<id>pre-integration-test</id>
<phase>pre-integration-test</phase>
<goals>
<goal>runForked</goal>
</goals>
</execution>
<execution>
<id>post-integration-test</id>
<phase>post-integration-test</phase>
<goals>
<goal>stopForked</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.my-domain</groupId>
<artifactId>my-callback-dependency</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
</plugin>
If MockServer is started using the command line then the callback classes must be added to the JVM using the classpath command line switch (cp or classpath). The classpath switch is ignored by the JVM if the jar switch is used. So to run the MockServer from the command line directly (with mockserver-netty-7.1.0-no-dependencies.jar) you must specify the org.mockserver.cli.Main main class specifically and not use the jar switch as follows.
java -Dfile.encoding=UTF-8 -cp mockserver-netty-7.1.0-no-dependencies.jar:my-callback-dependency.jar org.mockserver.cli.Main -serverPort 1080
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path")
)
.forward(
new ExpectationForwardCallback() {
@Override
public HttpRequest handle(HttpRequest httpRequest) {
return request()
.withPath(httpRequest.getPath())
.withMethod("POST")
.withHeaders(
header("x-callback", "test_callback_header"),
header("Content-Length", "a_callback_request".getBytes(UTF_8).length),
header("Connection", "keep-alive")
)
.withBody("a_callback_request");
}
}
);
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path")
)
.forward(
httpRequest -> request()
.withPath(httpRequest.getPath())
.withMethod("POST")
.withHeaders(
header("x-callback", "test_callback_header"),
header("Content-Length", "a_callback_request".getBytes(UTF_8).length),
header("Connection", "keep-alive")
)
.withBody("a_callback_request")
);
When using org.mockserver.client.MockServerClient each method / closure callback has a separate web socket client. To ensure the number of total threads does not grow too large for large numbers of method / closure callback expectations the default event loop thread pool for the web socket client is kept fairly low. However, if an extremely large load is matched against a single method / closure callback expectation the event loop thread pool may not be large enough for its web socket client.
The number of threads for the event loop thread pool for each web socket client (i.e. for each expectation with a method / closure callback) can be configured and is described in the configuration section.
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path")
)
.forward(
new ExpectationForwardCallback() {
@Override
public HttpRequest handle(HttpRequest httpRequest) throws Exception {
return request()
.withPath(httpRequest.getPath())
.withMethod("POST")
.withHeaders(
header("x-callback", "test_callback_header"),
header("Content-Length", "a_callback_request".getBytes(UTF_8).length),
header("Connection", "keep-alive")
)
.withBody("a_callback_request");
}
},
new ExpectationForwardAndResponseCallback() {
@Override
public HttpResponse handle(HttpRequest httpRequest, HttpResponse httpResponse) throws Exception {
return httpResponse
.withHeader("x-response-test", "x-response-test")
.removeHeader(CONTENT_LENGTH.toString())
.withBody("some_overridden_response_body");
}
}
);
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path")
)
.forward(
httpRequest ->
request()
.withPath(httpRequest.getPath())
.withMethod("POST")
.withHeaders(
header("x-callback", "test_callback_header"),
header("Content-Length", "a_callback_request".getBytes(UTF_8).length),
header("Connection", "keep-alive")
)
.withBody("a_callback_request"),
(httpRequest, httpResponse) ->
httpResponse
.withHeader("x-response-test", "x-response-test")
.removeHeader(CONTENT_LENGTH.toString())
.withBody("some_overridden_response_body")
);
When using org.mockserver.client.MockServerClient each method / closure callback has a separate web socket client. To ensure the number of total threads does not grow too large for large numbers of method / closure callback expectations the default event loop thread pool for the web socket client is kept fairly low. However, if an extremely large load is matched against a single method / closure callback expectation the event loop thread pool may not be large enough for its web socket client.
The number of threads for the event loop thread pool for each web socket client (i.e. for each expectation with a method / closure callback) can be configured and is described in the configuration section.
Forward with Fallback
A forward with fallback action (httpForwardWithFallback) forwards the request to an upstream service, but returns a pre-configured fallback response when the upstream returns an error status code or the connection fails. This is unique to MockServer's hybrid mock+proxy architecture.
Use cases:
- Resilience testing - test your application's behaviour when a downstream service is flaky
- Development against partially-available services - work offline with cached/mock responses while still connecting to real services when they are available
- Circuit breaker simulation - provide a fallback response on specific status codes like 429 (rate limited) or 503 (service unavailable)
Configuration
- httpForward - the upstream target (host, port, scheme)
- fallbackResponse - the mock response to return when fallback is triggered
- fallbackOnStatusCodes - list of HTTP status codes that trigger the fallback (defaults to 500-599 when not specified)
- fallbackOnTimeout - whether to return the fallback on connection errors or timeouts (defaults to true)
Java Client Example
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/api/downstream")
)
.forwardWithFallback(
forwardWithFallback()
.withForward(
forward()
.withHost("downstream-service.example.com")
.withPort(443)
.withScheme(HttpForward.Scheme.HTTPS)
)
.withFallback(
response()
.withStatusCode(200)
.withBody("{\"status\": \"cached\", \"data\": []}")
)
.withFallbackOnStatusCodes(500, 502, 503, 504)
.withFallbackOnTimeout(true)
);
JSON Example
{
"httpRequest": {
"path": "/api/downstream"
},
"httpForwardWithFallback": {
"httpForward": {
"host": "downstream-service.example.com",
"port": 443,
"scheme": "HTTPS"
},
"fallbackResponse": {
"statusCode": 200,
"body": "{\"status\": \"cached\", \"data\": []}"
},
"fallbackOnStatusCodes": [500, 502, 503, 504],
"fallbackOnTimeout": true
}
}
An error action can return an invalid response as a sequence of bytes or drop the connection (with an optional delay)
The following code examples show how to create different error actions.
An error action can include a delay to simulate a service that hangs before dropping the connection, which is useful for testing timeout handling.
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path")
)
.error(
error()
.withDropConnection(true)
.withDelay(TimeUnit.SECONDS, 5)
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"path": "/some/path"
},
"httpError": {
"dropConnection": true,
"delay": {
"timeUnit": "SECONDS",
"value": 5
}
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import HttpError, HttpRequest, Delay
client = MockServerClient("localhost", 1080)
client.when(
HttpRequest.request("/some/path")
).error(
HttpError(drop_connection=True, delay=Delay(time_unit="SECONDS", value=5))
)
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.when(
MockServer::HttpRequest.new(path: '/some/path')
).error(
MockServer::HttpError.new(
drop_connection: true,
delay: MockServer::Delay.new(time_unit: 'SECONDS', value: 5)
)
)
import mockserver "github.com/mock-server/mockserver-monorepo/mockserver-client-go"
client := mockserver.New("localhost", 1080)
client.When(
mockserver.Request().Path("/some/path"),
).RespondWithError(
mockserver.Error().DropConnection(true).WithDelay("SECONDS", 5),
)
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"": {
""path"": ""/some/path""
},
""httpError"": {
""dropConnection"": true,
""delay"": {
""timeUnit"": ""SECONDS"",
""value"": 5
}
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest": {
"path": "/some/path"
},
"httpError": {
"dropConnection": true,
"delay": {
"timeUnit": "SECONDS",
"value": 5
}
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest": {
"path": "/some/path"
},
"httpError": {
"dropConnection": true,
"delay": {
"timeUnit": "SECONDS",
"value": 5
}
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"path": "/some/path"
},
"httpError": {
"dropConnection": true,
"delay": {
"timeUnit": "SECONDS",
"value": 5
}
}
}'
See REST API for full JSON specification
// generate random bytes
byte[] randomByteArray = new byte[25];
new Random().nextBytes(randomByteArray);
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path")
)
.error(
error()
.withDropConnection(true)
.withResponseBytes(randomByteArray)
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest": {
"path": "/some/path"
},
"httpError": {
"dropConnection": true,
"responseBytes": "eQqmdjEEoaXnCvcK6lOAIZeU+Pn+womxmg=="
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import HttpError, HttpRequest
client = MockServerClient("localhost", 1080)
client.when(
HttpRequest.request("/some/path")
).error(
HttpError(drop_connection=True, response_bytes="eQqmdjEEoaXnCvcK6lOAIZeU+Pn+womxmg==")
)
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.when(
MockServer::HttpRequest.new(path: '/some/path')
).error(
MockServer::HttpError.new(
drop_connection: true,
response_bytes: 'eQqmdjEEoaXnCvcK6lOAIZeU+Pn+womxmg=='
)
)
import mockserver "github.com/mock-server/mockserver-monorepo/mockserver-client-go"
client := mockserver.New("localhost", 1080)
client.When(
mockserver.Request().Path("/some/path"),
).RespondWithError(
mockserver.Error().DropConnection(true).ResponseBytes("eQqmdjEEoaXnCvcK6lOAIZeU+Pn+womxmg=="),
)
using MockServer.Client;
using MockServer.Client.Models;
using var client = new MockServerClient("localhost", 1080);
client.When(
HttpRequest.Request().WithPath("/some/path")
).Error(
HttpError.Error()
.WithDropConnection(true)
.WithResponseBytes("eQqmdjEEoaXnCvcK6lOAIZeU+Pn+womxmg==")
);
use mockserver_client::{ClientBuilder, HttpRequest, HttpError};
let client = ClientBuilder::new("localhost", 1080).build().unwrap();
client.when(HttpRequest::new().path("/some/path"))
.error(
HttpError::new()
.drop_connection(true)
.response_bytes("eQqmdjEEoaXnCvcK6lOAIZeU+Pn+womxmg==")
)
.unwrap();
use MockServer\MockServerClient;
use MockServer\HttpRequest;
use MockServer\HttpError;
$client = new MockServerClient('localhost', 1080);
$client->when(
HttpRequest::request()
->path('/some/path')
)->error(
HttpError::error()
->dropConnection(true)
->responseBytes('eQqmdjEEoaXnCvcK6lOAIZeU+Pn+womxmg==')
);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest": {
"path": "/some/path"
},
"httpError": {
"dropConnection": true,
"responseBytes": "eQqmdjEEoaXnCvcK6lOAIZeU+Pn+womxmg=="
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.when(
request()
.withPath("/some/path")
)
.error(
error()
.withDropConnection(true)
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
"httpRequest" : {
"path" : "/some/path"
},
"httpError" : {
"dropConnection" : true
}
}).then(
function () {
console.log("expectation created");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import HttpError, HttpRequest
client = MockServerClient("localhost", 1080)
client.when(
HttpRequest.request("/some/path")
).error(
HttpError(drop_connection=True)
)
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.when(
MockServer::HttpRequest.new(path: '/some/path')
).error(
MockServer::HttpError.new(drop_connection: true)
)
import mockserver "github.com/mock-server/mockserver-monorepo/mockserver-client-go"
client := mockserver.New("localhost", 1080)
client.When(
mockserver.Request().Path("/some/path"),
).RespondWithError(
mockserver.Error().DropConnection(true),
)
using MockServer.Client;
using MockServer.Client.Models;
using var client = new MockServerClient("localhost", 1080);
client.When(
HttpRequest.Request().WithPath("/some/path")
).Error(
HttpError.Error().WithDropConnection(true)
);
use mockserver_client::{ClientBuilder, HttpRequest, HttpError};
let client = ClientBuilder::new("localhost", 1080).build().unwrap();
client.when(HttpRequest::new().path("/some/path"))
.error(HttpError::new().drop_connection(true))
.unwrap();
use MockServer\MockServerClient;
use MockServer\HttpRequest;
use MockServer\HttpError;
$client = new MockServerClient('localhost', 1080);
$client->when(
HttpRequest::request()
->path('/some/path')
)->error(
HttpError::error()
->dropConnection(true)
);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest" : {
"path" : "/some/path"
},
"httpError" : {
"dropConnection" : true
}
}'
See REST API for full JSON specification
Use respondBeforeBody on the request matcher to dispatch the configured response before MockServer reads the request body. The matcher must not include a body matcher and only RESPONSE and ERROR actions are supported. The connection is always closed after the response (the inbound body has not been consumed, so reuse is unsafe), so any closeSocket value is ignored — set keepAliveOverride(false) on the response if you want the Connection: close header on the wire. HTTP/1.1 only — HTTP/2 connections fall through to the standard pipeline. This is useful for reproducing client behaviour when a server responds and closes mid-upload.
new MockServerClient("localhost", 1080)
.when(
request()
.withMethod("POST")
.withPath("/upload")
.withRespondBeforeBody(true)
)
.respond(
response()
.withStatusCode(403)
.withBody("forbidden")
.withConnectionOptions(
connectionOptions().withKeepAliveOverride(false)
)
);
from mockserver.client import MockServerClient
from mockserver.models import Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict({
"httpRequest": {
"method": "POST",
"path": "/upload",
"respondBeforeBody": True
},
"httpResponse": {
"statusCode": 403,
"body": "forbidden",
"connectionOptions": {
"keepAliveOverride": False
}
}
}))
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.upsert(MockServer::Expectation.from_hash({
"httpRequest": {
"method": "POST",
"path": "/upload",
"respondBeforeBody": true
},
"httpResponse": {
"statusCode": 403,
"body": "forbidden",
"connectionOptions": {
"keepAliveOverride": false
}
}
}))
package main
import (
"bytes"
"net/http"
)
func main() {
body := []byte(`{
"httpRequest": {
"method": "POST",
"path": "/upload",
"respondBeforeBody": true
},
"httpResponse": {
"statusCode": 403,
"body": "forbidden",
"connectionOptions": {
"keepAliveOverride": false
}
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/expectation",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"": {
""method"": ""POST"",
""path"": ""/upload"",
""respondBeforeBody"": true
},
""httpResponse"": {
""statusCode"": 403,
""body"": ""forbidden"",
""connectionOptions"": {
""keepAliveOverride"": false
}
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/expectation",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
let client = Client::new();
let body = r#"{
"httpRequest": {
"method": "POST",
"path": "/upload",
"respondBeforeBody": true
},
"httpResponse": {
"statusCode": 403,
"body": "forbidden",
"connectionOptions": {
"keepAliveOverride": false
}
}
}"#;
client.put("http://localhost:1080/mockserver/expectation")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
$json = <<<'JSON'
{
"httpRequest" : {
"method" : "POST",
"path" : "/upload",
"respondBeforeBody" : true
},
"httpResponse" : {
"statusCode" : 403,
"body" : "forbidden",
"connectionOptions" : {
"keepAliveOverride" : false
}
}
}
JSON;
$ch = curl_init('http://localhost:1080/mockserver/expectation');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
"httpRequest" : {
"method" : "POST",
"path" : "/upload",
"respondBeforeBody" : true
},
"httpResponse" : {
"statusCode" : 403,
"body" : "forbidden",
"connectionOptions" : {
"keepAliveOverride" : false
}
}
}'
See REST API for full JSON specification
LLM Response
An LLM response action (httpLlmResponse) returns a provider-correct response from a high-level description of what the model should say. Instead of hand-assembling Anthropic or OpenAI response JSON, you describe the intent (text, tool calls, usage, stop reason) and MockServer produces the byte-correct wire format.
Seven providers have full codec support: ANTHROPIC, OPENAI (Chat Completions), OPENAI_RESPONSES, GEMINI, BEDROCK, AZURE_OPENAI, and OLLAMA — each produces the byte-correct wire format for both single completions and streaming. A request naming an unrecognised provider returns a structured 400 response listing the supported providers.
Java Client Example
import static org.mockserver.client.LlmMockBuilder.llmMock;
import static org.mockserver.model.Completion.completion;
import static org.mockserver.model.Provider.ANTHROPIC;
import static org.mockserver.model.ToolUse.toolUse;
import static org.mockserver.model.Usage.usage;
// Simple text completion
llmMock("/v1/messages")
.withProvider(ANTHROPIC)
.withModel("claude-sonnet-4")
.respondingWith(
completion()
.withText("The capital of France is Paris.")
.withStopReason("end_turn")
.withUsage(usage().withInputTokens(42).withOutputTokens(8))
)
.applyTo(mockServerClient);
// Tool / function call
llmMock("/v1/messages")
.withProvider(ANTHROPIC)
.respondingWith(
completion()
.withText("Let me check the weather.")
.withToolCall(toolUse("get_weather").withArguments("{\"city\":\"Paris\"}"))
.withStopReason("tool_use")
)
.applyTo(mockServerClient);
JSON Definition Format
{
"httpRequest": {
"method": "POST",
"path": "/v1/messages"
},
"httpLlmResponse": {
"provider": "ANTHROPIC",
"model": "claude-sonnet-4",
"completion": {
"text": "The capital of France is Paris.",
"stopReason": "end_turn",
"usage": { "inputTokens": 42, "outputTokens": 8 }
}
}
}
Streaming with Realistic Timing
When streaming is enabled, MockServer expands the completion into provider-correct streaming events with configurable timing physics. Most providers use SSE (Server-Sent Events with text/event-stream) — for example, message_start through message_stop for Anthropic, and chat.completion.chunk deltas for OpenAI. Two providers use alternative wire formats: Ollama uses native NDJSON (newline-delimited JSON with application/x-ndjson), and Bedrock uses the AWS event-stream binary framing (application/vnd.amazon.eventstream) where each streaming chunk is a binary message containing a base64-wrapped JSON payload — matching the InvokeModelWithResponseStream wire format. MockServer emits the correct wire format automatically based on the provider.
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.mockserver.client.Llm.jitter;
import static org.mockserver.client.Llm.timeToFirstToken;
import static org.mockserver.client.Llm.tokensPerSecond;
import static org.mockserver.client.LlmMockBuilder.llmMock;
import static org.mockserver.model.Completion.completion;
import static org.mockserver.model.Provider.OPENAI;
llmMock("/v1/chat/completions")
.withProvider(OPENAI)
.withModel("gpt-4o")
.respondingWith(
completion()
.withText("Streaming token by token...")
.streaming()
.withStreamingPhysics(
timeToFirstToken(300, MILLISECONDS),
tokensPerSecond(50),
jitter(0.2))
)
.applyTo(mockServerClient);
Embeddings (Deterministic from Input)
For OpenAI embeddings, deterministicFromInput() generates reproducible vectors seeded from the input text. Same input + same dimensions + same seed produces an identical L2-normalised vector across JVMs.
import static org.mockserver.client.Llm.embedding;
import static org.mockserver.client.LlmMockBuilder.llmMock;
import static org.mockserver.model.Provider.OPENAI;
llmMock("/v1/embeddings")
.withProvider(OPENAI)
.respondingWith(
embedding()
.withDimensions(1536)
.deterministicFromInput()
)
.applyTo(mockServerClient);
Structured-Output Validation
Attach an outputSchema (a JSON Schema) to a completion and MockServer validates the response text against it as the response is encoded. Validation is fail-soft: a mismatch never changes the response body — it adds an x-mockserver-structured-output-invalid response header and logs a warning, so a malformed structured-output fixture is surfaced without breaking the test (a blank or invalid schema, or a missing text, is a no-op). To assert schema conformance over already-recorded traffic instead, use the verify_structured_output tool.
import static org.mockserver.client.LlmMockBuilder.llmMock;
import static org.mockserver.model.Completion.completion;
import static org.mockserver.model.Provider.ANTHROPIC;
llmMock("/v1/messages")
.withProvider(ANTHROPIC)
.respondingWith(
completion()
.withText("{\"city\":\"Paris\",\"country\":\"France\"}")
.withOutputSchema("{\"type\":\"object\",\"required\":[\"city\",\"country\"]}")
)
.applyTo(mockServerClient);
Fault Injection & Rate-Limit Quota
A chaos block on the LLM response injects faults for resilience testing: probabilistic provider errors (e.g. 429/529 with a Retry-After header), mid-stream truncation, malformed SSE, and a stateful request quota. The quota is a deterministic fixed-window rate limit — expectations sharing a quotaName share one counter, so requests past quotaLimit within quotaWindowMillis are rejected with quotaErrorStatus (default 429) and the retryAfter header (the count resets when the window elapses and on server reset). The chaos block is set via the JSON definition (below) or the mock_llm_completion MCP tool, where the full field reference lives.
{
"httpRequest": {
"method": "POST",
"path": "/v1/messages"
},
"httpLlmResponse": {
"provider": "ANTHROPIC",
"completion": {
"text": "The capital of France is Paris."
},
"chaos": {
"quotaName": "anthropic-account",
"quotaLimit": 100,
"quotaWindowMillis": 60000,
"quotaErrorStatus": 429,
"retryAfter": "30"
}
}
}
For multi-turn LLM conversations with stateful scenario progression, see the LLM Conversation example in the Stateful Scenarios section.
WebSocket Response
A WebSocket response action (httpWebSocketResponse) accepts an HTTP Upgrade request and turns the connection into a WebSocket session. Two modes are available:
- Server-push — a fixed sequence of messages sent to the client immediately after the handshake, defined in the messages array.
- Bidirectional — incoming WebSocket frames are matched against a list of matchers; the first matching entry triggers its own response sequence. Matchers are evaluated in order; first match wins.
Both modes can be combined in a single expectation: MockServer sends any messages immediately after the upgrade, then waits for incoming frames and applies matchers for each one received.
Bidirectional Frame Matching
Each entry in the matchers array contains:
- frameType — the WebSocket frame type to match: TEXT, BINARY, PING, PONG, or ANY (matches any type).
- textMatcher — optional substring or exact string the text frame payload must contain. Omit to match all frames of the given frameType.
- responses — the sequence of messages to send back when this matcher fires. Each entry has a text field (and an optional delay).
JSON Definition Format
{
"httpRequest": {
"method": "GET",
"path": "/ws/chat"
},
"httpWebSocketResponse": {
"messages": [
{"text": "{\"type\": \"connected\"}"}
],
"matchers": [
{
"frameType": "TEXT",
"textMatcher": "ping",
"responses": [
{"text": "{\"type\": \"pong\"}"}
]
},
{
"frameType": "TEXT",
"textMatcher": "subscribe",
"responses": [
{"text": "{\"type\": \"ack\"}"},
{"text": "{\"type\": \"data\", \"value\": 42}"}
]
}
],
"closeConnection": false
}
}
In this example, MockServer sends {"type": "connected"} immediately after the WebSocket upgrade. If the client then sends a frame containing ping, MockServer replies with {"type": "pong"}. A frame containing subscribe triggers a two-message reply sequence. Frames that match no entry are silently ignored.
Bidirectional WebSocket expectations are also authorable in the dashboard Composer — select WebSocket response as the action type and use the Bidirectional frame matchers panel to add entries.
CRUD Simulation
CRUD Simulation lets you quickly stand up a fully functional RESTful resource without writing individual expectations for each HTTP method. You provide a base path and optional configuration, and MockServer automatically generates five endpoints that manage an in-memory collection of JSON objects.
This is useful when your tests need a realistic data store (e.g. users, products, orders) that supports create, read, update, and delete operations without manually defining expectations for each verb.
Auto-Generated Endpoints
Given a basePath of /api/users, MockServer generates:
| Method | Path | Description | Success Status |
|---|---|---|---|
| GET | /api/users | List all items | 200 |
| POST | /api/users | Create a new item | 201 |
| GET | /api/users/{id} | Get item by ID | 200 |
| PUT | /api/users/{id} | Update item by ID | 200 |
| DELETE | /api/users/{id} | Delete item by ID | 204 |
JSON Definition Format
A CRUD simulation is defined by a JSON object with the following fields:
- basePath (required) - the URL path prefix for the generated endpoints, e.g. /api/users
- idField (optional, default "id") - the field name used as the unique identifier in each JSON object
- idStrategy (optional, default "AUTO_INCREMENT") - how IDs are generated for new items:
- AUTO_INCREMENT - sequential numeric IDs (1, 2, 3, ...)
- UUID - random UUID strings
- initialData (optional) - an array of JSON objects to pre-populate the data store
REST API
Register a CRUD simulation using PUT /mockserver/crud:
curl -X PUT "http://localhost:1080/mockserver/crud" \
-H "Content-Type: application/json" \
-d '{
"basePath": "/api/users",
"idField": "id",
"idStrategy": "AUTO_INCREMENT",
"initialData": [
{"name": "Alice", "email": "alice@example.com"},
{"name": "Bob", "email": "bob@example.com"}
]
}'
After registration, the endpoints are immediately available:
# List all users
curl http://localhost:1080/api/users
# Create a new user
curl -X POST http://localhost:1080/api/users \
-H "Content-Type: application/json" \
-d '{"name": "Charlie", "email": "charlie@example.com"}'
# Get user by ID
curl http://localhost:1080/api/users/1
# Update user
curl -X PUT http://localhost:1080/api/users/1 \
-H "Content-Type: application/json" \
-d '{"name": "Alice Updated", "email": "alice@example.com"}'
# Delete user
curl -X DELETE http://localhost:1080/api/users/3
Java Client Example
new MockServerClient("localhost", 1080)
.crud(
new CrudExpectationsDefinition()
.withBasePath("/api/users")
.withIdField("id")
.withIdStrategy(CrudExpectationsDefinition.IdStrategy.AUTO_INCREMENT)
);
UUID ID Strategy Example
curl -X PUT "http://localhost:1080/mockserver/crud" \
-H "Content-Type: application/json" \
-d '{
"basePath": "/api/products",
"idStrategy": "UUID"
}'
# Create a product - ID will be a UUID like "550e8400-e29b-41d4-a716-446655440000"
curl -X POST http://localhost:1080/api/products \
-H "Content-Type: application/json" \
-d '{"name": "Widget", "price": 9.99}'
CRUD simulations are independent of regular expectations and are cleared when MockServer is reset. You can register multiple CRUD simulations with different base paths simultaneously.
2. Run Your Test Scenarios
With MockServer running and expectations configured, execute your application or test suite. Your application should make requests to MockServer (on the configured port) instead of the real dependencies. MockServer will match incoming requests against the configured expectations and return the specified responses.
3. Verify Requests
MockServer supports verification of requests and responses it has received, including both proxied requests and requests that have matched an expectation.
Verification can be specified as follows:
- a request matcher and a condition indicating the number of times the request should be matched
- a response matcher (optionally combined with a request matcher) and a condition indicating the number of times a matching response should have been recorded
- a sequence of request matchers that is matched in order
- a sequence of request and response matcher pairs that is matched in order
How Verification Works
MockServer records all received requests in an in-memory event log (separate from application logs). Verification checks this event log:
For request matcher count verification: MockServer filters the event log to find all RECEIVED_REQUEST entries matching your request matcher, counts them, and compares the count against your constraint (atLeast(n), exactly(n), etc.). Returns HTTP 202 if the count matches, or HTTP 406 with an error message if it does not.
For response verification: When a response matcher is included in the verification, MockServer retrieves all recorded request-response pairs (from EXPECTATION_RESPONSE, FORWARDED_REQUEST, and NO_MATCH_RESPONSE entries) and filters them by the response matcher. If a request matcher is also supplied, both must match the same pair. The count of matching pairs is then checked against VerificationTimes. On failure, MockServer returns HTTP 406 with a "Response not found ..." error message listing the actual responses recorded.
For expectation ID verification: MockServer retrieves all events associated with the specified expectation ID (including EXPECTATION_RESPONSE and FORWARDED_REQUEST entries) and verifies the count.
For sequence verification: MockServer scans recorded requests in order, checking that each expected request appears after the previous match. This is not a simple count comparison—order matters. When httpResponses are included in a sequence verification, each step checks both the request and the response matcher against the same recorded exchange.
Important notes for parallel testing:
- The event log size is bounded by the
maxLogEntriesconfiguration property (default: minimum of free heap KB / 8 and 100,000 entries—see configuration). When this limit is reached, the oldest entries are evicted. If you run many parallel tests generating thousands of requests, consider increasing this value. Similarly, the number of expectations held in memory is bounded bymaxExpectations(default: minimum of free heap KB / 10 and 15,000 expectations). - Event recording uses an asynchronous ring buffer. However, verification operations are serialized through the same ring buffer in FIFO order, so a request that has reached MockServer and been recorded will be visible to subsequent verification calls. Intermittent failures are more commonly caused by:
- Your application under test sending requests asynchronously—ensure the application has completed sending before you verify
- Cross-test interference—one test's requests appearing in another test's verification
- Log eviction due to high request volume exceeding
maxLogEntries
- Best practices for parallel tests:
- Use separate MockServer instances (different ports or containers) per test for complete isolation
- If sharing an instance, use unique paths per test (e.g.,
/test/{testId}/...) or unique headers/query parameters in matchers - Avoid broad matchers like only
path("/api")in parallel tests - Be careful with
clear()orreset()—they affect all tests sharing the instance - If verification fails intermittently because your system under test is asynchronous, use retry-with-backoff to wait for requests to arrive (not to wait for MockServer to process already-received requests)
- To retrieve recorded requests for debugging, use
PUT /mockserver/retrieve?type=REQUESTSormockServerClient.retrieveRecordedRequests(null).
For more details on the internal architecture, see the Event System documentation.
Verification Timing
Note: MockServer processes log entries asynchronously using a ring buffer. When calling verify() immediately after sending requests, there may be a brief delay before log entries are available for verification. If verification fails unexpectedly right after requests are sent, add a small delay (e.g., 100ms) before retrying. This is most commonly needed in high-throughput scenarios or when the system under test sends requests asynchronously.
Verifying Repeating Requests
Verify that a request has been received by MockServer a specific number of times using a Verification
new MockServerClient("localhost", 1080)
.verify(
request()
.withPath("/some/path"),
VerificationTimes.atLeast(2)
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080)
.verify(
{
'path': '/some/path'
}, 2)
.then(
function () {
console.log("request found at least 2 times");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import HttpRequest, VerificationTimes
client = MockServerClient("localhost", 1080)
client.verify(
HttpRequest(path="/some/path"),
VerificationTimes.at_least(2)
)
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.verify(
MockServer::HttpRequest.new(path: '/some/path'),
times: MockServer::VerificationTimes.at_least(2)
)
import mockserver "github.com/mock-server/mockserver-monorepo/mockserver-client-go"
client := mockserver.New("localhost", 1080)
err := client.Verify(
mockserver.Request().Path("/some/path"),
mockserver.AtLeast(2),
)
using MockServer.Client;
using MockServer.Client.Models;
using var client = new MockServerClient("localhost", 1080);
client.Verify(
HttpRequest.Request().WithPath("/some/path"),
VerificationTimes.AtLeastTimes(2)
);
use mockserver_client::{ClientBuilder, HttpRequest, VerificationTimes};
let client = ClientBuilder::new("localhost", 1080).build().unwrap();
client.verify(
HttpRequest::new().path("/some/path"),
VerificationTimes::at_least(2),
).unwrap();
use MockServer\MockServerClient;
use MockServer\HttpRequest;
use MockServer\VerificationTimes;
$client = new MockServerClient('localhost', 1080);
$client->verify(
HttpRequest::request()->path('/some/path'),
VerificationTimes::atLeast(2)
);
curl -v -X PUT "http://localhost:1080/mockserver/verify" -d '{
"httpRequest": {
"path": "/simple"
},
"times": {
"atLeast": 2
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.verify(
request()
.withPath("/some/path"),
VerificationTimes.atMost(2)
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080)
.verify(
{
'path': '/some/path'
}, 0, 2)
.then(
function () {
console.log("request found at most 2 times");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import HttpRequest, VerificationTimes
client = MockServerClient("localhost", 1080)
client.verify(
HttpRequest(path="/some/path"),
VerificationTimes.at_most(2)
)
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.verify(
MockServer::HttpRequest.new(path: '/some/path'),
times: MockServer::VerificationTimes.at_most(2)
)
import mockserver "github.com/mock-server/mockserver-monorepo/mockserver-client-go"
client := mockserver.New("localhost", 1080)
err := client.Verify(
mockserver.Request().Path("/some/path"),
mockserver.AtMost(2),
)
using MockServer.Client;
using MockServer.Client.Models;
using var client = new MockServerClient("localhost", 1080);
client.Verify(
HttpRequest.Request().WithPath("/some/path"),
VerificationTimes.AtMostTimes(2)
);
use mockserver_client::{ClientBuilder, HttpRequest, VerificationTimes};
let client = ClientBuilder::new("localhost", 1080).build().unwrap();
client.verify(
HttpRequest::new().path("/some/path"),
VerificationTimes::at_most(2),
).unwrap();
use MockServer\MockServerClient;
use MockServer\HttpRequest;
use MockServer\VerificationTimes;
$client = new MockServerClient('localhost', 1080);
$client->verify(
HttpRequest::request()->path('/some/path'),
VerificationTimes::atMost(2)
);
curl -v -X PUT "http://localhost:1080/mockserver/verify" -d '{
"httpRequest": {
"path": "/simple"
},
"times": {
"atMost": 2
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.verify(
request()
.withPath("/some/path"),
VerificationTimes.exactly(2)
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080)
.verify(
{
'path': '/some/path'
}, 2, 2)
.then(
function () {
console.log("request found exactly 2 times");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import HttpRequest, VerificationTimes
client = MockServerClient("localhost", 1080)
client.verify(
HttpRequest(path="/some/path"),
VerificationTimes.exactly(2)
)
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.verify(
MockServer::HttpRequest.new(path: '/some/path'),
times: MockServer::VerificationTimes.exactly(2)
)
import mockserver "github.com/mock-server/mockserver-monorepo/mockserver-client-go"
client := mockserver.New("localhost", 1080)
err := client.Verify(
mockserver.Request().Path("/some/path"),
mockserver.ExactlyTimes(2),
)
using MockServer.Client;
using MockServer.Client.Models;
using var client = new MockServerClient("localhost", 1080);
client.Verify(
HttpRequest.Request().WithPath("/some/path"),
VerificationTimes.ExactlyTimes(2)
);
use mockserver_client::{ClientBuilder, HttpRequest, VerificationTimes};
let client = ClientBuilder::new("localhost", 1080).build().unwrap();
client.verify(
HttpRequest::new().path("/some/path"),
VerificationTimes::exactly(2),
).unwrap();
use MockServer\MockServerClient;
use MockServer\HttpRequest;
use MockServer\VerificationTimes;
$client = new MockServerClient('localhost', 1080);
$client->verify(
HttpRequest::request()->path('/some/path'),
VerificationTimes::exactly(2)
);
curl -v -X PUT "http://localhost:1080/mockserver/verify" -d '{
"httpRequest": {
"path": "/simple"
},
"times": {
"atLeast": 2,
"atMost": 2
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.verify(
openAPI(
"https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json"
),
VerificationTimes.atLeast(2)
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080)
.verify(
{
'specUrlOrPayload': 'https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json'
}, 2)
.then(
function () {
console.log("request found exactly 2 times");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
import requests
# OpenAPI matchers are not supported in the Python client verify method;
# use the REST API directly
requests.put("http://localhost:1080/mockserver/verify", json={
"httpRequest": {
"specUrlOrPayload": "https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json"
},
"times": {
"atLeast": 2
}
})
require 'net/http'
require 'json'
# OpenAPI matchers are not supported in the Ruby client verify method;
# use the REST API directly
uri = URI("http://localhost:1080/mockserver/verify")
req = Net::HTTP::Put.new(uri, 'Content-Type' => 'application/json')
req.body = JSON.generate({
"httpRequest" => {
"specUrlOrPayload" => "https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json"
},
"times" => { "atLeast" => 2 }
})
Net::HTTP.start(uri.host, uri.port) { |http| http.request(req) }
package main
import (
"bytes"
"net/http"
)
func main() {
// OpenAPI matchers are not supported in the Go client;
// use the REST API directly
body := []byte(`{
"httpRequest": {
"specUrlOrPayload": "https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json"
},
"times": {
"atLeast": 2
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/verify",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
// OpenAPI matchers are not supported in the .NET client;
// use the REST API directly
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"": {
""specUrlOrPayload"": ""https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json""
},
""times"": {
""atLeast"": 2
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/verify",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
// OpenAPI matchers are not supported in the Rust client;
// use the REST API directly
let client = Client::new();
let body = r#"{
"httpRequest": {
"specUrlOrPayload": "https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json"
},
"times": {
"atLeast": 2
}
}"#;
client.put("http://localhost:1080/mockserver/verify")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
// OpenAPI matchers are not supported in the PHP client;
// use the REST API directly
$ch = curl_init('http://localhost:1080/mockserver/verify');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => json_encode([
'httpRequest' => [
'specUrlOrPayload' => 'https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json',
],
'times' => ['atLeast' => 2],
]),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/verify" -d '{
"httpRequest": {
"specUrlOrPayload": "https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json"
},
"times": {
"atLeast": 2
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.verify(
openAPI(
"org/mockserver/openapi/openapi_petstore_example.json",
"showPetById"
),
VerificationTimes.once()
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080)
.verify(
{
'specUrlOrPayload': 'org/mockserver/openapi/openapi_petstore_example.json',
'operationId': 'showPetById'
}, 1, 1)
.then(
function () {
console.log("request found exactly 1 time");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
import requests
# OpenAPI matchers are not supported in the Python client verify method;
# use the REST API directly
requests.put("http://localhost:1080/mockserver/verify", json={
"httpRequest": {
"specUrlOrPayload": "org/mockserver/openapi/openapi_petstore_example.json",
"operationId": "showPetById"
},
"times": {
"atLeast": 1,
"atMost": 1
}
})
require 'net/http'
require 'json'
# OpenAPI matchers are not supported in the Ruby client verify method;
# use the REST API directly
uri = URI("http://localhost:1080/mockserver/verify")
req = Net::HTTP::Put.new(uri, 'Content-Type' => 'application/json')
req.body = JSON.generate({
"httpRequest" => {
"specUrlOrPayload" => "org/mockserver/openapi/openapi_petstore_example.json",
"operationId" => "showPetById"
},
"times" => { "atLeast" => 1, "atMost" => 1 }
})
Net::HTTP.start(uri.host, uri.port) { |http| http.request(req) }
package main
import (
"bytes"
"net/http"
)
func main() {
// OpenAPI matchers are not supported in the Go client;
// use the REST API directly
body := []byte(`{
"httpRequest": {
"specUrlOrPayload": "org/mockserver/openapi/openapi_petstore_example.json",
"operationId": "showPetById"
},
"times": {
"atLeast": 1,
"atMost": 1
}
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/verify",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
// OpenAPI matchers are not supported in the .NET client;
// use the REST API directly
using var httpClient = new HttpClient();
var json = @"{
""httpRequest"": {
""specUrlOrPayload"": ""org/mockserver/openapi/openapi_petstore_example.json"",
""operationId"": ""showPetById""
},
""times"": {
""atLeast"": 1,
""atMost"": 1
}
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/verify",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
// OpenAPI matchers are not supported in the Rust client;
// use the REST API directly
let client = Client::new();
let body = r#"{
"httpRequest": {
"specUrlOrPayload": "org/mockserver/openapi/openapi_petstore_example.json",
"operationId": "showPetById"
},
"times": {
"atLeast": 1,
"atMost": 1
}
}"#;
client.put("http://localhost:1080/mockserver/verify")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
// OpenAPI matchers are not supported in the PHP client;
// use the REST API directly
$ch = curl_init('http://localhost:1080/mockserver/verify');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => json_encode([
'httpRequest' => [
'specUrlOrPayload' => 'org/mockserver/openapi/openapi_petstore_example.json',
'operationId' => 'showPetById',
],
'times' => ['atLeast' => 1, 'atMost' => 1],
]),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/verify" -d '{
"httpRequest": {
"specUrlOrPayload": "org/mockserver/openapi/openapi_petstore_example.json",
"operationId": "showPetById"
},
"times": {
"atLeast": 1,
"atMost": 1
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.verify(
"31e4ca35-66c6-4645-afeb-6e66c4ca0559",
VerificationTimes.once()
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080)
.verifyById(
{
'id': '31e4ca35-66c6-4645-afeb-6e66c4ca0559'
}, 1, 1)
.then(
function () {
console.log("request found exactly 1 time");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
import requests
# verify by expectation ID is not supported in the Python client;
# use the REST API directly
requests.put("http://localhost:1080/mockserver/verify", json={
"expectationId": {
"id": "31e4ca35-66c6-4645-afeb-6e66c4ca0559"
}
})
require 'net/http'
require 'json'
# verify by expectation ID is not supported in the Ruby client;
# use the REST API directly
uri = URI("http://localhost:1080/mockserver/verify")
req = Net::HTTP::Put.new(uri, 'Content-Type' => 'application/json')
req.body = JSON.generate({
"expectationId" => {
"id" => "31e4ca35-66c6-4645-afeb-6e66c4ca0559"
}
})
Net::HTTP.start(uri.host, uri.port) { |http| http.request(req) }
package main
import (
"bytes"
"net/http"
)
func main() {
// verify by expectation ID is not supported in the Go client;
// use the REST API directly
body := []byte(`{"expectationId": {"id": "31e4ca35-66c6-4645-afeb-6e66c4ca0559"}}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/verify",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
// verify by expectation ID is not supported in the .NET client;
// use the REST API directly
using var httpClient = new HttpClient();
var json = @"{""expectationId"": {""id"": ""31e4ca35-66c6-4645-afeb-6e66c4ca0559""}}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/verify",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
// verify by expectation ID is not supported in the Rust client;
// use the REST API directly
let client = Client::new();
client.put("http://localhost:1080/mockserver/verify")
.header("Content-Type", "application/json")
.body(r#"{"expectationId": {"id": "31e4ca35-66c6-4645-afeb-6e66c4ca0559"}}"#.to_string())
.send()
.unwrap();
// verify by expectation ID is not supported in the PHP client;
// use the REST API directly
$ch = curl_init('http://localhost:1080/mockserver/verify');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => json_encode(['expectationId' => ['id' => '31e4ca35-66c6-4645-afeb-6e66c4ca0559']]),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/verify" -d '{
"expectationId": {
"id": "31e4ca35-66c6-4645-afeb-6e66c4ca0559"
}
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.verify(
request()
.withPath("/some/path"),
VerificationTimes.exactly(0)
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080)
.verify(
{
'path': '/some/path'
}, 0, 0)
.then(
function () {
console.log("request found zero times");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import HttpRequest, VerificationTimes
client = MockServerClient("localhost", 1080)
client.verify(
HttpRequest(path="/some/path"),
VerificationTimes.exactly(0)
)
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.verify(
MockServer::HttpRequest.new(path: '/some/path'),
times: MockServer::VerificationTimes.at_most(0)
)
import mockserver "github.com/mock-server/mockserver-monorepo/mockserver-client-go"
client := mockserver.New("localhost", 1080)
err := client.Verify(
mockserver.Request().Path("/some/path"),
mockserver.AtMost(0),
)
using MockServer.Client;
using MockServer.Client.Models;
using var client = new MockServerClient("localhost", 1080);
client.Verify(
HttpRequest.Request().WithPath("/some/path"),
VerificationTimes.AtMostTimes(0)
);
use mockserver_client::{ClientBuilder, HttpRequest, VerificationTimes};
let client = ClientBuilder::new("localhost", 1080).build().unwrap();
client.verify(
HttpRequest::new().path("/some/path"),
VerificationTimes::exactly(0),
).unwrap();
use MockServer\MockServerClient;
use MockServer\HttpRequest;
use MockServer\VerificationTimes;
$client = new MockServerClient('localhost', 1080);
$client->verify(
HttpRequest::request()->path('/some/path'),
VerificationTimes::exactly(0)
);
curl -v -X PUT "http://localhost:1080/mockserver/verify" -d '{
"httpRequest": {
"path": "/simple"
},
"times": {
"atMost": 0
}
}'
See REST API for full JSON specification
Unlike verify requests never received above (which checks a specific request matcher was matched zero times), verifyZeroInteractions() verifies that no requests of any kind have been received by MockServer. It is equivalent to verifying a match-all request matcher with exactly(0).
new MockServerClient("localhost", 1080)
.verifyZeroInteractions();
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080)
.verifyZeroInteractions()
.then(
function () {
console.log("no requests received");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
client = MockServerClient("localhost", 1080)
client.verify_zero_interactions()
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.verify_zero_interactions
import mockserver "github.com/mock-server/mockserver-monorepo/mockserver-client-go"
client := mockserver.New("localhost", 1080)
// verify that no requests were received
err := client.Verify(
mockserver.Request(),
mockserver.AtMost(0),
)
using MockServer.Client;
using MockServer.Client.Models;
using var client = new MockServerClient("localhost", 1080);
// verify that no requests were received
client.Verify(
HttpRequest.Request(),
VerificationTimes.AtMostTimes(0)
);
use mockserver_client::{ClientBuilder, HttpRequest, VerificationTimes};
let client = ClientBuilder::new("localhost", 1080).build().unwrap();
// verify that no requests were received
client.verify(
HttpRequest::new(),
VerificationTimes::at_most(0),
).unwrap();
use MockServer\MockServerClient;
use MockServer\HttpRequest;
use MockServer\VerificationTimes;
$client = new MockServerClient('localhost', 1080);
// verify that no requests were received
$client->verify(
HttpRequest::request(),
VerificationTimes::exactly(0)
);
curl -v -X PUT "http://localhost:1080/mockserver/verify" -d '{
"httpRequest": {},
"times": {
"atMost": 0
}
}'
See REST API for full JSON specification
Verifying Responses
MockServer can verify the responses recorded from proxied/forwarded upstream systems, or from served expectations. This is especially useful when MockServer acts as a proxy in front of a system under test (SUT) — you can assert not only that the correct requests were sent, but that the SUT returned the expected responses.
When a response matcher is supplied in a verification, MockServer switches from counting received requests to counting recorded request-response pairs whose response matches. The response matcher can match by:
- Status code — exact match (e.g.,
200,404) - Reason phrase — regex match
- Headers — same header matching as request matchers (subset match, multi-value)
- Body — the same body matchers available for request bodies: JSON, JSON Schema, JSONPath, XML, XPath, regex, sub-string, binary, etc.
If both a request matcher and a response matcher are supplied, both must match the same recorded exchange. VerificationTimes (atLeast, atMost, exactly) applies to the count of matching pairs, exactly like request verification.
REST API: PUT /mockserver/verify with body { "httpRequest": {...}, "httpResponse": {...}, "times": {...} }. Returns HTTP 202 on pass, or HTTP 406 with a "Response not found ..." error message on failure. The request matcher is optional — omit it to match responses regardless of which request produced them.
new MockServerClient("localhost", 1080)
.verify(
request()
.withPath("/some/path"),
response()
.withStatusCode(200)
.withBody(json("{\"status\": \"ok\"}")),
VerificationTimes.atLeast(1)
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080)
.verify(
{
'path': '/some/path'
},
{
'statusCode': 200,
'body': JSON.stringify({status: 'ok'})
}, 1)
.then(
function () {
console.log("matching request-response pair found at least once");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import HttpRequest, HttpResponse, VerificationTimes
client = MockServerClient("localhost", 1080)
client.verify(
HttpRequest(path="/some/path"),
HttpResponse(status_code=200, body='{"status": "ok"}'),
VerificationTimes.at_least(1)
)
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.verify(
MockServer::HttpRequest.new(path: '/some/path'),
MockServer::HttpResponse.new(status_code: 200, body: '{"status": "ok"}'),
times: MockServer::VerificationTimes.at_least(1)
)
import mockserver "github.com/mock-server/mockserver-monorepo/mockserver-client-go"
client := mockserver.New("localhost", 1080)
err := client.Verify(
mockserver.Request().Path("/some/path"),
mockserver.Response().StatusCode(200).Body(`{"status": "ok"}`),
mockserver.AtLeast(1),
)
using MockServer.Client;
using MockServer.Client.Models;
using var client = new MockServerClient("localhost", 1080);
client.Verify(
HttpRequest.Request().WithPath("/some/path"),
HttpResponse.Response().WithStatusCode(200).WithBody("{\"status\": \"ok\"}"),
VerificationTimes.AtLeastTimes(1)
);
use mockserver_client::{ClientBuilder, HttpRequest, HttpResponse, VerificationTimes};
let client = ClientBuilder::new("localhost", 1080).build().unwrap();
client.verify_with_response(
HttpRequest::new().path("/some/path"),
HttpResponse::new().status_code(200).body(r#"{"status": "ok"}"#),
VerificationTimes::at_least(1),
).unwrap();
use MockServer\MockServerClient;
use MockServer\HttpRequest;
use MockServer\HttpResponse;
use MockServer\VerificationTimes;
$client = new MockServerClient('localhost', 1080);
$client->verify(
HttpRequest::request()->path('/some/path'),
HttpResponse::response()->statusCode(200)->body('{"status": "ok"}'),
VerificationTimes::atLeast(1)
);
curl -v -X PUT "http://localhost:1080/mockserver/verify" -d '{
"httpRequest": {
"path": "/some/path"
},
"httpResponse": {
"statusCode": 200,
"body": "{\"status\": \"ok\"}"
},
"times": {
"atLeast": 1
}
}'
See REST API for full JSON specification
When no request matcher is supplied, MockServer matches responses from all recorded request-response pairs. This is useful when you want to verify that a particular response was returned regardless of which request produced it.
new MockServerClient("localhost", 1080)
.verify(
response()
.withStatusCode(200)
.withHeaders(
header("Content-Type", "application/json")
),
VerificationTimes.atLeast(1)
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080)
.verify(
null,
{
'statusCode': 200,
'headers': {
'Content-Type': ['application/json']
}
}, 1)
.then(
function () {
console.log("matching response found at least once");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import HttpResponse, VerificationTimes
client = MockServerClient("localhost", 1080)
client.verify(
HttpResponse(status_code=200, headers={"Content-Type": "application/json"}),
VerificationTimes.at_least(1)
)
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.verify(
MockServer::HttpResponse.new(
status_code: 200,
headers: { 'Content-Type' => 'application/json' }
),
times: MockServer::VerificationTimes.at_least(1)
)
import mockserver "github.com/mock-server/mockserver-monorepo/mockserver-client-go"
client := mockserver.New("localhost", 1080)
err := client.VerifyResponse(
mockserver.Response().StatusCode(200).
Header("Content-Type", "application/json"),
mockserver.AtLeast(1),
)
using MockServer.Client;
using MockServer.Client.Models;
using var client = new MockServerClient("localhost", 1080);
client.Verify(
HttpResponse.Response().WithStatusCode(200)
.WithHeader("Content-Type", "application/json"),
VerificationTimes.AtLeastTimes(1)
);
use mockserver_client::{ClientBuilder, HttpResponse, VerificationTimes};
let client = ClientBuilder::new("localhost", 1080).build().unwrap();
client.verify_response(
HttpResponse::new().status_code(200)
.header("Content-Type", "application/json"),
VerificationTimes::at_least(1),
).unwrap();
use MockServer\MockServerClient;
use MockServer\HttpResponse;
use MockServer\VerificationTimes;
$client = new MockServerClient('localhost', 1080);
$client->verify(
HttpResponse::response()->statusCode(200)
->header('Content-Type', 'application/json'),
VerificationTimes::atLeast(1)
);
curl -v -X PUT "http://localhost:1080/mockserver/verify" -d '{
"httpResponse": {
"statusCode": 200,
"headers": {
"Content-Type": ["application/json"]
}
},
"times": {
"atLeast": 1
}
}'
See REST API for full JSON specification
Response body matchers support the same matching types as request body matchers, including JSON Schema. This example verifies that a response was recorded whose body conforms to a given JSON Schema.
new MockServerClient("localhost", 1080)
.verify(
request()
.withPath("/api/users"),
response()
.withStatusCode(200)
.withBody(jsonSchema("{" +
" \"type\": \"object\"," +
" \"required\": [\"id\", \"name\"]," +
" \"properties\": {" +
" \"id\": { \"type\": \"integer\" }," +
" \"name\": { \"type\": \"string\" }" +
" }" +
"}")),
VerificationTimes.atLeast(1)
);
curl -v -X PUT "http://localhost:1080/mockserver/verify" -d '{
"httpRequest": {
"path": "/api/users"
},
"httpResponse": {
"statusCode": 200,
"body": {
"type": "JSON_SCHEMA",
"jsonSchema": "{\"type\":\"object\",\"required\":[\"id\",\"name\"],\"properties\":{\"id\":{\"type\":\"integer\"},\"name\":{\"type\":\"string\"}}}"
}
},
"times": {
"atLeast": 1
}
}'
See REST API for full JSON specification
Verifying Request Sequences
Verify that a sequence of requests has been received by MockServer in the specified order using a VerificationSequence
The each request in the sequence will be verified to have been received at least once, in the exact order specified.
new MockServerClient("localhost", 1080)
.verify(
request()
.withPath("/some/path/one"),
request()
.withPath("/some/path/two"),
request()
.withPath("/some/path/three")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080)
.verifySequence(
{
'path': '/some/path/one'
},
{
'path': '/some/path/two'
},
{
'path': '/some/path/three'
}
)
.then(
function () {
console.log("request sequence found in the order specified");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import HttpRequest
client = MockServerClient("localhost", 1080)
client.verify_sequence(
HttpRequest(path="/some/path/one"),
HttpRequest(path="/some/path/two"),
HttpRequest(path="/some/path/three"),
)
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.verify_sequence(
MockServer::HttpRequest.new(path: '/some/path/one'),
MockServer::HttpRequest.new(path: '/some/path/two'),
MockServer::HttpRequest.new(path: '/some/path/three'),
)
import mockserver "github.com/mock-server/mockserver-monorepo/mockserver-client-go"
client := mockserver.New("localhost", 1080)
err := client.VerifySequence(
mockserver.Request().Path("/some/path/one"),
mockserver.Request().Path("/some/path/two"),
mockserver.Request().Path("/some/path/three"),
)
using MockServer.Client;
using MockServer.Client.Models;
using var client = new MockServerClient("localhost", 1080);
client.VerifySequence(
HttpRequest.Request().WithPath("/some/path/one"),
HttpRequest.Request().WithPath("/some/path/two"),
HttpRequest.Request().WithPath("/some/path/three")
);
use mockserver_client::{ClientBuilder, HttpRequest};
let client = ClientBuilder::new("localhost", 1080).build().unwrap();
client.verify_sequence(vec![
HttpRequest::new().path("/some/path/one"),
HttpRequest::new().path("/some/path/two"),
HttpRequest::new().path("/some/path/three"),
]).unwrap();
use MockServer\MockServerClient;
use MockServer\HttpRequest;
$client = new MockServerClient('localhost', 1080);
$client->verifySequence(
HttpRequest::request()->path('/some/path/one'),
HttpRequest::request()->path('/some/path/two'),
HttpRequest::request()->path('/some/path/three')
);
curl -v -X PUT "http://localhost:1080/mockserver/verifySequence" -d '{
"httpRequests":[
{
"path":"/some/path/one"
},
{
"path":"/some/path/two"
},
{
"path":"/some/path/three"
}
]
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.verify(
request()
.withPath("/status"),
openAPI(
"org/mockserver/openapi/openapi_petstore_example.json",
"listPets"
),
openAPI(
"org/mockserver/openapi/openapi_petstore_example.json",
"showPetById"
)
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080)
.verifySequence(
{
'path': '/status'
},
{
'specUrlOrPayload': 'org/mockserver/openapi/openapi_petstore_example.json',
'operationId': 'listPets'
},
{
'specUrlOrPayload': 'org/mockserver/openapi/openapi_petstore_example.json',
'operationId': 'showPetById'
}
)
.then(
function () {
console.log("request sequence found in the order specified");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
import requests
# OpenAPI matchers in verification sequences are not supported in the
# Python client; use the REST API directly
requests.put("http://localhost:1080/mockserver/verifySequence", json={
"httpRequests": [
{"path": "/status"},
{
"specUrlOrPayload": "org/mockserver/openapi/openapi_petstore_example.json",
"operationId": "listPets"
},
{
"specUrlOrPayload": "org/mockserver/openapi/openapi_petstore_example.json",
"operationId": "showPetById"
}
]
})
require 'net/http'
require 'json'
# OpenAPI matchers in verification sequences are not supported in the
# Ruby client; use the REST API directly
uri = URI("http://localhost:1080/mockserver/verifySequence")
req = Net::HTTP::Put.new(uri, 'Content-Type' => 'application/json')
req.body = JSON.generate({
"httpRequests" => [
{ "path" => "/status" },
{
"specUrlOrPayload" => "org/mockserver/openapi/openapi_petstore_example.json",
"operationId" => "listPets"
},
{
"specUrlOrPayload" => "org/mockserver/openapi/openapi_petstore_example.json",
"operationId" => "showPetById"
}
]
})
Net::HTTP.start(uri.host, uri.port) { |http| http.request(req) }
package main
import (
"bytes"
"net/http"
)
func main() {
// OpenAPI matchers are not supported in the Go client;
// use the REST API directly
body := []byte(`{
"httpRequests":[
{"path": "/status"},
{
"specUrlOrPayload": "org/mockserver/openapi/openapi_petstore_example.json",
"operationId": "listPets"
},
{
"specUrlOrPayload": "org/mockserver/openapi/openapi_petstore_example.json",
"operationId": "showPetById"
}
]
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/verifySequence",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
// OpenAPI matchers are not supported in the .NET client;
// use the REST API directly
using var httpClient = new HttpClient();
var json = @"{
""httpRequests"":[
{""path"": ""/status""},
{
""specUrlOrPayload"": ""org/mockserver/openapi/openapi_petstore_example.json"",
""operationId"": ""listPets""
},
{
""specUrlOrPayload"": ""org/mockserver/openapi/openapi_petstore_example.json"",
""operationId"": ""showPetById""
}
]
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/verifySequence",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
// OpenAPI matchers are not supported in the Rust client;
// use the REST API directly
let client = Client::new();
let body = r#"{
"httpRequests":[
{"path": "/status"},
{
"specUrlOrPayload": "org/mockserver/openapi/openapi_petstore_example.json",
"operationId": "listPets"
},
{
"specUrlOrPayload": "org/mockserver/openapi/openapi_petstore_example.json",
"operationId": "showPetById"
}
]
}"#;
client.put("http://localhost:1080/mockserver/verifySequence")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
// OpenAPI matchers in verification sequences are not supported in the
// PHP client; use the REST API directly
$ch = curl_init('http://localhost:1080/mockserver/verifySequence');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => json_encode([
'httpRequests' => [
['path' => '/status'],
[
'specUrlOrPayload' => 'org/mockserver/openapi/openapi_petstore_example.json',
'operationId' => 'listPets',
],
[
'specUrlOrPayload' => 'org/mockserver/openapi/openapi_petstore_example.json',
'operationId' => 'showPetById',
],
],
]),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/verifySequence" -d '{
"httpRequests":[
{
"path": "/status"
},
{
"specUrlOrPayload": "org/mockserver/openapi/openapi_petstore_example.json",
"operationId": "listPets"
},
{
"specUrlOrPayload": "org/mockserver/openapi/openapi_petstore_example.json",
"operationId": "showPetById"
}
]
}'
See REST API for full JSON specification
new MockServerClient("localhost", 1080)
.verify(
"31e4ca35-66c6-4645-afeb-6e66c4ca0559",
"66c6ca35-ca35-66f5-8feb-5e6ac7ca0559",
"ca3531e4-23c8-ff45-88f5-4ca0c7ca0559"
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080)
.verifySequenceById(
{
'id': '31e4ca35-66c6-4645-afeb-6e66c4ca0559'
},
{
'id': '66c6ca35-ca35-66f5-8feb-5e6ac7ca0559'
},
{
'id': 'ca3531e4-23c8-ff45-88f5-4ca0c7ca0559'
}
)
.then(
function () {
console.log("request sequence found in the order specified");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
import requests
# verify sequence by expectation IDs is not supported in the Python
# client; use the REST API directly
requests.put("http://localhost:1080/mockserver/verifySequence", json={
"expectationIds": [
{"id": "31e4ca35-66c6-4645-afeb-6e66c4ca0559"},
{"id": "66c6ca35-ca35-66f5-8feb-5e6ac7ca0559"},
{"id": "ca3531e4-23c8-ff45-88f5-4ca0c7ca0559"}
]
})
require 'net/http'
require 'json'
# verify sequence by expectation IDs is not supported in the Ruby
# client; use the REST API directly
uri = URI("http://localhost:1080/mockserver/verifySequence")
req = Net::HTTP::Put.new(uri, 'Content-Type' => 'application/json')
req.body = JSON.generate({
"expectationIds" => [
{ "id" => "31e4ca35-66c6-4645-afeb-6e66c4ca0559" },
{ "id" => "66c6ca35-ca35-66f5-8feb-5e6ac7ca0559" },
{ "id" => "ca3531e4-23c8-ff45-88f5-4ca0c7ca0559" }
]
})
Net::HTTP.start(uri.host, uri.port) { |http| http.request(req) }
package main
import (
"bytes"
"net/http"
)
func main() {
// verify sequence by expectation IDs is not supported in the Go
// client; use the REST API directly
body := []byte(`{
"expectationIds": [
{"id": "31e4ca35-66c6-4645-afeb-6e66c4ca0559"},
{"id": "66c6ca35-ca35-66f5-8feb-5e6ac7ca0559"},
{"id": "ca3531e4-23c8-ff45-88f5-4ca0c7ca0559"}
]
}`)
req, _ := http.NewRequest("PUT",
"http://localhost:1080/mockserver/verifySequence",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
using System.Net.Http;
using System.Text;
// verify sequence by expectation IDs is not supported in the .NET
// client; use the REST API directly
using var httpClient = new HttpClient();
var json = @"{
""expectationIds"": [
{""id"": ""31e4ca35-66c6-4645-afeb-6e66c4ca0559""},
{""id"": ""66c6ca35-ca35-66f5-8feb-5e6ac7ca0559""},
{""id"": ""ca3531e4-23c8-ff45-88f5-4ca0c7ca0559""}
]
}";
await httpClient.PutAsync(
"http://localhost:1080/mockserver/verifySequence",
new StringContent(json, Encoding.UTF8, "application/json")
);
use reqwest::blocking::Client;
// verify sequence by expectation IDs is not supported in the Rust
// client; use the REST API directly
let client = Client::new();
let body = r#"{
"expectationIds": [
{"id": "31e4ca35-66c6-4645-afeb-6e66c4ca0559"},
{"id": "66c6ca35-ca35-66f5-8feb-5e6ac7ca0559"},
{"id": "ca3531e4-23c8-ff45-88f5-4ca0c7ca0559"}
]
}"#;
client.put("http://localhost:1080/mockserver/verifySequence")
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.unwrap();
// verify sequence by expectation IDs is not supported in the PHP
// client; use the REST API directly
$ch = curl_init('http://localhost:1080/mockserver/verifySequence');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => json_encode([
'expectationIds' => [
['id' => '31e4ca35-66c6-4645-afeb-6e66c4ca0559'],
['id' => '66c6ca35-ca35-66f5-8feb-5e6ac7ca0559'],
['id' => 'ca3531e4-23c8-ff45-88f5-4ca0c7ca0559'],
],
]),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Content-Type: application/json; charset=utf-8'],
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/verifySequence" -d '{
"expectationIds": [
{
"id": "31e4ca35-66c6-4645-afeb-6e66c4ca0559"
},
{
"id": "66c6ca35-ca35-66f5-8feb-5e6ac7ca0559"
},
{
"id": "ca3531e4-23c8-ff45-88f5-4ca0c7ca0559"
}
]
}'
See REST API for full JSON specification
You can verify that a sequence of request-response pairs was recorded in order. Each step in the sequence can include a request matcher, a response matcher, or both. The httpRequests and httpResponses arrays are matched by index — httpRequests[0] is paired with httpResponses[0], and so on. Either array element can be omitted (or null) to act as a wildcard for that side of the pair.
new MockServerClient("localhost", 1080)
.verify(
verificationSequence()
.withRequests(
request().withPath("/api/login"),
request().withPath("/api/data")
)
.withResponses(
response().withStatusCode(200),
response().withStatusCode(200)
.withBody(json("{\"result\": \"success\"}"))
)
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080)
.verifySequence(
{
httpRequests: [
{ 'path': '/api/login' },
{ 'path': '/api/data' }
],
httpResponses: [
{ 'statusCode': 200 },
{ 'statusCode': 200, 'body': JSON.stringify({result: 'success'}) }
]
}
)
.then(
function () {
console.log("request-response sequence found in the order specified");
},
function (error) {
console.log(error);
}
);
See REST API for full JSON specification
from mockserver.client import MockServerClient
from mockserver.models import HttpRequest, HttpResponse
client = MockServerClient("localhost", 1080)
client.verify_sequence(
requests=[
HttpRequest(path="/api/login"),
HttpRequest(path="/api/data"),
],
responses=[
HttpResponse(status_code=200),
HttpResponse(status_code=200, body='{"result": "success"}'),
]
)
require 'mockserver-client'
client = MockServer::Client.new('localhost', 1080)
client.verify_sequence(
requests: [
MockServer::HttpRequest.new(path: '/api/login'),
MockServer::HttpRequest.new(path: '/api/data'),
],
responses: [
MockServer::HttpResponse.new(status_code: 200),
MockServer::HttpResponse.new(status_code: 200, body: '{"result": "success"}'),
]
)
import mockserver "github.com/mock-server/mockserver-monorepo/mockserver-client-go"
client := mockserver.New("localhost", 1080)
err := client.VerifySequenceWithResponses(
[]mockserver.RequestDefinition{
mockserver.Request().Path("/api/login"),
mockserver.Request().Path("/api/data"),
},
[]mockserver.HttpResponse{
mockserver.Response().StatusCode(200),
mockserver.Response().StatusCode(200).Body(`{"result": "success"}`),
},
)
using MockServer.Client;
using MockServer.Client.Models;
using var client = new MockServerClient("localhost", 1080);
client.VerifySequence(
new[] {
HttpRequest.Request().WithPath("/api/login"),
HttpRequest.Request().WithPath("/api/data")
},
new[] {
HttpResponse.Response().WithStatusCode(200),
HttpResponse.Response().WithStatusCode(200).WithBody("{\"result\": \"success\"}")
}
);
use mockserver_client::{ClientBuilder, HttpRequest, HttpResponse};
let client = ClientBuilder::new("localhost", 1080).build().unwrap();
client.verify_sequence_with_responses(
vec![
HttpRequest::new().path("/api/login"),
HttpRequest::new().path("/api/data"),
],
vec![
HttpResponse::new().status_code(200),
HttpResponse::new().status_code(200).body(r#"{"result": "success"}"#),
],
).unwrap();
use MockServer\MockServerClient;
use MockServer\HttpRequest;
use MockServer\HttpResponse;
$client = new MockServerClient('localhost', 1080);
$client->verifySequence(
[
HttpRequest::request()->path('/api/login'),
HttpRequest::request()->path('/api/data'),
],
[
HttpResponse::response()->statusCode(200),
HttpResponse::response()->statusCode(200)->body('{"result": "success"}'),
]
);
curl -v -X PUT "http://localhost:1080/mockserver/verifySequence" -d '{
"httpRequests": [
{
"path": "/api/login"
},
{
"path": "/api/data"
}
],
"httpResponses": [
{
"statusCode": 200
},
{
"statusCode": 200,
"body": "{\"result\": \"success\"}"
}
]
}'
See REST API for full JSON specification
Next Steps
- Creating Expectations — the full reference for request matchers and response, forward, callback, and error actions
- Verify Requests — assert that your code under test sent the requests you expected
- Testcontainers Integration — start a MockServer container for your JVM tests with the official Testcontainers module
- Importing Expectations — load expectations in bulk from JSON or an OpenAPI specification instead of one at a time
Spring Boot Compatibility
MockServer targets Java 17 as the minimum supported version and uses the jakarta namespace (Jakarta EE / Spring Framework 6+) throughout. This means MockServer is compatible with Spring Boot 3.x and later. Spring Boot 2.x (which uses Spring Framework 5.x and the older javax namespace) is no longer the target.
Spring Boot 3 migrated from the javax namespace to the jakarta namespace, and MockServer has moved to jakarta to match. The Spring Test Execution Listener and JUnit integrations that depend on Spring classpath integration target Spring Boot 3.x and later.
| Spring Boot Version | Spring Framework | Namespace | MockServer Compatible |
|---|---|---|---|
| 3.x and later | 6+ | jakarta | Yes |
| 2.x | 5.x | javax | No (use Docker or standalone) |
Upgrading MockServer
When upgrading MockServer between versions, be aware of the following changes that may affect your setup:
- Java 17 minimum - MockServer requires Java 17 or later. If you are running on Java 11 or earlier, you must upgrade your JVM before upgrading MockServer.
- JSON Schema validator version change - the underlying JSON Schema validation library was updated in recent versions. If you use JSON Schema body matchers with custom schemas, verify they still validate correctly after upgrading.
- Expectation JSON format - the JSON format for expectations has evolved between major versions. If you use JSON expectation initializer files (MOCKSERVER_INITIALIZATION_JSON_PATH), test your initializer files against the new version before deploying. Fields that were previously accepted may be rejected or interpreted differently.
It is recommended to run your full test suite after upgrading to catch any compatibility issues early.
HTTP/2 Proxy Limitations
MockServer can accept HTTP/2 connections and serve mock responses over HTTP/2. However, when MockServer is used as a proxy and forwards requests to downstream services, HTTP/2 requests are downgraded to HTTP/1.1. This means:
- Mocking with HTTP/2 - works correctly. Clients can connect to MockServer using HTTP/2 and receive mock responses.
- Proxying with HTTP/2 - the forwarded request to the downstream service will be sent as HTTP/1.1, regardless of the original protocol version. The response returned to the client will also be HTTP/1.1.
If your tests require end-to-end HTTP/2 proxying (including HTTP/2 to the upstream server), this is not currently supported. Consider using MockServer in mock mode instead of proxy mode for HTTP/2 endpoints.
Single Port Architecture
MockServer serves both mock and proxy traffic on the same port (default 1080). There is no separate port for proxying. The proxyRemotePort and proxyRemoteHost settings specify the upstream target server that unmatched requests are forwarded to — they do not open a separate listening port. All expectations, proxy forwarding, and protocol support (HTTP, HTTPS, SOCKS) share the single serverPort.