Forum Discussion
d00wirre
14 years agoOccasional Contributor
I have used a script connecting to a database with modulus as a twist to get new users for each request.
The following script needs the Oracle jar driver to work. It can easaly be adopted to other DBs.
The following script needs the Oracle jar driver to work. It can easaly be adopted to other DBs.
com.eviware.soapui.support.GroovyUtils.registerJdbcDriver("oracle.jdbc.driver.OracleDriver")
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
import groovy.sql.Sql;
//Establish JDBC Connection to the DB
def con = Sql.newInstance( "jdbc:oracle:thin:@server:port/serivce", "user", "passwd", "oracle.jdbc.driver.OracleDriver");
//Modulus user
con.execute("UPDATE user_mod SET user_id = mod( (user_id +1 ), (select count(1) from user_account) )")
//get user
def res = con.rows("Select username, passwd from user_account a, user_mod m where a.user_id =(m.user_id +1)")
con.close()
groovyUtils.setPropertyValue("Properties", "user", res[0].username)
groovyUtils.setPropertyValue("Properties", "passwd", res[0].passwd)
testRunner.testCase.properties['user'].setValue( res[0].username)