Forum Discussion

Penny404's avatar
12 years ago

Assertions for null values

Hi, I was wondering if anyone could help me out on assertions for null values (soap 4.6.1)..

I am getting an xml response back which is null (the colour of the car was entering in the request) -

<car>
<details>
<make>Ford</make>
<model>Mustang</model>
<colour null="true"/>
</details>
</car>


How can i assert that the colour attribute is being returned, but the value is NULL.

Currently i am using this xpath match assertion.. but i dont think this is the best approach, (if i make a typo in the path it will still 'pass')

concat(//*:car/*:details/*:colour,"")

If anyone can help me out, that would be great.

thanks
Capgemini is a trading name used by the Capgemini Group of companies which includes Capgemini UK plc, a company registered in England and Wales (number 943935) whose registered office is at No. 1 Forge End, Woking, Surrey, GU21 6DB. This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.

1 Reply

  • SiKing's avatar
    SiKing
    Community Expert
    So first thing you need to realize is that in XML there are no nulls, everything is a string.

    To test for your example, that the element colour contains an attribute called null that as a value of true, you could use something like:
    //*:colour/@null
    and compare that with the string "true".
    Alternatively you could verify the element colour is empty, using something like:
    empty(//*:colour)
    and compare that against true.