Skip to content

Commit

Permalink
Fixed bug causing http status of last event to not get reported.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Collin committed Jul 20, 2012
1 parent 6f92b13 commit 2f1fc49
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class FileDownloader {
private String localDownloadPath = System.getProperty("java.io.tmpdir");
private boolean followRedirects = true;
private boolean mimicWebDriverCookieState = true;
private int httpStatusOfLastDownloadAttempt;
private int httpStatusOfLastDownloadAttempt = 0;

public FileDownloader(WebDriver driverObject) {
this.driver = driverObject;
Expand Down Expand Up @@ -103,7 +103,7 @@ public String downloadImage(WebElement element) throws Exception {
*
* @return
*/
public int httpStatusOfLastDownloadAttempt() {
public int getHTTPStatusOfLastDownloadAttempt() {
return this.httpStatusOfLastDownloadAttempt;
}

Expand Down Expand Up @@ -169,7 +169,8 @@ private String downloader(WebElement element, String attribute) throws IOExcepti

LOG.info("Sending GET request for: " + httpget.getURI());
HttpResponse response = client.execute(httpget, localContext);
LOG.info("HTTP GET request status: " + response.getStatusLine().getStatusCode());
this.httpStatusOfLastDownloadAttempt = response.getStatusLine().getStatusCode();
LOG.info("HTTP GET request status: " + this.httpStatusOfLastDownloadAttempt);
LOG.info("Downloading file: " + downloadedFile.getName());
FileUtils.copyInputStreamToFile(response.getEntity().getContent(), downloadedFile);
response.getEntity().getContent().close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public void downloadAFile() throws Exception {
String downloadedFileAbsoluteLocation = downloadTestFile.downloadFile(downloadLink);

assertThat(new File(downloadedFileAbsoluteLocation).exists(), is(equalTo(true)));
assertThat(downloadTestFile.getHTTPStatusOfLastDownloadAttempt(), is(equalTo(200)));
}

@Test
Expand All @@ -73,5 +74,6 @@ public void downloadAnImage() throws Exception {
String downloadedImageAbsoluteLocation = downloadTestFile.downloadImage(image);

assertThat(new File(downloadedImageAbsoluteLocation).exists(), is(equalTo(true)));
assertThat(downloadTestFile.getHTTPStatusOfLastDownloadAttempt(), is(equalTo(200)));
}
}

0 comments on commit 2f1fc49

Please sign in to comment.