citrusframework / citrusframework/citrus

Using variables within a http client receive

Open
#676 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
485
Forks
155
Avg merge
4d 22h
Merged PRs (30d)
6

Description

**Citrus Version**
2.8.0

**Expected behavior**
Specifying a variable name within an http.receive().validate() should extract the value of the variable and use that as the final value.

For example:

```
variable("VERSION_PATH", "//root/version/@number");

http(http -> http
.client(SomeServiceEndpoint)
.receive()
.response(HttpStatus.OK)
.validate("${VERSION_PATH}", "1.0")

```
The ${VERSION_PATH} in the .validate should be replaced by its value = '//root/version/@number'.

**Actual behavior**
The .validate step is completely bypassed on execution and as a result, a failure is never caught, even if the expected result is wrong.

In other words, the use of a variable in the spot above is not working (or supported?).

However, if I specified the following, it would successfully validate:

```
http(http -> http
.client(SomeServiceEndpoint)
.receive()
.response(HttpStatus.OK)
.validate("//root/version/@number", "1.0")

```

**Test case sample**
> Please see above for my sample.

Is this expected behavior, perhaps not supported?

Thank you.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the sample on Citrus 2.8.0, comparing http.receive().validate() with the literal XPath case. Trace how variable() values are resolved before validation. Done means ${VERSION_PATH} is used as //root/version/@number and an incorrect expected value causes the validation to fail.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.