Forum Discussion

Said's avatar
Said
Contributor
9 years ago

Automate loading message in HermesJMS from SOAPUI

Hi,

 

Currently I am manually loading messages on a queue in HermesJMS, via Send TextMessage (Ctrl +S).

The name of the session is: WMQ_PRIVATE_SESSIONNAME

The name of the queue is: O.APP_TO.ESB.TST.DATA

 

I would like to automate this manual step in SoapUI via a groovy script. I am using SoapUI 5.0.0. I found sample code at Smarbear. Below is the code partly adjusted.

 

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

log.info "jms endpoint zetten"
log.info testRunner.testCase.testSuite.project.hermesConfig

//def jmsEndpoint = new JMSEndpoint("jms://activeMQSession::queue_testQ1::queue_testQ1");
def jmsEndpoint = new JMSEndpoint("jms://WMQ_PRIVATE_SESSIONNAME::O.APP_TO.ESB.TST.DATA::O.APP_TO.ESB.TST.DATA");

//log.info testRunner.testCase.testSuite.project.getPropertyValue ("Hermes Config")

log.info "hermes zetten"
//def hermes = HermesUtils.getHermes( context.testCase.testSuite.project, jmsEndpoint.sessionName)
//def hermes = HermesUtils.getHermes( "H:/.hermes/hermes-config.xml", jmsEndpoint.sessionName)
def hermes = HermesUtils.getHermes( testRunner.testCase.testSuite.project.hermesConfig , jmsEndpoint.sessionName )


log.info "jms connectionholder"
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

 

 

The line below gives error: javax.naming.NamingException: : error at line 18

def hermes = HermesUtils.getHermes( testRunner.testCase.testSuite.project.hermesConfig , jmsEndpoint.sessionName

 

I have a project propery "Hermes Config"

The value is: "H:/.hermes"

 

Can someone tell me why this error occurs and how to do to fix this issue?

Also is this the right way to go (to automate loading TextMessage)?

 

Thanks in advance,

 

MadSaid

    • nmrao's avatar
      nmrao
      Champion Level 3
      def hermes = HermesUtils.getHermes(context.testCase.testSuite.project, jmsEndPoint.sessionName)
      def jmsConnectionHolder = new com.eviware.soapui.impl.wsdl.submit.transports.jms.JMSConnectionHolder(jmsEndPoint, hermes, false, clientID, username, password)

       See if this is helpful.

      • Said's avatar
        Said
        Contributor

        Thanks for you suggestion Rao.

        I pasted this:

        def hermes = HermesUtils.getHermes(context.testCase.testSuite.project, jmsEndPoint.sessionName)

         

        But I get this error on that line:

        groovy.lang.MissingPropertyException: No such property: jmsEndPoint for class: Script2 error at line: 22.

         

        I added line below to check the sessionName

        log.info "jmsEndpoint.sessionName: " + jmsEndpoint.sessionName

         

        Gives: jmsEndpoint.sessionName: WMQ_PRIVATE_SESSIONNAME

         

        I get the session name there. Could it be an issue with processing hermes-config.xml?