Ask a Question

Dynamically set JMS Properties from groovy code

SOLVED
qazwsx
Occasional Contributor

Dynamically set JMS Properties from groovy code

Dears,

 

Can you please tell me if there is any way to set JMS Property from groovy code?

soapJMS.png

I tried different ways to find a solution but unfortunately, nothing is working.

I can't use for example something like this ${#TestCase#PROPERTY_NAME}, because the number of JMS properties might be different like also names of properties.

 

Can you please help me with this topic?

19 REPLIES 19
nmrao
Champion Level 3

Are you using SoapUI Pro?


Regards,
Rao.
qazwsx
Occasional Contributor

Yes, I'm using SoapUI Pro.

tc.png

 

nmrao
Champion Level 3

Thanks, moved to right forum.

Do you able to use datasource values in SubmitListener.beforeSubmit()?


Regards,
Rao.
nmrao
Champion Level 3

@qazwsx ,

 

Can you quickly try with below change?

 

From:

def existingProperties = step.httpRequest.getJMSPropertiesConfig().getJMSProperties()

 

To

def existingProperties = ((com.eviware.soapui.impl.wsdl.teststeps.WsdlTestStepWithProperties)step).httpRequest.getJMSPropertiesConfig().getJMSProperties()

 



Regards,
Rao.
qazwsx
Occasional Contributor

With this change I got this error:

groovy.lang.MissingPropertyException: No such property: httpRequest for class: com.eviware.soapui.impl.wsdl.teststeps.JMSTestStep error at line: 23

nmrao
Champion Level 3

What about this?

Do you able to use datasource values in SubmitListener.beforeSubmit()?


Regards,
Rao.
qazwsx
Occasional Contributor

I think I will able to use it. Or at least I will try.

nmrao
Champion Level 3

@qazwsx 

 

Ok. Try to put below code in SubmitListener.beforeSubmit

 

 

import com.eviware.soapui.config.JMSPropertyConfig

//Assign your data from datasource into map below - have your logic; otherwise try with fixed data
def map = [a: 'one', b:'two']
if ('JMSRequestReply' == submit.request.name) {
    def existingProperties = submit.request.getJMSPropertiesConfig().getJMSProperties()

   def newList = new ArrayList<JMSPropertyConfig>()
   map.each { key, value ->
	def jmsPropertyConfig = JMSPropertyConfig.Factory.newInstance()
	jmsPropertyConfig.setName(key)
	jmsPropertyConfig.setValue(value)
	newList.add(jmsPropertyConfig)
   }
           
   existingProperties.clear()
   existingProperties.addAll(newList)

}

 



Regards,
Rao.
qazwsx
Occasional Contributor

Thank you it's working. For now, I tried with static data, but it's working.

nmrao
Champion Level 3

Glad to know. Would you like to mark it the above solution as solved?


Regards,
Rao.
cancel
Showing results for 
Search instead for 
Did you mean: