sanathkd
4 years agoOccasional Contributor
Creating databaseConnectionContainer in readyapi using groovy script
I know below groovy scripts are used to get JDBC details from the ReadyAPI tool.
========================================
jdbcName = context.testCase.testSuite.project.databaseConnectionContainer.getResourceAt(0).getName();
jdbcDriver = context.testCase.testSuite.project.databaseConnectionContainer.getResourceAt(0).getDriver();
jdbcString = context.testCase.testSuite.project.databaseConnectionContainer.getResourceAt(0).getConnectionString();
========================================
envJdbcName = context.testCase.testSuite.project.activeEnvironment.databaseConnectionContainer.getResourceAt(i)
envJdbcString = context.testCase.testSuite.project.activeEnvironment.databaseConnectionContainer.getResourceAt(i)
But I'm interested in creating these values using groovy. Is there any set scripts? Something like below?
String jdbcName = "abcd";
log.info "Trying to Create new JDBC Connection with Name: " + jdbcName;
String newJdbcString = context.testCase.testSuite.project.databaseConnectionContainer.setContainer( jdbcName );
I get below error when i use this
groovy.lang.MissingMethodException: No signature of method: com.eviware.soapui.impl.wsdl.support.connections.DefaultDatabaseConnectionContainer.setContainer() is applicable for argument types: (String) values: [abcd] error at line: 4
Any help is appreciated, thanks in advance.
I even know how to set values once this created.
newJdbcName = getEnv.databaseConnectionContainer.getResourceAt(i).setConnectionString(pwhConnectionString)
One time creation of JDBC row under databaseConnectionContainer is the problem I'm facing.
sanathkd :
You can create using below lines ://Get test env where you require changes. def env=testRunner.testCase.testSuite.project.getEnvironmentByName("EnvName") //Get getDatabaseConnectionContainer for that environemnt. dbContainer= env.getDatabaseConnectionContainer(); // Add new connection def connection = dbContainer.addResource(conName) //Set all properties. connection.setDriver(driver) connection.setConnectionString(conString) connection.<AnyOtherProperty>()
Thank you,
Sunil Devasya