Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validating XPath numbers with Hamcrest <Double> matchers fails with ClassCastException #291

Closed
karnis opened this Issue Sep 27, 2017 · 0 comments

Comments

Projects
None yet
2 participants
@karnis
Copy link
Contributor

karnis commented Sep 27, 2017

I must admit that even if .validate("number:count(//someNode)", greaterThan("0")) succeeds using a <Double> matcher .validate("number:count(//someNode)", greaterThan(0.0)) fails with

FAILURE: Caused by: ClassCastException: java.lang.Double cannot be cast to java.lang.String

It seems that the cause is line 167 converting the result to a string
https://github.com/christophd/citrus/blob/4393d0a152a10d1bebb8ccbf7a5ee4324046de43/modules/citrus-core/src/main/java/com/consol/citrus/xml/xpath/XPathUtils.java#L161-L169
as no other if in this method matches the XPathExpressionResult.NUMBER.

The user guide in
https://github.com/christophd/citrus/blob/19641388661c1e129c744c48937d2ccddf1af4a9/src/manual/xpath.adoc#L151-L153

shows using an <Integer> matcher which will also fail with a ClassCastException.

An additional improvement might be even supporting Integer casts with e.g. integer: thus allowing
.validate("integer:count(//someNode)", greaterThan(0)), TBD

@karnis karnis changed the title Validating XPath numbers with Hamcrest matchers fails with ClassCastException Validating XPath numbers with Hamcrest <Double> matchers fails with ClassCastException Sep 27, 2017

@christophd christophd added this to the v2.7.3 milestone Sep 28, 2017

@christophd christophd added IN PROGRESS and removed READY labels Oct 24, 2017

@christophd christophd removed the IN PROGRESS label Oct 24, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.