Add proxy to download report via Smart Reporting API in Java
When utilizing the ReportiumExportUtils.java file, 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.
To add a proxy to download a report:
-
In the ReportiumExportUtils.java file, search for the following line:
Copyprivate static final String PERFECTO_SECURITY_TOKEN = "MY_CONTINUOUS_QUALITY_LAB_SECURITY_TOKEN";
-
Immediate following the line you found in step 1, add the 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); -
Search for the following line:
Copyprivate static HttpClient httpClient = HttpClientBuilder.create()
-
Right before the line you find in step 3, add the following lines:
Copy//need to import org.apache.http.HttpHost;
private static HttpHost proxyHost = new HttpHost(PROXY_HOST, Integer.parseInt(PROXY_PORT)); -
Search for the following line:
Copyprivate static HttpClient httpClient = HttpClientBuilder.create()
-
To the line that you find in step 5, add the following method:
Copy.setProxy(proxyHost)
Related articles