2010/04/22

soapUI: Re-use of a Property with random value

In a test suite I wanted to use a Random value for a soap request, so I defined a Property that is initialized with a random value (see also my previous post on soapui).
The next thing that I wanted to do is to use that same Property to check whether an item was correctly inserted into a database. So for example:
Property
Name: empid  Value: ${=(int)(Math.random()*100000000)}

step1: soap request    
${#TestCase#empid}

step2: JDBC request 
select * from Employees where
   empid = '${#TestCase#empid}'

To my surprise this construction did not work!
In fact in the second step the empid property was given a new random number !!

I tried several other options, like:
  • Define properties on other level (TestSuite, TestCase, Project)
  • Use a second Property and transfer the first random Property to the second. In this case the transfer is just a transfer of the Groovy script !!??
In the end I got the following solution:
  • Double click on the TestCase
  • Define a Property empid with value 0 (for example, it does not matter) (On the Properties tab)
  • On the Setup Script tab initialize the Property:
  •  Now you can use this Property with random value and that is initialized only once !
Hope this blog item helps you in using the tool, just the way you want :-)

soapUI: Use of dynamic enpoints in OTAP street

When you have an OTAP (Development, Test, Acceptance, Production) street you want to sent your soap requests, jdbc requests and JMS requests to be sent to different endpoints depending on the environment you are running the test. This small blog shows how you can do this.

First you define the properties you need for your endpoints. You do this on project level.
  • Select project
  • Select Custom Properties tab
  • Add the needed properties

  • Save the properties to a file, i.e. properties_dev.txt (this is the icon on the far right)
  • Copy the file and also make properties_tst.txt, properties_acc.txt and properties_prod.txt

Now that you defined the properties we are ready to use them within test steps.

SOAP Request step

Note:You can change the endpoint by select [edit current..]
Note: For a JMS endpoints holds the same, just add a property with jms://<host> <port>

JDBC Request step

2010/04/21

soapUI: Use of JMS

For the use of JMS steps within soapUI it integrates with HermesJMS. So first you have to install HermesJMS (version 1.14 or greater).

Configure HermesJMS

To be able to use HermesJMS with OSB 10gR3 you have to configure the hermes-config.xml file.


    
        
    
...
    
        
            
                
                
                
                
                
            
        
        
            
        
        
        
            
                
                
                
            
        
    


Configure soapUI (3.5.1)


  • Select File > Preferences
  • Select Tools
  • At Hermes JMS fill in the directory where you installed Hermes
  • Click OK

Use JMS Queues/Topics within a TestSuite

  • Select a Binding of a project
  • Right-click Add JMS endpoint



  • Browse to the folder where you have placed the hermes-config.xml file (usually document and settings/.hermes)
  • Select Session
  • Select a Publish destination
  • (Optionally) select a Subscribe destination



Note: All your defined endpoints can be found:
  • Right-click binding > Show Interface Viewer
  • Select Service Endpoints tab

Now you are able to send a soap message to a JMS Queue/Topic destination just by selecting the JMS endpoint in the test step.

soapUI: The usage of dynamic properties

In my test case I wanted to use a Random number for a particular soap request and use that number in subsequent test steps. I used the following Groovy script within my soap request:
<PersNumber>${=(int)(Math.random()*10000)}</PersNumber>

Then I wanted to use this generated number within a JDBC Step to check whether the customer was correctly inserted within a database. So I used a JDBC step with a persnumber property:




Then the next thing I did was to create a Transfer step to transfer the <PersNumber> content within the request to the persnumber property of the JDBC step.
This did not work because in the end the persnumber property contained:
${=(int)(Math.random()*10000)}

The trick here is to use a test Property for this and to use this property within the soap step and within the JDBC SQL Query.

So first define a property:



Use this property within the soap request:
<PersNumber>${Properties#persnumber}</tns1:PersNumber>

And use the following construction within the SQL Query:
select * from nummers_update where
   pers_nummer = ${Properties#persnumber}

Note:
The only disadvantage is that the property is not initialized with a new random value in case you restart the case.

2010/04/18

Automatic SOA black box testing with soapUI

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.

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.

JDBC Request step
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
Now you have to define the source and target of the transfer. You use XPath expressions to select elements.
  • 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.
We now select the SofiNumber element from within the Request 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
The result of a select statement is in the form of:
<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.

2010/04/03

File Connector for Cordys BOP4

When I wanted to use files to read from a directory I had to install the file connector of Cordys. Unfortunately I could not find much documentation of it on the Cordys wiki, so I started to find it out myself. This blog guides you through the installation, configuration and use of the File Connector package.

I use the latest BOP4 VM environment and the file connector isv package can be found here.

Install ISV Package


  • Goto Application Registry (Note: This is only available within organization "system")



  • Select Install New Applications
  • Click “Upload New Application”
  • Select the .isvp file (in our example the CoE_File Connector_1.2.14.isvp)
  • Check “Cordys CoE File Connector 1.2” and click “Start Installation”



  • Click Next

  • Check the connector and click next
  • Click Install
  • The package should be installed and the next window is shown



  • Click Finish

Configuration


  • Goto System Resource Manager
  • Show All Service Groups
  • New Service Group


  • Select File Connector and Next
  • Fill in Service Group Details



  • Click Next
  • Fill in Service Container Details


  • Click Next
  • Fill in File Connector configuration where to read files




  • Click Next
  • Leave Connection Point Details default settings
  • Click Finish
  • Notice in the Service Containers window that the File Connector is starting or started

Configuring of File Polling


  • In the File Connector just created you can configure the Reader- and Writer configurations
  • Goto Properties of the File Connector
  • Click the File Connector Tab



  • Go to the XMLStore



  • Create fileconnector and config directories
  • Create New Item within config directory: reader-config.xml

Content:

  
    BPM
    /home/declaraties
    *.xml
    10
    
      FunctieDeclaratie
      http://schemas.cordys.com/default
      o=Organization1,cn=cordys,cn=defaultInst,o=cordys.com
      cn=Student1,cn=organizational users,o=Organization1,cn=cordys,cn=defaultInst,o=cordys.com
      
        definition
        Business Process Models/FunctieDeclaratie
        
          
        
        Run from Directory Poller
      
    
  
 

Use of File Interface


  • In WebServices Folder in the Workspace select Add Runtime Reference – Webservice Interface



  • Select File Connector and click Finish



  • Now you can use the methods within a Process


  • When you run the operation you can get the error:
    “Student1 not in the any role …”. This is due to the fact that the user has to have the “everyone” role (Do not forget to check “Include internal roles”)