Package org.mockserver.client
Class MockServerClient.Builder
java.lang.Object
org.mockserver.client.MockServerClient.Builder
- Enclosing class:
- MockServerClient
Fluent builder for
MockServerClient.
Covers every dimension exposed by the MockServerClient constructors and
with... setters:
configuration(ClientConfiguration)/configuration(Configuration)host(String)(default"localhost")port(int)(default1080)contextPath(String)(default empty)portFuture(CompletableFuture)(mutually exclusive with host/port/contextPath)secure(boolean)— TLS, delegates toMockServerClient.withSecure(boolean)proxyConfiguration(ProxyConfiguration)— delegates toMockServerClient.withProxyConfiguration(ProxyConfiguration)controlPlaneJWT(String)/controlPlaneJWT(Supplier)— delegates toMockServerClient.withControlPlaneJWT(Supplier)requestOverride(HttpRequest)— delegates toMockServerClient.withRequestOverride(HttpRequest)
build() is called, at which
point it selects the matching constructor and applies the configured setters, so the
resulting client is identical to one built directly. Validation (for example, the
empty-host check) is inherited from the constructors and surfaces from build().-
Method Summary
Modifier and TypeMethodDescriptionbuild()Build theMockServerClient, selecting the matching constructor and applying the configuredwith...setters.configuration(ClientConfiguration configuration) Use the givenClientConfiguration.configuration(Configuration configuration) Use the givenConfiguration, wrapped as aClientConfiguration(the same conversion theMockServerClient(Configuration, ...)constructors perform).contextPath(String contextPath) The context path that the MockServer war is deployed to.controlPlaneJWT(String controlPlaneJWT) A fixed JWT for control plane authorisation.controlPlaneJWT(Supplier<String> controlPlaneJWTSupplier) A JWT supplier for control plane authorisation.The host of the MockServer to communicate with.port(int port) The port of the MockServer to communicate with.portFuture(CompletableFuture<Integer> portFuture) Resolve the port lazily from aCompletableFuture, for use when the MockServer port is not yet known at client-construction time.proxyConfiguration(ProxyConfiguration proxyConfiguration) Route communication to MockServer via a proxy.requestOverride(HttpRequest requestOverride) A request override applied to every control plane request.secure(boolean secure) Whether to communicate with MockServer over TLS.
-
Method Details
-
configuration
Use the givenClientConfiguration. Whennullthe client falls back to the default configuration, matching the constructors' behaviour. -
configuration
Use the givenConfiguration, wrapped as aClientConfiguration(the same conversion theMockServerClient(Configuration, ...)constructors perform). -
host
The host of the MockServer to communicate with. Defaults to"localhost". -
port
The port of the MockServer to communicate with. Defaults to1080. -
contextPath
The context path that the MockServer war is deployed to. Defaults to empty. -
portFuture
Resolve the port lazily from aCompletableFuture, for use when the MockServer port is not yet known at client-construction time. This is mutually exclusive withhost(String),port(int)andcontextPath(String): the future-based constructor always communicates withlocalhostusing an empty context path. -
secure
Whether to communicate with MockServer over TLS. Delegates toMockServerClient.withSecure(boolean). -
proxyConfiguration
Route communication to MockServer via a proxy. Delegates toMockServerClient.withProxyConfiguration(ProxyConfiguration). -
controlPlaneJWT
A fixed JWT for control plane authorisation. Delegates toMockServerClient.withControlPlaneJWT(String). -
controlPlaneJWT
A JWT supplier for control plane authorisation. Delegates toMockServerClient.withControlPlaneJWT(Supplier). -
requestOverride
A request override applied to every control plane request. Delegates toMockServerClient.withRequestOverride(HttpRequest). -
build
Build theMockServerClient, selecting the matching constructor and applying the configuredwith...setters. Constructor validation (such as the empty-host check) surfaces from here.- Throws:
IllegalArgumentException- ifportFuture(CompletableFuture)is combined with an explicit host, port or context path, or if a constructor rejects the supplied values
-