Introduction To JMS Testing
Introduction To JMS Testing
Testing
SoapUI Hermes Integration
In SoapUI 3.5 we introduced support for JMS messaging allowing you
to send and receive both text and binary messages.
SoapUI integrates with the HermesJMS open source application which
supports many different JMS providers.
For the purpose of this tutorial we will need to download the new
soapUI 3.5 installer which integrates the installer ofHermesJMS.
Installing soapUI
When starting the new soapUI installer you will get an option that you
can select to install HermesJMS also. This is mandatory if you want to
try this tutorial (unless you already have HermesJMS 1.14 or later
installed).
Open the Preferences editor and choose the Providers tab first at the
bottom. Select Classpath Groups on the right and choose 'Add Group',
type the name 'ActiveMQ-5.2'
Than add these two jar files also by clicking on 'Add JAR(s)', activemq-
core-5.X.X.jar( or activemq-client-5.X.X.jar for newer versions of activeMQ) and geronimo-j2ee-
management_1.0_spec-1.0.jar. (These jar files can be found in
%actvemq_home%/lib folder).
Now choose the session tab in HermesJMS and first choose the Loader
to 'ActiveMQ-5.2' and then add the settings and properties as displayed below.
Here you can COPY-PASTE serviceURL: service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi
and also the brokerURL: tcp://localhost:61616
First set the Hermes Config path to the folder where hermes-config.xml is (usually .hermes), than select the
above configured session and queue-topic for sending-publishing and queue-topic for receiving-subscribing.
You can choose send-publish only by leaving Receive Queue field blank and also receive-subscribe only by
leaving Send Queue-Topic blank.
Example:
* send only jms://activeMQsession::queue_testQ1
* receive only jms://activeMQsession::-::queue_testQ1
* send and receive jms://activeMQsession::queue_testQ1::topic_testT1
Last one is usefull in cases when you send something to a queue and checks topic as response imediatelly as
it first subscribe to this topic ( durable subscription ) and then send to a queue.
All combinations are allowed. Available queues and topics depend on what we have configured in
HermesJMS, so if we add another queue for example it will be available in this combo box also. You can add
as many JMS endpoints this way as you need.
Next we need to create a new TestSuite and TestCase and add a Soap TestRequest. Select the operation to
invoke (for example the Request login), which opens the editor with a corresponding default message.
Select an endpoint where the send queue and receive queues are the same and submit the request.
Special note for TIBCO EMS users: Add tibjmsadmin.jar and tibjms.jar to %SoapUI%\bin\ext folder, and
restart SoapUI application after that.
.
Websphere MQ users:
You need the following JAR-files in SoapUI's hermes/lib folder:
com.ibm.mq.pcf-6.1.jar
com.ibm.mq.jar
com.ibm.mqjms.jar
dhbcore.jar
connector.jar
As you can see, the message we sent is shown in the response window since we sent and received from the
same JMS queue (for the purpose of this example).In JMS Header inspector you can specify JMS Headers ,Time
to Live(miliseconds) , to select if you want to send message as BytesMessage , to add SoapAction in property
(required by some providers, Tibco EMS ...) as well as Durable Subscription Name, CliendID and you can filter
response messages with Message Selector. Response has a JMS inspector showing all JMS headers and
properties
You can also set custom JMS Properties for your request.
Another important thing to set is the Timeout property
where you set the time to wait ( in milliseconds ) for the receiving-subscribing queue-topic. If this is not set
or set to zero it will wait to infinity.
Also here you can specify username and password if needed.
The method described above allows us to send-publish and receive-subscribe jms TextMessage
Another important thing we have to mention is that you can also use Groovy Script Test Step if you want
something else to do with your queues and topics. Here is one example of how to use our API to browse
messages from one queue without receiving it.
import com.eviware.soapui.impl.wsdl.submit.transports.jms.JMSConnectionHolder
import com.eviware.soapui.impl.wsdl.submit.transports.jms.util.HermesUtils
import com.eviware.soapui.impl.wsdl.submit.transports.jms.JMSEndpoint
import hermes.Hermes
import javax.jms.*
QueueBrowser qb = queueSession.createBrowser(queueBrowse);
Enumeration en= qb.getEnumeration();
while(en.hasMoreElements()){
TextMessage tm = (TextMessage)en.nextElement();
log.info tm.getText()
}
jmsConnectionHolder.closeAll()// don't forget to close session and connection