Search in sources :

Example 6 with ActionParser

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);
}
Also used : ActionParser(com.axway.ats.agent.core.templateactions.model.objects.ActionParser) Node(org.w3c.dom.Node)

Aggregations

ActionParser (com.axway.ats.agent.core.templateactions.model.objects.ActionParser)6 Node (org.w3c.dom.Node)4 ArrayList (java.util.ArrayList)3 TemplateActionsResponseVerificationConfigurator (com.axway.ats.agent.core.configuration.TemplateActionsResponseVerificationConfigurator)2 TemplateActionsBaseTest (com.axway.ats.agent.core.templateactions.TemplateActionsBaseTest)2 HashMap (java.util.HashMap)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 Test (org.junit.Test)2 ActionExecutionException (com.axway.ats.agent.core.exceptions.ActionExecutionException)1 CompositeResult (com.axway.ats.agent.core.templateactions.CompositeResult)1 XmlUtilitiesException (com.axway.ats.agent.core.templateactions.exceptions.XmlUtilitiesException)1 HttpClient (com.axway.ats.agent.core.templateactions.model.HttpClient)1 XmlReader (com.axway.ats.agent.core.templateactions.model.XmlReader)1 XmlUtilities (com.axway.ats.agent.core.templateactions.model.XmlUtilities)1 HeaderMatcher (com.axway.ats.agent.core.templateactions.model.matchers.HeaderMatcher)1 ResponseMatcher (com.axway.ats.agent.core.templateactions.model.matchers.ResponseMatcher)1 XPathBodyMatcher (com.axway.ats.agent.core.templateactions.model.matchers.XPathBodyMatcher)1 ActionHeader (com.axway.ats.agent.core.templateactions.model.objects.ActionHeader)1 ActionResponseObject (com.axway.ats.agent.core.templateactions.model.objects.ActionResponseObject)1