Forum Discussion

Yariv_Amar's avatar
Yariv_Amar
Contributor
13 years ago

bug in "Message Content Assetrion" with dates

I have a step that runs JDBC request to query an Oracle table and then validates the result using Message Content Assertion and Xpath.
When I run the step on my machine (win) it works fine, but when it runs from Maven on our Hudson env. I get failure (see logs below).
The problematic field type is (any) date-time, in my example DETECTION_TIME.
the result from the DB is:
<DETECTION_TIME>2012-12-25 11:00:00</DETECTION_TIME>
in Message Content Assertion i wrote the value: 2012-12-25 11:00:00
This fails on our Maven run w/o details on the error (see the log below).

In addition i've added another Xpath Assertion for the same field:
Xpath: //Results[1]/ResultSet[1]/Row[1]/DETECTION_TIME[1]/text()
Value: 2012-12-25 11:00:00
This assertion pass OK.

There are 2 bugs here (to my opinion )
1. Message Content Assertion for JDBC response does not validate dates properly when run from Maven
2. Message Content Assertion failure message is poor. it should say what was expected and what is the actual value in the logs.

thanks,

here is the relevant part from the log.

2013-01-06 17:19:54,891 INFO [SoapUIProTestCaseRunner] running step [Validate TimeDetection]
2013-01-06 17:19:54,960 INFO [log] this is the result as seen by groovy script:
<ResultSet fetchSize="10">
<Row rowNumber="1">
<ID>b7c8c25c-e385-4bf4-b19b-e874155e2454</ID>
<DETECTION_TIME>2012-12-25 11:00:00</DETECTION_TIME>
<STATUS_TYPE_ENUM>ON</STATUS_TYPE_ENUM>
</Row>
</ResultSet>
2013-01-06 17:19:54,969 INFO [SoapUIProTestCaseRunner] Assertion [JDBC Status] has status VALID
2013-01-06 17:19:54,970 INFO [SoapUIProTestCaseRunner] Assertion [Match content of [DETECTION_TIME]] has status VALID
2013-01-06 17:19:54,971 INFO [SoapUIProTestCaseRunner] Assertion [Message Content Assertion] has status FAILED
2013-01-06 17:19:54,972 ERROR [SoapUIProTestCaseRunner] ASSERTION FAILED -> Message Content Assertion failed : failed/compared = 1/2
2013-01-06 17:19:54,974 ERROR [SoapUIProTestCaseRunner] Validate Edit Detection failed, exporting to [/o.../xxx_path removed_xxx/tion-0-FAILED.txt]

6 Replies

  • Hi,

    We are very sorry that it took us so long so see your post! It must have gone in at a very busy time and somehow it skipped our attention.

    I have confirmed both issues you have raised.

    For now, would you be able to use a Groovy testStep to actually print the response contents, something similar to this (adapting the XPath of course, you can use Pro's feature to do it automatically, right-click on the script, click on "Get Data..."):

    def response = context.expand( '${getItems#Response#declare namespace ns2=\'http://ws.app4test.eviware.com/\'; //ns2:getItemsResponse[1]/return[12]/cost[1]}' )
    log.info "Value found is '${response}'"


    About the date not validating properly, it will be clearer what's going on once we know what the value returned is.... if it's exactly the same as expected, then I might have to fill a bug for this. Please let us know if you still get the exact expected answer (even without trailing white spaces) in Maven.

    Regards,

    Renato
    SmartBear Software
  • Well, it's really a long time bug.
    I've used similar 'tricks' to get the logs and do validations using custom code.

    For dates we are still having lots of difficulties with their formatting.
    We are a team of developers and QE's working with a single SoapUI project that "talks" to our (single) integration web-server.
    In some tests we are querying and Oracle DB (using JDBC request) and we always have troubles with date-formatting.

    For some developers the date format on the JDBC response is:
    yyyy-MM-DD.HH.mm.s.SSSSSSSSS

    While for other developers the date format is:
    yyyy-MM-DD HH:mm. SSSSSSSSS

    As you can understand, it's very difficult to write assertions that works for everyone. (BTW, we worked-around it with groovy script).

    I thought it's related to the local of the end user, but all our locales are the same.
  • Hi again,

    How about you try to set these environment variables in your Oracle system:


    // replace with the values you want
    export NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P15
    export NLS_DATE_FORMAT="dd/mon/yyyy hh24:mi:ss"


    And then, use the exact same formats in SoapUI to read the dates as Strings in a Groovy Script:


    String responseDate = context.expand( ... ) // get the date String from the response
    Date date = Date.parse( "d/M/yyyy H:m:s", responseDate ) // this format is the same as shown above but in Java syntax
    // compare with expected value


    Regards,

    Renato
    SmartBear Software
  • Hi
    Thank you Renato.
    We are now using Groovy script to overcome this glitch, the groovy is familiar with both formats, and does the assertion correctly.
    Although it works, I don't like it .

    --
    I'm not sure I can change the Oracle system as this DB contains many schemas\users for other projects too (I will ask our DBA).
    I was looking for the same configuration on the client side.

    Thanks to your reply, we've rechecked our environments and discovered that we had several different ojdbc.jar versions in use.
    We will make sure that all users will have the same ojdbc.jar and that will resolve our issue.
    I guess that oracle driver have different date format / strategy on different driver version.
  • Hi,

    Yeah, I guessed from your previous answer that you had come up with something similar, but I decided to post the script anyway so that others can also benefit from the information.
    At the end of the day, nothing can be as flexible and powerful as pure code, so although SoapUI goes a long way towards helping automate tests, there's always going to be corner cases which we can't cover: for those, Groovy script is your friend

    Best regards,
    Renato
    SmartBear Software