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=...

Example:

-Dmockserver.enableCORSForAllResponses="false"

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=...

Example:

-Dmockserver.enableCORSForAllResponses="true"

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=...

Example:

-Dmockserver.maxExpectations="2000"

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=...

Example:

-Dmockserver.maxWebSocketExpectations="2000"

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=...

Example:

-Dmockserver.maxInitialLineLength="8192"

Maximum size HTTP request headers

Type: int Default: 8192

Java Code:

ConfigurationProperties.maxHeaderSize(int size)

System Property:

-Dmockserver.maxHeaderSize=...

Property File:

mockserver.maxHeaderSize=...

Example:

-Dmockserver.maxHeaderSize="16384"

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=...

Example:

-Dmockserver.maxChunkSize="16384"

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=...

Example:

-Dmockserver.nioEventLoopThreadCount="20"

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=...

Example:

-Dmockserver.maxSocketTimeout="10000"

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=...

Example:

-Dmockserver.socketConnectionTimeout="10000"

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=...

Example:

-Dmockserver.javaKeyStoreFilePath="mockserver_keystore.jks"

The java key store password

Type: string Default: changeit

Java Code:

ConfigurationProperties.javaKeyStorePassword(String keyStorePassword)

System Property:

-Dmockserver.javaKeyStorePassword=...

Property File:

mockserver.javaKeyStorePassword=...

Example:

-Dmockserver.javaKeyStorePassword="changeit"

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=...

Example:

-Dmockserver.javaKeyStoreType="jks"

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=...

Example:

-Dmockserver.deleteGeneratedKeyStoreOnExit="false"

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=...

Example:

-Dmockserver.sslCertificateDomainName="localhost"

The Subject Alternative Name (SAN) domain names for auto-generate TLS certificates as a comma separated list

Type: string Default: localhost

Java Code:

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

System Property:

-Dmockserver.sslSubjectAlternativeNameDomains=...

Property File:

mockserver.sslSubjectAlternativeNameDomains=...

Example:

-Dmockserver.sslSubjectAlternativeNameDomains="localhost,www.foo.bar"

The Subject Alternative Name (SAN) IP addresses for auto-generate TLS certificates as a comma separated list

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=...

Example:

-Dmockserver.sslSubjectAlternativeNameIps="127.0.0.1,0.0.0.0"

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

Example:

-Dmockserver.logLevel="DEBUG"

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=...

Example:

-Dmockserver.disableRequestAudit="true"

Disable logging to the system output

Type: boolean Default: false

Java Code:

ConfigurationProperties.disableSystemOut(boolean disableSystemOut)

System Property:

-Dmockserver.disableSystemOut=...

Property File:

mockserver.disableSystemOut=...

Example:

-Dmockserver.disableSystemOut="true"

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=...

Example:

-Dmockserver.httpProxy="127.0.0.1:1090"

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=...

Example:

-Dmockserver.httpsProxy="127.0.0.1:1090"

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=...

Example:

-Dmockserver.socksProxy="127.0.0.1:1090"

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=...

Example:

-Dmockserver.localBoundIP="0.0.0.0"

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=...

Example:

-Dmockserver.proxyAuthenticationRealm="MockServer HTTP Proxy"

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=...

Example:

-Dmockserver.proxyAuthenticationUsername=john.doe

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=...

Example:

-Dmockserver.proxyAuthenticationPassword="p@ssw0rd"

The class (and package) used to initialize expectations in MockServer at startup

Type: string Default: null

Java Code:

ConfigurationProperties.initializationClass(String initializationClass)

System Property:

-Dmockserver.initializationClass=...

Property File:

mockserver.initializationClass=...

Example:

-Dmockserver.initializationClass="org.mockserver.server.initialize.ExpectationInitializerExample"

The path to the json file used to initialize expectations in MockServer at startup

Type: string Default: null

Java Code:

ConfigurationProperties.initializationJsonPath(String initializationJsonPath)

System Property:

-Dmockserver.initializationJsonPath=...

Property File:

mockserver.initializationJsonPath=...

Example:

-Dmockserver.initializationJsonPath="org/mockserver/server/initialize/initializerJson.json"