How to parameterize request-url in citrus-context.xml for citrus-http:client tag dynamically?

153 Views Asked by At

I did the following setup in citrus-context.xml file to parameterize but it does only the value we set in endpoint.properties file. This needs to be dynamic nature in my case and URL should come from client request. Is that possible to configure dynamically? like wanted to use same automation code for two different domain url endpoints for dev and qa enviroments.

 <citrus-http:client
    id="service_endpoint"
    request-url="${Service.Endpoint.URL}"
    request-method="GET"
    content-type="text/xml"
    charset="UTF-8"
    timeout="60000" />

endpoint.properties file

<context:property-placeholder location="classpath:endpoint.properties"/>
1

There are 1 best solutions below

0
On

You can use the endpointUriResolver on the http-client endpoint as follows:

<citrus-http:client 
         ...
         endpoint-resolver="dynamicEndpointResolver"/>

<bean id="dynamicEndpointResolver" 
    class="com.consol.citrus.endpoint.resolver.DynamicEndpointUriResolver"/>

And the set the endpoint request URL in the test action as special header:

<header>
  <element name="citrus_endpoint_uri"
           value="http://${host}:${port}/${path}" />
</header>