Package org.mockserver.integration
Class ClientAndServer
java.lang.Object
org.mockserver.client.MockServerClient
org.mockserver.integration.ClientAndServer
- All Implemented Interfaces:
Closeable,AutoCloseable,Stoppable
- Author:
- jamesdbloom
-
Field Summary
Fields inherited from class org.mockserver.client.MockServerClient
portFuture -
Constructor Summary
ConstructorsConstructorDescriptionClientAndServer(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
Modifier and TypeMethodDescriptiongetPort()booleanReturns whether MockServer has started, if called after MockServer has been stopped this method will block for 5 seconds while confirming MockServer is not startingbooleanReturns 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()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, etcLaunch 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, etcregisterListener(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)Stop MockServer gracefully (only support for Netty version, not supported for WAR version)Methods inherited from class org.mockserver.client.MockServerClient
advanceClock, asyncApiStatus, bind, clear, clear, clear, clear, clear, clear, clearGrpcDescriptors, clearServiceChaos, clockStatus, close, contextPath, crud, debugMismatch, freezeClock, freezeClock, hasStarted, hasStopped, hasStopped, isRunning, isSecure, loadAsyncApi, remoteAddress, removeServiceChaos, reset, resetClock, retrieveActiveExpectations, retrieveActiveExpectations, retrieveConfiguration, retrieveGrpcServices, retrieveLogEntries, retrieveLogEntries, retrieveLogEntriesByCorrelationId, retrieveLogMessages, retrieveLogMessagesArray, retrieveLogsByCorrelationId, retrieveMetrics, retrieveRecordedExpectations, retrieveRecordedExpectations, retrieveRecordedRequests, retrieveRecordedRequests, retrieveRecordedRequestsAndResponses, retrieveRecordedRequestsAndResponses, sendExpectation, serviceChaosStatus, setProxyConfiguration, setRequestOverride, setServiceChaos, setServiceChaos, stop, updateConfiguration, uploadGrpcDescriptor, upsert, upsert, verify, verify, verify, verify, verify, verify, verify, verify, verify, verify, verifyAsyncMessage, verifyZeroInteractions, when, when, when, when, withControlPlaneJWT, withControlPlaneJWT, withProxyConfiguration, withRequestOverride, withSecure
-
Constructor Details
-
ClientAndServer
-
ClientAndServer
-
ClientAndServer
-
ClientAndServer
public ClientAndServer(Configuration configuration, String remoteHost, Integer remotePort, Integer... ports)
-
-
Method Details
-
startClientAndServer
-
startClientAndServer
public static ClientAndServer startClientAndServer(Configuration configuration, List<Integer> ports) -
startClientAndServer
-
startClientAndServer
-
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
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
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
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
- Overrides:
getPortin classMockServerClient
-
getLocalPort
-
getLocalPorts
-
getRemoteAddress
-
registerListener
-
setLogEventListener
-