use of com.axway.ats.agent.core.templateactions.model.objects.ActionParser in project ats-framework by Axway.
the class Test_HttpClient method httpMessage.
private void httpMessage(String contentType, String contentEncoding, String downloadFileExtension) throws Exception {
resolveActionName(true);
// construct the fake client
MockHttpURLConnection mockHttpURLConnection = new MockHttpURLConnection();
String expectedResponseFile = mockHttpURLConnection.setFakeInputStream(TEST_ACTIONS_HOME, actionName + "_response.bin");
mockHttpURLConnection.setFakeContentType(contentType);
mockHttpURLConnection.setFakeContentEncoding(contentEncoding);
HttpClient client = getHttpClient(mockHttpURLConnection);
XmlUtilities xmlUtilities = new XmlUtilities();
String downloadsFolder = getDownloadsFolder();
/*Node actualResponseNode = xmlUtilities.readActionResponse( client, true, downloadsFolder + actionName
+ ".xml", 1, false );
String actualResponseBody = xmlUtilities.xmlToString( actualResponseNode );*/
ActionParser actionParser = xmlUtilities.readActionResponse(client, downloadsFolder + actionName + ".xml", 1, false);
Node actualResponseNode = actionParser.getActionNodeWithoutBody();
String actualResponseBody = xmlUtilities.xmlNodeToString(actualResponseNode);
actualResponseBody = actualResponseBody.replace("<HTTP_RESPONSE>", "").replace("</HTTP_RESPONSE>", "").trim();
String expectedResponseBody = readFileLineByLine(TEST_ACTIONS_HOME + actionName + "_response.xml");
verifyResponseMatch(expectedResponseBody, actualResponseBody, "response body", "response bodies");
verifyDownloadedFileMatch(expectedResponseFile, downloadsFolder + actionName + "/actual/" + Thread.currentThread().getName() + "/HTTP_FILE_1." + downloadFileExtension);
}
Aggregations