0% found this document useful (0 votes)
122 views

Introduction To JMS Testing

This document provides instructions for configuring and using JMS messaging in SoapUI. It describes downloading SoapUI and HermesJMS, setting up an ActiveMQ server, creating a HermesJMS session, adding JMS endpoints in SoapUI, and sending and receiving JMS messages. It also provides tips for using Websphere MQ and TIBCO EMS with SoapUI.

Uploaded by

Moinuddin Ansari
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
122 views

Introduction To JMS Testing

This document provides instructions for configuring and using JMS messaging in SoapUI. It describes downloading SoapUI and HermesJMS, setting up an ActiveMQ server, creating a HermesJMS session, adding JMS endpoints in SoapUI, and sending and receiving JMS messages. It also provides tips for using Websphere MQ and TIBCO EMS with SoapUI.

Uploaded by

Moinuddin Ansari
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Introduction to JMS

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.

HermesJMS with binary distributions


If you want to use binary distributions you need to install HermesJMS
1.14 manually (download here) and set its path to Preferences->Tools.

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).

Downloading ActiveMQ and starting the


server
Also for the purpose of this tutorial we will need ActiveMQ (a free JMS
implementation). Download it from the serverhere . Unpack it and start
activemq.bat file under bin folder. This will start activemq server on
your local machine.
Setting HermesJMS sessions
For purpose of this tutorial we will create one session in HermesJMS.

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

We have now created a session in HermesJMS named activeMQSession


with two queues and two topics which we can use from within SoapUI.
Working with JMS
Messages
Ifyou have configured the session in HermesJMS from Getting Started,
you can use soapUI support for JMS.
First you need to use the sample project that goes with the soapUI
installation %soapui_home%/Tutorials/sample-soapui-project.xml
Open the project and right-click on interface
SampleServiceSoapBinding and choose Add JMS Endpoint
The following popup dialog will open

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.*

def jmsEndpoint = new JMSEndpoint("jms://activeMQSession::queue_testQ1::queue_testQ1");


def hermes = HermesUtils.getHermes( context.testCase.testSuite.project,
jmsEndpoint.sessionName)
def jmsConnectionHolder = new JMSConnectionHolder( jmsEndpoint, hermes, false, null ,null
,null);

Session queueSession = jmsConnectionHolder.getSession();


Queue queueSend = jmsConnectionHolder.getQueue(
jmsConnectionHolder.getJmsEndpoint().getSend() );
Queue queueBrowse = jmsConnectionHolder.getQueue(
jmsConnectionHolder.getJmsEndpoint().getReceive() );

MessageProducer messageProducer =queueSession.createProducer( queueSend );


TextMessage textMessageSend = queueSession.createTextMessage();
textMessageSend.setText( "jms message from groovy");
messageProducer.send( textMessageSend );
textMessageSend.setText( "another jms message from groovy");
messageProducer.send( textMessageSend );

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

You might also like