Skip to content

Commit

Permalink
Add URL details as part of the exception (#74)
Browse files Browse the repository at this point in the history
* Add URL details as part of the exception

* Add success and failure message assertions

---------

Co-authored-by: BuildTools <james@example.com>
Co-authored-by: Mark Waite <mark.earl.waite@gmail.com>
  • Loading branch information
3 people authored Feb 4, 2023
1 parent bf98edf commit bcd8751
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ private void responseCodeIsValid(ResponseContentSupplier response) throws AbortE
return;
}
}
throw new AbortException("Fail: Status code " + response.getStatus() + " is not in the accepted range: " + validResponseCodes);
throw new AbortException("Fail: Status code " + response.getStatus() + " is not in the accepted range: " + validResponseCodes + " while calling " + url);
}

private void processResponse(ResponseContentSupplier response) throws IOException, InterruptedException {
Expand All @@ -478,7 +478,7 @@ private void processResponse(ResponseContentSupplier response) throws IOExceptio
//validate content
if (!validResponseContent.isEmpty()) {
if (!response.getContent().contains(validResponseContent)) {
throw new AbortException("Fail: Response doesn't contain expected content '" + validResponseContent + "'");
throw new AbortException("Fail: Response doesn't contain expected content '" + validResponseContent + "'" + " while calling " + url);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ public void badContentFailsTheBuild() throws Exception {
// Check expectations
j.assertBuildStatus(Result.FAILURE, run);
j.assertLogContains("Fail: Response doesn't contain expected content 'bad content'", run);
j.assertLogContains(" while calling " + baseURL(), run);
j.assertLogContains("Success: Status code 200 is in the accepted range: 100:399", run);
}

Expand Down Expand Up @@ -248,6 +249,7 @@ public void invalidResponseCodeFailsTheBuild() throws Exception {
j.assertBuildStatus(Result.FAILURE, run);
j.assertLogContains("Throwing status 400 for test",run);
j.assertLogContains("Fail: Status code 400 is not in the accepted range: 100:399", run);
j.assertLogContains(" while calling " + baseURL(), run);
}

@Test
Expand All @@ -272,6 +274,7 @@ public void invalidResponseCodeIsAccepted() throws Exception {
j.assertBuildStatusSuccess(run);
j.assertLogContains("Throwing status 400 for test",run);
j.assertLogContains("Success: Status code 400 is in the accepted range: 100:599", run);
j.assertLogNotContains(" while calling " + baseURL(), run);
}

@Test
Expand Down Expand Up @@ -448,6 +451,7 @@ public void timeoutFailsTheBuild() throws Exception {
// Check expectations
j.assertBuildStatus(Result.FAILURE, run);
j.assertLogContains("Fail: Status code 408 is not in the accepted range: 100:399", run);
j.assertLogContains(" while calling " + baseURL(), run);
}

@Test
Expand Down

0 comments on commit bcd8751

Please sign in to comment.