Add proxy to download report via Smart Reporting API in Java

When utilizing ReportiumExportUtils, for example as described for downloading PDF reports in PDF download after test execution and Download Summary PDF Report for a Job in Java, you may need to define a proxy to connect to the Perfecto Smart Reporting API.

Step-by-step guide

In the ReportiumExportUtils:

  1. Add following lines:

    Copy
    //replace with the actual proxy host and port
    private static final String PROXY_H = "<proxy_host>";
    private static final String PROXY_P = "<proxy_port>";
        
    private static final String PROXY_HOST = System.getProperty("https.proxyHost", PROXY_H);
    private static final String PROXY_PORT = System.getProperty("https.proxyPort", PROXY_P);

    right after:

    Copy
    private static final String PERFECTO_SECURITY_TOKEN = "MY_CONTINUOUS_QUALITY_LAB_SECURITY_TOKEN";
  2. Add the following lines:

    Copy
    //need to import org.apache.http.HttpHost;
    private static HttpHost proxyHost = new HttpHost(PROXY_HOST, Integer.parseInt(PROXY_PORT));

    right before:

    Copy
    private static HttpClient httpClient = HttpClientBuilder.create()
  3. Add the following method:

    Copy
    .setProxy(proxyHost)

    to:

    Copy
    private static HttpClient httpClient = HttpClientBuilder.create()