Forum Discussion
nmrao
Champion Level 1
12 years agoDo you get the response in multiple formats for the same request? How do you tell in which format response is expected? I haven't seen such as so far, interesting.
May be you can have script assertion, and check the response is xml.
Here is some sample script to check :
Hope this helps.
Regards,
Rao.
May be you can have script assertion, and check the response is xml.
Here is some sample script to check :
import groovy.xml.*
def xml = '''
<books xmlns:meta="http://meta/book/info" count="3">
<book id="1">
<title lang="en">Groovy in Action</title>
<meta:isbn>1-932394-84-2</meta:isbn>
</book>
<book id="2">
<title lang="en">Groovy Programming</title>
<meta:isbn>0123725070</meta:isbn>
</book>
<book id="3">
<title>Groovy & Grails</title>
<!--Not yet available.-->
</book>
<book id="4">
<title>Griffon Guide</title>
</book>
</books>
'''
def books = new XmlSlurper().parseText(xml).declareNamespace([meta:'http://meta/book/info'])
assert books instanceof groovy.util.slurpersupport.GPathResult
Hope this helps.
Regards,
Rao.