Soapui Tutorial: Jra1 Meeting Cambridge 8 June 2007 Michalis Michael Cynet
Soapui Tutorial: Jra1 Meeting Cambridge 8 June 2007 Michalis Michael Cynet
JRA1 Meeting
Cambridge 8 June 2007
Michalis Michael
Cynet
What is soapUI?
soapUI is a free and open source desktop
application for inspecting, invoking,
developing, simulating/mocking and
functional/load/compliance testing of web
services over HTTP.
Note that the xsd files are created in a directory because more
than one xsd files may be created each time.
def resultList=[]
sql.eachRow("select id,status_oper,status_admin from domain_link"){
def result=[:]
result=[id:it.id,status:it.status_oper,admin:it.status_admin]
resultList.add(result)
}
Above you can see an example of accessing a mySQL database and
retrieving data from it.
First we define a map
def knownResultsMap=[id:"DFN-Surfnet-Link-5678",status:"down",admin:"UNKNOWN"]
With sql.eachRow the select statement is executed and the results are stored
inside the result map with the help of an iterator “it” . The result map holds the
results for one row and all rows are stored in the result list.
There is not need to declare the iterator, its “built-in” with the .eachRow method
Groovy IV
resultList.each{
if((it.id==knownResultsMap.id)&&(it.status==knownResultsMap.status)&&(it.
admin==knownResultsMap.admin))
println "\n We have a match" + "\n"+ it.id +" "+it.status+" "+it.admin
}
The former piece of code uses the withWriter method and the
help of a “closure” to write the map to the file.
Writing our results with the help of groovy to an external file,
can give us the reporting capability that we have using
traditional languages for functional testing as Java and Perl
Groovy and soapUI VI-Tips
The groovy script editor is pretty raw and I
wouldn’t suggest it for any serious developing
I’d suggest to install groovy on a machine and
try most of the code apart from soapUI
There is also an eclipse plug-in. Instructions on
how to install it are found at
http://groovy.codehaus.org/Eclipse+Plugin
When you finish testing the code pieces that
are independent from soapUI you can copy the
code to the soapUI script editor and add the
remaining code.
Groovy and soapUI VII-Tips
Be careful! The embedded groovy language in soapUI
can only accept new packages only if it is installed on
your machine. JNLP versions can not accept new
packages.
Adding new packages to the embedded groovy-such as
xmldb- can be tricky.
Modification of soapUI.bat or .sh is needed.
Copy the packages you want to add in the lib directory
of the soapUI installation folder.
Then modify the soapUI.bat or .sh file adding
set CLASSPATH=%CLASSPATH%;..\lib\mypackage.jar
Restart soapUI so that the changes may take place
This is necessary for the mysql-connector and xmldb
packages.
Groovy and soapUI VIII
Questions?
Thanks!