From 653f7338874bf96163839901f7b24cb8a6ab5601 Mon Sep 17 00:00:00 2001 From: Tom Page Date: Thu, 16 Mar 2023 14:07:33 +0000 Subject: [PATCH] APPS-1593 Only load the response content if we need it. --- .../src/main/java/org/alfresco/rest/core/v0/BaseAPI.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/amps/ags/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/v0/BaseAPI.java b/amps/ags/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/v0/BaseAPI.java index e205e935e1..d45a8748fb 100644 --- a/amps/ags/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/v0/BaseAPI.java +++ b/amps/ags/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/v0/BaseAPI.java @@ -512,7 +512,12 @@ public abstract class BaseAPI try { HttpResponse httpResponse = doRequestJson(HttpPost.class, requestUrl, adminUser, adminPassword, requestParams); - assertEquals("POST request to " + requestUrl + " was not successful. Response: " + responseBodyToJson(httpResponse), expectedStatusCode, httpResponse.getStatusLine().getStatusCode()); + if (httpResponse.getStatusLine().getStatusCode() != expectedStatusCode) + { + // It's only possible to stream the response body once, so ensure we only do this if the test has failed. + JSONObject responseJson = responseBodyToJson(httpResponse); + assertEquals("POST request to " + requestUrl + " was not successful. Response: " + responseJson, expectedStatusCode, httpResponse.getStatusLine().getStatusCode()); + } return httpResponse; } catch (InstantiationException | IllegalAccessException error)