Package org.mockserver.integration
Class ClientAndServer
- java.lang.Object
-
- org.mockserver.client.MockServerClient
-
- org.mockserver.integration.ClientAndServer
-
- All Implemented Interfaces:
Closeable,AutoCloseable,Stoppable
public class ClientAndServer extends MockServerClient
- Author:
- jamesdbloom
-
-
Field Summary
-
Fields inherited from class org.mockserver.client.MockServerClient
portFuture
-
-
Constructor Summary
Constructors Constructor Description ClientAndServer(Integer... ports)ClientAndServer(String remoteHost, Integer remotePort, Integer... ports)ClientAndServer(Configuration configuration, Integer... ports)ClientAndServer(Configuration configuration, String remoteHost, Integer remotePort, Integer... ports)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description IntegergetLocalPort()List<Integer>getLocalPorts()IntegergetPort()InetSocketAddressgetRemoteAddress()booleanhasStarted()Returns whether MockServer has started, if called after MockServer has been stopped this method will block for 5 seconds while confirming MockServer is not startingbooleanisRunning()Returns whether MockServer is running, if called too quickly after starting MockServer this may return false because MockServer has not yet started, to ensure MockServer has started use hasStarted()ClientAndServeropenUI()Launch UI and wait the default period to allow the UI to launch and start collecting logs, this ensures that the log are visible in the UI even if MockServer is shutdown by a test shutdown function, such as After, AfterClass, AfterAll, etcClientAndServeropenUI(TimeUnit timeUnit, long pause)Launch UI and wait a specified period to allow the UI to launch and start collecting logs, this ensures that the log are visible in the UI even if MockServer is shutdown by a test shutdown function, such as After, AfterClass, AfterAll, etcClientAndServerregisterListener(ExpectationsListener expectationsListener)static voidsetLogEventListener(Consumer<LogEntry> listener)static ClientAndServerstartClientAndServer(Integer... port)static ClientAndServerstartClientAndServer(String remoteHost, Integer remotePort, Integer... port)static ClientAndServerstartClientAndServer(List<Integer> ports)static ClientAndServerstartClientAndServer(Configuration configuration, Integer... port)static ClientAndServerstartClientAndServer(Configuration configuration, String remoteHost, Integer remotePort, Integer... port)static ClientAndServerstartClientAndServer(Configuration configuration, List<Integer> ports)voidstop()Stop MockServer gracefully (only support for Netty version, not supported for WAR version)CompletableFuturestopAsync()Stop MockServer gracefully (only support for Netty version, not supported for WAR version)-
Methods inherited from class org.mockserver.client.MockServerClient
bind, clear, clear, clear, clear, clear, clear, clearGrpcDescriptors, close, contextPath, crud, debugMismatch, hasStarted, hasStopped, hasStopped, isRunning, isSecure, remoteAddress, reset, retrieveActiveExpectations, retrieveActiveExpectations, retrieveConfiguration, retrieveGrpcServices, retrieveLogEntries, retrieveLogEntries, retrieveLogEntriesByCorrelationId, retrieveLogMessages, retrieveLogMessagesArray, retrieveLogsByCorrelationId, retrieveMetrics, retrieveRecordedExpectations, retrieveRecordedExpectations, retrieveRecordedRequests, retrieveRecordedRequests, retrieveRecordedRequestsAndResponses, retrieveRecordedRequestsAndResponses, sendExpectation, setProxyConfiguration, setRequestOverride, stop, updateConfiguration, uploadGrpcDescriptor, upsert, upsert, verify, verify, verify, verify, verify, verify, verify, verify, verify, verify, verifyZeroInteractions, when, when, when, when, withControlPlaneJWT, withControlPlaneJWT, withProxyConfiguration, withRequestOverride, withSecure
-
-
-
-
Constructor Detail
-
ClientAndServer
public ClientAndServer(Integer... ports)
-
ClientAndServer
public ClientAndServer(Configuration configuration, Integer... ports)
-
ClientAndServer
public ClientAndServer(Configuration configuration, String remoteHost, Integer remotePort, Integer... ports)
-
-
Method Detail
-
startClientAndServer
public static ClientAndServer startClientAndServer(List<Integer> ports)
-
startClientAndServer
public static ClientAndServer startClientAndServer(Configuration configuration, List<Integer> ports)
-
startClientAndServer
public static ClientAndServer startClientAndServer(Integer... port)
-
startClientAndServer
public static ClientAndServer startClientAndServer(Configuration configuration, Integer... port)
-
startClientAndServer
public static ClientAndServer startClientAndServer(String remoteHost, Integer remotePort, Integer... port)
-
startClientAndServer
public static ClientAndServer startClientAndServer(Configuration configuration, String remoteHost, Integer remotePort, Integer... port)
-
openUI
public ClientAndServer openUI()
Launch UI and wait the default period to allow the UI to launch and start collecting logs, this ensures that the log are visible in the UI even if MockServer is shutdown by a test shutdown function, such as After, AfterClass, AfterAll, etc- Overrides:
openUIin classMockServerClient
-
openUI
public ClientAndServer openUI(TimeUnit timeUnit, long pause)
Launch UI and wait a specified period to allow the UI to launch and start collecting logs, this ensures that the log are visible in the UI even if MockServer is shutdown by a test shutdown function, such as After, AfterClass, AfterAll, etc- Overrides:
openUIin classMockServerClient- Parameters:
timeUnit- TimeUnit the time unit, for example TimeUnit.SECONDSpause- the number of time units to delay before the function returns to ensure the UI is receiving logs
-
isRunning
public boolean isRunning()
Description copied from class:MockServerClientReturns whether MockServer is running, if called too quickly after starting MockServer this may return false because MockServer has not yet started, to ensure MockServer has started use hasStarted()- Overrides:
isRunningin classMockServerClient
-
hasStarted
public boolean hasStarted()
Description copied from class:MockServerClientReturns whether MockServer has started, if called after MockServer has been stopped this method will block for 5 seconds while confirming MockServer is not starting- Overrides:
hasStartedin classMockServerClient
-
stopAsync
public CompletableFuture stopAsync()
Description copied from class:MockServerClientStop MockServer gracefully (only support for Netty version, not supported for WAR version)- Overrides:
stopAsyncin classMockServerClient
-
stop
public void stop()
Description copied from class:MockServerClientStop MockServer gracefully (only support for Netty version, not supported for WAR version)- Specified by:
stopin interfaceStoppable- Overrides:
stopin classMockServerClient
-
getPort
public Integer getPort()
- Overrides:
getPortin classMockServerClient
-
getLocalPort
public Integer getLocalPort()
-
getRemoteAddress
public InetSocketAddress getRemoteAddress()
-
registerListener
public ClientAndServer registerListener(ExpectationsListener expectationsListener)
-
-