Forum Discussion

Sears_Holdings__3's avatar
Sears_Holdings__3
Occasional Contributor
12 years ago

Setting datasink properties using groovy

Hi,
I am trying to set the query, connection string and password in a datasink step using groovy script. When I run the groovy script directly as a test step, it all works fine. The scripts change the properties in datasink and I can see that change when I open the datasink step.

But, when I run the test case, I don't see the changes in datasink. Any idea why?

The same works fine for datasource step - both as teststep and test case. Here is the code that am using

//Read keyword name from property
keyword_name = context.expand( '${#Project#keyword_name}' )
//Get datasink object for updating mark for delete
datasinkStep = testRunner.testCase.getTestStepByName( "update_producttable_flag_for_delete" )
dataSink = datasinkStep.getDataSink()
dataSink.setDriver("com.mysql.jdbc.Driver")
dataSink.setConnectionString("$connectionString")
dataSink.setPassword("$password")
//Query to update the product table
updateQuery ="update product set mark_for_delete = '1' where created_by='auto_user' "+
"and keyword_id=(select keyword_id from keyword where keyword_name=\"$keyword_name\")"+
"and mark_for_delete='0'"
dataSink.setQuery("$updateQuery")


Thanks,
AJ

1 Reply

  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hmm, I tried the same code and it works fine for me in soapUI Pro 4.5.0.

    My TestCase looks like this:
    • Groovy Script

    • DataSink (JDBC)


    How does your TestCase look, and which version of soapUI are you running?

    Regards

    Henrik
    SmartBear Software