advanced assertions in soapui presented by kushan athukorala

13
Advanced Assertions in soapUI Presented by Kushan Athukorala

Upload: rudolf-burke

Post on 05-Jan-2016

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Advanced Assertions in soapUI Presented by Kushan Athukorala

Advanced Assertions in soapUI

Presented by Kushan Athukorala

Page 2: Advanced Assertions in soapUI Presented by Kushan Athukorala

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

3

XPath Match Assertion

• Study XPath First

Page 4: Advanced Assertions in soapUI Presented by Kushan Athukorala

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

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

6

XQuery Match Assertion

• Study XQuery First

Page 7: Advanced Assertions in soapUI Presented by Kushan Athukorala

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

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

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

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

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

12

Thank You

Page 13: Advanced Assertions in soapUI Presented by Kushan Athukorala

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]