HsacAcceptanceTests.SlimTests.HttpTest.JsonHttpTest


variable defined: jsonToTest=!-{ "airplanes": [{ "id": "001", "type": "747", "brand": "Boeing", "seats": "400", "airline": "KLM" }, { "id": "002", "type": "737", "brand": "Boeing", "seats": "400", "airline": "Virgin" }] } -!

script mock xml server setup localhost 7000-9000 /mock
add response { "airplanes": [{ "id": "001", "type": "747", "brand": "Boeing", "seats": "400", "airline": "KLM" }, { "id": "002", "type": "737", "brand": "Boeing", "seats": "400", "airline": "Virgin" }] }
add response Broken with status 500
$url<-[http://127.0.0.1:7000/mock] get mock server url

script json http test
get from $url->[http://127.0.0.1:7000/mock]
check json path count airplanes[*] 2
check json path airplanes.length() 2
show all json path matches airplanes[*].airline
  • KLM
  • Virgin
check all json path matches airplanes[*].airline /.*KLM.*Virgin.*/ found in: <div><ul><li>KLM</li><li>Virgin</li></ul></div>
check json path airplanes[0].seats 400
check element 0 of json path airplanes[?(@.airline=='KLM')].type 747
set json path airplanes[0].seats to 300
check json path airplanes[0].seats 300
ensure json path exists airplanes[0].seats
reject json path exists airplanes[0].beds
ensure json path exists airplanes[*].airline
reject json path exists airplanes[*].beds
show response
{"airplanes": [
    {
        "id": "001",
        "type": "747",
        "airline": "KLM",
        "brand": "Boeing",
        "seats": "300"
    },
    {
        "id": "002",
        "type": "737",
        "airline": "Virgin",
        "brand": "Boeing",
        "seats": "400"
    }
]}

And now a call which returns an error status code.

script
reject get from $url->[http://127.0.0.1:7000/mock]
check response status 500
check response Broken

script mock xml server setup /mock
stop