Jimmy
Jimmy

Reputation: 16428

XQuery, assert on format of date rather than actual date?

I've got some soap UI tests, that contain XQuery assertions on the responses it receives, such as the following :

declare namespace soapenv='http://schemas.xmlsoap.org/soap/envelope/';
declare namespace ns2='http://mydomain.com/mydata_1';
/soapenv:Envelope/soapenv:Body/ns2:itemDetail/ns2:startDate

Currently, I use the following expected result :

<ns2:startDate>2008-01-01T00:00:00.000Z</ns2:startDate>

This works fine, for now, however that piece of data can change.

Question : Is there a way I can assert on the format of the date, for example I don't care what date value I get back providing it matches a particular format?

I could use :

<ns2:startDate>*</ns2:startDate>

But then I could get any date format

Is there something like this?

<ns2:startDate>yyyy-MM-dd HH:mm:ss.ms</ns2:startDate>

Thanks

Upvotes: 1

Views: 739

Answers (1)

Michael Kay
Michael Kay

Reputation: 163322

You could write your query as

/soapenv:Envelope/soapenv:Body/ns2:itemDetail/ns2:startDate/matches(., $regex)

with an expected result of true, where $regex is a regular expression that you expect the data to match.

Upvotes: 2

Related Questions