1

I am working on a project where we have multiple environments and for each environment we have a separate database connection string which I have added in environments section.

Now I want to get the environment connection string at runtime using Groovy test step to use it further to execute query. Below is my script:

def connectionString = context.testCase.testSuite.project.activeEnvironment.databaseConnectionContainer.getDatabaseConnectionByName("dbconnection").getConnectionString()

Now in response I am getting connection error as I can see in response the script is returning jdbc:oracle:thin:Username/PASS_VALUE@machine details. As per my understanding the PASS_VALUE is causing this issue.

com.eviware.soapui.support.GroovyUtils.registerJdbcDriver( "oracle.jdbc.driver.OracleDriver" )
import groovy.sql.Sql;
//get active environment connection string
def connectionString = context.testCase.testSuite.pro
log.info ("Connection String#####"+connectionString)
def driver="oracle.jdbc.driver.OracleDriver";
def  con = Sql.newInstance(connectionString,driver);

So this getConnectionString() should return the password so that it can be used in further script.

Suncatcher
  • 10,355
  • 10
  • 52
  • 90
Lavnya
  • 9
  • 2

0 Answers0