开发者

How to add assertion for HTTP 204 content in REST

开发者 https://www.devze.com 2023-03-12 06:33 出处:网络
When I run the REST request, my response is 开发者_如何学Python HTTP/1.1 204 No Content Date: Fri, 01 Oct 2010 17:18:11 GMT

When I run the REST request, my response is 开发者_如何学Python

HTTP/1.1 204 No Content Date: Fri, 01 Oct 2010 17:18:11 GMT X-Response-ID: 10016

How to verify this? Because it is header i guess. How to add assertion for this? When i decloare


You can use the method messageExchange.responseHeaders[field] to access the HTTP header fields like #status*, Content-Type, Accept etc.

def http_status = messageExchange.responseHeaders["#status#"][0]
assert http_status.contains("204")


import com.eviware.soapui.support.XmlHolder

def holder = new XmlHolder( messageExchange.responseContentAsXml )
def node = holder.getDomNode( "//data[1]/@contentType" )

assert node != null
assert((com.eviware.soapui.support.types.StringList)messageExchange.responseHeaders["#status#"]).containsValue("HTTP/1.1 204 No Content")
0

精彩评论

暂无评论...
验证码 换一张
取 消