cancel
Showing results for 
Search instead for 
Did you mean: 

Parametize test data from JDBC into request

Highlighted
New Contributor

Parametize test data from JDBC into request

Hi, I am new to SoapUI, I am able to connect to my database for now. I want to know how can I use the data from the query and input that into the request parameter so that it gives a response using groovy script. My query will give tracking numbers and I want the soapui to input these tracking numbers and give the appropriate response.

 

 

Thanks.

2 REPLIES
Contributor

Re: Parametize test data from JDBC into request

In SoapUI open source, after JDBC connection, response will be shown in xml format.

Please see below image, wher I am doing a sample JDBC connection

jDBC connection.jpg

 

From this response I retrieve Email value with this groovy script. And set this Email value as a Properties in TestSuite. So that I can use this property in any TestCase. [${#TestSuite#Properties}]

 

script.jpg

 

Like Email You can retreve Tracking Number from response. I think It will help you. 

 

Occasional Contributor

Re: Parametize test data from JDBC into request

hi

i got solution for you.

example of groovy script which recover and test one database field value : 

before you have : testcase property with expected values, and a JDBC Step which give you database answer :

<Results>
<ResultSet fetchSize="0">
<Row rowNumber="1">
<databasename.datafield1>123</databasename.datafield1>

...
<databasename.datafieldname>123</databasename.datafieldname>
... 

</Row>
</ResultSet>
</Results>

 

import com.eviware.soapui.support.XmlHolder

def reponse = context.expand( '${JDBCTestStep#ResponseAsXml#//*:Results/ResultSet/Row}' )
def egal = true
if (reponse != "") {
// log.info " answer recover : " + reponse 
// Test field in database 
def Slurp = new XmlSlurper().parseText(reponse)
def FieldDB = Slurp."databasename.datafieldname"
// log.info " FieldDB : " + FieldDB
def FieldExpected = testRunner.testCase.getPropertyValue("FieldValueExpected")
if (FieldDB == FieldExpected ) { log.info " the field  " + FieldDB + " is correct in database."}
else { egal = false; log.info " the field " + FieldDB + " is not correct in database."}
}
else { egal = false; log.info " request sent is empty !"}
assert egal

Share Your Stories
Read Latest News
Top Kudoed Authors