Using Setup Script
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2010
09:17 AM
09-09-2010
09:17 AM
Using Setup Script
I have following steps in my Single Testcase.
I'm using Data source to fectch values from DB and feeding to my Create operation
And then doing Groovy script step to verify values fetched from DB
fetching of one of my response value from Create operation and feeding to get operation
Looping above 3 steps through Datasource loop step
Now, I want to create a setup script where I want to intialize DB connection. Since I do not want to open and close DB connection for every of my testcase. I tried placing following piece of code in setup script tab. However, while running my DB_Checker step, UI complains that it could NOT find property sql which is defined in setup script. ANY help will be useful
- Data source
Create operation
DB Checker
Get operation
Datasource Loop
I'm using Data source to fectch values from DB and feeding to my Create operation
And then doing Groovy script step to verify values fetched from DB
fetching of one of my response value from Create operation and feeding to get operation
Looping above 3 steps through Datasource loop step
Now, I want to create a setup script where I want to intialize DB connection. Since I do not want to open and close DB connection for every of my testcase. I tried placing following piece of code in setup script tab. However, while running my DB_Checker step, UI complains that it could NOT find property sql which is defined in setup script. ANY help will be useful
import groovy.sql.Sql;
def MA_UUID;
def ERR_MESSAGE = "DATABASE MISMATCH ";
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context );
def sql = Sql.newInstance("jdbc:db2://IP_ADDRESS:60000/DB_NAME", "USERNAME","PASWORD", "com.ibm.db2.jcc.DB2Driver");
2 REPLIES 2
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2010
03:19 AM
09-20-2010
03:19 AM
I had the same issue, check out this link :
http://onebyteatatime.wordpress.com/2009/02/17/reusable-sql-connection-in-soapui/
Worked a charm! Hope it helps you.
Cheers
Matt
http://onebyteatatime.wordpress.com/2009/02/17/reusable-sql-connection-in-soapui/
Worked a charm! Hope it helps you.
Cheers
Matt
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2010
10:01 AM
09-21-2010
10:01 AM
Thanks .. I followed that link and I could able to do it..
I'm storing values of DB connection in a file and reading that file to create my DB connection string.
please tell me if any more efficient step to do this.
in the teardown script I'm closing the connection
I'm storing values of DB connection in a file and reading that file to create my DB connection string.
please tell me if any more efficient step to do this.
import groovy.sql.Sql;
def DB_prp= new Object[4]; //array to store the db properties
def results;
def DB_connection;
//Groovy open file for reading DB related properties
def target ="D:\\soapui-release-B\\properties\\DB_connection.csv"
def i=0;
def FILE_NOT_EXISTS="$target file NOT present";
File wf= new File(target);
assert wf.exists():FILE_NOT_EXISTS;
wf.eachLine{line->
results = line.tokenize("\t");
//log.info results[1];
DB_prp[i++]=results[1].trim();
}
//for (item in DB_prp) {
//log.info item;
//}
try {
DB_connection = Sql.newInstance(DB_prp[0], DB_prp[1],DB_prp[2],DB_prp[3]);
context.setProperty("dbConn", DB_connection);
} catch (Exception e) {
log.error "Could not establish connection to the database."
}
in the teardown script I'm closing the connection
//Close db connection
if (context.dbConn)
{
context.dbConn.close();
log.info "Closed Database Connection."
}
