Interface TestHttpClient


  • public interface TestHttpClient
    A Http Client focused on testing Ratpack applications.
    • Method Detail

      • testHttpClient

        static TestHttpClient testHttpClient​(ApplicationUnderTest applicationUnderTest)
        A method to create an instance of the default implementation of TestHttpClient.
        Parameters:
        applicationUnderTest - the Ratpack application to make requests against
        Returns:
        a http client which is configured to make requests against the provided ApplicationUnderTest
      • getApplicationUnderTest

        ApplicationUnderTest getApplicationUnderTest()
        Returns:
        the application requests are being made against
      • params

        TestHttpClient params​(Action<? super com.google.common.collect.ImmutableMultimap.Builder<java.lang.String,​java.lang.Object>> params)
        Parameters:
        params - the params that will be used with the HttpUrlBuilder passed into HttpUrlBuilder.params(Action)
        Returns:
        this
      • resetRequest

        void resetRequest()
        Set the requestSpec back to a No Op default and clear the cookies.
      • getResponse

        ReceivedResponse getResponse()
        Returns:
        the response from the last request sent
      • head

        ReceivedResponse head()
        Make a HEAD request with a path of "" this is the same as calling head("").
        Returns:
        the response from the request
      • head

        ReceivedResponse head​(java.lang.String path)
        Make a HEAD request to the specified path.
        Parameters:
        path - the path the request is made against
        Returns:
        the response from the request
      • options

        ReceivedResponse options()
        Make a OPTIONS request with a path of "" this is the same as calling options("").
        Returns:
        the response from the request
      • options

        ReceivedResponse options​(java.lang.String path)
        Make a OPTIONS request to the specified path.
        Parameters:
        path - the path the request is made against
        Returns:
        the response from the request
      • optionsText

        java.lang.String optionsText​(java.lang.String path)
        A convenience method for doing a OPTIONS request then calling ReceivedResponse.getBody() then TypedData.getText().
        Parameters:
        path - the path the request is made against
        Returns:
        the response body as a String
        Since:
        1.1
      • get

        ReceivedResponse get()
        Make a GET request with a path of "" this is the same as calling get("").
        Returns:
        the response from the request
      • get

        ReceivedResponse get​(java.lang.String path)
        Make a GET request to the specified path.
        Parameters:
        path - the path the request is made against
        Returns:
        the response from the request
      • getText

        java.lang.String getText()
        A convenience method for doing a GET request then calling ReceivedResponse.getBody() then TypedData.getText(). Useful if you need to only check details of the response body.
        Returns:
        the response body as a String
      • getText

        java.lang.String getText​(java.lang.String path)
        A convenience method for doing a GET request then calling ReceivedResponse.getBody() then TypedData.getText(). Useful if you need to only check details of the response body.
        Parameters:
        path - the path the request is made against
        Returns:
        the response body as a String
      • post

        ReceivedResponse post()
        Make a POST request with a path of "" this is the same as calling post("").
        Returns:
        the response from the request
      • post

        ReceivedResponse post​(java.lang.String path)
        Make a POST request to the specified path.
        Parameters:
        path - the path the request is made against
        Returns:
        the response from the request
      • postText

        java.lang.String postText​(java.lang.String path)
        A convenience method for doing a POST request then calling ReceivedResponse.getBody() then TypedData.getText().
        Parameters:
        path - the path the request is made against
        Returns:
        the response body as a String
      • put

        ReceivedResponse put()
        Make a PUT request with a path of "" this is the same as calling put("").
        Returns:
        the response from the request
      • put

        ReceivedResponse put​(java.lang.String path)
        Make a PUT request to the specified path.
        Parameters:
        path - the path the request is made against
        Returns:
        the response from the request
      • putText

        java.lang.String putText​(java.lang.String path)
        A convenience method for doing a PUT request then calling ReceivedResponse.getBody() then TypedData.getText().
        Parameters:
        path - the path the request is made against
        Returns:
        the response body as a String
      • patch

        ReceivedResponse patch()
        Make a PATCH request with a path of "" this is the same as calling patch("").
        Returns:
        the response from the request
      • patch

        ReceivedResponse patch​(java.lang.String path)
        Make a PATCH request to the specified path.
        Parameters:
        path - the path the request is made against
        Returns:
        the response from the request
      • patchText

        java.lang.String patchText​(java.lang.String path)
        A convenience method for doing a PATCH request then calling ReceivedResponse.getBody() then TypedData.getText().
        Parameters:
        path - the path the request is made against
        Returns:
        the response body as a String
      • delete

        ReceivedResponse delete()
        Make a DELETE request with a path of "" this is the same as calling delete("").
        Returns:
        the response from the request
      • delete

        ReceivedResponse delete​(java.lang.String path)
        Make a DELETE request to the specified path.
        Parameters:
        path - the path the request is made against
        Returns:
        the response from the request
      • deleteText

        java.lang.String deleteText​(java.lang.String path)
        A convenience method for doing a DELETE request then calling ReceivedResponse.getBody() then TypedData.getText().
        Parameters:
        path - the path the request is made against
        Returns:
        the response body as a String
      • getCookies

        java.util.List<io.netty.handler.codec.http.cookie.Cookie> getCookies​(java.lang.String path)
        Get cookies with Path= attribute equal to path and all its subpaths.
        Parameters:
        path - a URI path attached to cookies
        Returns:
        the list of cookies attached to the given path