Class ServerConfigurationProperties
-
Field Summary
Fields inherited from class software.xdev.mockserver.configuration.ConfigurationProperties
MOCKSERVER_ATTEMPT_TO_PROXY_IF_NO_MATCHING_EXPECTATION, MOCKSERVER_CLIENT_NIO_EVENT_LOOP_THREAD_COUNT, MOCKSERVER_FORWARD_HTTP_PROXY, MOCKSERVER_FORWARD_PROXY_AUTHENTICATION_PASSWORD, MOCKSERVER_FORWARD_PROXY_AUTHENTICATION_USERNAME, MOCKSERVER_FORWARD_SOCKS_PROXY, MOCKSERVER_MAX_FUTURE_TIMEOUT, MOCKSERVER_MAX_SOCKET_TIMEOUT, MOCKSERVER_MAX_WEB_SOCKET_EXPECTATIONS, MOCKSERVER_SOCKET_CONNECTION_TIMEOUT, MOCKSERVER_WEB_SOCKET_CLIENT_EVENT_LOOP_THREAD_COUNT, properties, propertyCache -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intstatic voidactionHandlerThreadCount(int count) Number of threads for the action handler thread poolstatic booleanstatic voidalwaysCloseSocketConnections(boolean alwaysClose) 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.static booleanstatic voidassumeAllRequestsAreHttp(boolean assumeAllRequestsAreHttp) If true requests are assumed as binary if the method isn't one of "GET", "POST", "PUT", "HEAD", "OPTIONS", "PATCH", "DELETE", "TRACE" or "CONNECT"static booleanstatic voidcorsAllowCredentials(boolean allow) The value used for CORS in the access-control-allow-credentials header.static Stringstatic voidcorsAllowHeaders(String corsAllowHeaders) the value used for CORS in the access-control-allow-headers and access-control-expose-headers headers.static Stringstatic voidcorsAllowMethods(String corsAllowMethods) The value used for CORS in the access-control-allow-methods header.static Stringstatic voidcorsAllowOrigin(String corsAllowOrigin) the value used for CORS in the access-control-allow-origin header.static intstatic voidcorsMaxAgeInSeconds(int ageInSeconds) The value used for CORS in the access-control-max-age header.static booleanstatic voiddetailedMatchFailures(boolean enable) 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.static booleanstatic voiddisableLogging(boolean disable) Disable all logging and processing of log eventsstatic booleanstatic voiddisableSystemOut(boolean disable) Disable printing log to system out for JVM, default is enabledstatic booleanstatic voidenableCORSForAllResponses(boolean enable) Enable CORS for all responses from MockServer, including the REST API and expectation responsesstatic booleanstatic voidenableCORSForAPI(boolean enable) Enable CORS for MockServer REST API so that the API can be used for javascript running in browsers, such as seleniumstatic Stringstatic Stringstatic voidlivenessHttpGetPath(String livenessPath) Path to support HTTP GET requests for status response (also available on PUT /mockserver/status).static Stringstatic voidlocalBoundIP(String localBoundIP) The local IP address to bind to for accepting new socket connectionsstatic org.slf4j.event.LevellogLevel()static voidOverride the default logging level of INFOstatic booleanstatic voidmatchersFailFast(boolean enable) If true (the default) request matchers will fail on the first non-matching field, if false request matchers will compare all fields.static intstatic voidmaxChunkSize(int size) Maximum size of HTTP chunks in request or responsesstatic intstatic voidmaxExpectations(int count) Maximum number of expectations stored in memory.static intstatic voidmaxHeaderSize(int size) Maximum size of HTTP request headersstatic Integerstatic voidmaximumNumberOfRequestToReturnInVerificationFailure(Integer maximumNumberOfRequestToReturnInVerification) The maximum number of requests to return in verification failure result, if more expectations are found the failure result does not list them separatelystatic intstatic voidmaxInitialLineLength(int length) Maximum size of the first line of an HTTP requeststatic intstatic voidmaxLogEntries(int count) Maximum number of log entries stored in memory.static intstatic voidnioEventLoopThreadCount(int count) Netty worker thread pool size for handling requests and response.static Stringstatic voidnoProxyHosts(String noProxyHosts) The list of hostnames to not use the configured proxy.static Stringstatic voidproxyAuthenticationPassword(String proxyAuthenticationPassword) The required password for proxy authentication to MockServerstatic Stringstatic voidproxyAuthenticationRealm(String proxyAuthenticationRealm) The authentication realm for proxy authentication to MockServerstatic Stringstatic voidproxyAuthenticationUsername(String proxyAuthenticationUsername) The required username for proxy authentication to MockServerstatic voidtemporaryLogLevel(String level, Runnable runnable) static booleanstatic voiduseSemicolonAsQueryParameterSeparator(boolean useAsQueryParameterSeparator) 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.Methods inherited from class software.xdev.mockserver.configuration.ConfigurationProperties
attemptToProxyIfNoMatchingExpectation, attemptToProxyIfNoMatchingExpectation, clearProperty, clientNioEventLoopThreadCount, clientNioEventLoopThreadCount, forwardBinaryRequestsWithoutWaitingForResponse, forwardBinaryRequestsWithoutWaitingForResponse, forwardHttpProxy, forwardHttpProxy, forwardHttpProxy, forwardProxyAuthenticationPassword, forwardProxyAuthenticationPassword, forwardProxyAuthenticationUsername, forwardProxyAuthenticationUsername, forwardSocksProxy, forwardSocksProxy, forwardSocksProxy, getPropertyCache, maxFutureTimeout, maxFutureTimeout, maxSocketTimeout, maxSocketTimeout, maxWebSocketExpectations, maxWebSocketExpectations, readInetSocketAddressProperty, readIntegerProperty, readLongProperty, readPropertyHierarchically, setProperty, socketConnectionTimeout, socketConnectionTimeout, validateHostAndPortAndSetProperty, webSocketClientEventLoopThreadCount, webSocketClientEventLoopThreadCount
-
Constructor Details
-
ServerConfigurationProperties
public ServerConfigurationProperties()
-
-
Method Details
-
logLevel
public static org.slf4j.event.Level logLevel() -
javaLoggerLogLevel
-
logLevel
Override the default logging level of INFO- Parameters:
level- the log level, which can be TRACE, DEBUG, INFO, WARN, ERROR, OFF, FINEST, FINE, INFO, WARNING, SEVERE
-
temporaryLogLevel
-
disableSystemOut
public static boolean disableSystemOut() -
disableSystemOut
public static void disableSystemOut(boolean disable) Disable printing log to system out for JVM, default is enabled- Parameters:
disable- printing log to system out for JVM
-
disableLogging
public static boolean disableLogging() -
disableLogging
public static void disableLogging(boolean disable) Disable all logging and processing of log eventsThe default is false
- Parameters:
disable- disable all logging
-
detailedMatchFailures
public static boolean detailedMatchFailures() -
detailedMatchFailures
public static void detailedMatchFailures(boolean enable) 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.- Parameters:
enable- enabled detailed match failure log events
-
maxExpectations
public static int maxExpectations() -
maxExpectations
public static void maxExpectations(int count) Maximum number of expectations stored in memory. Expectations are stored in a circular queue so once this limit is reach the oldest and lowest priority expectations are overwritten
The default maximum depends on the available memory in the JVM with an upper limit of 5000
- Parameters:
count- maximum number of expectations to store
-
maxLogEntries
public static int maxLogEntries() -
maxLogEntries
public static void maxLogEntries(int count) Maximum number of log entries stored in memory. Log entries are stored in a circular queue so once this limit is reach the oldest log entries are overwritten.
The default maximum depends on the available memory in the JVM with an upper limit of 60000, but can be overridden using defaultMaxLogEntries
- Parameters:
count- maximum number of expectations to store
-
nioEventLoopThreadCount
public static int nioEventLoopThreadCount() -
nioEventLoopThreadCount
public static void nioEventLoopThreadCount(int count) Netty worker thread pool size for handling requests and response. These threads are used for fast non-blocking activities such as, reading and de-serialise all requests and responses.
- Parameters:
count- Netty worker thread pool size
-
actionHandlerThreadCount
public static int actionHandlerThreadCount() -
actionHandlerThreadCount
public static void actionHandlerThreadCount(int count) Number of threads for the action handler thread pool
These threads are used for handling actions such as:
- serialising and writing expectation or proxied responses
- handling response delays in a non-blocking way (i.e. using a scheduler)
- executing class callbacks
- handling method / closure callbacks (using web sockets)
Default is maximum of 5 or available processors count
- Parameters:
count- Netty worker thread pool size
-
matchersFailFast
public static boolean matchersFailFast() -
matchersFailFast
public static void matchersFailFast(boolean enable) If true (the default) request matchers will fail on the first non-matching field, if false request matchers will compare all fields. This is useful to see all mismatching fields in the log event recording that a request matcher did not match.- Parameters:
enable- enabled request matchers failing fast
-
alwaysCloseSocketConnections
public static void alwaysCloseSocketConnections(boolean alwaysClose) 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.
Default is false
- Parameters:
alwaysClose- true socket connections will always be closed after a response is returned
-
alwaysCloseSocketConnections
public static boolean alwaysCloseSocketConnections() -
localBoundIP
-
localBoundIP
The local IP address to bind to for accepting new socket connectionsDefault is 0.0.0.0
- Parameters:
localBoundIP- local IP address to bind to for accepting new socket connections
-
maxInitialLineLength
public static int maxInitialLineLength() -
maxInitialLineLength
public static void maxInitialLineLength(int length) Maximum size of the first line of an HTTP requestThe default is Integer.MAX_VALUE
- Parameters:
length- maximum size of the first line of an HTTP request
-
maxHeaderSize
public static int maxHeaderSize() -
maxHeaderSize
public static void maxHeaderSize(int size) Maximum size of HTTP request headersThe default is Integer.MAX_VALUE
- Parameters:
size- maximum size of HTTP request headers
-
maxChunkSize
public static int maxChunkSize() -
maxChunkSize
public static void maxChunkSize(int size) Maximum size of HTTP chunks in request or responsesThe default is Integer.MAX_VALUE
- Parameters:
size- maximum size of HTTP chunks in request or responses
-
useSemicolonAsQueryParameterSeparator
public static void useSemicolonAsQueryParameterSeparator(boolean useAsQueryParameterSeparator) 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.The default is true
- Parameters:
useAsQueryParameterSeparator- true semicolons are treated as a separator for a query parameter string
-
useSemicolonAsQueryParameterSeparator
public static boolean useSemicolonAsQueryParameterSeparator() -
assumeAllRequestsAreHttp
public static void assumeAllRequestsAreHttp(boolean assumeAllRequestsAreHttp) If true requests are assumed as binary if the method isn't one of "GET", "POST", "PUT", "HEAD", "OPTIONS", "PATCH", "DELETE", "TRACE" or "CONNECT"The default is true
- Parameters:
assumeAllRequestsAreHttp- if true requests are assumed as binary if the method isn't one of "GET", "POST", "PUT", "HEAD", "OPTIONS", "PATCH", "DELETE", "TRACE" or "CONNECT"
-
assumeAllRequestsAreHttp
public static boolean assumeAllRequestsAreHttp() -
enableCORSForAPI
public static boolean enableCORSForAPI() -
enableCORSForAPI
public static void enableCORSForAPI(boolean enable) Enable CORS for MockServer REST API so that the API can be used for javascript running in browsers, such as seleniumThe default is false
- Parameters:
enable- CORS for MockServer REST API
-
enableCORSForAllResponses
public static boolean enableCORSForAllResponses() -
enableCORSForAllResponses
public static void enableCORSForAllResponses(boolean enable) Enable CORS for all responses from MockServer, including the REST API and expectation responsesThe default is false
- Parameters:
enable- CORS for all responses from MockServer
-
corsAllowOrigin
-
corsAllowOrigin
the value used for CORS in the access-control-allow-origin header.
The default is ""
- Parameters:
corsAllowOrigin- the value used for CORS in the access-control-allow-methods header
-
corsAllowMethods
-
corsAllowMethods
The value used for CORS in the access-control-allow-methods header.
The default is "CONNECT, DELETE, GET, HEAD, OPTIONS, POST, PUT, PATCH, TRACE"
- Parameters:
corsAllowMethods- the value used for CORS in the access-control-allow-methods header
-
corsAllowHeaders
-
corsAllowHeaders
the value used for CORS in the access-control-allow-headers and access-control-expose-headers headers.
In addition to this default value any headers specified in the request header access-control-request-headers also get added to access-control-allow-headers and access-control-expose-headers headers in a CORS response.
The default is "Allow, Content-Encoding, Content-Length, Content-Type, ETag, Expires, Last-Modified, Location, Server, Vary, Authorization"
- Parameters:
corsAllowHeaders- the value used for CORS in the access-control-allow-headers and access-control-expose-headers headers
-
corsAllowCredentials
public static boolean corsAllowCredentials() -
corsAllowCredentials
public static void corsAllowCredentials(boolean allow) The value used for CORS in the access-control-allow-credentials header.The default is true
- Parameters:
allow- the value used for CORS in the access-control-allow-credentials header
-
corsMaxAgeInSeconds
public static int corsMaxAgeInSeconds() -
corsMaxAgeInSeconds
public static void corsMaxAgeInSeconds(int ageInSeconds) The value used for CORS in the access-control-max-age header.The default is 300
- Parameters:
ageInSeconds- the value used for CORS in the access-control-max-age header.
-
maximumNumberOfRequestToReturnInVerificationFailure
-
maximumNumberOfRequestToReturnInVerificationFailure
public static void maximumNumberOfRequestToReturnInVerificationFailure(Integer maximumNumberOfRequestToReturnInVerification) The maximum number of requests to return in verification failure result, if more expectations are found the failure result does not list them separately- Parameters:
maximumNumberOfRequestToReturnInVerification- maximum number of expectations to return in verification failure result
-
proxyAuthenticationRealm
-
proxyAuthenticationRealm
The authentication realm for proxy authentication to MockServer- Parameters:
proxyAuthenticationRealm- the authentication realm for proxy authentication
-
proxyAuthenticationUsername
-
proxyAuthenticationUsername
The required username for proxy authentication to MockServer
Note: 8u111 Update Release Notes state that the Basic authentication scheme has been deactivated when setting up an HTTPS tunnel. To resolve this clear or set to an empty string the following system properties:
jdk.http.auth.tunneling.disabledSchemesandjdk.http.auth.proxying.disabledSchemes.The default is ""
- Parameters:
proxyAuthenticationUsername- required username for proxy authentication to MockServer
-
proxyAuthenticationPassword
-
noProxyHosts
The list of hostnames to not use the configured proxy. Several values may be present, seperated by comma (,)
The default is ""- Parameters:
noProxyHosts- Comma-seperated list of hosts to not be proxied.
-
noProxyHosts
-
proxyAuthenticationPassword
The required password for proxy authentication to MockServer
Note: 8u111 Update Release Notes state that the Basic authentication scheme has been deactivated when setting up an HTTPS tunnel. To resolve this clear or set to an empty string the following system properties:
jdk.http.auth.tunneling.disabledSchemesandjdk.http.auth.proxying.disabledSchemes.The default is ""
- Parameters:
proxyAuthenticationPassword- required password for proxy authentication to MockServer
-
livenessHttpGetPath
-
livenessHttpGetPath
Path to support HTTP GET requests for status response (also available on PUT /mockserver/status).If this value is not modified then only PUT /mockserver/status but is a none blank value is provided for this value then GET requests to this path will return the 200 Ok status response showing the MockServer version and bound ports.
A GET request to this path will be matched before any expectation matching or proxying of requests.
The default is ""
- Parameters:
livenessPath- path to support HTTP GET requests for status response
-