Configuration |
Configuration.actionHandlerThreadCount(Integer actionHandlerThreadCount) |
Number of threads for the action handler thread pool
|
Configuration |
Configuration.alwaysCloseSocketConnections(Boolean alwaysCloseSocketConnections) |
If true socket connections will always be closed after a response is returned, if false connection is only closed if request header indicate connection should be closed.
|
Configuration |
Configuration.assumeAllRequestsAreHttp(Boolean assumeAllRequestsAreHttp) |
If false requests are assumed as binary if the method isn't one of "GET", "POST", "PUT", "HEAD", "OPTIONS", "PATCH", "DELETE", "TRACE" or "CONNECT"
|
Configuration |
Configuration.attemptToProxyIfNoMatchingExpectation(Boolean attemptToProxyIfNoMatchingExpectation) |
If true (the default) when no matching expectation is found, and the host header of the request does not match MockServer's host, then MockServer attempts to proxy the request if that fails then a 404 is returned.
|
Configuration |
Configuration.binaryProxyListener(BinaryProxyListener binaryProxyListener) |
Set a org.mockserver.model.BinaryProxyListener called when binary content is proxied
|
Configuration |
Configuration.certificateAuthorityCertificate(String certificateAuthorityCertificate) |
File system path or classpath location of custom X.509 Certificate for Certificate Authority for TLS, the certificate must be a X509 PEM file and must match the certificateAuthorityPrivateKey
|
Configuration |
Configuration.certificateAuthorityPrivateKey(String certificateAuthorityPrivateKey) |
File system path or classpath location of custom Private Key for Certificate Authority for TLS, the private key must be a PKCS#8 or PKCS#1 PEM file and must match the certificateAuthorityCertificate
To convert a PKCS#1 (i.e. default for Bouncy Castle) to a PKCS#8 the following command can be used: openssl pkcs8 -topk8 -inform PEM -in private_key_PKCS_1.pem -out private_key_PKCS_8.pem -nocrypt
|
Configuration |
Configuration.clientNioEventLoopThreadCount(Integer clientNioEventLoopThreadCount) |
Client Netty worker thread pool size for handling requests and response.
|
Configuration |
Configuration.compactLogFormat(Boolean compactLogFormat) |
|
static Configuration |
Configuration.configuration() |
|
Configuration |
Configuration.connectionDelay(Delay connectionDelay) |
|
Configuration |
Configuration.controlPlaneJWTAuthenticationExpectedAudience(String controlPlaneJWTAuthenticationExpectedAudience) |
Audience claim (i.e. aud) required when JWT authentication is enabled for control plane requests
|
Configuration |
Configuration.controlPlaneJWTAuthenticationJWKSource(String controlPlaneJWTAuthenticationJWKSource) |
JWK source used when JWT authentication is enabled for control plane requests
|
Configuration |
Configuration.controlPlaneJWTAuthenticationMatchingClaims(Map<String,String> controlPlaneJWTAuthenticationMatchingClaims) |
Matching claims expected when JWT authentication is enabled for control plane requests
|
Configuration |
Configuration.controlPlaneJWTAuthenticationRequired(Boolean controlPlaneJWTAuthenticationRequired) |
Require JWT authentication for all control plane requests
|
Configuration |
Configuration.controlPlaneJWTAuthenticationRequiredClaims(Set<String> controlPlaneJWTAuthenticationRequiredClaims) |
Required claims that should exist (i.e. with any value) when JWT authentication is enabled for control plane requests
|
Configuration |
Configuration.controlPlanePrivateKeyPath(String controlPlanePrivateKeyPath) |
File system path or classpath location of a fixed custom private key for control plane connections using mTLS for authentication.
|
Configuration |
Configuration.controlPlaneTLSMutualAuthenticationCAChain(String controlPlaneTLSMutualAuthenticationCAChain) |
File system path or classpath location of custom mTLS (TLS client authentication) X.509 Certificate Chain for control plane mTLS authentication
|
Configuration |
Configuration.controlPlaneTLSMutualAuthenticationRequired(Boolean controlPlaneTLSMutualAuthenticationRequired) |
Require mTLS (also called client authentication and two-way TLS) for all control plane requests
|
Configuration |
Configuration.controlPlaneX509CertificatePath(String controlPlaneX509CertificatePath) |
File system path or classpath location of a fixed custom X.509 Certificate for control plane connections using mTLS for authentication.
|
Configuration |
Configuration.corsAllowCredentials(Boolean corsAllowCredentials) |
The value used for CORS in the access-control-allow-credentials header.
|
Configuration |
Configuration.corsAllowHeaders(String corsAllowHeaders) |
the value used for CORS in the access-control-allow-headers and access-control-expose-headers headers.
|
Configuration |
Configuration.corsAllowMethods(String corsAllowMethods) |
the value used for CORS in the access-control-allow-methods header.
|
Configuration |
Configuration.corsAllowOrigin(String corsAllowOrigin) |
the value used for CORS in the access-control-allow-origin header.
|
Configuration |
Configuration.corsMaxAgeInSeconds(Integer corsMaxAgeInSeconds) |
The value used for CORS in the access-control-max-age header.
|
Configuration |
Configuration.detailedMatchFailures(Boolean detailedMatchFailures) |
If true (the default) the log event recording that a request matcher did not match will include a detailed reason why each non-matching field did not match.
|
Configuration |
Configuration.detailedVerificationFailures(Boolean detailedVerificationFailures) |
If true (the default) verification failure messages include a detailed diff showing which fields did not match for the closest matching request.
|
Configuration |
Configuration.directoryToSaveDynamicSSLCertificate(String directoryToSaveDynamicSSLCertificate) |
Directory used to save the dynamically generated Certificate Authority X.509 Certificate and Private Key.
|
Configuration |
Configuration.disableLogging(Boolean disableLogging) |
Disable all logging and processing of log events
|
Configuration |
Configuration.disableSystemOut(Boolean disableSystemOut) |
Disable printing log to system out for JVM, default is enabled
|
Configuration |
Configuration.dnsEnabled(Boolean dnsEnabled) |
|
Configuration |
Configuration.dnsPort(Integer dnsPort) |
|
Configuration |
Configuration.dynamicallyCreateCertificateAuthorityCertificate(Boolean dynamicallyCreateCertificateAuthorityCertificate) |
Enable dynamic creation of Certificate Authority X509 certificate and private key.
|
Configuration |
Configuration.enableCORSForAllResponses(Boolean enableCORSForAllResponses) |
Enable CORS for all responses from MockServer, including the REST API and expectation responses
|
Configuration |
Configuration.enableCORSForAPI(Boolean enableCORSForAPI) |
Enable CORS for MockServer REST API so that the API can be used for javascript running in browsers, such as selenium
|
Configuration |
Configuration.forwardAdjustHostHeader(Boolean forwardAdjustHostHeader) |
If true (the default) the Host header will be automatically adjusted to match the target server when forwarding requests.
|
Configuration |
Configuration.forwardBinaryRequestsWithoutWaitingForResponse(Boolean forwardBinaryRequestsWithoutWaitingForResponse) |
If true the BinaryProxyListener is called before a response is received from the
remote host.
|
Configuration |
Configuration.forwardDefaultHostHeader(String forwardDefaultHostHeader) |
Set a default Host header value to use when forwarding requests.
|
Configuration |
Configuration.forwardHttpProxy(InetSocketAddress forwardHttpProxy) |
Use HTTP proxy (i.e. via Host header) for all outbound / forwarded requests
|
Configuration |
Configuration.forwardHttpsProxy(InetSocketAddress forwardHttpsProxy) |
Use HTTPS proxy (i.e.
|
Configuration |
Configuration.forwardProxyAuthenticationPassword(String forwardProxyAuthenticationPassword) |
Password for proxy authentication when using HTTPS proxy (i.e.
|
Configuration |
Configuration.forwardProxyAuthenticationUsername(String forwardProxyAuthenticationUsername) |
Username for proxy authentication when using HTTPS proxy (i.e.
|
Configuration |
Configuration.forwardProxyBlockPrivateNetworks(Boolean forwardProxyBlockPrivateNetworks) |
When set to true, MockServer rejects forward and proxy targets that resolve to
loopback, link-local, RFC 1918 private, or cloud metadata addresses
(such as 169.254.169.254), blocking server-side request forgery (SSRF) via
malicious expectations.
|
Configuration |
Configuration.forwardProxyCertificateChain(String forwardProxyCertificateChain) |
File system path or classpath location of custom mTLS (TLS client authentication) X.509 Certificate Chain for Trusting (i.e. signature verification of) Client X.509 Certificates, the certificate chain must be a X509 PEM file.
|
Configuration |
Configuration.forwardProxyPrivateKey(String forwardProxyPrivateKey) |
File system path or classpath location of custom Private Key for proxied TLS connections out of MockServer, the private key must be a PKCS#8 or PKCS#1 PEM file
|
Configuration |
Configuration.forwardProxyTLSCustomTrustX509Certificates(String forwardProxyTLSCustomTrustX509Certificates) |
File system path or classpath location of custom file for trusted X509 Certificate Authority roots for forwarded or proxied requests, the certificate chain must be a X509 PEM file.
|
Configuration |
Configuration.forwardProxyTLSX509CertificatesTrustManagerType(ForwardProxyTLSX509CertificatesTrustManager forwardProxyTLSX509CertificatesTrustManagerType) |
Configure trusted set of certificates for forwarded or proxied requests.
|
Configuration |
Configuration.forwardSocksProxy(InetSocketAddress forwardSocksProxy) |
Use SOCKS proxy for all outbound / forwarded requests, support TLS tunnelling of TCP connections
|
Configuration |
Configuration.globalResponseDelayMillis(Long globalResponseDelayMillis) |
|
Configuration |
Configuration.grpcDescriptorDirectory(String grpcDescriptorDirectory) |
|
Configuration |
Configuration.grpcEnabled(Boolean grpcEnabled) |
|
Configuration |
Configuration.grpcProtocPath(String grpcProtocPath) |
|
Configuration |
Configuration.grpcProtoDirectory(String grpcProtoDirectory) |
|
Configuration |
Configuration.http2Enabled(Boolean http2Enabled) |
If false HTTP/2 is disabled and ALPN no longer advertises h2, so HTTP/2 capable clients are
forced to use HTTP/1.1 (and the HTTP/2 cleartext h2c upgrade is not detected)
|
Configuration |
Configuration.initializationClass(String initializationClass) |
The class (and package) used to initialize expectations in MockServer at startup, if set MockServer will load and call this class to initialize expectations when is starts.
|
Configuration |
Configuration.initializationJsonPath(String initializationJsonPath) |
The path to the json file used to initialize expectations in MockServer at startup, if set MockServer will load this file and initialise expectations for each item in the file when is starts.
|
Configuration |
Configuration.initializationOpenAPIPath(String initializationOpenAPIPath) |
The path to the OpenAPI spec file used to initialize expectations in MockServer at startup, if set MockServer will load this file and create expectations for each operation when it starts.
|
Configuration |
Configuration.javascriptDisallowedClasses(String javascriptDisallowedClasses) |
Set comma separate list of classes not allowed to be used by javascript templates
|
Configuration |
Configuration.javascriptDisallowedText(String javascriptDisallowedText) |
Set comma separate list of text not allowed to be contained in javascript templates
|
Configuration |
Configuration.launchUIForLogLevelDebug(Boolean launchUIForLogLevelDebug) |
If true (the default) the ClientAndServer constructor will open the UI in the default browser when the log level is set to DEBUG.
|
Configuration |
Configuration.livenessHttpGetPath(String livenessHttpGetPath) |
Path to support HTTP GET requests for status response (also available on PUT /mockserver/status).
|
Configuration |
Configuration.localBoundIP(String localBoundIP) |
The local IP address to bind to for accepting new socket connections
|
Configuration |
Configuration.logEventListener(Consumer<LogEntry> logEventListener) |
|
Configuration |
Configuration.logLevel(String level) |
Override the default logging level of INFO
|
Configuration |
Configuration.logLevel(org.slf4j.event.Level level) |
Override the default logging level of INFO
|
Configuration |
Configuration.logLevelOverrides(Map<String,String> logLevelOverrides) |
|
Configuration |
Configuration.matchersFailFast(Boolean matchersFailFast) |
If true (the default) request matchers will fail on the first non-matching field, if false request matchers will compare all fields.
|
Configuration |
Configuration.maxChunkSize(Integer maxChunkSize) |
Maximum size of HTTP chunks in request or responses
|
Configuration |
Configuration.maxExpectations(Integer maxExpectations) |
Maximum number of expectations stored in memory.
|
Configuration |
Configuration.maxFutureTimeoutInMillis(Long maxFutureTimeoutInMillis) |
Maximum time allowed in milliseconds for any future to wait, for example when waiting for a response over a web socket callback.
|
Configuration |
Configuration.maxHeaderSize(Integer maxHeaderSize) |
Maximum size of HTTP request headers
|
Configuration |
Configuration.maximumNumberOfRequestToReturnInVerificationFailure(Integer maximumNumberOfRequestToReturnInVerificationFailure) |
The maximum number of requests to return in verification failure result, if more expectations are found the failure result does not list them separately
|
Configuration |
Configuration.maxInitialLineLength(Integer maxInitialLineLength) |
Maximum size of the first line of an HTTP request
|
Configuration |
Configuration.maxLlmConversationBodySize(Integer maxLlmConversationBodySize) |
Maximum body size (in bytes) for LLM conversation request bodies.
|
Configuration |
Configuration.maxLogEntries(Integer maxLogEntries) |
Maximum number of log entries stored in memory.
|
Configuration |
Configuration.maxRequestBodySize(Integer maxRequestBodySize) |
Maximum aggregated body size (in bytes) accepted on inbound HTTP/1.1 and HTTP/2 requests.
|
Configuration |
Configuration.maxResponseBodySize(Integer maxResponseBodySize) |
Maximum aggregated body size (in bytes) accepted on responses received from upstream
servers when MockServer is acting as a proxy or forwarder.
|
Configuration |
Configuration.maxSocketTimeoutInMillis(Long maxSocketTimeoutInMillis) |
Maximum time in milliseconds allowed for a response from a socket
|
Configuration |
Configuration.maxStreamingCaptureBytes(Integer maxStreamingCaptureBytes) |
The maximum number of bytes of a streaming response body captured into the event log while relaying it.
|
Configuration |
Configuration.maxWebSocketExpectations(Integer maxWebSocketExpectations) |
Maximum number of remote (not the same JVM) method callbacks (i.e. web sockets) registered for expectations.
|
Configuration |
Configuration.mcpEnabled(Boolean mcpEnabled) |
|
Configuration |
Configuration.memoryUsageCsvDirectory(String memoryUsageCsvDirectory) |
Directory to output JVM memory usage metrics CSV files to when outputMemoryUsageCsv enabled
|
Configuration |
Configuration.metricsEnabled(Boolean metricsEnabled) |
Enable gathering of metrics, default is false
|
Configuration |
Configuration.mustacheDisallowedText(String mustacheDisallowedText) |
Set comma separate list of text not allowed to be contained in mustache templates
|
Configuration |
Configuration.nioEventLoopThreadCount(Integer nioEventLoopThreadCount) |
Netty worker thread pool size for handling requests and response.
|
Configuration |
Configuration.noProxyHosts(String noProxyHosts) |
The list of hostnames to not use the configured proxy.
|
Configuration |
Configuration.openAPIContextPathPrefix(String openAPIContextPathPrefix) |
A path prefix to add to all paths generated from OpenAPI specifications.
|
Configuration |
Configuration.openAPIResponseValidation(Boolean openAPIResponseValidation) |
If enabled MockServer will validate that mock responses conform to the OpenAPI spec schema they were generated from.
|
Configuration |
Configuration.outputMemoryUsageCsv(Boolean outputMemoryUsageCsv) |
Output JVM memory usage metrics to CSV file periodically called memoryUsage_<yyyy-MM-dd>.csv
|
Configuration |
Configuration.persistedExpectationsPath(String persistedExpectationsPath) |
The file path used to save persisted expectations as json, which is updated whenever the expectation state is updated (i.e. add, clear, expires, etc.)
|
Configuration |
Configuration.persistedRecordedExpectationsPath(String persistedRecordedExpectationsPath) |
The file path used to save persisted recorded expectations as json, which is updated whenever a new request is forwarded
|
Configuration |
Configuration.persistExpectations(Boolean persistExpectations) |
Enable the persisting of expectations as json, which is updated whenever the expectation state is updated (i.e. add, clear, expires, etc.)
|
Configuration |
Configuration.persistRecordedExpectations(Boolean persistRecordedExpectations) |
Enable the persisting of recorded expectations (proxy traffic) as json, which is updated whenever a new request is forwarded
|
Configuration |
Configuration.preventCertificateDynamicUpdate(Boolean preventCertificateDynamicUpdate) |
Prevent certificates from dynamically updating when domain list changes
|
Configuration |
Configuration.privateKeyPath(String privateKeyPath) |
File system path or classpath location of a fixed custom private key for TLS connections into MockServer.
|
Configuration |
Configuration.proactivelyInitialiseTLS(Boolean proactivelyInitialiseTLS) |
Proactively initialise TLS during start to ensure that if dynamicallyCreateCertificateAuthorityCertificate is enabled the Certificate Authority X.509 Certificate and Private Key will be created during start up and not when the first TLS connection is received.
|
Configuration |
Configuration.proxyAuthenticationPassword(String proxyAuthenticationPassword) |
The required password for proxy authentication to MockServer
|
Configuration |
Configuration.proxyAuthenticationRealm(String proxyAuthenticationRealm) |
The authentication realm for proxy authentication to MockServer
|
Configuration |
Configuration.proxyAuthenticationUsername(String proxyAuthenticationUsername) |
The required username for proxy authentication to MockServer
|
Configuration |
Configuration.proxyPassMappings(List<ProxyPassMapping> proxyPassMappings) |
Configure ProxyPass mappings that map incoming path prefixes to upstream servers with automatic path rewriting.
|
Configuration |
Configuration.proxyRemoteHost(String proxyRemoteHost) |
The hostname of the remote server to proxy all requests to.
|
Configuration |
Configuration.proxyRemotePort(Integer proxyRemotePort) |
The port of the remote server to proxy all requests to.
|
Configuration |
Configuration.rebuildServerTLSContext(boolean rebuildServerTLSContext) |
|
Configuration |
Configuration.rebuildTLSContext(boolean rebuildTLSContext) |
|
Configuration |
Configuration.socketConnectionTimeoutInMillis(Long socketConnectionTimeoutInMillis) |
Maximum time in milliseconds allowed to connect to a socket
|
Configuration |
Configuration.sslCertificateDomainName(String sslCertificateDomainName) |
The domain name for auto-generate TLS certificates
|
Configuration |
Configuration.sslSubjectAlternativeNameDomains(String... sslSubjectAlternativeNameDomains) |
The Subject Alternative Name (SAN) domain names for auto-generate TLS certificates
|
Configuration |
Configuration.sslSubjectAlternativeNameDomains(Set<String> sslSubjectAlternativeNameDomains) |
The Subject Alternative Name (SAN) domain names for auto-generate TLS certificates
|
Configuration |
Configuration.sslSubjectAlternativeNameIps(String... sslSubjectAlternativeNameIps) |
The Subject Alternative Name (SAN) IP addresses for auto-generate TLS certificates
|
Configuration |
Configuration.sslSubjectAlternativeNameIps(Set<String> sslSubjectAlternativeNameIps) |
The Subject Alternative Name (SAN) IP addresses for auto-generate TLS certificates
|
Configuration |
Configuration.streamIdleTimeoutSeconds(Integer streamIdleTimeoutSeconds) |
The maximum time in seconds a streaming response connection may be idle (no chunk received) before it is
considered dead and closed.
|
Configuration |
Configuration.streamingResponsesEnabled(Boolean streamingResponsesEnabled) |
If true (the default) streaming responses (Server-Sent Events with Content-Type: text/event-stream)
received while proxying are relayed to the client incrementally as they arrive, instead of being fully
buffered before being forwarded.
|
Configuration |
Configuration.tlsAllowInsecureProtocols(Boolean tlsAllowInsecureProtocols) |
Whether to allow TLSv1 and TLSv1.1 in the effective TLS protocols list.
|
Configuration |
Configuration.tlsMutualAuthenticationCertificateChain(String tlsMutualAuthenticationCertificateChain) |
File system path or classpath location of custom mTLS (TLS client authentication) X.509 Certificate Chain for trusting (i.e. signature verification of) Client X.509 Certificates, the certificate chain must be a X509 PEM file.
|
Configuration |
Configuration.tlsMutualAuthenticationRequired(Boolean tlsMutualAuthenticationRequired) |
Require mTLS (also called client authentication and two-way TLS) for all TLS connections / HTTPS requests to MockServer
|
Configuration |
Configuration.tlsProtocols(String tlsProtocols) |
Comma seperated list of TLS protocols, by default TLSv1,TLSv1.1,TLSv1.2
|
Configuration |
ClientConfiguration.toServerConfiguration() |
|
Configuration |
Configuration.useSemicolonAsQueryParameterSeparator(Boolean useSemicolonAsQueryParameterSeparator) |
If true semicolons are treated as a separator for a query parameter string, if false the semicolon is treated as a normal character that is part of a query parameter value.
|
Configuration |
Configuration.velocityDisallowClassLoading(Boolean velocityDisallowClassLoading) |
If true class loading is not allowed in velocity templates
|
Configuration |
Configuration.velocityDisallowedText(String velocityDisallowedText) |
Set comma separate list of text not allowed to be contained in velocity templates
|
Configuration |
Configuration.watchInitializationJson(Boolean watchInitializationJson) |
If enabled the initialization json file will be watched for changes, any changes found will result in expectations being created, remove or updated by matching against their key.
|
Configuration |
Configuration.webSocketClientEventLoopThreadCount(Integer webSocketClientEventLoopThreadCount) |
Client Netty worker thread pool size for handling requests and response.
|
Configuration |
Configuration.x509CertificatePath(String x509CertificatePath) |
File system path or classpath location of a fixed custom X.509 Certificate for TLS connections into MockServer.
|