use of net.lightbody.bmp.util.HttpMessageInfo in project opennms by OpenNMS.
the class DatabaseReportIT method customizeCapabilities.
// setup proxy and response filter
@Override
protected void customizeCapabilities(DesiredCapabilities caps) {
proxy = new BrowserMobProxyServer();
proxy.start(0);
proxy.addResponseFilter(new ResponseFilter() {
@Override
public void filterResponse(HttpResponse response, HttpMessageContents contents, HttpMessageInfo messageInfo) {
if (isReportDownloadResponse(response)) {
LOG.info("Report download response received with headers: {}", response.headers().entries());
try (ByteArrayInputStream input = new ByteArrayInputStream(contents.getBinaryContents());
FileOutputStream output = new FileOutputStream(getFile())) {
ByteStreams.copy(input, output);
} catch (IOException e) {
Throwables.propagate(e);
}
}
}
});
// configure the Browser Mob Proxy as a desired capability
Proxy seleniumProxy = ClientUtil.createSeleniumProxy(proxy);
caps.setCapability(CapabilityType.PROXY, seleniumProxy);
}
Aggregations