Forum Discussion

charsnonumber's avatar
charsnonumber
New Contributor
11 years ago

[Res] DB Connection string is not updated when changing env

Hi,

I'm running 4.5.2 (PRO) on Windows 7 PC.

There is a problem when switchning between environments. The DataBase (DB2) connections are not changed.
The user must run each test step that contains database request first once as a test step to make the right connection.
This problem was actually solved in "soapUI Pro 4.5.1-NB-SNAPSHOT", but has come back.

In my case I have the DataBase access in a test case that the main test case access by use of "Run TestCase" test step,
but I don't think this makes any differense.

If I use the 4.5.1-NB-SNAPSHOT this work fine when using the GUI.
But, I also need to run, using schtasks, testrunner.bat. That is to run tests at certain times during night.
In this case, not even 4.5.1-NB-SNAPSHOT woks ok. There the fix doesn't work, problem remains. I use the -E switch to select environment.

Hope you can help me with this!

Best Regards
Anders D.
Sweden

Ps. when I run 4.5.1-NB-SNAPSHOT and got the offer to upgraede to 4.5.2, there was a popup that was a pop-up that should describe the changes, but it just said something like: no information available. Ds.
Pps. I have a PRO, registered in a group, whith owner: Anna Reimer, Bankgirocentralen BGC AB. Dds.

17 Replies

  • SiKing's avatar
    SiKing
    Community Expert
    I just tried it with a clean project with SoapUI-Pro 4.6.1. This is definitely still broken!

    If I go further, and use the workaround as above (open and close the JDBC step) and then try to run against the previous environment it uses the updated credentials. The workaround mentioned in my reply way above still works tho'.

    You can confirm this by using composite project. Set everything up as I mentioned. When you exist SoapUI in step 5, backup the test file. When you perform the workaround in step 9, exit again. Compare the two test files - you will notice everything inside is hard-wired!!!
  • benonline's avatar
    benonline
    New Contributor
    Here at Topicus Finan we also have this issue and I have created a workaround for it with help of Groovy.

    On all suite levels inside the 'Setup script' tab I added the following Groovy script.


    // Get first databaseName.
    databaseName = testSuite.project.activeEnvironment.databaseConnectionContainer.getDatabaseConnectionAt(0).getName()

    // Get connectionString of active environment.
    connectionString = testSuite.project.activeEnvironment.databaseConnectionContainer.getDatabaseConnectionByName(databaseName).getConnectionString()

    // Iterate all testcases in the suite.
    for(testCase in testSuite.getTestCaseList())
    {
    // Iterate all test steps in the test case and change connectionString for all ProJdbcRequestTestStep to the selected environment connectionString.
    for(testStep in testCase.getTestStepList())
    {
    // Set the connectionString for all ProJdbcRequestTestStep
    if(testStep instanceof com.eviware.soapui.impl.wsdl.teststeps.ProJdbcRequestTestStep)
    {
    testStep.setConnectionString(connectionString)
    }
    }
    }


    And on test case levels inside the 'Setup script' tab I added the following Groovy script.


    // Get first databaseName.
    databaseName = testCase.testSuite.project.activeEnvironment.databaseConnectionContainer.getDatabaseConnectionAt(0).getName()

    // Get connectionString of active environment.
    connectionString = testCase.testSuite.project.activeEnvironment.databaseConnectionContainer.getDatabaseConnectionByName(databaseName).getConnectionString()

    // Iterate all test steps in the test case and change connectionString for all ProJdbcRequestTestStep to the selected environment connectionString.
    for(testStep in testCase.getTestStepList())
    {
    // Set the connectionString for all ProJdbcRequestTestStep
    if(testStep instanceof com.eviware.soapui.impl.wsdl.teststeps.ProJdbcRequestTestStep)
    {
    testStep.setConnectionString(connectionString)
    }
    }


    Now when you switch from environment inside a suite or test case the setup script will automatically set the correct connection string based on the configured JDBC inside the enviroment tab of the working project.

    Regards, Ben.
  • benonline's avatar
    benonline
    New Contributor
    A better workaround could be to add almost the same code inside the project 'Event' tab and then for the event name TestRunListener.beforeRun:


    // Get first databaseName.
    databaseName = context.testCase.testSuite.project.activeEnvironment.databaseConnectionContainer.getDatabaseConnectionAt(0).getName()

    // Get connectionString of active environment.
    connectionString = context.testCase.testSuite.project.activeEnvironment.databaseConnectionContainer.getDatabaseConnectionByName(databaseName).getConnectionString()

    // Iterate all test steps in the test case and change connectionString for all ProJdbcRequestTestStep to the selected environment connectionString.
    for(testStep in context.testCase.getTestStepList())
    {
    // Set the connectionString for all ProJdbcRequestTestStep
    if(testStep instanceof com.eviware.soapui.impl.wsdl.teststeps.ProJdbcRequestTestStep)
    {
    testStep.setConnectionString(connectionString)
    }
    }


    Then for every test case the connectionString will be set correctly, this will make my last workaround not necessary to configure it separately for every test suite and test case.
  • Hi All,

    Thank you for your investigation into this problem.
    This issue has been noted and a defect has been opened.
    SOAP-1013 is being used to track this issue.