Frage

My method is:

def client = new SOAPClient("http://...")
def response = client.send(
    """<?xml version='1.0' encoding='UTF-8'?>
       <soap-env:Envelope xmlns:SOAP='http://schemas.xmlsoap.org/soap/envelope/'>
           <soap-env:Body>
               <GetFoo>bar</GetFoo>
           </soap-env:Body>
       </soap-env:Envelope>"""
)
return response.httpResponse.statusCode

SOAPClient is a plugin for Grails.

So in my unit test, how can I mock SOAPClient and its send method?

War es hilfreich?

Lösung

def client = Mock(SOAPClient)
client.send(_) >> response

Of course you need to create desired response object first.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top