Class HTTPSClientUtils


  • public class HTTPSClientUtils
    extends Object
    This class is high level implementation for the HTTP client for Secure connection
    • Constructor Detail

      • HTTPSClientUtils

        public HTTPSClientUtils()
    • Method Detail

      • doGet

        public static org.wso2.carbon.automation.test.utils.http.client.HttpResponse doGet​(String url,
                                                                                           Map<String,​String> headers)
                                                                                    throws IOException
        do HTTP GET operation for the given URL
        Parameters:
        url - request URL
        headers - headers to be send
        Returns:
        org.wso2.carbon.automation.test.utils.http.client.HttpResponse
        Throws:
        IOException - if connection issue occurred
      • doPost

        public static org.wso2.carbon.automation.test.utils.http.client.HttpResponse doPost​(String url,
                                                                                            Map<String,​String> headers,
                                                                                            List<org.apache.http.NameValuePair> urlParameters)
                                                                                     throws IOException
        do HTTP POST operation for the given URL
        Parameters:
        url - request URL
        headers - headers to be send
        urlParameters - parameters to be sent as payload
        Returns:
        org.wso2.carbon.automation.test.utils.http.client.HttpResponse
        Throws:
        IOException - if connection issue occurred
      • doPost

        public static org.wso2.carbon.automation.test.utils.http.client.HttpResponse doPost​(String url,
                                                                                            Map<String,​String> headers,
                                                                                            String payload)
                                                                                     throws IOException
        do HTTP POST operation for the given URL
        Parameters:
        url - request URL
        headers - headers to be sent
        Returns:
        org.wso2.carbon.automation.test.utils.http.client.HttpResponse
        Throws:
        IOException - if connection issue occurred
      • doPut

        public static org.wso2.carbon.automation.test.utils.http.client.HttpResponse doPut​(String url,
                                                                                           Map<String,​String> headers,
                                                                                           String payload)
                                                                                    throws IOException
        do HTTP PUT operation for the given URL
        Parameters:
        url - request URL
        headers - headers to be sent
        Returns:
        org.wso2.carbon.automation.test.utils.http.client.HttpResponse
        Throws:
        IOException - if connection issue occurred
      • doPost

        public static org.wso2.carbon.automation.test.utils.http.client.HttpResponse doPost​(URL url,
                                                                                            Map<String,​String> headers,
                                                                                            String json)
                                                                                     throws IOException
        do HTTP POST operation for the given URL with JSON entity
        Parameters:
        url -
        headers -
        json -
        Returns:
        org.wso2.carbon.automation.test.utils.http.client.HttpResponse
        Throws:
        IOException
      • doPost

        public static org.wso2.carbon.automation.test.utils.http.client.HttpResponse doPost​(URL url,
                                                                                            String urlParams,
                                                                                            Map<String,​String> headers)
                                                                                     throws IOException
        do HTTP POST operation for the given URL
        Parameters:
        url - request URL
        headers - headers to be send
        urlParams - parameter string to be sent as payload
        Returns:
        org.wso2.carbon.automation.test.utils.http.client.HttpResponse
        Throws:
        IOException - if connection issue occurred
      • getHttpsClient

        public static org.apache.http.impl.client.CloseableHttpClient getHttpsClient()
        get the HTTP Client
        Returns:
        CloseableHttpClient
      • getResponseBody

        public static String getResponseBody​(org.apache.http.HttpResponse response)
                                      throws IOException
        read the response body as String
        Parameters:
        response - http response with type org.apache.http.HttpResponse
        Returns:
        String of the response body
        Throws:
        IOException - throws if any error occurred