cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamically set JMS Properties from groovy code

SOLVED
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?

1 ACCEPTED SOLUTION

Accepted Solutions
Community Hero

Re: Dynamically set JMS Properties from groovy code

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

View solution in original post

19 REPLIES 19
Occasional Contributor

Re: Dynamically set JMS Properties from groovy code

Can you please help me?

Occasional Contributor

Re: Dynamically set JMS Properties from groovy code

Can you please provide an answer?

Community Hero

Re: Dynamically set JMS Properties from groovy code

@qazwsx,

What a patience!

What is happening with your script?
What properties would you like to add?


Regards,
Rao.
Occasional Contributor

Re: Dynamically set JMS Properties from groovy code

Is there is any possibility to add JMS Properties dynamically? Because in my case a number of these properties will be different, also a value of the key.

For eg., I will have a data source with the data loop and inside I will have a JMS Request. And during the first iteration

JMS Request will have 2 keys:

Key Value
Key1 Value1
Key2 Value2

and during the second iteration will have 3 keys:

Key Value
Key3 Value3
Key4 Value4
Key5 Value5

and so on.

In some cases, JMS Request might have 0 keys.

 

I'm searching for a solution for this kind case.

Community Hero

Re: Dynamically set JMS Properties from groovy code

Occasional Contributor

Re: Dynamically set JMS Properties from groovy code

I'm getting this error:

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

Community Hero

Re: Dynamically set JMS Properties from groovy code

@qazwsx ,

 

Difficult to say without more information.

 

Can you please post the result of below statements?

log.info step.metaClass
log.info step.metaClass.methods*.name


Regards,
Rao.
Occasional Contributor

Re: Dynamically set JMS Properties from groovy code

  • Wed Feb 13 11:44:53 CET 2019: INFO: org.codehaus.groovy.runtime.HandleMetaClass@46689895[groovy.lang.MetaClassImpl@46689895[class com.eviware.soapui.impl.wsdl.teststeps.JMSTestStep]]
  • Wed Feb 13 11:44:53 CET 2019: INFO: [equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait, addPropertyChangeListener, addPropertyChangeListener, fireIndexedPropertyChange, getChildren, getDashboardDbId, getProject, initItemOrder, isNotifyPropertyChanged, notifyPropertyChanged, release, removePropertyChangeListener, removePropertyChangeListener, setDashboardDbId, setNotifyPropertyChanged, afterLoad, afterSave, beforeSave, clearIdCache, dependsOn, getConfig, getDescription, getExternalAction, getExternalDependencies, getIcon, getId, getName, getParent, getSettings, getWsdlModelItemById, getWsdlModelItemByName, initItemOrder, initWsdlModelItemOrder, release, resetConfigOnMove, resolve, setConfig, setDescription, setExternalAction, setIcon, setName, afterCopy, afterCreateFromGUI, cancel, clone, dependsOn, finish, getDefaultSourcePropertyName, getDefaultTargetPropertyName, getLabel, getModelItem, getPropertiesLabel, getRequiredInterfaces, getTestCase, getTestStepTitle, hasEditor, isDisabled, isForLoadTest, prepare, resetConfigOnMove, setDisabled, setName, addTestPropertyListener, firePropertyValueChanged, getProperties, getProperty, getPropertyAt, getPropertyCount, getPropertyList, getPropertyNames, getPropertyValue, hasProperties, hasProperty, moveProperty, moveProperty, propertyRenamed, release, removeTestPropertyListener, setPropertyValue, afterLoad, beforeSave, cancel, getAuthProfileHolder, getConnectionFactoryProducer, getConnectionProducer, getContextProducer, getDestinationProducer, getIcon, getIconAnimator, getMessageConsumerProducer, getRequestStep, getRequiredInterfaces, getSessionProducer, propertyChange, release, run, setConnectionFactoryProducer, setConnectionProducer, setContextProducer, setDestinationProducer, setMessageConsumerProducer, setName, setSessionProducer, addPropertyChangeListener]
Community Hero

Re: Dynamically set JMS Properties from groovy code

Thanks. Possible to attach the screen shot of test case?


Regards,
Rao.
New Here?
Join us and watch the welcome video:
Top Kudoed Authors