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:
-
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:
Copyprivate static final String PERFECTO_SECURITY_TOKEN = "MY_CONTINUOUS_QUALITY_LAB_SECURITY_TOKEN";
-
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:
Copyprivate static HttpClient httpClient = HttpClientBuilder.create()
-
Add the following method:
Copy.setProxy(proxyHost)
to:
Copyprivate static HttpClient httpClient = HttpClientBuilder.create()