Forum Discussion

ppietersz's avatar
11 years ago

Changing connection

Hi,

I'm trying to change the connection of a datasource teststep (without the use of environments for specific reasons), but I guess I'm missing a few steps in the process? The script below is executed from within the testsuite's setup script and is supposed to be changing all datasource (teststep) connections to a projectdefined variable that contains the name of one of the projectdefined JDBC Connections. However, the connections remain the same. Should I reload or re-initialize in some way? It might as well be a syntax issue ..

Any help would be very much appriciated!

Regards,
Patrick

[hr:1qio71b6][/hr:1qio71b6]
import com.eviware.soapui.impl.wsdl.teststeps.*

testCaseList = testSuite.getTestCases()
testCaseList.each {
testCase = testSuite.getTestCaseByName(it.key)

datasrcTestSteps = testCase.getTestStepsOfType( com.eviware.soapui.impl.wsdl.teststeps.WsdlDataSourceTestStep.class )
datasrcTestSteps.each {
it.getDataSource().setDbConnectionName("NewConnection")
}
}
  • Cizo89's avatar
    Cizo89
    Frequent Contributor
    Hi Patrick,

    if I'm not wrong, the problem is that JDBC Configuration in DataSource TestStep isn't that complex as JDBC config in JDBC TestSteps.
    Although the API contains getter and setter for the DB connection name, there is no such thing in the DataSource JDBC configuration.

    You can either switch to Data Connection in the DataSource configuration or if you want use the JDBC configuration, try using this instead of getDataSource().setDbConnectionName("NewConnection"):

    testStep.getDataSource().setDriver("driver")
    testStep.getDataSource().setConnectionString("connectionString")
    testStep.getDataSource().setPassword("password")


    Regards,
    Marek