advanced assertions in soapui presented by kushan athukorala
TRANSCRIPT
![Page 1: Advanced Assertions in soapUI Presented by Kushan Athukorala](https://reader036.vdocuments.mx/reader036/viewer/2022082711/56649f305503460f94c4b738/html5/thumbnails/1.jpg)
Advanced Assertions in soapUI
Presented by Kushan Athukorala
![Page 2: Advanced Assertions in soapUI Presented by Kushan Athukorala](https://reader036.vdocuments.mx/reader036/viewer/2022082711/56649f305503460f94c4b738/html5/thumbnails/2.jpg)
2
Agenda
• XPath Match Assertion• XQuery Match Asserion• Script Assertions• WS-Addressing Response Assertion• WS-Addressing Request Assertion
![Page 3: Advanced Assertions in soapUI Presented by Kushan Athukorala](https://reader036.vdocuments.mx/reader036/viewer/2022082711/56649f305503460f94c4b738/html5/thumbnails/3.jpg)
3
XPath Match Assertion
• Study XPath First
![Page 4: Advanced Assertions in soapUI Presented by Kushan Athukorala](https://reader036.vdocuments.mx/reader036/viewer/2022082711/56649f305503460f94c4b738/html5/thumbnails/4.jpg)
4
XPath Match Assertion
• The XPath Match assertion allows specification of an XPath expression to be evaluated against the received response message and compare its result to a predefined value.
• Expressions can select everything from attribute values, make Boolean evaluations or select the entire response body.
• XmlUnit is used internally for comparing xml elements, nodes or hierarchies
![Page 5: Advanced Assertions in soapUI Presented by Kushan Athukorala](https://reader036.vdocuments.mx/reader036/viewer/2022082711/56649f305503460f94c4b738/html5/thumbnails/5.jpg)
5
XPath Assertion Examples
• Example1 - Validate that the result contains how many hits• declare namespace ns1='http://webservices.amazon.com/AWSECommerceService/2005-07-26';
count(//ns1:Item)
• Example2 - Validate that the ProductGroup element always is "Book“• declare namespace ns1='http://webservices.amazon.com/AWSECommerceService/2005-07-26';
count(//ns1:ProductGroup[text()!='Book'])
• Example3 -Validate that DetailPageURL always starts with 'http://www.amazon.com/exec/obidos':• declare namespace ns1='http://webservices.amazon.com/AWSECommerceService/2005-07-26';
count(//ns1:DetailPageURL) = count(//ns1:DetailPageURL[starts-with(text(), 'http://www.amazon.com/exec/obidos')])
![Page 6: Advanced Assertions in soapUI Presented by Kushan Athukorala](https://reader036.vdocuments.mx/reader036/viewer/2022082711/56649f305503460f94c4b738/html5/thumbnails/6.jpg)
6
XQuery Match Assertion
• Study XQuery First
![Page 7: Advanced Assertions in soapUI Presented by Kushan Athukorala](https://reader036.vdocuments.mx/reader036/viewer/2022082711/56649f305503460f94c4b738/html5/thumbnails/7.jpg)
7
XQuery Match Assertion
• The XQuery Match assertions is configured exactly like the XPath Math assertion described above.
• Difference being that the specified expression is evaluated as an XQuery expression instead
• This assertion is useful when you want to assert a subset of your data and for example not be dependent on other data, the data order, etc
![Page 8: Advanced Assertions in soapUI Presented by Kushan Athukorala](https://reader036.vdocuments.mx/reader036/viewer/2022082711/56649f305503460f94c4b738/html5/thumbnails/8.jpg)
8
Script Assertion – Using Groovy script editor
• Script Assertion allows for arbitrary validations • Script has access to the following objects:
• messageExchange : Message Exchange for the current request/response. Gives direct access to message content, HTTP Headers, Attachments, etc.
• context : TestRunContext running the current TestCase, this will for now always be an instance of WsdlTestRunContext
• log : a standard log4j Logger object available for logging arbitrary information
![Page 9: Advanced Assertions in soapUI Presented by Kushan Athukorala](https://reader036.vdocuments.mx/reader036/viewer/2022082711/56649f305503460f94c4b738/html5/thumbnails/9.jpg)
9
Examples
• Validate a certain response time• assert messageExchange.timeTaken < 400
• Validate existence of a response HTTP Header• assert messageExchange.responseHeaders["x-amz-id-1"] != null
• Validate the existence of a specific element using GroovyUtils• def groovyUtils = new
com.eviware.soapui.support.GroovyUtils( context ) def holder = groovyUtils.getXmlHolder( messageExchange.responseContent ) assert holder["//ns1:RequestId"] != null
![Page 10: Advanced Assertions in soapUI Presented by Kushan Athukorala](https://reader036.vdocuments.mx/reader036/viewer/2022082711/56649f305503460f94c4b738/html5/thumbnails/10.jpg)
10
WS-Addressing Response Assertion
• Validates that the response has valid WS-A header properties.
![Page 11: Advanced Assertions in soapUI Presented by Kushan Athukorala](https://reader036.vdocuments.mx/reader036/viewer/2022082711/56649f305503460f94c4b738/html5/thumbnails/11.jpg)
11
WS-Addressing Request Assertion
• Validates that the request has valid WS-A header properties
![Page 12: Advanced Assertions in soapUI Presented by Kushan Athukorala](https://reader036.vdocuments.mx/reader036/viewer/2022082711/56649f305503460f94c4b738/html5/thumbnails/12.jpg)
12
Thank You
![Page 13: Advanced Assertions in soapUI Presented by Kushan Athukorala](https://reader036.vdocuments.mx/reader036/viewer/2022082711/56649f305503460f94c4b738/html5/thumbnails/13.jpg)
13
USA INDIA SRILANKA UK
www.virtusa.com
© V I r t u s a C o r p o r a t i o n
"Virtusa" is a trademark of the company and a registered trademark in the EU and In India. "Productization" is a service mark of the company and a registered service mark in the United States.
"vRule" is a service mark of the company.
For more information please contact [email protected]