Cannot Access Global Variables Inside citrus-context.xml


Cannot Access Global Variables Inside citrus-context.xml
Given the following citrus-context.xml
:
citrus-context.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:citrus="http://www.citrusframework.org/schema/config"
xmlns:citrus-http="http://www.citrusframework.org/schema/http/config"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.citrusframework.org/schema/config http://www.citrusframework.org/schema/config/citrus-config.xsd
http://www.citrusframework.org/schema/http/config http://www.citrusframework.org/schema/http/config/citrus-http-config.xsd">
<citrus:global-variables>
<citrus:file
path="classpath:endpoints.properties" />
</citrus:global-variables>
<citrus-http:client
id="service_endpoint"
request-url="$Service.Endpoint.URL"
request-method="GET"
content-type="text/xml"
charset="UTF-8"
timeout="60000" />
</beans>
Instead of evaluating $Service.Endpoint.URL
to http://foo.io/service
I get the following error:
$Service.Endpoint.URL
http://foo.io/service
com.consol.citrus.exceptions.TestCaseFailedException: Illegal character in path at index 1: $Service.Endpoint.URL
...
Caused by: java.lang.IllegalArgumentException: Illegal character in path at index 1: $Service.Endpoint.URL
...
Caused by: java.net.URISyntaxException: Illegal character in path at index 1: $Service.Endpoint.URL
Is it this because of a configuration issue, or is the current set-up not possible?
1 Answer
1
Please add a Spring property placeholder configurer to your application context. The configurer is able to evaluate property expressions in Spring bean definitions. The Citrus global variables are not taken into account at design time when the Spring beans are parsed in the application context.
<context:property-placeholder location="classpath:endpoint.properties"/>
The property placeholder is using the special context:
Spring bean namespace. So you need to declare this namespace in your configuration file:
context:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:citrus="http://www.citrusframework.org/schema/config"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
...">
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Comments
Post a Comment