Forum Discussion

Mason's avatar
Mason
Frequent Contributor
15 years ago

Inconsistent behavior with property expansion in xQuery assertions

We're trying to figure out why in some cases, SoapUI will throw exceptions on some properties that are not encased in single-quotes while other properties do not require single-quotes.

Here is an xQuery assert declaration that will cause an exception or will return an empty result set when attempting to select:

declare namespace ns2='http://pat.ws.aab.att.com/webService/Subscriber';
declare namespace ns3='http://pat.ws.aab.att.com/webService/Contact';
<result>
{
for $z in //ns3:IM[ns3:IM = ${#TestSuite#myInfo.im0.IM}]/ns3:type/text()
order by $z
return <type>{data($z)}</type>
}
</result>


But if we run the same assertion with single quotes, it will proceed normally.

declare namespace ns2='http://pat.ws.aab.att.com/webService/Subscriber';
declare namespace ns3='http://pat.ws.aab.att.com/webService/Contact';
<result>
{
for $z in //ns3:IM[ns3:IM = '${#TestSuite#myInfo.im0.IM}']/ns3:type/text()
order by $z
return <type>{data($z)}</type>
}
</result>


We have another assert that will work with or without the single quotes.

declare namespace ns2='http://pat.ws.aab.att.com/webService/Subscriber';
declare namespace ns3='http://pat.ws.aab.att.com/webService/Contact';
<result>
{
for $z in //ns3:phone[ns3:number = ${#TestSuite#myInfo.phone0.number}]/ns3:type/text()
order by $z
return <type>{data($z)}</type>
}
</result>
 

So, 2 questions. 

1)  What might account for this inconsistency? 

2)  Also, shouldn't SoapUI catch this exception and perhaps tell the user "why" (if possible) the syntax is wrong or if the property expands to null?

EDIT:  Forgot to mention the error description (this is when the property is null):

"XQuery Match Assertion failed for path [declare namespace ns2='http://pat.ws.aab.att.com/webService/Subscriber'; declare namespace ns3='http://pat.ws.aab.att.com/webService/Contact';  { for $z in //ns3:IM[ns3:IM = ${#TestSuite#myInfo.im0.IM}]/ns3:type/text() order by $z return  {data($z)}  }  ] : RuntimeException:java.lang.reflect.InvocationTargetException"

5 Replies

  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi!

    it seems to me the property is not getting expanded at all, since the error message contains the property-expansion instead of the replaced value (which would be an empty string if not found). Does the expansion seem to work in other scenarios?

    regards,

    /Ole
    eviware.com
  • Mason's avatar
    Mason
    Frequent Contributor
    We are asking why some property-expansions require single-quotes and others don't.  We are working around this by enclosing all property-expansion strings in single quotes.

    Also, we are hoping for better exception handling in this area.  The errors that trip on bad syntax or null properties aren't very descriptive.
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi!

    ok.. could it be that those properties that evaluate to numbers work without quotes?

    I'll put in a ticket on the improved error messages, thanks!

    /Ole
    eviware.com
  • Mason's avatar
    Mason
    Frequent Contributor
    I forgot to mention one very important point:  The exception is thrown when you click "select from current" or the "Test" button from the XQuery assertion dialog.
  • shamane2000's avatar
    shamane2000
    Occasional Contributor

    I am also interested in the Question 2)

    Why aren't Exeptions in Assertions handled?

     

    Or ist there a workaround like "Try/Catch" ? (If so, i haven't found the rigth Syntax there. )

     

    Thanks in advance for help...