Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

How to perform assertion on XML response having CDATA

LegacyForum
LegacyForum Posts: 1,664 ✭✭
edited December 2016 in SOAtest
Performing asserions on CDATA Block.
Hello,

I have an XML response as below:

<soap-env:Body>
<SabreCommandLLSRS
AltLangID="en-us" EchoToken="String" PrimaryLangID="en-us"
SequenceNmbr="1" Target="Production" TimeStamp="2012-04-03T04:07:08"
Version="2003A.TsabreXML1.6.1" xmlns="http://webservices.sabre.com/sabreXML/2003/07"&gt;
<Response><![CDATA[GNT:SCLZAK EMP:682606 CTY:SCL STA:89940001 03APR12/0106A
SALES SUMMARY REPORT FOR 03APR12
-------------------------------------------------------------
SEQ TKT NUMBER FOP FARE TAX TTL TIME

00012 TWENTYSEVEN/SETH PNR-HQOZTQ BEC33E
E 0452100577531
ET CLP 373694 28294 401988 1254A
XX CLP 259312 0 259312
XX CLP 17261 15155 32416
00013 TWENTYSEVEN/SETH PNR-HQOAMU BEC33E
E 0452100579346
CA CLP 373694 28294 401988 1256A
00014 TWENTYSEVEN/SETH PNR-HQOAMU BEC33E
E 0452100577535
ET CLP 373694 28294 401988 1256A
XX CLP 259312 0 259312
XX CLP 17261 15155 32416
00015 TWENTYSEVEN/SETH PNR-IKHUNK BEC33E
E 0452100579365
CA CLP 373694 28294 401988 0106A
00016 TWENTYSEVEN/SETH PNR-IKHUNK BEC33E
E 0452100575958
ET CLP 373694 28294 401988 0106A
XX CLP 259312 0 259312
XX CLP 17261 15155 32416


*** TOTAL DAILY SALES CASH/CHECK AMOUNT CREDIT AMOUNT
CLP 3215904 3215904 0
ET 3215904
XX 2333824

END OF REPORT ]]></Response>
</SabreCommandLLSRS>
</soap-env:Body>
</soap-env:Envelope>

Where in my Data bank I have:
Lineone: TWENTYSEVEN/SETH PNR-IKHUNK BEC33E
LineTwo: E 0452100575958
LineThree: ET CLP 373694 28294 401988
LineFour: XX CLP 259312 0 259312
LineFive: XX CLP 17261 15155 32416

NO MATTER, which Assertions I use, It only checks the first Line 'GNT:SCLZAK EMP:682606 CTY:SCL STA:89940001 03APR12/0106A' & Fails.

How can I go through the entire CDATA Block to look for all these Databank values.. also need to have an AND Operation, because all need to exist for the Test case to pass..

Please HELP....

Comments

  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    If you want to match part of an element value, then create in an XML Assertor a String Comparison Assertion and use the option to check that "Element must contain" (instead of, for example, "Element must equal" to match the entire string). For the expected value, you can use a parameterized value, such as your "Lineone" variable.

    If you want to verify that each of your five values occurs in the element, you will need to create five assertions, each identical except with a different parameterized expected value.

    You can use a simple XPath: //*:Response

    You do not need to explicitly create an AND assertion: the XML Assertor fails if any one of its assertions fails.

    The use of CDATA in your XML should not make a difference when evaluating XPath: CDATA just provides you with an easier way to write out your XML.