Class AbstractHttpClientJUnit<T>

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void closeHttpClient()
      Closes the HttpClient.
      org.apache.http.HttpResponse execute​(org.apache.http.client.methods.HttpUriRequest request)
      Convenience method to execute the HttpUriRequest.
      T followRedirects​(boolean isFollowRedirects)
      Flags whether to follow redirects.
      org.apache.http.client.HttpClient getHttpClient()
      Obtains the HttpClient.
      protected void openHttpClient()
      Opens the CloseableHttpClient.
      T timeout​(int timeout)
      Specifies the request timeout in milliseconds.
      java.lang.String url​(java.lang.String path)
      Creates URL to the server.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AbstractHttpClientJUnit

        public AbstractHttpClientJUnit()
        Instantiate for non-secure (HTTP) connection to HttpServer.
      • AbstractHttpClientJUnit

        public AbstractHttpClientJUnit​(boolean isSecure)
        Instantiate with flagging if secure (HTTPS) connection to HttpServer.
        Parameters:
        isSecure - Indicates if secure (HTTPS).
      • AbstractHttpClientJUnit

        public AbstractHttpClientJUnit​(boolean isSecure,
                                       int port)
        Instantiate indicating the server port.
        Parameters:
        isSecure - Indicates if secure (HTTPS).
        port - Server port to connect.
    • Method Detail

      • followRedirects

        public T followRedirects​(boolean isFollowRedirects)
        Flags whether to follow redirects.
        Parameters:
        isFollowRedirects - Indicates if follow redirects.
        Returns:
        this.
      • timeout

        public T timeout​(int timeout)
        Specifies the request timeout in milliseconds.
        Parameters:
        timeout - Time out.
        Returns:
        this.
      • getHttpClient

        public org.apache.http.client.HttpClient getHttpClient()
        Obtains the HttpClient.
        Returns:
        HttpClient.
      • url

        public java.lang.String url​(java.lang.String path)
        Creates URL to the server.
        Parameters:
        path - Path on the server.
        Returns:
        URL to the server.
      • execute

        public org.apache.http.HttpResponse execute​(org.apache.http.client.methods.HttpUriRequest request)
                                             throws java.io.IOException,
                                                    org.apache.http.client.ClientProtocolException
        Convenience method to execute the HttpUriRequest.
        Parameters:
        request - HttpUriRequest.
        Returns:
        HttpResponse.
        Throws:
        java.io.IOException - If failure in communication with server.
        org.apache.http.client.ClientProtocolException - If client protocol issue.
      • openHttpClient

        protected void openHttpClient()
        Opens the CloseableHttpClient.
      • closeHttpClient

        protected void closeHttpClient()
                                throws java.io.IOException
        Closes the HttpClient.
        Throws:
        java.io.IOException - If fails to close the HttpClient.