Forum Discussion

VLiljeb_ck's avatar
VLiljeb_ck
Occasional Contributor
12 years ago

[Res] Compare part of JDBC/SOAP response node with mult..

Hi,

I want to compare a JDBC response with a SOAP response. The nodes I want to compare/assert consists of multiple lines. The tricky part is that I would like to only compare two of the rows not all rows..
In the example below I would like to check that "Number accounts processed" and "Daily count" is the same in JDBC and SOAP response. I tried to use contains assertion but I do not know how to access the JDBC response in the contains assertion and also not only two rows of the JDBC response node... Can anyone assist in which direction I should proceed to solve this? Could groovy scripting solve it? I am new to groovy so before plunging into that area I want to know if somebody thinks that would solve the issue?

JDBC node look like this:
<STATUSTEXT>Number accounts processed: 21534
Daily count: 21534
Daily amount: 220804.12610000148
Monthly count: 0
Monthly amount: 0.0
Yearly count: 0
Yearly amount: 0.0
</STATUSTEXT>

SOAP node look like this:
<STATUSTEXT>Number accounts processed: 21534
Daily count: 21534
Daily amount: 220424.11710000022
Monthly count: 0
Monthly amount: 0.0
Yearly count: 0
Yearly amount: 0.0
</STATUSTEXT>
  • Hello,

    I believe you can accomplish this with an "XPATH ASSERTION." Just add an "Xpath assertion," declare the node and in the "Expected results" section, you can right click, click on "Get Data" and select the "JDBC Step" with the desired expected result. I believe you will need 2 Xpath assertions for what you want to accomplish. Please take a look at the link below for more information and if you have any questions let me know.

    http://www.soapui.org/Functional-Testin ... tions.html

    Regarads,
    Temil
  • VLiljeb_ck's avatar
    VLiljeb_ck
    Occasional Contributor
    I still can't get part of a node response through xpath assertion. I use the xpath assertion method for my othere testcases where I want to assert the whole node and it works perfectly! But in this case I do not want to assert the whole node but only part of the node... I still do not get how this can be solved by xpath...

    But I have created a groovy script that solves the issue, the groovy script below collects the JDBC response and then split the response to collect only the number of interest from the response. The number is then transferred into a property. And then I use the property in a contains assertion for the SOAP response. Maybe not the best solution but it works

    def responseAsXml = context.expand( '${GetJDBCresponse#ResponseAsXml#//Results[1]/ResultSet[1]/Row[1]/STATUSTEXT[1]}' )
    def onlynumber = responseAsXml.split(" ")
    testRunner.testCase.getTestStepByName("Properties").setPropertyValue("value", onlynumber[20])