Forum Discussion

MikeGatward's avatar
MikeGatward
Occasional Contributor
8 years ago

Event to remove CDATA from response

So - the service I am testing returns its relevant data in a CDATA wrapper. I created an event to remove the CDATA wrapper so that I can assert against xml fields.

 

It works fine but when my tests are in a Datasource Loop, the event only runs within the loop if I send a request first.

 

It's annoying that I've a mass of regression tests to run but I have so send the request once before I can kick off the loop

 

Any ideas ?

 

Event is a SubmitListener.afterSubmit abd contains:

 

if( submit.response == null )
   return
def responseContent = submit.response.responseContent
responseContent = responseContent.replaceAll( "<!\\[CDATA\\[", "")
responseContent = responseContent.replaceAll( "]]>", "" )
responseContent = responseContent.replace( '<?xml version="1.0" encoding="UTF-8"?>',"" )


log.info( responseContent )
submit.response.responseContent =  responseContent