--- title: Getting Started Mocking description: Step-by-step guide to starting MockServer, creating your first expectation, running tests against it, and verifying requests. shortTitle: Getting Started layout: page pageOrder: 1 section: 'Mock Server' subsection: true sitemap: priority: 0.9 changefreq: 'monthly' lastmod: 2019-11-10T08:00:00+01:00 ---

The typical sequence for using MockServer is as follows:

For example code see the code examples folder in the git repository.
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.
MockServer targets Java 17 as the minimum supported version and uses the javax namespace throughout. This means MockServer is compatible with Spring Boot 2.x (which uses Spring Framework 5.x) but is not compatible with Spring Boot 3.x (which uses Spring Framework 6.x).
Spring Boot 3 migrated from the javax namespace to the jakarta namespace. If your project uses Spring Boot 3, you can still use MockServer as a standalone Docker container or process, but the Spring Test Execution Listener and JUnit integrations that depend on Spring classpath integration are not supported.
| Spring Boot Version | Spring Framework | Namespace | MockServer Compatible |
|---|---|---|---|
| 2.x | 5.x | javax | Yes |
| 3.x | 6.x | jakarta | No (use Docker or standalone) |
When upgrading MockServer between versions, be aware of the following changes that may affect your setup:
It is recommended to run your full test suite after upgrading to catch any compatibility issues early.
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:
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.
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.