Forum Discussion

giannisdoe's avatar
giannisdoe
New Contributor
12 years ago

How to set JMSCorelationId during test execution

Hi all,

does anyone know if it's possible to set the JMSCorrelationId of a soap request during test execution?
I would like to run a test case, that sends some requests to a JMS queue.
The first step of my test case, reads a sequence number from a database and inserts it in the XML Request using a Property Transfer.
However I have to set the JMSCorrelationId equal to this sequence number, and it doesn't seem I can set JMS Headers from a property transfer..
Is there any way to do it, i.e. with a groovy script?

Thanks a lot

Panos
  • nmrao's avatar
    nmrao
    Icon for Champion Level 2 rankChampion Level 2
    Hi,

    Yes, that is possible to create uniquId and set it to JMSCorrelationID during runtime using groovy.

    Add a groovy script step say GenerateCorrelationID before the request step with the following code:

    import java.util.UUID
    def correlationId = String.valueOf(UUID.randomUUID())
    testRunner.testCase.testSuite.project.setPropertyValue("CORRELATIONID", correlationId)


    Now in the request step chage the value to ${#Project#CORRELATIONID} for JMSCorrelationID of JMSHeaders. Note, that you may also change to test case level property as well if you want to.

    Then run your TestCase and see. Hope this helps.

    Regards,
    Rao.