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
  • Constructor Details

  • Method Details

    • 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:
      openUI in class MockServerClient
    • 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:
      openUI in class MockServerClient
      Parameters:
      timeUnit - TimeUnit the time unit, for example TimeUnit.SECONDS
      pause - 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: MockServerClient
      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()
      Overrides:
      isRunning in class MockServerClient
    • hasStarted

      public boolean hasStarted()
      Description copied from class: MockServerClient
      Returns 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:
      hasStarted in class MockServerClient
    • stopAsync

      public CompletableFuture stopAsync()
      Description copied from class: MockServerClient
      Stop MockServer gracefully (only support for Netty version, not supported for WAR version)
      Overrides:
      stopAsync in class MockServerClient
    • stop

      public void stop()
      Description copied from class: MockServerClient
      Stop MockServer gracefully (only support for Netty version, not supported for WAR version)
      Specified by:
      stop in interface Stoppable
      Overrides:
      stop in class MockServerClient
    • getPort

      public Integer getPort()
      Overrides:
      getPort in class MockServerClient
    • getLocalPort

      public Integer getLocalPort()
    • getLocalPorts

      public List<Integer> getLocalPorts()
    • getRemoteAddress

      public InetSocketAddress getRemoteAddress()
    • registerListener

      public ClientAndServer registerListener(ExpectationsListener expectationsListener)
    • setLogEventListener

      public static void setLogEventListener(Consumer<LogEntry> listener)