With the introduction of soapUI 3.5.1 it is possible to check database and JMS sources.
This can also be very useful for automatic blackbox testing of your OSB services.
I used it wihin my projects to check if correct soap responses were returned, the correct data was written to a database
and with the use of HermesJMS I was able to inject JMS messages.
This blog describes how i used soapUI for this.
SOAP Request Step
Note: Within the red box you see that some Groovy scripting is inserted (${ <groovy script> }). In this case a rondom number between 0 and 9999999.
JDBC Request stepThis can also be very useful for automatic blackbox testing of your OSB services.
I used it wihin my projects to check if correct soap responses were returned, the correct data was written to a database
and with the use of HermesJMS I was able to inject JMS messages.
This blog describes how i used soapUI for this.
Install required software
- Install soapUI 3.5.1 (see also http://www.eviware.com/nightly-builds)
- Install required JDBC drivers
For the use of JDBC steps you have to install the correct driver: see here
You need to close soapUI and put the driver jar file within the SOAPUI/bin/ext directory and start soapUI again.
Note that within the logging you can see that soapUI picks up the jar file.
- Install HermesJMS 1.13
Setup Test Suite
- Right-click a project and select New TestSuite and enter name for the suite
- Right-clik the TestSuite and select new TestCase
A testcase contains several test steps
- Right-click a test case and you can add several test steps
SOAP Request Step
- Right-click Insert Step
- Select Test Request
- Fill in the request
Note: Within the red box you see that some Groovy scripting is inserted (${ <groovy script> }). In this case a rondom number between 0 and 9999999.
Next we will check that the Employee is inserted within a particular database
- Right-click -> Add Step -> JDBC Request
- Select the JDBC Request to add a database call
- Enter the needed fields, example
In the upper part of the dialog you can fill in properties that are dynamic and can be used
within the SQL Query. In this case a sofinumber property is used.
Next the Configuration for the database is filled in. Dependant on the used Driver a different
Connection String is required.
The SQL Query in the example gets all employees with a particular sofinumber. Note that the ":" is used in front of the dynamic property (sofinumber).
How data can be transfered to this property from previous steps i will explain next.
Property Transfer step
With a property transfer step we transfer the input request sofinumber to the property within the JDBC step.
- Right-click Add Step -> Property Transfer
- Add Property Transfer
- enter a name for the transfer
- First we fill in the source (Step: Nieuwe Employee, Property: Request)
You also have to use an XPath expression to select the SofiNumber.
- Select the ns icon to import all namespaces that are known within the step.
- Fill in the next XPath expression
- Select in Target the JDBC Request step
- Select as property the sofinumber property. Note that this is the property you defined earlier within the JBDC step.
The next steps must be defined now:
Because the sofinumber of an exmployee must be unique we can add an Assertion to the JDBC step as follows.
- Double-click on JDBC Request step
- Click on Assertions
- Click on Add an Assertion
- Select XPath Match
<Results>
<ResultSet>
<Row>*
In this case we only expect 1 row, so this is how we will setup the assertion.
- Fill in the next fields
This concludes this simple automatics test steps within soapUI that can also be used to blackbox test your SOA services.
Next time I will include an example that uses a JMS Queue as the transport instead of soap over HTTP.
Great Article!!
BeantwoordenVerwijderenCool! Now I don't have to write Groovy Script to get stuff from the DB.
BeantwoordenVerwijderenOne annoying thing: Instead of "jdbc:oracle:thin://@::", it should be "jdbc:oracle:thin:/@::". That extra slash caused me about 15 minutes worth of frustration. :) Good post regardless.
BeantwoordenVerwijderen@thetestingblog.com:
BeantwoordenVerwijderenThanks for the remark, sorry i wasted 15 mins of your precious time ;)
Thx
Roger
Great!
BeantwoordenVerwijderenBut how do I delete the test employee again from the DB after the test?
I dont want to fill up the db with test users...
@eerie Just make JDBC step with truncate table commands and the columns are removed from your database. Or use other JDBC commands as you like.
BeantwoordenVerwijderenHope this helps?
Regards Roger