Forum Discussion
JHunt
7 years agoCommunity Hero
OK, I discovered that the Contains assertion uses
content.matches(replToken)
i.e. java's String.matches(String), and the default RegEx behaviour for Java is different to Groovy:
String content = '''
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:sam="http://www.soapui.org/sample/"> <soapenv:Header/> <soapenv:Body> <sam:buyResponse> <sam:buyResponseContent> <purchasestatus> <rte>100</rte> <stockStatus>?</stockStatus> <expectedDelivery>?</expectedDelivery> </purchasestatus> </sam:buyResponseContent> </sam:buyResponse> </soapenv:Body> </soapenv:Envelope>''' String replToken = /.*rte.*/ "java: ${content.matches(replToken)}, groovy: ${(content =~ replToken).find()}"
java: false, groovy: true
The difference is in whether . matches to newline character. You can specify that it should in your Regex with (?s):
String replToken = /(?s).*rte.*/ "java: ${content.matches(replToken)}, groovy: ${(content =~ replToken).find()}"
java: true, groovy: true
Remember to write a pattern that matches to the whole response.
Related Content
- 7 years ago
Recent Discussions
- 3 days ago