camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Claus Ibsen (JIRA)" <>
Subject [jira] Commented: (CAMEL-772) Predicates with two types should consider casting to desired type before evaluating
Date Sun, 28 Dec 2008 11:52:05 GMT


Claus Ibsen commented on CAMEL-772:

I have attached a patch with this change. However as it's a bit magical that Camel will type
convert to the right value (usually the data type on the exchange/message) before performing
the matching.

But you can do: 
And it will convert the string to byte[] as the body() is a byte[]

You can still do the convertBodyTo as well:

> Predicates with two types should consider casting to desired type before evaluating
> -----------------------------------------------------------------------------------
>                 Key: CAMEL-772
>                 URL:
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>    Affects Versions: 1.4.0
>            Reporter: Claus Ibsen
>            Assignee: Claus Ibsen
>             Fix For: 2.0.0
>         Attachments: CAMEL-772.patch
> I had this unit test where I want to assert that the message body contains this string
> {code}
>         MockEndpoint error = getMockEndpoint("mock:errorQueue");
>         error.expectedMessageCount(1);
>         error.message(0).body().contains("<patientCpr>0101701234</patientCpr>");
> {code}
> But the expression fails because the body is byte array and is not casted to String as
the contains type is.
> If I change the code to:
> {code}
>         error.message(0).body().convertTo(String.class).contains("<patientCpr>0101701234</patientCpr>");
> {code}
> Then it of course works. But what if there already is a type convert in Camel that could
have done the cast for me?
> But is it dangerous to add such automatic type casting behind the end-users back? Any

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message