Skip to content

Commit

Permalink
Add response body to report
Browse files Browse the repository at this point in the history
  • Loading branch information
bpross-52n committed Jul 27, 2023
1 parent 398b31e commit 0f014f2
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public void storeRequirementClassesInTestContext( ITestContext testContext ) {
public void testValidateConformanceOperationAndResponse( TestPoint testPoint ) {
String testPointUri = testPoint.getServerUrl() + testPoint.getPath();
Response response = init().baseUri( testPointUri ).accept( JSON ).when().request( GET );
this.rspEntity = response.getBody().asInputStream();
validateConformanceOperationResponse( testPointUri, response );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class GeneralHttp extends CommonFixture {
@Test(description = "Implements A.2.1.1. HTTP, Abstract Test 1 (Requirement /req/core/http)")
public void testHttp() {
Response response = init().baseUri( rootUri.toString() ).when().request( GET, "/" );
this.rspEntity = response.getBody().asInputStream();
response.then().statusLine( containsString( "HTTP/1.1" ) );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,9 @@ public void testJobList() {
HttpResponse httpResponse = client.execute(request);
StringWriter writer = new StringWriter();
String encoding = StandardCharsets.UTF_8.name();
IOUtils.copy(httpResponse.getEntity().getContent(), writer, encoding);
String responsePayload = writer.toString();
IOUtils.copy(httpResponse.getEntity().getContent(), writer, encoding);
String responsePayload = writer.toString();
this.rspEntity = responsePayload;
JsonNode responseNode = new ObjectMapper().readTree(responsePayload);
ArrayNode arrayNode = (ArrayNode) responseNode.get("jobs");
Assert.assertTrue(arrayNode.size()>0,"No processes listed at "+getJobListURL.toString());
Expand Down Expand Up @@ -156,6 +157,7 @@ public void testJobListSuccess() {
String encoding = StandardCharsets.UTF_8.name();
IOUtils.copy(httpResponse.getEntity().getContent(), writer, encoding);
String responsePayload = writer.toString();
this.rspEntity = responsePayload;
JsonNode responseNode = new ObjectMapper().readTree(responsePayload);
Body body = Body.from(responseNode);
Header contentType = httpResponse.getFirstHeader(CONTENT_TYPE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,7 @@ public void testJobCreationInputRef() {
}

String responsePayload = writer.toString();
this.rspEntity = responsePayload;

if(!responsePayload.contains("Content-Type: multipart/related")) {
JsonNode responseNode = null;
Expand Down Expand Up @@ -954,6 +955,7 @@ public void testJobCreationInputValidation() {

httpResponse = sendPostRequestSync(executeNode);
responsePayload = parseRawResponse(httpResponse);
this.rspEntity = responsePayload;

}
catch(Exception ee)
Expand Down Expand Up @@ -1001,6 +1003,7 @@ public void testJobCreationInputValidation() {
StringWriter writer = new StringWriter();
String encoding = StandardCharsets.UTF_8.name();
IOUtils.copy(httpResponse.getEntity().getContent(), writer, encoding);
this.rspEntity = writer.toString();
JsonNode responseNode = new ObjectMapper().readTree(writer.toString());
Body body = Body.from(responseNode);
responseContentType = httpResponse.getFirstHeader(CONTENT_TYPE);
Expand Down Expand Up @@ -1317,6 +1320,7 @@ private JsonNode parseResponse(HttpResponse httpResponse) throws IOException {
StringWriter writer = new StringWriter();
String encoding = StandardCharsets.UTF_8.name();
IOUtils.copy(httpResponse.getEntity().getContent(), writer, encoding);
this.rspEntity = writer.toString();
return new ObjectMapper().readTree(writer.toString());
}

Expand Down Expand Up @@ -1422,6 +1426,7 @@ private void validateMultipartResponse(String responsePayload, JsonNode executeN

boolean multipartIsValid = true;
String errorMessage = "";
this.rspEntity = responsePayload;

try {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ public void testOGCProcessDescriptionJSON() {
StringWriter writer2 = new StringWriter();
String encoding2 = StandardCharsets.UTF_8.name();
IOUtils.copy(httpResponse2.getEntity().getContent(), writer2, encoding2);
this.rspEntity = (this.rspEntity == null ? "" : this.rspEntity) + "\n" + writer2.toString();
JsonNode responseNode2 = new ObjectMapper().readTree(writer2.toString());
Body body2 = Body.from(responseNode2);
Header contentType2 = httpResponse2.getFirstHeader(CONTENT_TYPE);
Expand All @@ -145,6 +146,7 @@ public void testOGCProcessDescriptionJSON() {
StringWriter writer2 = new StringWriter();
String encoding2 = StandardCharsets.UTF_8.name();
IOUtils.copy(httpResponse2.getEntity().getContent(), writer2, encoding2);
this.rspEntity = writer2.toString();
JsonNode responseNode2 = new ObjectMapper().readTree(writer2.toString());
Body body2 = Body.from(responseNode2);
Header contentType2 = httpResponse2.getFirstHeader(CONTENT_TYPE);
Expand Down Expand Up @@ -192,6 +194,7 @@ public void testOGCProcessDescriptionInputsDef() {
StringWriter writer = new StringWriter();
String encoding = StandardCharsets.UTF_8.name();
IOUtils.copy(httpResponse.getEntity().getContent(), writer, encoding);
this.rspEntity = writer.toString();
JsonNode responseNode = new ObjectMapper().readTree(writer.toString());
JsonNode processesNode = responseNode.get("processes");
if(processesNode.isArray()) {
Expand Down Expand Up @@ -246,6 +249,7 @@ public void testOGCProcessDescriptionInputDef() {
StringWriter writer = new StringWriter();
String encoding = StandardCharsets.UTF_8.name();
IOUtils.copy(httpResponse.getEntity().getContent(), writer, encoding);
this.rspEntity = writer.toString();
JsonNode responseNode = new ObjectMapper().readTree(writer.toString());
JsonNode processesNode = responseNode.get("processes");
if(processesNode.isArray()) {
Expand Down Expand Up @@ -303,6 +307,7 @@ public void testOGCProcessDescriptionInputDefinitionOfMixedType() {
StringWriter writer = new StringWriter();
String encoding = StandardCharsets.UTF_8.name();
IOUtils.copy(httpResponse.getEntity().getContent(), writer, encoding);
this.rspEntity = writer.toString();
JsonNode responseNode = new ObjectMapper().readTree(writer.toString());
JsonNode processesNode = responseNode.get("processes");
if(processesNode.isArray()) {
Expand Down Expand Up @@ -361,6 +366,7 @@ public void testOGCProcessDescriptionOutputsDef() {
StringWriter writer = new StringWriter();
String encoding = StandardCharsets.UTF_8.name();
IOUtils.copy(httpResponse.getEntity().getContent(), writer, encoding);
this.rspEntity = writer.toString();
JsonNode responseNode = new ObjectMapper().readTree(writer.toString());
JsonNode processesNode = responseNode.get("processes");
if(processesNode.isArray()) {
Expand Down Expand Up @@ -415,6 +421,7 @@ public void testOGCProcessDescriptionOutputDef() {
StringWriter writer = new StringWriter();
String encoding = StandardCharsets.UTF_8.name();
IOUtils.copy(httpResponse.getEntity().getContent(), writer, encoding);
this.rspEntity = writer.toString();
JsonNode responseNode = new ObjectMapper().readTree(writer.toString());
JsonNode processesNode = responseNode.get("processes");
if(processesNode.isArray()) {
Expand Down Expand Up @@ -472,6 +479,7 @@ public void testOGCProcessDescriptionOutputDefinitionOfMixedType() {
StringWriter writer = new StringWriter();
String encoding = StandardCharsets.UTF_8.name();
IOUtils.copy(httpResponse.getEntity().getContent(), writer, encoding);
this.rspEntity = writer.toString();
JsonNode responseNode = new ObjectMapper().readTree(writer.toString());
JsonNode processesNode = responseNode.get("processes");
if(processesNode.isArray()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public void testProcessExceptionNoSuchProcess() {
StringWriter writer = new StringWriter();
String encoding = StandardCharsets.UTF_8.name();
IOUtils.copy(httpResponse.getEntity().getContent(), writer, encoding);
this.rspEntity = writer.toString();
JsonNode responseNode = new ObjectMapper().readTree(writer.toString());
Body body = Body.from(responseNode);
Header contentType = httpResponse.getFirstHeader(CONTENT_TYPE);
Expand Down Expand Up @@ -153,6 +154,7 @@ public void testProcess() {
StringWriter writer = new StringWriter();
String encoding = StandardCharsets.UTF_8.name();
IOUtils.copy(httpResponse.getEntity().getContent(), writer, encoding);
this.rspEntity = writer.toString();
JsonNode responseNode = new ObjectMapper().readTree(writer.toString());
Body body = Body.from(responseNode);
Header contentType = httpResponse.getFirstHeader(CONTENT_TYPE);
Expand Down Expand Up @@ -199,6 +201,7 @@ public void testProcessSuccess() {
StringWriter writer = new StringWriter();
String encoding = StandardCharsets.UTF_8.name();
IOUtils.copy(httpResponse.getEntity().getContent(), writer, encoding);
this.rspEntity = writer.toString();
JsonNode responseNode = new ObjectMapper().readTree(writer.toString());
Body body = Body.from(responseNode);
Header contentType = httpResponse.getFirstHeader(CONTENT_TYPE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ public void testPlLimitResponse() {
StringWriter writer = new StringWriter();
String encoding = StandardCharsets.UTF_8.name();
IOUtils.copy(httpResponse.getEntity().getContent(), writer, encoding);
this.rspEntity = writer.toString();
JsonNode responseNode = new ObjectMapper().readTree(writer.toString());
JsonNode processesNode = responseNode.get("processes");
if(!(processesNode instanceof ArrayNode)) {
Expand Down Expand Up @@ -160,6 +161,7 @@ public void testPlLinks() {
StringWriter writer = new StringWriter();
String encoding = StandardCharsets.UTF_8.name();
IOUtils.copy(httpResponse.getEntity().getContent(), writer, encoding);
this.rspEntity = writer.toString();
JsonNode responseNode = new ObjectMapper().readTree(writer.toString());
JsonNode linksNode = responseNode.get("links");
if(!(linksNode instanceof ArrayNode)) {
Expand Down Expand Up @@ -197,7 +199,8 @@ public void testProcessList() {
HttpResponse httpResponse = client.execute(request);
StringWriter writer = new StringWriter();
String encoding = StandardCharsets.UTF_8.name();
IOUtils.copy(httpResponse.getEntity().getContent(), writer, encoding);
IOUtils.copy(httpResponse.getEntity().getContent(), writer, encoding);
this.rspEntity = writer.toString();
String responsePayload = writer.toString();
JsonNode responseNode = new ObjectMapper().readTree(responsePayload);
ArrayNode arrayNode = (ArrayNode) responseNode.get("processes");
Expand Down Expand Up @@ -241,6 +244,7 @@ public void testProcessListSuccess() {
StringWriter writer = new StringWriter();
String encoding = StandardCharsets.UTF_8.name();
IOUtils.copy(httpResponse.getEntity().getContent(), writer, encoding);
this.rspEntity = writer.toString();
String responsePayload = writer.toString();
JsonNode responseNode = new ObjectMapper().readTree(responsePayload);
Body body = Body.from(responseNode);
Expand Down

0 comments on commit 0f014f2

Please sign in to comment.