Class ServerConfigurationProperties

java.lang.Object
software.xdev.mockserver.configuration.ConfigurationProperties
software.xdev.mockserver.configuration.ServerConfigurationProperties

public class ServerConfigurationProperties extends ConfigurationProperties
  • Constructor Details

    • ServerConfigurationProperties

      public ServerConfigurationProperties()
  • Method Details

    • logLevel

      public static org.slf4j.event.Level logLevel()
    • javaLoggerLogLevel

      public static String javaLoggerLogLevel()
    • logLevel

      public static void logLevel(String level)
      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

      public static void temporaryLogLevel(String level, Runnable runnable)
    • 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 events

      The 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

      public static String localBoundIP()
    • localBoundIP

      public static void 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 static int maxInitialLineLength()
    • maxInitialLineLength

      public static void maxInitialLineLength(int length)
      Maximum size of the first line of an HTTP request

      The 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 headers

      The 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 responses

      The 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 selenium

      The 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 responses

      The default is false

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

      public static String corsAllowOrigin()
    • corsAllowOrigin

      public static void 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 static String corsAllowMethods()
    • corsAllowMethods

      public static void corsAllowMethods(String 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

      public static String corsAllowHeaders()
    • corsAllowHeaders

      public static void 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 "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

      public static Integer 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

      public static String proxyAuthenticationRealm()
    • proxyAuthenticationRealm

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

      public static String proxyAuthenticationUsername()
    • proxyAuthenticationUsername

      public static void 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 static String proxyAuthenticationPassword()
    • noProxyHosts

      public static void 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.
    • noProxyHosts

      public static String noProxyHosts()
    • proxyAuthenticationPassword

      public static void 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
    • livenessHttpGetPath

      public static String livenessHttpGetPath()
    • livenessHttpGetPath

      public static void livenessHttpGetPath(String livenessPath)
      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