I am seeing this too and can't get SoapUI to pass a test for given header for a given string value:
Script Input:
log.info "messageExchange.responseHeaders(Content-Type)="
log.info messageExchange.responseHeaders["Content-Type"]
log.info "messageExchange.getResponseHeaders().get(Content-Type)="
log.info messageExchange.getResponseHeaders().get("Content-Type")
assert messageExchange.responseHeaders["Content-Type"].equals("[image/jpeg]")
Output shows the brackets using either method:
- Mon Dec 21 14:22:16 MST 2015:INFO:messageExchange.responseHeaders(Content-Type)=
- Mon Dec 21 14:22:16 MST 2015:INFO:[image/jpeg]
- Mon Dec 21 14:22:16 MST 2015:INFO:messageExchange.getResponseHeaders().get(Content-Type)=
- Mon Dec 21 14:22:16 MST 2015:INFO:[image/jpeg]
The assert fails with this message:
assert messageExchange.responseHeaders["Content-Type"].equals("[image/jpeg]") | | | | | | [image/jpeg] false | [X-ORCHESTRATE-REQ-ID:[f9a4ddb0-a811-11e5-b81b-000c29cce2b5], Orchestrate-Destination-Host:[api.ctl-uc1-a.orchestrate.io], ETag:["2219eba0b33107f398c81e8808e2f5a2e6212a4e-gzip"], Vary:[Accept-Encoding], Transfer-Encoding:[chunked], Date:[Mon, 21 Dec 2015 18:38:06 GMT], #status#:[HTTP/1.1 200 OK], Last-Modified:[Mon, 21 Dec 2015 18:36:48 GMT], Content-Encoding:[gzip], Content-Location:[/v0/media/keyHagar/refs/2219eba0b33107f398c81e8808e2f5a2e6212a4e], Orchestrate-Source-Host:[api.ctl-va1-a.orchestrate.io], Connection:[keep-alive], Content-Type:[image/jpeg], Server:[nginx]] com.eviware.soapui.impl.wsdl.teststeps.RestResponseMessageExchange@75b8d2ca
I also tried these asserts
assert messageExchange.responseHeaders["Content-Type"].equals("image/jpeg")
assert messageExchange.responseHeaders["Content-Type"].equals("/[image/jpeg/]")
assert messageExchange.responseHeaders["Content-Type"].equals("/[image//jpeg/]")
assert messageExchange.responseHeaders["Content-Type"].equals("\[image/jpeg\]")
All give a similar error messages.
How do I test a specific header for a specific value?
Testing for != null passes:
assert messageExchange.responseHeaders["Content-Type"] != null
but not testing for a specific string.
Thanks in advance!