Settings Properties

Properties can be set by java code, system property, or property file. The order of precedence means that properties set by java code overrides those set by system properties which in tern overrides properties set in a property file.

The property file defaults to filename mockserver.properties in the current working directory of MockServer. This value can be overridden by setting mockserver.propertyFile, for example:

-Dmockserver.propertyFile=/config/mockserver.properties

An example properties file can be found in github, as follows:

###############################
# MockServer & Proxy Settings #
###############################

# Socket & Port Settings

# socket timeout in milliseconds (default 120000)
mockserver.maxSocketTimeout=120000

# Java KeyStore

# keystore file path if keystore does not already exist a new keystore with this file name will be created
# (default depends on javaKeyStoreType value: keystore.jks or keystore.p12 or keystore.jceks)
mockserver.javaKeyStoreFilePath=keystore.jks
# keystore password (default "changeit")
mockserver.javaKeyStorePassword=changeit
# keystore type options are "jks", "pkcs12" or "jceks" (default "jks")
mockserver.javaKeyStoreType=jks

# Certificate Generation

# delete KeyStore file on JVM shutdown (default true)
mockserver.deleteGeneratedKeyStoreOnExit=true
# certificate domain name (default "localhost")
mockserver.sslCertificateDomainName=localhost
# comma separated list of ip addresses for Subject Alternative Name domain names (default empty list)
mockserver.sslSubjectAlternativeNameDomains=www.example.com,www.another.com
# comma separated list of ip addresses for Subject Alternative Name ips (default empty list)
mockserver.sslSubjectAlternativeNameIps=127.0.0.1

# CORS

# enable CORS for MockServer REST API
mockserver.enableCORSForAPI=true
# enable CORS for all responses
mockserver.enableCORSForAllResponses=true

Properties

Enabled CORS for MockServer REST API so that the API can be used from javascript running in browsers, such as selenium.

Type: boolean Default: true

Java Code:

ConfigurationProperties.enableCORSForAPI(boolean enableCORSForAPI)

System Property:

-Dmockserver.enableCORSForAPI=...

Property File:

mockserver.enableCORSForAPI=...

Enabled CORS for all responses from MockServer, including the REST API and expectation responses.

Type: boolean Default: false

Java Code:

ConfigurationProperties.enableCORSForAllResponses(boolean enableCORSForAllResponses)

System Property:

-Dmockserver.enableCORSForAllResponses=...

Property File:

mockserver.enableCORSForAllResponses=...

Maximum number of expectations held in the in-memory ring buffer.

Type: int Default: 1000

Java Code:

ConfigurationProperties.maxExpectations(int count)

System Property:

-Dmockserver.maxExpectations=...

Property File:

mockserver.maxExpectations=...

Maximum number of WebSockets held in the in-memory ring buffer.

Type: int Default: 1000

Java Code:

ConfigurationProperties.maxWebSocketExpectations(int count)

System Property:

-Dmockserver.maxWebSocketExpectations=...

Property File:

mockserver.maxWebSocketExpectations=...

Maximum size the first line of an HTTP request.

Type: int Default: 4096

Java Code:

ConfigurationProperties.maxInitialLineLength(int length)

System Property:

-Dmockserver.maxInitialLineLength=...

Property File:

mockserver.maxInitialLineLength=...

Maximum size HTTP request headers.

Type: int Default: 8192

Java Code:

ConfigurationProperties.maxHeaderSize(int size)

System Property:

-Dmockserver.maxHeaderSize=...

Property File:

mockserver.maxHeaderSize=...

Maximum size of HTTP chunks in request or responses.

Type: int Default: 8192

Java Code:

ConfigurationProperties.maxChunkSize(int size)

System Property:

-Dmockserver.maxChunkSize=...

Property File:

mockserver.maxChunkSize=...

Maximum number of threads for main event loop.

Type: int Default: maximum of (5 * availableProcessors) or 1

Java Code:

ConfigurationProperties.nioEventLoopThreadCount(int count)

System Property:

-Dmockserver.nioEventLoopThreadCount=...

Property File:

mockserver.nioEventLoopThreadCount=...

Maximum time allowed for a response from a socket.

Type: long Default: 20000

Java Code:

ConfigurationProperties.maxSocketTimeout(long milliseconds)

System Property:

-Dmockserver.maxSocketTimeout=...

Property File:

mockserver.maxSocketTimeout=...

Maximum time allowed to connect to a socket.

Type: long Default: 20000

Java Code:

ConfigurationProperties.socketConnectionTimeout(int milliseconds)

System Property:

-Dmockserver.socketConnectionTimeout=...

Property File:

mockserver.socketConnectionTimeout=...

The relative or absolute file path to the java key store.

Type: string Default: `mockserver_keystore` file name with extension depending on `mockserver.javaKeyStoreType` property

Java Code:

ConfigurationProperties.javaKeyStoreFilePath(String keyStoreFilePath)

System Property:

-Dmockserver.javaKeyStoreFilePath=...

Property File:

mockserver.javaKeyStoreFilePath=...

The java key store password.

Type: string Default: changeit

Java Code:

ConfigurationProperties.javaKeyStorePassword(String keyStorePassword)

System Property:

-Dmockserver.javaKeyStorePassword=...

Property File:

mockserver.javaKeyStorePassword=...

The type of the java key store.

Type: string Default: KeyStore.getDefaultType() - in Java 1.7 this uses the system property `keystore.type` or defaults to `jks`

Java Code:

ConfigurationProperties.javaKeyStoreType(String keyStoreType)

System Property:

-Dmockserver.javaKeyStoreType=...

Property File:

mockserver.javaKeyStoreType=...

Determines if an auto-generated java key store file is deleted on exit.

Type: boolean Default: true

Java Code:

ConfigurationProperties.deleteGeneratedKeyStoreOnExit(boolean deleteGeneratedKeyStoreOnExit)

System Property:

-Dmockserver.deleteGeneratedKeyStoreOnExit=...

Property File:

mockserver.deleteGeneratedKeyStoreOnExit=...

The domain name for auto-generate TLS certificates.

Type: string Default: localhost

Java Code:

ConfigurationProperties.sslCertificateDomainName(String domainName)

System Property:

-Dmockserver.sslCertificateDomainName=...

Property File:

mockserver.sslCertificateDomainName=...

The Subject Alternative Name (SAN) domain names for auto-generate TLS certificates.

Type: string Default: localhost

Java Code:

ConfigurationProperties.addSslSubjectAlternativeNameDomains(String... additionalSubjectAlternativeNameDomains)
or
ConfigurationProperties.clearSslSubjectAlternativeNameDomains()

System Property:

-Dmockserver.sslSubjectAlternativeNameDomains=...

Property File:

mockserver.sslSubjectAlternativeNameDomains=...

The Subject Alternative Name (SAN) IP addresses for auto-generate TLS certificates.

Type: string Default: 127.0.0.1,0.0.0.0

Java Code:

ConfigurationProperties.addSslSubjectAlternativeNameIps(String... additionalSubjectAlternativeNameIps)
or
ConfigurationProperties.clearSslSubjectAlternativeNameIps()

System Property:

-Dmockserver.sslSubjectAlternativeNameIps=...

Property File:

mockserver.sslSubjectAlternativeNameIps=...

The log level, note if this is lower then INFO then verification logic does not work because no log events are captured to enable verification.

Type: string Default: INFO

Java Code:

ConfigurationProperties.logLevel(String level)

System Property:

-Dmockserver.logLevel=...

Property File:

mockserver.logLevel

The log level, which can be TRACE, DEBUG, INFO, WARN, ERROR, OFF

Disable requests audit logging to improve performance, note if this is disabled then verification logic does not work because no log events are captured to enable verification.

Type: boolean Default: false

Java Code:

ConfigurationProperties.disableRequestAudit(boolean disableRequestAudit)

System Property:

-Dmockserver.disableRequestAudit=...

Property File:

mockserver.disableRequestAudit=...

Disable logging to the system output.

Type: boolean Default: false

Java Code:

ConfigurationProperties.disableSystemOut((boolean disableSystemOut)

System Property:

-Dmockserver.disableSystemOut=...

Property File:

mockserver.disableSystemOut=...

Specifies that all output / forwarded requests are sent via an HTTP proxy.

Type: string Default: null

Java Code:

ConfigurationProperties.httpProxy(String hostAndPort)

System Property:

-Dmockserver.httpProxy=...

Property File:

mockserver.httpProxy=...

Specifies that all output / forwarded requests are sent via an HTTPS proxy.

Type: string Default: null

Java Code:

ConfigurationProperties.httpsProxy(String hostAndPort)

System Property:

-Dmockserver.httpsProxy=...

Property File:

mockserver.httpsProxy=...

Specifies that all output / forwarded requests are sent via a SOCKS proxy.

Type: string Default: null

Java Code:

ConfigurationProperties.socksProxy(String hostAndPort)

System Property:

-Dmockserver.socksProxy=...

Property File:

mockserver.socksProxy=...

The local IP address to bind to for accepting new socket connections.

Type: string Default: 0.0.0.0

Java Code:

ConfigurationProperties.localBoundIP(String localBoundIP)

System Property:

-Dmockserver.localBoundIP=...

Property File:

mockserver.localBoundIP=...

The authentication realm for proxy authentication to MockServer

Type: string Default: MockServer HTTP Proxy

Java Code:

ConfigurationProperties.proxyAuthenticationRealm(String proxyAuthenticationRealm)

System Property:

-Dmockserver.proxyAuthenticationRealm=...

Property File:

mockserver.proxyAuthenticationRealm=...

The required username for proxy authentication to MockServer

Type: string Default: john.doe

Java Code:

ConfigurationProperties.proxyAuthenticationUsername(String proxyAuthenticationUsername)

System Property:

-Dmockserver.proxyAuthenticationUsername=...

Property File:

mockserver.proxyAuthenticationUsername=...

The required password for proxy authentication to MockServer

Type: string Default: p@ssw0rd

Java Code:

ConfigurationProperties.proxyAuthenticationPassword(String proxyAuthenticationPassword)

System Property:

-Dmockserver.proxyAuthenticationPassword=...

Property File:

mockserver.proxyAuthenticationPassword=...