HttpClient

  • 19
    Oct

    Standalone extent report for a TestNG testcase (Extent Reports < 3.0 ver)

    import java.io.File; import org.testng.Assert; import org.testng.ITestResult; import org.testng.SkipException; import org.testng.annotations.AfterMethod; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; import com.relevantcodes.extentreports.ExtentReports; import com.relevantcodes.extentreports.ExtentTest; import com.relevantcodes.extentreports.LogStatus; import libraries.*; public class ExtentReportsClass { ExtentReports...

    Read More
  • 03
    Sep

    solution to “unable to find valid certification path to requested target” in java

    How to import certificate offline Go to URL in your firefox browser, click on HTTPS certificate chain (next to URL address). Click “more info” > “security” > “show certificate”...

    Read More
  • 31
    Aug

    Automation standards for testing a REST webservice

    The testing strategy is not just a one time document, which defines standards of testing. It’s reflects on all the activities — development, testing and the continuous loop of...

    Read More
  • 13
    Jul

    Setting connection timeout and other timeouts with HttpClient

    Following code snippet demonstrates how to configure “connection-timeout”, “socket-timeout” with HttpClient package RestAssured; import java.io.IOException; import org.apache.http.client.config.RequestConfig; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; public class ConnectionTimeout {...

    Read More
  • 13
    Jul

    Request.setEntity() to attach an XML load to a REST request via HttpClient

    Following code demonstrates how to attach a XML Load while sending request to server for processing // Payload for XML Request String xmlLoad = “ Jackychan 999999999“; HttpClient httpClient...

    Read More
  • 13
    Jul

    Processing response with response.entity in HttpClient

    import java.io.IOException; import java.io.InputStream; import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; public class ClientConnectionRelease { public final static void main(String args) throws Exception { CloseableHttpClient httpclient...

    Read More
  • 13
    Jul

    How to process response from HttpClient

    Following code-snippet demonstrates way to handle Response.entity import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import org.apache.http.HttpResponse; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.impl.client.HttpClients;...

    Read More
  • 13
    Jul

    How to abort an HTTP method before its normal completion

    Following example demonstrates how to abort a HttpClient connection (based on condition) and finally close it manually import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; public class AbortWithHttpClient {...

    Read More