Sears_Holdings__3
12 years agoOccasional Contributor
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
Thanks,
AJ
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