Interface MockServer

    • Method Detail

      • onStart

        default void onStart()
        This method is called right before start. Override it to add extra initialization.
      • onShutdown

        default void onShutdown()
        This method is called right after shutdown. Override it to add extra cleanup.
      • getPort

        int getPort()
        The port for the MockWebServer.
        Returns:
        the MockWebServer port.
      • getHostName

        String getHostName()
        The host name for the MockWebServer.
        Returns:
        the MockWebServer host name;
      • toProxyAddress

        Proxy toProxyAddress()
        Returns a Proxy for the MockWebServer with the current HostName and Port.
        Returns:
        a Proxy for the MockWebServer.
      • getSelfSignedCertificate

        io.vertx.core.net.SelfSignedCertificate getSelfSignedCertificate()
        Returns the SelfSignedCertificate for the Mock Web Server.
        Returns:
        the SelfSignedCertificate for the MockWebServer.
      • url

        String url​(String path)
        Returns a String URL for connecting to this server.
        Parameters:
        path - the request path, such as "/".
      • getRequestCount

        int getRequestCount()
        Returns the number of HTTP requests received thus far by this server. This may exceed the number of HTTP connections when connection reuse is in practice.
      • takeRequest

        RecordedRequest takeRequest()
                             throws InterruptedException
        Awaits the next HTTP request, removes it, and returns it. Callers should use this to verify the request was sent as intended. This method will block until the request is available, possibly forever.
        Returns:
        the head of the request queue
        Throws:
        InterruptedException
      • takeRequest

        RecordedRequest takeRequest​(long timeout,
                                    TimeUnit unit)
                             throws InterruptedException
        Awaits the next HTTP request (waiting up to the specified wait time if necessary), removes it, and returns it. Callers should use this to verify the request was sent as intended within the given time.
        Parameters:
        timeout - how long to wait before giving up, in units of unit
        unit - a TimeUnit determining how to interpret the timeout parameter
        Returns:
        the head of the request queue
        Throws:
        InterruptedException