Class ServerConfiguration

java.lang.Object
software.xdev.mockserver.configuration.Configuration
software.xdev.mockserver.configuration.ServerConfiguration

public class ServerConfiguration extends Configuration
  • Constructor Details

    • ServerConfiguration

      public ServerConfiguration()
  • Method Details

    • configuration

      public static ServerConfiguration configuration()
    • detailedMatchFailures

      public Boolean detailedMatchFailures()
    • detailedMatchFailures

      public ServerConfiguration 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.
      Parameters:
      detailedMatchFailures - enabled detailed match failure log events
    • maxExpectations

      public Integer maxExpectations()
    • maxExpectations

      public ServerConfiguration maxExpectations(Integer maxExpectations)

      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:
      maxExpectations - maximum number of expectations to store
    • maxLogEntries

      public Integer maxLogEntries()
    • maxLogEntries

      public ServerConfiguration maxLogEntries(Integer maxLogEntries)

      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

      Parameters:
      maxLogEntries - maximum number of expectations to store
    • nioEventLoopThreadCount

      public Integer nioEventLoopThreadCount()
    • nioEventLoopThreadCount

      public ServerConfiguration nioEventLoopThreadCount(Integer nioEventLoopThreadCount)

      Netty worker thread pool size for handling requests and response. These threads handle deserializing and serialising HTTP requests and responses and some other fast logic, long running tasks are done on the action handler thread pool.

      Parameters:
      nioEventLoopThreadCount - Netty worker thread pool size
    • actionHandlerThreadCount

      public Integer actionHandlerThreadCount()
    • actionHandlerThreadCount

      public ServerConfiguration actionHandlerThreadCount(Integer actionHandlerThreadCount)

      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:
      actionHandlerThreadCount - Netty worker thread pool size
    • matchersFailFast

      public Boolean matchersFailFast()
    • matchersFailFast

      public ServerConfiguration 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. This is useful to see all mismatching fields in the log event recording that a request matcher did not match.
      Parameters:
      matchersFailFast - enabled request matchers failing fast
    • alwaysCloseSocketConnections

      public Boolean alwaysCloseSocketConnections()
    • alwaysCloseSocketConnections

      public ServerConfiguration 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.

      Default is false

      Parameters:
      alwaysCloseSocketConnections - true socket connections will always be closed after a response is returned
    • localBoundIP

      public String localBoundIP()
    • localBoundIP

      public ServerConfiguration localBoundIP(String localBoundIP)
      The local IP address to bind to for accepting new socket connections

      Default is 0.0.0.0

      Parameters:
      localBoundIP - local IP address to bind to for accepting new socket connections
    • maxInitialLineLength

      public Integer maxInitialLineLength()
    • maxInitialLineLength

      public ServerConfiguration maxInitialLineLength(Integer maxInitialLineLength)
      Maximum size of the first line of an HTTP request

      The default is Integer.MAX_VALUE

      Parameters:
      maxInitialLineLength - maximum size of the first line of an HTTP request
    • maxHeaderSize

      public Integer maxHeaderSize()
    • maxHeaderSize

      public ServerConfiguration maxHeaderSize(Integer maxHeaderSize)
      Maximum size of HTTP request headers

      The default is Integer.MAX_VALUE

      Parameters:
      maxHeaderSize - maximum size of HTTP request headers
    • maxChunkSize

      public Integer maxChunkSize()
    • maxChunkSize

      public ServerConfiguration maxChunkSize(Integer maxChunkSize)
      Maximum size of HTTP chunks in request or responses

      The default is Integer.MAX_VALUE

      Parameters:
      maxChunkSize - maximum size of HTTP chunks in request or responses
    • useSemicolonAsQueryParameterSeparator

      public Boolean useSemicolonAsQueryParameterSeparator()
    • useSemicolonAsQueryParameterSeparator

      public ServerConfiguration 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.

      The default is true

      Parameters:
      useSemicolonAsQueryParameterSeparator - if true semicolons are treated as a separator for a query parameter string
    • assumeAllRequestsAreHttp

      public Boolean assumeAllRequestsAreHttp()
    • assumeAllRequestsAreHttp

      public ServerConfiguration 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"

      The default is false

      Parameters:
      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"
    • binaryProxyListener

      public BinaryProxyListener binaryProxyListener()
    • binaryProxyListener

      public ServerConfiguration binaryProxyListener(BinaryProxyListener binaryProxyListener)
      Set a software.xdev.mockserver.model.BinaryProxyListener called when binary content is proxied
      Parameters:
      binaryProxyListener - a BinaryProxyListener called when binary content is proxied
    • enableCORSForAPI

      public Boolean enableCORSForAPI()
    • enableCORSForAPI

      public ServerConfiguration enableCORSForAPI(Boolean enableCORSForAPI)
      Enable CORS for MockServer REST API so that the API can be used for javascript running in browsers, such as selenium

      The default is false

      Parameters:
      enableCORSForAPI - CORS for MockServer REST API
    • enableCORSForAllResponses

      public Boolean enableCORSForAllResponses()
    • enableCORSForAllResponses

      public ServerConfiguration enableCORSForAllResponses(Boolean enableCORSForAllResponses)
      Enable CORS for all responses from MockServer, including the REST API and expectation responses

      The default is false

      Parameters:
      enableCORSForAllResponses - CORS for all responses from MockServer
    • corsAllowOrigin

      public String corsAllowOrigin()
    • corsAllowOrigin

      public ServerConfiguration corsAllowOrigin(String 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

      public String corsAllowMethods()
    • corsAllowMethods

      public ServerConfiguration corsAllowMethods(String corsAllowMethods)

      the value used for CORS in the access-control-allow-methods header.

      The default is ""

      Parameters:
      corsAllowMethods - the value used for CORS in the access-control-allow-methods header
    • corsAllowHeaders

      public String corsAllowHeaders()
    • corsAllowHeaders

      public ServerConfiguration corsAllowHeaders(String 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 ""

      Parameters:
      corsAllowHeaders - the value used for CORS in the access-control-allow-headers and access-control-expose-headers headers
    • corsAllowCredentials

      public Boolean corsAllowCredentials()
    • corsAllowCredentials

      public ServerConfiguration corsAllowCredentials(Boolean corsAllowCredentials)
      The value used for CORS in the access-control-allow-credentials header.

      The default is false

      Parameters:
      corsAllowCredentials - the value used for CORS in the access-control-allow-credentials header
    • corsMaxAgeInSeconds

      public Integer corsMaxAgeInSeconds()
    • corsMaxAgeInSeconds

      public ServerConfiguration corsMaxAgeInSeconds(Integer corsMaxAgeInSeconds)
      The value used for CORS in the access-control-max-age header.

      The default is 0

      Parameters:
      corsMaxAgeInSeconds - the value used for CORS in the access-control-max-age header.
    • maximumNumberOfRequestToReturnInVerificationFailure

      public Integer maximumNumberOfRequestToReturnInVerificationFailure()
    • maximumNumberOfRequestToReturnInVerificationFailure

      public ServerConfiguration 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
      Parameters:
      maximumNumberOfRequestToReturnInVerificationFailure - maximum number of expectations to return in verification failure result
    • proxyAuthenticationRealm

      public String proxyAuthenticationRealm()
    • proxyAuthenticationRealm

      public ServerConfiguration proxyAuthenticationRealm(String proxyAuthenticationRealm)
      The authentication realm for proxy authentication to MockServer
      Parameters:
      proxyAuthenticationRealm - the authentication realm for proxy authentication
    • proxyAuthenticationUsername

      public String proxyAuthenticationUsername()
    • proxyAuthenticationUsername

      public ServerConfiguration proxyAuthenticationUsername(String 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.disabledSchemes and jdk.http.auth.proxying.disabledSchemes.

      The default is ""

      Parameters:
      proxyAuthenticationUsername - required username for proxy authentication to MockServer
    • proxyAuthenticationPassword

      public String proxyAuthenticationPassword()
    • proxyAuthenticationPassword

      public ServerConfiguration proxyAuthenticationPassword(String 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.disabledSchemes and jdk.http.auth.proxying.disabledSchemes.

      The default is ""

      Parameters:
      proxyAuthenticationPassword - required password for proxy authentication to MockServer
    • noProxyHosts

      public String noProxyHosts()
    • noProxyHosts

      public ServerConfiguration noProxyHosts(String 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.
    • livenessHttpGetPath

      public String livenessHttpGetPath()
    • livenessHttpGetPath

      public ServerConfiguration livenessHttpGetPath(String 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:
      livenessHttpGetPath - path to support HTTP GET requests for status response
    • ringBufferSize

      public int ringBufferSize()