You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Charles Moulliard <cm...@gmail.com> on 2009/10/20 16:48:05 UTC
Camel assertion error
Unit test return the following error :
java.lang.AssertionError: mock://result Body of message: 0.
Expected:
<[{org.apache.camel.dataformat.bindy.model.fix.simple.Header=Model :
org.apache.camel.dataformat.bindy.model.fix.simple.Header, FIX 4.1,
20, 10, INVMGR, BRKR,
org.apache.camel.dataformat.bindy.model.fix.simple.Order=Model :
org.apache.camel.dataformat.bindy.model.fix.simple.Order, BE.CHM.001,
CHM0001-01, 4, BE0001245678, 1, this is a camel - bindy test,
org.apache.camel.dataformat.bindy.model.fix.simple.Trailer=Model :
org.apache.camel.dataformat.bindy.model.fix.simple.Trailer, 220}]>
but was:
<[{org.apache.camel.dataformat.bindy.model.fix.simple.Header=Model :
org.apache.camel.dataformat.bindy.model.fix.simple.Header, FIX.4.1,
20, 10, INVMGR, BRKR,
org.apache.camel.dataformat.bindy.model.fix.simple.Order=Model :
org.apache.camel.dataformat.bindy.model.fix.simple.Order, BE.CHM.001,
CHM0001-01, 4, BE0001245678, 1, this is a camel - bindy test,
org.apache.camel.dataformat.bindy.model.fix.simple.Trailer=Model :
org.apache.camel.dataformat.bindy.model.fix.simple.Trailer, 220}]>
I don't understand why test fail because comparison of both is the same !!!
Here is the method used to compare what I receive :
result.expectedBodiesReceived()
result = result endpoint
Regards,
Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer
*****************************
blog : http://cmoulliard.blogspot.com
twitter : http://twitter.com/cmoulliard
Re: Camel assertion error
Posted by Charles Moulliard <cm...@gmail.com>.
The result.expectedBodiesReceived( generateModel().toString() ); was working
There was a stupid "." character instead of a " " in the expected string.
So forget my question
Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer
*****************************
blog : http://cmoulliard.blogspot.com
twitter : http://twitter.com/cmoulliard
On Wed, Oct 21, 2009 at 11:08 AM, Claus Ibsen <cl...@gmail.com> wrote:
> Yeah they are not String equals
>
> See below:
>> [{org.apache.camel.dataformat.bindy.model.fix.simple.Header=org.apache.camel.dataformat.bindy.model.fix.simple.Header@35bb0f[
>> [{org.apache.camel.dataformat.bindy.model.fix.simple.Header=org.apache.camel.dataformat.bindy.model.fix.simple.Header@366573[
>
> You can override and implement a toString in the Header class to avoid
> printing the @xxxx stuff (hash coded)
>
> Or implement equals / hashCode on your objects and let them be able to compare.
>
> Or just do a simple check if X text exists using indexOf
>
>
>
> On Wed, Oct 21, 2009 at 11:04 AM, Charles Moulliard
> <cm...@gmail.com> wrote:
>> Assertion error is also generated using what you propose Claus :
>>
>> java.lang.AssertionError: mock://result body ==
>> [{org.apache.camel.dataformat.bindy.model.fix.simple.Header=org.apache.camel.dataformat.bindy.model.fix.simple.Header@35bb0f[
>> beginString=FIX 4.1
>> bodyLength=20
>> msgSeqNum=1
>> msgType=0
>> sendCompId=INVMGR
>> targetCompId=BRKR
>> ], org.apache.camel.dataformat.bindy.model.fix.simple.Order=org.apache.camel.dataformat.bindy.model.fix.simple.Order@11eb199[
>> header=org.apache.camel.dataformat.bindy.model.fix.simple.Header@35bb0f[
>> beginString=FIX 4.1
>> bodyLength=20
>> msgSeqNum=1
>> msgType=0
>> sendCompId=INVMGR
>> targetCompId=BRKR
>> ]
>> trailer=org.apache.camel.dataformat.bindy.model.fix.simple.Trailer@8ae45a[
>> checkSum=220
>> ]
>> account=BE.CHM.001
>> clOrdId=CHM0001-01
>> iDSource=4
>> securityId=BE0001245678
>> side=1
>> text=this is a camel - bindy test
>> ], org.apache.camel.dataformat.bindy.model.fix.simple.Trailer=org.apache.camel.dataformat.bindy.model.fix.simple.Trailer@8ae45a[
>> checkSum=220
>> ]}] on Exchange[GenericFileMessage with body:
>> [{org.apache.camel.dataformat.bindy.model.fix.simple.Header=org.apache.camel.dataformat.bindy.model.fix.simple.Header@366573[
>> beginString=FIX.4.1
>> bodyLength=20
>> msgSeqNum=1
>> msgType=0
>> sendCompId=INVMGR
>> targetCompId=BRKR
>> ], org.apache.camel.dataformat.bindy.model.fix.simple.Order=org.apache.camel.dataformat.bindy.model.fix.simple.Order@13e75a5[
>> header=org.apache.camel.dataformat.bindy.model.fix.simple.Header@366573[
>> beginString=FIX.4.1
>> bodyLength=20
>> msgSeqNum=1
>> msgType=0
>> sendCompId=INVMGR
>> targetCompId=BRKR
>> ]
>> trailer=org.apache.camel.dataformat.bindy.model.fix.simple.Trailer@19da967[
>> checkSum=220
>> ]
>> account=BE.CHM.001
>> clOrdId=CHM0001-01
>> iDSource=4
>> securityId=BE0001245678
>> side=1
>> text=this is a camel - bindy test
>> ], org.apache.camel.dataformat.bindy.model.fix.simple.Trailer=org.apache.camel.dataformat.bindy.model.fix.simple.Trailer@19da967[
>> checkSum=220
>> ]}]]
>>
>> Charles Moulliard
>> Senior Enterprise Architect
>> Apache Camel Committer
>>
>> *****************************
>> blog : http://cmoulliard.blogspot.com
>> twitter : http://twitter.com/cmoulliard
>>
>>
>>
>> On Wed, Oct 21, 2009 at 10:48 AM, Claus Ibsen <cl...@gmail.com> wrote:
>>> On Wed, Oct 21, 2009 at 10:41 AM, Charles Moulliard
>>> <cm...@gmail.com> wrote:
>>>> How do you do the comparison ?
>>>>
>>>> If I extend my model class with the AbstractParent and that I use the
>>>> following method :
>>>>
>>>> result.expectedBodiesReceived( generateModel().toString() );
>>>
>>> This one does a simple assertEquals from junit.
>>> Maybe we should extend it to use Camels type coverter system as well.
>>>
>>>
>>> You can do this in Camel instead
>>> result.message(0).body().isEqualTo(generateModel().toString());
>>>
>>>
>>>>
>>>> to compare what I receive from camel-bindy unmarshalling with a model
>>>> generated from scratch, the test fail
>>>>
>>>> java.lang.AssertionError: mock://result Body of message: 0. Expected:
>>>> <[{org.apache.camel.dataformat.bindy.model.fix.sorted.body.Order=org.apache.camel.dataformat.bindy.model.fix.sorted.body.Order@e45b5e[
>>>> header=org.apache.camel.dataformat.bindy.model.fix.sorted.header.Header@7f58ef[
>>>> beginString=FIX 4.1
>>>> bodyLength=20
>>>> msgSeqNum=1
>>>> msgType=0
>>>> sendCompId=INVMGR
>>>> targetCompId=BRKR
>>>> ]
>>>> trailer=org.apache.camel.dataformat.bindy.model.fix.sorted.trailer.Trailer@e1dac2[
>>>> checkSum=220
>>>> ]
>>>> account=BE.CHM.001
>>>> clOrdId=CHM0001-01
>>>> iDSource=4
>>>> securityId=BE0001245678
>>>> side=1
>>>> text=this is a camel - bindy test
>>>> ], org.apache.camel.dataformat.bindy.model.fix.sorted.header.Header=org.apache.camel.dataformat.bindy.model.fix.sorted.header.Header@7f58ef[
>>>> beginString=FIX 4.1
>>>> bodyLength=20
>>>> msgSeqNum=1
>>>> msgType=0
>>>> sendCompId=INVMGR
>>>> targetCompId=BRKR
>>>> ], org.apache.camel.dataformat.bindy.model.fix.sorted.trailer.Trailer=org.apache.camel.dataformat.bindy.model.fix.sorted.trailer.Trailer@e1dac2[
>>>> checkSum=220
>>>> ]}]> but was: <[{org.apache.camel.dataformat.bindy.model.fix.sorted.body.Order=org.apache.camel.dataformat.bindy.model.fix.sorted.body.Order@19f03d7[
>>>> header=org.apache.camel.dataformat.bindy.model.fix.sorted.header.Header@4bf53e[
>>>> beginString=FIX.4.1
>>>> bodyLength=20
>>>> msgSeqNum=1
>>>> msgType=0
>>>> sendCompId=INVMGR
>>>> targetCompId=BRKR
>>>> ]
>>>> trailer=org.apache.camel.dataformat.bindy.model.fix.sorted.trailer.Trailer@d1e7c2[
>>>> checkSum=220
>>>> ]
>>>> account=BE.CHM.001
>>>> clOrdId=CHM0001-01
>>>> iDSource=4
>>>> securityId=BE0001245678
>>>> side=1
>>>> text=this is a camel - bindy test
>>>> ], org.apache.camel.dataformat.bindy.model.fix.sorted.header.Header=org.apache.camel.dataformat.bindy.model.fix.sorted.header.Header@4bf53e[
>>>> beginString=FIX.4.1
>>>> bodyLength=20
>>>> msgSeqNum=1
>>>> msgType=0
>>>> sendCompId=INVMGR
>>>> targetCompId=BRKR
>>>> ], org.apache.camel.dataformat.bindy.model.fix.sorted.trailer.Trailer=org.apache.camel.dataformat.bindy.model.fix.sorted.trailer.Trailer@d1e7c2[
>>>> checkSum=220
>>>> ]}]>
>>>>
>>>> Regards,
>>>>
>>>> Charles Moulliard
>>>> Senior Enterprise Architect
>>>> Apache Camel Committer
>>>>
>>>> *****************************
>>>> blog : http://cmoulliard.blogspot.com
>>>> twitter : http://twitter.com/cmoulliard
>>>>
>>>>
>>>>
>>>> On Wed, Oct 21, 2009 at 9:16 AM, Dmitry Ulanov <du...@gmail.com> wrote:
>>>>> In Java Objects are comared via equals() method, not toString(). I usually
>>>>> use Jakarta Lang libarary to automate it. For example:
>>>>>
>>>>> import java.io.Serializable;
>>>>>
>>>>> import org.apache.commons.lang.builder.EqualsBuilder;
>>>>> import org.apache.commons.lang.builder.HashCodeBuilder;
>>>>> import org.apache.commons.lang.builder.ToStringBuilder;
>>>>> import org.apache.commons.lang.builder.ToStringStyle;
>>>>>
>>>>> public abstract class AbstractParent<T extends AbstractParent> implements
>>>>> Serializable {
>>>>>
>>>>> private static final long serialVersionUID = 1L;
>>>>>
>>>>> @Override public boolean equals(Object obj) {
>>>>> return EqualsBuilder.reflectionEquals(this, obj);
>>>>> }
>>>>>
>>>>> @Override public int hashCode() {
>>>>> return HashCodeBuilder.reflectionHashCode(this);
>>>>> }
>>>>>
>>>>> @Override public String toString() {
>>>>> return ToStringBuilder.reflectionToString(this,
>>>>> ToStringStyle.MULTI_LINE_STYLE);
>>>>> }
>>>>> }
>>>>>
>>>>> On Wed, Oct 21, 2009 at 11:12 AM, Charles Moulliard <cm...@gmail.com>wrote:
>>>>>
>>>>>> I have customized the toString method of each Class. What is strange
>>>>>> is that in another the test generating the same objects, it works.
>>>>>>
>>>>>> I will adapt the test to compare object differently.
>>>>>>
>>>>>> Charles Moulliard
>>>>>> Senior Enterprise Architect
>>>>>> Apache Camel Committer
>>>>>>
>>>>>> *****************************
>>>>>> blog : http://cmoulliard.blogspot.com
>>>>>> twitter : http://twitter.com/cmoulliard
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Tue, Oct 20, 2009 at 7:48 PM, Claus Ibsen <cl...@gmail.com>
>>>>>> wrote:
>>>>>> > Hi
>>>>>> >
>>>>>> > If you are comparing objects it will use equals and it may not be able
>>>>>> > to detect that they are identical.
>>>>>> >
>>>>>> > If they have a nice toString you can convert them to String and do a
>>>>>> > string equals.
>>>>>> >
>>>>>> > At least their to string output in this mail looks as if they are
>>>>>> identical.
>>>>>> >
>>>>>> > On Tue, Oct 20, 2009 at 4:48 PM, Charles Moulliard <cm...@gmail.com>
>>>>>> wrote:
>>>>>> >> Unit test return the following error :
>>>>>> >>
>>>>>> >> java.lang.AssertionError: mock://result Body of message: 0.
>>>>>> >>
>>>>>> >> Expected:
>>>>>> >>
>>>>>> >> <[{org.apache.camel.dataformat.bindy.model.fix.simple.Header=Model :
>>>>>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Header, FIX 4.1,
>>>>>> >> 20, 10, INVMGR, BRKR,
>>>>>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Order=Model :
>>>>>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Order, BE.CHM.001,
>>>>>> >> CHM0001-01, 4, BE0001245678, 1, this is a camel - bindy test,
>>>>>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Trailer=Model :
>>>>>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Trailer, 220}]>
>>>>>> >>
>>>>>> >> but was:
>>>>>> >>
>>>>>> >> <[{org.apache.camel.dataformat.bindy.model.fix.simple.Header=Model :
>>>>>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Header, FIX.4.1,
>>>>>> >> 20, 10, INVMGR, BRKR,
>>>>>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Order=Model :
>>>>>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Order, BE.CHM.001,
>>>>>> >> CHM0001-01, 4, BE0001245678, 1, this is a camel - bindy test,
>>>>>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Trailer=Model :
>>>>>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Trailer, 220}]>
>>>>>> >>
>>>>>> >> I don't understand why test fail because comparison of both is the same
>>>>>> !!!
>>>>>> >>
>>>>>> >> Here is the method used to compare what I receive :
>>>>>> >> result.expectedBodiesReceived()
>>>>>> >>
>>>>>> >> result = result endpoint
>>>>>> >>
>>>>>> >> Regards,
>>>>>> >>
>>>>>> >> Charles Moulliard
>>>>>> >> Senior Enterprise Architect
>>>>>> >> Apache Camel Committer
>>>>>> >>
>>>>>> >> *****************************
>>>>>> >> blog : http://cmoulliard.blogspot.com
>>>>>> >> twitter : http://twitter.com/cmoulliard
>>>>>> >>
>>>>>> >
>>>>>> >
>>>>>> >
>>>>>> > --
>>>>>> > Claus Ibsen
>>>>>> > Apache Camel Committer
>>>>>> >
>>>>>> > Open Source Integration: http://fusesource.com
>>>>>> > Blog: http://davsclaus.blogspot.com/
>>>>>> > Twitter: http://twitter.com/davsclaus
>>>>>> >
>>>>>>
>>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> Claus Ibsen
>>> Apache Camel Committer
>>>
>>> Open Source Integration: http://fusesource.com
>>> Blog: http://davsclaus.blogspot.com/
>>> Twitter: http://twitter.com/davsclaus
>>>
>>
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>
Re: Camel assertion error
Posted by Claus Ibsen <cl...@gmail.com>.
Yeah they are not String equals
See below:
> [{org.apache.camel.dataformat.bindy.model.fix.simple.Header=org.apache.camel.dataformat.bindy.model.fix.simple.Header@35bb0f[
> [{org.apache.camel.dataformat.bindy.model.fix.simple.Header=org.apache.camel.dataformat.bindy.model.fix.simple.Header@366573[
You can override and implement a toString in the Header class to avoid
printing the @xxxx stuff (hash coded)
Or implement equals / hashCode on your objects and let them be able to compare.
Or just do a simple check if X text exists using indexOf
On Wed, Oct 21, 2009 at 11:04 AM, Charles Moulliard
<cm...@gmail.com> wrote:
> Assertion error is also generated using what you propose Claus :
>
> java.lang.AssertionError: mock://result body ==
> [{org.apache.camel.dataformat.bindy.model.fix.simple.Header=org.apache.camel.dataformat.bindy.model.fix.simple.Header@35bb0f[
> beginString=FIX 4.1
> bodyLength=20
> msgSeqNum=1
> msgType=0
> sendCompId=INVMGR
> targetCompId=BRKR
> ], org.apache.camel.dataformat.bindy.model.fix.simple.Order=org.apache.camel.dataformat.bindy.model.fix.simple.Order@11eb199[
> header=org.apache.camel.dataformat.bindy.model.fix.simple.Header@35bb0f[
> beginString=FIX 4.1
> bodyLength=20
> msgSeqNum=1
> msgType=0
> sendCompId=INVMGR
> targetCompId=BRKR
> ]
> trailer=org.apache.camel.dataformat.bindy.model.fix.simple.Trailer@8ae45a[
> checkSum=220
> ]
> account=BE.CHM.001
> clOrdId=CHM0001-01
> iDSource=4
> securityId=BE0001245678
> side=1
> text=this is a camel - bindy test
> ], org.apache.camel.dataformat.bindy.model.fix.simple.Trailer=org.apache.camel.dataformat.bindy.model.fix.simple.Trailer@8ae45a[
> checkSum=220
> ]}] on Exchange[GenericFileMessage with body:
> [{org.apache.camel.dataformat.bindy.model.fix.simple.Header=org.apache.camel.dataformat.bindy.model.fix.simple.Header@366573[
> beginString=FIX.4.1
> bodyLength=20
> msgSeqNum=1
> msgType=0
> sendCompId=INVMGR
> targetCompId=BRKR
> ], org.apache.camel.dataformat.bindy.model.fix.simple.Order=org.apache.camel.dataformat.bindy.model.fix.simple.Order@13e75a5[
> header=org.apache.camel.dataformat.bindy.model.fix.simple.Header@366573[
> beginString=FIX.4.1
> bodyLength=20
> msgSeqNum=1
> msgType=0
> sendCompId=INVMGR
> targetCompId=BRKR
> ]
> trailer=org.apache.camel.dataformat.bindy.model.fix.simple.Trailer@19da967[
> checkSum=220
> ]
> account=BE.CHM.001
> clOrdId=CHM0001-01
> iDSource=4
> securityId=BE0001245678
> side=1
> text=this is a camel - bindy test
> ], org.apache.camel.dataformat.bindy.model.fix.simple.Trailer=org.apache.camel.dataformat.bindy.model.fix.simple.Trailer@19da967[
> checkSum=220
> ]}]]
>
> Charles Moulliard
> Senior Enterprise Architect
> Apache Camel Committer
>
> *****************************
> blog : http://cmoulliard.blogspot.com
> twitter : http://twitter.com/cmoulliard
>
>
>
> On Wed, Oct 21, 2009 at 10:48 AM, Claus Ibsen <cl...@gmail.com> wrote:
>> On Wed, Oct 21, 2009 at 10:41 AM, Charles Moulliard
>> <cm...@gmail.com> wrote:
>>> How do you do the comparison ?
>>>
>>> If I extend my model class with the AbstractParent and that I use the
>>> following method :
>>>
>>> result.expectedBodiesReceived( generateModel().toString() );
>>
>> This one does a simple assertEquals from junit.
>> Maybe we should extend it to use Camels type coverter system as well.
>>
>>
>> You can do this in Camel instead
>> result.message(0).body().isEqualTo(generateModel().toString());
>>
>>
>>>
>>> to compare what I receive from camel-bindy unmarshalling with a model
>>> generated from scratch, the test fail
>>>
>>> java.lang.AssertionError: mock://result Body of message: 0. Expected:
>>> <[{org.apache.camel.dataformat.bindy.model.fix.sorted.body.Order=org.apache.camel.dataformat.bindy.model.fix.sorted.body.Order@e45b5e[
>>> header=org.apache.camel.dataformat.bindy.model.fix.sorted.header.Header@7f58ef[
>>> beginString=FIX 4.1
>>> bodyLength=20
>>> msgSeqNum=1
>>> msgType=0
>>> sendCompId=INVMGR
>>> targetCompId=BRKR
>>> ]
>>> trailer=org.apache.camel.dataformat.bindy.model.fix.sorted.trailer.Trailer@e1dac2[
>>> checkSum=220
>>> ]
>>> account=BE.CHM.001
>>> clOrdId=CHM0001-01
>>> iDSource=4
>>> securityId=BE0001245678
>>> side=1
>>> text=this is a camel - bindy test
>>> ], org.apache.camel.dataformat.bindy.model.fix.sorted.header.Header=org.apache.camel.dataformat.bindy.model.fix.sorted.header.Header@7f58ef[
>>> beginString=FIX 4.1
>>> bodyLength=20
>>> msgSeqNum=1
>>> msgType=0
>>> sendCompId=INVMGR
>>> targetCompId=BRKR
>>> ], org.apache.camel.dataformat.bindy.model.fix.sorted.trailer.Trailer=org.apache.camel.dataformat.bindy.model.fix.sorted.trailer.Trailer@e1dac2[
>>> checkSum=220
>>> ]}]> but was: <[{org.apache.camel.dataformat.bindy.model.fix.sorted.body.Order=org.apache.camel.dataformat.bindy.model.fix.sorted.body.Order@19f03d7[
>>> header=org.apache.camel.dataformat.bindy.model.fix.sorted.header.Header@4bf53e[
>>> beginString=FIX.4.1
>>> bodyLength=20
>>> msgSeqNum=1
>>> msgType=0
>>> sendCompId=INVMGR
>>> targetCompId=BRKR
>>> ]
>>> trailer=org.apache.camel.dataformat.bindy.model.fix.sorted.trailer.Trailer@d1e7c2[
>>> checkSum=220
>>> ]
>>> account=BE.CHM.001
>>> clOrdId=CHM0001-01
>>> iDSource=4
>>> securityId=BE0001245678
>>> side=1
>>> text=this is a camel - bindy test
>>> ], org.apache.camel.dataformat.bindy.model.fix.sorted.header.Header=org.apache.camel.dataformat.bindy.model.fix.sorted.header.Header@4bf53e[
>>> beginString=FIX.4.1
>>> bodyLength=20
>>> msgSeqNum=1
>>> msgType=0
>>> sendCompId=INVMGR
>>> targetCompId=BRKR
>>> ], org.apache.camel.dataformat.bindy.model.fix.sorted.trailer.Trailer=org.apache.camel.dataformat.bindy.model.fix.sorted.trailer.Trailer@d1e7c2[
>>> checkSum=220
>>> ]}]>
>>>
>>> Regards,
>>>
>>> Charles Moulliard
>>> Senior Enterprise Architect
>>> Apache Camel Committer
>>>
>>> *****************************
>>> blog : http://cmoulliard.blogspot.com
>>> twitter : http://twitter.com/cmoulliard
>>>
>>>
>>>
>>> On Wed, Oct 21, 2009 at 9:16 AM, Dmitry Ulanov <du...@gmail.com> wrote:
>>>> In Java Objects are comared via equals() method, not toString(). I usually
>>>> use Jakarta Lang libarary to automate it. For example:
>>>>
>>>> import java.io.Serializable;
>>>>
>>>> import org.apache.commons.lang.builder.EqualsBuilder;
>>>> import org.apache.commons.lang.builder.HashCodeBuilder;
>>>> import org.apache.commons.lang.builder.ToStringBuilder;
>>>> import org.apache.commons.lang.builder.ToStringStyle;
>>>>
>>>> public abstract class AbstractParent<T extends AbstractParent> implements
>>>> Serializable {
>>>>
>>>> private static final long serialVersionUID = 1L;
>>>>
>>>> @Override public boolean equals(Object obj) {
>>>> return EqualsBuilder.reflectionEquals(this, obj);
>>>> }
>>>>
>>>> @Override public int hashCode() {
>>>> return HashCodeBuilder.reflectionHashCode(this);
>>>> }
>>>>
>>>> @Override public String toString() {
>>>> return ToStringBuilder.reflectionToString(this,
>>>> ToStringStyle.MULTI_LINE_STYLE);
>>>> }
>>>> }
>>>>
>>>> On Wed, Oct 21, 2009 at 11:12 AM, Charles Moulliard <cm...@gmail.com>wrote:
>>>>
>>>>> I have customized the toString method of each Class. What is strange
>>>>> is that in another the test generating the same objects, it works.
>>>>>
>>>>> I will adapt the test to compare object differently.
>>>>>
>>>>> Charles Moulliard
>>>>> Senior Enterprise Architect
>>>>> Apache Camel Committer
>>>>>
>>>>> *****************************
>>>>> blog : http://cmoulliard.blogspot.com
>>>>> twitter : http://twitter.com/cmoulliard
>>>>>
>>>>>
>>>>>
>>>>> On Tue, Oct 20, 2009 at 7:48 PM, Claus Ibsen <cl...@gmail.com>
>>>>> wrote:
>>>>> > Hi
>>>>> >
>>>>> > If you are comparing objects it will use equals and it may not be able
>>>>> > to detect that they are identical.
>>>>> >
>>>>> > If they have a nice toString you can convert them to String and do a
>>>>> > string equals.
>>>>> >
>>>>> > At least their to string output in this mail looks as if they are
>>>>> identical.
>>>>> >
>>>>> > On Tue, Oct 20, 2009 at 4:48 PM, Charles Moulliard <cm...@gmail.com>
>>>>> wrote:
>>>>> >> Unit test return the following error :
>>>>> >>
>>>>> >> java.lang.AssertionError: mock://result Body of message: 0.
>>>>> >>
>>>>> >> Expected:
>>>>> >>
>>>>> >> <[{org.apache.camel.dataformat.bindy.model.fix.simple.Header=Model :
>>>>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Header, FIX 4.1,
>>>>> >> 20, 10, INVMGR, BRKR,
>>>>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Order=Model :
>>>>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Order, BE.CHM.001,
>>>>> >> CHM0001-01, 4, BE0001245678, 1, this is a camel - bindy test,
>>>>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Trailer=Model :
>>>>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Trailer, 220}]>
>>>>> >>
>>>>> >> but was:
>>>>> >>
>>>>> >> <[{org.apache.camel.dataformat.bindy.model.fix.simple.Header=Model :
>>>>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Header, FIX.4.1,
>>>>> >> 20, 10, INVMGR, BRKR,
>>>>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Order=Model :
>>>>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Order, BE.CHM.001,
>>>>> >> CHM0001-01, 4, BE0001245678, 1, this is a camel - bindy test,
>>>>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Trailer=Model :
>>>>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Trailer, 220}]>
>>>>> >>
>>>>> >> I don't understand why test fail because comparison of both is the same
>>>>> !!!
>>>>> >>
>>>>> >> Here is the method used to compare what I receive :
>>>>> >> result.expectedBodiesReceived()
>>>>> >>
>>>>> >> result = result endpoint
>>>>> >>
>>>>> >> Regards,
>>>>> >>
>>>>> >> Charles Moulliard
>>>>> >> Senior Enterprise Architect
>>>>> >> Apache Camel Committer
>>>>> >>
>>>>> >> *****************************
>>>>> >> blog : http://cmoulliard.blogspot.com
>>>>> >> twitter : http://twitter.com/cmoulliard
>>>>> >>
>>>>> >
>>>>> >
>>>>> >
>>>>> > --
>>>>> > Claus Ibsen
>>>>> > Apache Camel Committer
>>>>> >
>>>>> > Open Source Integration: http://fusesource.com
>>>>> > Blog: http://davsclaus.blogspot.com/
>>>>> > Twitter: http://twitter.com/davsclaus
>>>>> >
>>>>>
>>>>
>>>
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
>
--
Claus Ibsen
Apache Camel Committer
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Re: Camel assertion error
Posted by Charles Moulliard <cm...@gmail.com>.
Assertion error is also generated using what you propose Claus :
java.lang.AssertionError: mock://result body ==
[{org.apache.camel.dataformat.bindy.model.fix.simple.Header=org.apache.camel.dataformat.bindy.model.fix.simple.Header@35bb0f[
beginString=FIX 4.1
bodyLength=20
msgSeqNum=1
msgType=0
sendCompId=INVMGR
targetCompId=BRKR
], org.apache.camel.dataformat.bindy.model.fix.simple.Order=org.apache.camel.dataformat.bindy.model.fix.simple.Order@11eb199[
header=org.apache.camel.dataformat.bindy.model.fix.simple.Header@35bb0f[
beginString=FIX 4.1
bodyLength=20
msgSeqNum=1
msgType=0
sendCompId=INVMGR
targetCompId=BRKR
]
trailer=org.apache.camel.dataformat.bindy.model.fix.simple.Trailer@8ae45a[
checkSum=220
]
account=BE.CHM.001
clOrdId=CHM0001-01
iDSource=4
securityId=BE0001245678
side=1
text=this is a camel - bindy test
], org.apache.camel.dataformat.bindy.model.fix.simple.Trailer=org.apache.camel.dataformat.bindy.model.fix.simple.Trailer@8ae45a[
checkSum=220
]}] on Exchange[GenericFileMessage with body:
[{org.apache.camel.dataformat.bindy.model.fix.simple.Header=org.apache.camel.dataformat.bindy.model.fix.simple.Header@366573[
beginString=FIX.4.1
bodyLength=20
msgSeqNum=1
msgType=0
sendCompId=INVMGR
targetCompId=BRKR
], org.apache.camel.dataformat.bindy.model.fix.simple.Order=org.apache.camel.dataformat.bindy.model.fix.simple.Order@13e75a5[
header=org.apache.camel.dataformat.bindy.model.fix.simple.Header@366573[
beginString=FIX.4.1
bodyLength=20
msgSeqNum=1
msgType=0
sendCompId=INVMGR
targetCompId=BRKR
]
trailer=org.apache.camel.dataformat.bindy.model.fix.simple.Trailer@19da967[
checkSum=220
]
account=BE.CHM.001
clOrdId=CHM0001-01
iDSource=4
securityId=BE0001245678
side=1
text=this is a camel - bindy test
], org.apache.camel.dataformat.bindy.model.fix.simple.Trailer=org.apache.camel.dataformat.bindy.model.fix.simple.Trailer@19da967[
checkSum=220
]}]]
Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer
*****************************
blog : http://cmoulliard.blogspot.com
twitter : http://twitter.com/cmoulliard
On Wed, Oct 21, 2009 at 10:48 AM, Claus Ibsen <cl...@gmail.com> wrote:
> On Wed, Oct 21, 2009 at 10:41 AM, Charles Moulliard
> <cm...@gmail.com> wrote:
>> How do you do the comparison ?
>>
>> If I extend my model class with the AbstractParent and that I use the
>> following method :
>>
>> result.expectedBodiesReceived( generateModel().toString() );
>
> This one does a simple assertEquals from junit.
> Maybe we should extend it to use Camels type coverter system as well.
>
>
> You can do this in Camel instead
> result.message(0).body().isEqualTo(generateModel().toString());
>
>
>>
>> to compare what I receive from camel-bindy unmarshalling with a model
>> generated from scratch, the test fail
>>
>> java.lang.AssertionError: mock://result Body of message: 0. Expected:
>> <[{org.apache.camel.dataformat.bindy.model.fix.sorted.body.Order=org.apache.camel.dataformat.bindy.model.fix.sorted.body.Order@e45b5e[
>> header=org.apache.camel.dataformat.bindy.model.fix.sorted.header.Header@7f58ef[
>> beginString=FIX 4.1
>> bodyLength=20
>> msgSeqNum=1
>> msgType=0
>> sendCompId=INVMGR
>> targetCompId=BRKR
>> ]
>> trailer=org.apache.camel.dataformat.bindy.model.fix.sorted.trailer.Trailer@e1dac2[
>> checkSum=220
>> ]
>> account=BE.CHM.001
>> clOrdId=CHM0001-01
>> iDSource=4
>> securityId=BE0001245678
>> side=1
>> text=this is a camel - bindy test
>> ], org.apache.camel.dataformat.bindy.model.fix.sorted.header.Header=org.apache.camel.dataformat.bindy.model.fix.sorted.header.Header@7f58ef[
>> beginString=FIX 4.1
>> bodyLength=20
>> msgSeqNum=1
>> msgType=0
>> sendCompId=INVMGR
>> targetCompId=BRKR
>> ], org.apache.camel.dataformat.bindy.model.fix.sorted.trailer.Trailer=org.apache.camel.dataformat.bindy.model.fix.sorted.trailer.Trailer@e1dac2[
>> checkSum=220
>> ]}]> but was: <[{org.apache.camel.dataformat.bindy.model.fix.sorted.body.Order=org.apache.camel.dataformat.bindy.model.fix.sorted.body.Order@19f03d7[
>> header=org.apache.camel.dataformat.bindy.model.fix.sorted.header.Header@4bf53e[
>> beginString=FIX.4.1
>> bodyLength=20
>> msgSeqNum=1
>> msgType=0
>> sendCompId=INVMGR
>> targetCompId=BRKR
>> ]
>> trailer=org.apache.camel.dataformat.bindy.model.fix.sorted.trailer.Trailer@d1e7c2[
>> checkSum=220
>> ]
>> account=BE.CHM.001
>> clOrdId=CHM0001-01
>> iDSource=4
>> securityId=BE0001245678
>> side=1
>> text=this is a camel - bindy test
>> ], org.apache.camel.dataformat.bindy.model.fix.sorted.header.Header=org.apache.camel.dataformat.bindy.model.fix.sorted.header.Header@4bf53e[
>> beginString=FIX.4.1
>> bodyLength=20
>> msgSeqNum=1
>> msgType=0
>> sendCompId=INVMGR
>> targetCompId=BRKR
>> ], org.apache.camel.dataformat.bindy.model.fix.sorted.trailer.Trailer=org.apache.camel.dataformat.bindy.model.fix.sorted.trailer.Trailer@d1e7c2[
>> checkSum=220
>> ]}]>
>>
>> Regards,
>>
>> Charles Moulliard
>> Senior Enterprise Architect
>> Apache Camel Committer
>>
>> *****************************
>> blog : http://cmoulliard.blogspot.com
>> twitter : http://twitter.com/cmoulliard
>>
>>
>>
>> On Wed, Oct 21, 2009 at 9:16 AM, Dmitry Ulanov <du...@gmail.com> wrote:
>>> In Java Objects are comared via equals() method, not toString(). I usually
>>> use Jakarta Lang libarary to automate it. For example:
>>>
>>> import java.io.Serializable;
>>>
>>> import org.apache.commons.lang.builder.EqualsBuilder;
>>> import org.apache.commons.lang.builder.HashCodeBuilder;
>>> import org.apache.commons.lang.builder.ToStringBuilder;
>>> import org.apache.commons.lang.builder.ToStringStyle;
>>>
>>> public abstract class AbstractParent<T extends AbstractParent> implements
>>> Serializable {
>>>
>>> private static final long serialVersionUID = 1L;
>>>
>>> @Override public boolean equals(Object obj) {
>>> return EqualsBuilder.reflectionEquals(this, obj);
>>> }
>>>
>>> @Override public int hashCode() {
>>> return HashCodeBuilder.reflectionHashCode(this);
>>> }
>>>
>>> @Override public String toString() {
>>> return ToStringBuilder.reflectionToString(this,
>>> ToStringStyle.MULTI_LINE_STYLE);
>>> }
>>> }
>>>
>>> On Wed, Oct 21, 2009 at 11:12 AM, Charles Moulliard <cm...@gmail.com>wrote:
>>>
>>>> I have customized the toString method of each Class. What is strange
>>>> is that in another the test generating the same objects, it works.
>>>>
>>>> I will adapt the test to compare object differently.
>>>>
>>>> Charles Moulliard
>>>> Senior Enterprise Architect
>>>> Apache Camel Committer
>>>>
>>>> *****************************
>>>> blog : http://cmoulliard.blogspot.com
>>>> twitter : http://twitter.com/cmoulliard
>>>>
>>>>
>>>>
>>>> On Tue, Oct 20, 2009 at 7:48 PM, Claus Ibsen <cl...@gmail.com>
>>>> wrote:
>>>> > Hi
>>>> >
>>>> > If you are comparing objects it will use equals and it may not be able
>>>> > to detect that they are identical.
>>>> >
>>>> > If they have a nice toString you can convert them to String and do a
>>>> > string equals.
>>>> >
>>>> > At least their to string output in this mail looks as if they are
>>>> identical.
>>>> >
>>>> > On Tue, Oct 20, 2009 at 4:48 PM, Charles Moulliard <cm...@gmail.com>
>>>> wrote:
>>>> >> Unit test return the following error :
>>>> >>
>>>> >> java.lang.AssertionError: mock://result Body of message: 0.
>>>> >>
>>>> >> Expected:
>>>> >>
>>>> >> <[{org.apache.camel.dataformat.bindy.model.fix.simple.Header=Model :
>>>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Header, FIX 4.1,
>>>> >> 20, 10, INVMGR, BRKR,
>>>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Order=Model :
>>>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Order, BE.CHM.001,
>>>> >> CHM0001-01, 4, BE0001245678, 1, this is a camel - bindy test,
>>>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Trailer=Model :
>>>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Trailer, 220}]>
>>>> >>
>>>> >> but was:
>>>> >>
>>>> >> <[{org.apache.camel.dataformat.bindy.model.fix.simple.Header=Model :
>>>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Header, FIX.4.1,
>>>> >> 20, 10, INVMGR, BRKR,
>>>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Order=Model :
>>>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Order, BE.CHM.001,
>>>> >> CHM0001-01, 4, BE0001245678, 1, this is a camel - bindy test,
>>>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Trailer=Model :
>>>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Trailer, 220}]>
>>>> >>
>>>> >> I don't understand why test fail because comparison of both is the same
>>>> !!!
>>>> >>
>>>> >> Here is the method used to compare what I receive :
>>>> >> result.expectedBodiesReceived()
>>>> >>
>>>> >> result = result endpoint
>>>> >>
>>>> >> Regards,
>>>> >>
>>>> >> Charles Moulliard
>>>> >> Senior Enterprise Architect
>>>> >> Apache Camel Committer
>>>> >>
>>>> >> *****************************
>>>> >> blog : http://cmoulliard.blogspot.com
>>>> >> twitter : http://twitter.com/cmoulliard
>>>> >>
>>>> >
>>>> >
>>>> >
>>>> > --
>>>> > Claus Ibsen
>>>> > Apache Camel Committer
>>>> >
>>>> > Open Source Integration: http://fusesource.com
>>>> > Blog: http://davsclaus.blogspot.com/
>>>> > Twitter: http://twitter.com/davsclaus
>>>> >
>>>>
>>>
>>
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>
Re: Camel assertion error
Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Oct 21, 2009 at 10:41 AM, Charles Moulliard
<cm...@gmail.com> wrote:
> How do you do the comparison ?
>
> If I extend my model class with the AbstractParent and that I use the
> following method :
>
> result.expectedBodiesReceived( generateModel().toString() );
This one does a simple assertEquals from junit.
Maybe we should extend it to use Camels type coverter system as well.
You can do this in Camel instead
result.message(0).body().isEqualTo(generateModel().toString());
>
> to compare what I receive from camel-bindy unmarshalling with a model
> generated from scratch, the test fail
>
> java.lang.AssertionError: mock://result Body of message: 0. Expected:
> <[{org.apache.camel.dataformat.bindy.model.fix.sorted.body.Order=org.apache.camel.dataformat.bindy.model.fix.sorted.body.Order@e45b5e[
> header=org.apache.camel.dataformat.bindy.model.fix.sorted.header.Header@7f58ef[
> beginString=FIX 4.1
> bodyLength=20
> msgSeqNum=1
> msgType=0
> sendCompId=INVMGR
> targetCompId=BRKR
> ]
> trailer=org.apache.camel.dataformat.bindy.model.fix.sorted.trailer.Trailer@e1dac2[
> checkSum=220
> ]
> account=BE.CHM.001
> clOrdId=CHM0001-01
> iDSource=4
> securityId=BE0001245678
> side=1
> text=this is a camel - bindy test
> ], org.apache.camel.dataformat.bindy.model.fix.sorted.header.Header=org.apache.camel.dataformat.bindy.model.fix.sorted.header.Header@7f58ef[
> beginString=FIX 4.1
> bodyLength=20
> msgSeqNum=1
> msgType=0
> sendCompId=INVMGR
> targetCompId=BRKR
> ], org.apache.camel.dataformat.bindy.model.fix.sorted.trailer.Trailer=org.apache.camel.dataformat.bindy.model.fix.sorted.trailer.Trailer@e1dac2[
> checkSum=220
> ]}]> but was: <[{org.apache.camel.dataformat.bindy.model.fix.sorted.body.Order=org.apache.camel.dataformat.bindy.model.fix.sorted.body.Order@19f03d7[
> header=org.apache.camel.dataformat.bindy.model.fix.sorted.header.Header@4bf53e[
> beginString=FIX.4.1
> bodyLength=20
> msgSeqNum=1
> msgType=0
> sendCompId=INVMGR
> targetCompId=BRKR
> ]
> trailer=org.apache.camel.dataformat.bindy.model.fix.sorted.trailer.Trailer@d1e7c2[
> checkSum=220
> ]
> account=BE.CHM.001
> clOrdId=CHM0001-01
> iDSource=4
> securityId=BE0001245678
> side=1
> text=this is a camel - bindy test
> ], org.apache.camel.dataformat.bindy.model.fix.sorted.header.Header=org.apache.camel.dataformat.bindy.model.fix.sorted.header.Header@4bf53e[
> beginString=FIX.4.1
> bodyLength=20
> msgSeqNum=1
> msgType=0
> sendCompId=INVMGR
> targetCompId=BRKR
> ], org.apache.camel.dataformat.bindy.model.fix.sorted.trailer.Trailer=org.apache.camel.dataformat.bindy.model.fix.sorted.trailer.Trailer@d1e7c2[
> checkSum=220
> ]}]>
>
> Regards,
>
> Charles Moulliard
> Senior Enterprise Architect
> Apache Camel Committer
>
> *****************************
> blog : http://cmoulliard.blogspot.com
> twitter : http://twitter.com/cmoulliard
>
>
>
> On Wed, Oct 21, 2009 at 9:16 AM, Dmitry Ulanov <du...@gmail.com> wrote:
>> In Java Objects are comared via equals() method, not toString(). I usually
>> use Jakarta Lang libarary to automate it. For example:
>>
>> import java.io.Serializable;
>>
>> import org.apache.commons.lang.builder.EqualsBuilder;
>> import org.apache.commons.lang.builder.HashCodeBuilder;
>> import org.apache.commons.lang.builder.ToStringBuilder;
>> import org.apache.commons.lang.builder.ToStringStyle;
>>
>> public abstract class AbstractParent<T extends AbstractParent> implements
>> Serializable {
>>
>> private static final long serialVersionUID = 1L;
>>
>> @Override public boolean equals(Object obj) {
>> return EqualsBuilder.reflectionEquals(this, obj);
>> }
>>
>> @Override public int hashCode() {
>> return HashCodeBuilder.reflectionHashCode(this);
>> }
>>
>> @Override public String toString() {
>> return ToStringBuilder.reflectionToString(this,
>> ToStringStyle.MULTI_LINE_STYLE);
>> }
>> }
>>
>> On Wed, Oct 21, 2009 at 11:12 AM, Charles Moulliard <cm...@gmail.com>wrote:
>>
>>> I have customized the toString method of each Class. What is strange
>>> is that in another the test generating the same objects, it works.
>>>
>>> I will adapt the test to compare object differently.
>>>
>>> Charles Moulliard
>>> Senior Enterprise Architect
>>> Apache Camel Committer
>>>
>>> *****************************
>>> blog : http://cmoulliard.blogspot.com
>>> twitter : http://twitter.com/cmoulliard
>>>
>>>
>>>
>>> On Tue, Oct 20, 2009 at 7:48 PM, Claus Ibsen <cl...@gmail.com>
>>> wrote:
>>> > Hi
>>> >
>>> > If you are comparing objects it will use equals and it may not be able
>>> > to detect that they are identical.
>>> >
>>> > If they have a nice toString you can convert them to String and do a
>>> > string equals.
>>> >
>>> > At least their to string output in this mail looks as if they are
>>> identical.
>>> >
>>> > On Tue, Oct 20, 2009 at 4:48 PM, Charles Moulliard <cm...@gmail.com>
>>> wrote:
>>> >> Unit test return the following error :
>>> >>
>>> >> java.lang.AssertionError: mock://result Body of message: 0.
>>> >>
>>> >> Expected:
>>> >>
>>> >> <[{org.apache.camel.dataformat.bindy.model.fix.simple.Header=Model :
>>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Header, FIX 4.1,
>>> >> 20, 10, INVMGR, BRKR,
>>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Order=Model :
>>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Order, BE.CHM.001,
>>> >> CHM0001-01, 4, BE0001245678, 1, this is a camel - bindy test,
>>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Trailer=Model :
>>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Trailer, 220}]>
>>> >>
>>> >> but was:
>>> >>
>>> >> <[{org.apache.camel.dataformat.bindy.model.fix.simple.Header=Model :
>>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Header, FIX.4.1,
>>> >> 20, 10, INVMGR, BRKR,
>>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Order=Model :
>>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Order, BE.CHM.001,
>>> >> CHM0001-01, 4, BE0001245678, 1, this is a camel - bindy test,
>>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Trailer=Model :
>>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Trailer, 220}]>
>>> >>
>>> >> I don't understand why test fail because comparison of both is the same
>>> !!!
>>> >>
>>> >> Here is the method used to compare what I receive :
>>> >> result.expectedBodiesReceived()
>>> >>
>>> >> result = result endpoint
>>> >>
>>> >> Regards,
>>> >>
>>> >> Charles Moulliard
>>> >> Senior Enterprise Architect
>>> >> Apache Camel Committer
>>> >>
>>> >> *****************************
>>> >> blog : http://cmoulliard.blogspot.com
>>> >> twitter : http://twitter.com/cmoulliard
>>> >>
>>> >
>>> >
>>> >
>>> > --
>>> > Claus Ibsen
>>> > Apache Camel Committer
>>> >
>>> > Open Source Integration: http://fusesource.com
>>> > Blog: http://davsclaus.blogspot.com/
>>> > Twitter: http://twitter.com/davsclaus
>>> >
>>>
>>
>
--
Claus Ibsen
Apache Camel Committer
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Re: Camel assertion error
Posted by Charles Moulliard <cm...@gmail.com>.
How do you do the comparison ?
If I extend my model class with the AbstractParent and that I use the
following method :
result.expectedBodiesReceived( generateModel().toString() );
to compare what I receive from camel-bindy unmarshalling with a model
generated from scratch, the test fail
java.lang.AssertionError: mock://result Body of message: 0. Expected:
<[{org.apache.camel.dataformat.bindy.model.fix.sorted.body.Order=org.apache.camel.dataformat.bindy.model.fix.sorted.body.Order@e45b5e[
header=org.apache.camel.dataformat.bindy.model.fix.sorted.header.Header@7f58ef[
beginString=FIX 4.1
bodyLength=20
msgSeqNum=1
msgType=0
sendCompId=INVMGR
targetCompId=BRKR
]
trailer=org.apache.camel.dataformat.bindy.model.fix.sorted.trailer.Trailer@e1dac2[
checkSum=220
]
account=BE.CHM.001
clOrdId=CHM0001-01
iDSource=4
securityId=BE0001245678
side=1
text=this is a camel - bindy test
], org.apache.camel.dataformat.bindy.model.fix.sorted.header.Header=org.apache.camel.dataformat.bindy.model.fix.sorted.header.Header@7f58ef[
beginString=FIX 4.1
bodyLength=20
msgSeqNum=1
msgType=0
sendCompId=INVMGR
targetCompId=BRKR
], org.apache.camel.dataformat.bindy.model.fix.sorted.trailer.Trailer=org.apache.camel.dataformat.bindy.model.fix.sorted.trailer.Trailer@e1dac2[
checkSum=220
]}]> but was: <[{org.apache.camel.dataformat.bindy.model.fix.sorted.body.Order=org.apache.camel.dataformat.bindy.model.fix.sorted.body.Order@19f03d7[
header=org.apache.camel.dataformat.bindy.model.fix.sorted.header.Header@4bf53e[
beginString=FIX.4.1
bodyLength=20
msgSeqNum=1
msgType=0
sendCompId=INVMGR
targetCompId=BRKR
]
trailer=org.apache.camel.dataformat.bindy.model.fix.sorted.trailer.Trailer@d1e7c2[
checkSum=220
]
account=BE.CHM.001
clOrdId=CHM0001-01
iDSource=4
securityId=BE0001245678
side=1
text=this is a camel - bindy test
], org.apache.camel.dataformat.bindy.model.fix.sorted.header.Header=org.apache.camel.dataformat.bindy.model.fix.sorted.header.Header@4bf53e[
beginString=FIX.4.1
bodyLength=20
msgSeqNum=1
msgType=0
sendCompId=INVMGR
targetCompId=BRKR
], org.apache.camel.dataformat.bindy.model.fix.sorted.trailer.Trailer=org.apache.camel.dataformat.bindy.model.fix.sorted.trailer.Trailer@d1e7c2[
checkSum=220
]}]>
Regards,
Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer
*****************************
blog : http://cmoulliard.blogspot.com
twitter : http://twitter.com/cmoulliard
On Wed, Oct 21, 2009 at 9:16 AM, Dmitry Ulanov <du...@gmail.com> wrote:
> In Java Objects are comared via equals() method, not toString(). I usually
> use Jakarta Lang libarary to automate it. For example:
>
> import java.io.Serializable;
>
> import org.apache.commons.lang.builder.EqualsBuilder;
> import org.apache.commons.lang.builder.HashCodeBuilder;
> import org.apache.commons.lang.builder.ToStringBuilder;
> import org.apache.commons.lang.builder.ToStringStyle;
>
> public abstract class AbstractParent<T extends AbstractParent> implements
> Serializable {
>
> private static final long serialVersionUID = 1L;
>
> @Override public boolean equals(Object obj) {
> return EqualsBuilder.reflectionEquals(this, obj);
> }
>
> @Override public int hashCode() {
> return HashCodeBuilder.reflectionHashCode(this);
> }
>
> @Override public String toString() {
> return ToStringBuilder.reflectionToString(this,
> ToStringStyle.MULTI_LINE_STYLE);
> }
> }
>
> On Wed, Oct 21, 2009 at 11:12 AM, Charles Moulliard <cm...@gmail.com>wrote:
>
>> I have customized the toString method of each Class. What is strange
>> is that in another the test generating the same objects, it works.
>>
>> I will adapt the test to compare object differently.
>>
>> Charles Moulliard
>> Senior Enterprise Architect
>> Apache Camel Committer
>>
>> *****************************
>> blog : http://cmoulliard.blogspot.com
>> twitter : http://twitter.com/cmoulliard
>>
>>
>>
>> On Tue, Oct 20, 2009 at 7:48 PM, Claus Ibsen <cl...@gmail.com>
>> wrote:
>> > Hi
>> >
>> > If you are comparing objects it will use equals and it may not be able
>> > to detect that they are identical.
>> >
>> > If they have a nice toString you can convert them to String and do a
>> > string equals.
>> >
>> > At least their to string output in this mail looks as if they are
>> identical.
>> >
>> > On Tue, Oct 20, 2009 at 4:48 PM, Charles Moulliard <cm...@gmail.com>
>> wrote:
>> >> Unit test return the following error :
>> >>
>> >> java.lang.AssertionError: mock://result Body of message: 0.
>> >>
>> >> Expected:
>> >>
>> >> <[{org.apache.camel.dataformat.bindy.model.fix.simple.Header=Model :
>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Header, FIX 4.1,
>> >> 20, 10, INVMGR, BRKR,
>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Order=Model :
>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Order, BE.CHM.001,
>> >> CHM0001-01, 4, BE0001245678, 1, this is a camel - bindy test,
>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Trailer=Model :
>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Trailer, 220}]>
>> >>
>> >> but was:
>> >>
>> >> <[{org.apache.camel.dataformat.bindy.model.fix.simple.Header=Model :
>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Header, FIX.4.1,
>> >> 20, 10, INVMGR, BRKR,
>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Order=Model :
>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Order, BE.CHM.001,
>> >> CHM0001-01, 4, BE0001245678, 1, this is a camel - bindy test,
>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Trailer=Model :
>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Trailer, 220}]>
>> >>
>> >> I don't understand why test fail because comparison of both is the same
>> !!!
>> >>
>> >> Here is the method used to compare what I receive :
>> >> result.expectedBodiesReceived()
>> >>
>> >> result = result endpoint
>> >>
>> >> Regards,
>> >>
>> >> Charles Moulliard
>> >> Senior Enterprise Architect
>> >> Apache Camel Committer
>> >>
>> >> *****************************
>> >> blog : http://cmoulliard.blogspot.com
>> >> twitter : http://twitter.com/cmoulliard
>> >>
>> >
>> >
>> >
>> > --
>> > Claus Ibsen
>> > Apache Camel Committer
>> >
>> > Open Source Integration: http://fusesource.com
>> > Blog: http://davsclaus.blogspot.com/
>> > Twitter: http://twitter.com/davsclaus
>> >
>>
>
Re: Camel assertion error
Posted by Charles Moulliard <cm...@gmail.com>.
Thks. I will try.
Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer
*****************************
blog : http://cmoulliard.blogspot.com
twitter : http://twitter.com/cmoulliard
On Wed, Oct 21, 2009 at 9:16 AM, Dmitry Ulanov <du...@gmail.com> wrote:
> In Java Objects are comared via equals() method, not toString(). I usually
> use Jakarta Lang libarary to automate it. For example:
>
> import java.io.Serializable;
>
> import org.apache.commons.lang.builder.EqualsBuilder;
> import org.apache.commons.lang.builder.HashCodeBuilder;
> import org.apache.commons.lang.builder.ToStringBuilder;
> import org.apache.commons.lang.builder.ToStringStyle;
>
> public abstract class AbstractParent<T extends AbstractParent> implements
> Serializable {
>
> private static final long serialVersionUID = 1L;
>
> @Override public boolean equals(Object obj) {
> return EqualsBuilder.reflectionEquals(this, obj);
> }
>
> @Override public int hashCode() {
> return HashCodeBuilder.reflectionHashCode(this);
> }
>
> @Override public String toString() {
> return ToStringBuilder.reflectionToString(this,
> ToStringStyle.MULTI_LINE_STYLE);
> }
> }
>
> On Wed, Oct 21, 2009 at 11:12 AM, Charles Moulliard <cm...@gmail.com>wrote:
>
>> I have customized the toString method of each Class. What is strange
>> is that in another the test generating the same objects, it works.
>>
>> I will adapt the test to compare object differently.
>>
>> Charles Moulliard
>> Senior Enterprise Architect
>> Apache Camel Committer
>>
>> *****************************
>> blog : http://cmoulliard.blogspot.com
>> twitter : http://twitter.com/cmoulliard
>>
>>
>>
>> On Tue, Oct 20, 2009 at 7:48 PM, Claus Ibsen <cl...@gmail.com>
>> wrote:
>> > Hi
>> >
>> > If you are comparing objects it will use equals and it may not be able
>> > to detect that they are identical.
>> >
>> > If they have a nice toString you can convert them to String and do a
>> > string equals.
>> >
>> > At least their to string output in this mail looks as if they are
>> identical.
>> >
>> > On Tue, Oct 20, 2009 at 4:48 PM, Charles Moulliard <cm...@gmail.com>
>> wrote:
>> >> Unit test return the following error :
>> >>
>> >> java.lang.AssertionError: mock://result Body of message: 0.
>> >>
>> >> Expected:
>> >>
>> >> <[{org.apache.camel.dataformat.bindy.model.fix.simple.Header=Model :
>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Header, FIX 4.1,
>> >> 20, 10, INVMGR, BRKR,
>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Order=Model :
>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Order, BE.CHM.001,
>> >> CHM0001-01, 4, BE0001245678, 1, this is a camel - bindy test,
>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Trailer=Model :
>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Trailer, 220}]>
>> >>
>> >> but was:
>> >>
>> >> <[{org.apache.camel.dataformat.bindy.model.fix.simple.Header=Model :
>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Header, FIX.4.1,
>> >> 20, 10, INVMGR, BRKR,
>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Order=Model :
>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Order, BE.CHM.001,
>> >> CHM0001-01, 4, BE0001245678, 1, this is a camel - bindy test,
>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Trailer=Model :
>> >> org.apache.camel.dataformat.bindy.model.fix.simple.Trailer, 220}]>
>> >>
>> >> I don't understand why test fail because comparison of both is the same
>> !!!
>> >>
>> >> Here is the method used to compare what I receive :
>> >> result.expectedBodiesReceived()
>> >>
>> >> result = result endpoint
>> >>
>> >> Regards,
>> >>
>> >> Charles Moulliard
>> >> Senior Enterprise Architect
>> >> Apache Camel Committer
>> >>
>> >> *****************************
>> >> blog : http://cmoulliard.blogspot.com
>> >> twitter : http://twitter.com/cmoulliard
>> >>
>> >
>> >
>> >
>> > --
>> > Claus Ibsen
>> > Apache Camel Committer
>> >
>> > Open Source Integration: http://fusesource.com
>> > Blog: http://davsclaus.blogspot.com/
>> > Twitter: http://twitter.com/davsclaus
>> >
>>
>
Re: Camel assertion error
Posted by Dmitry Ulanov <du...@gmail.com>.
In Java Objects are comared via equals() method, not toString(). I usually
use Jakarta Lang libarary to automate it. For example:
import java.io.Serializable;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
public abstract class AbstractParent<T extends AbstractParent> implements
Serializable {
private static final long serialVersionUID = 1L;
@Override public boolean equals(Object obj) {
return EqualsBuilder.reflectionEquals(this, obj);
}
@Override public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override public String toString() {
return ToStringBuilder.reflectionToString(this,
ToStringStyle.MULTI_LINE_STYLE);
}
}
On Wed, Oct 21, 2009 at 11:12 AM, Charles Moulliard <cm...@gmail.com>wrote:
> I have customized the toString method of each Class. What is strange
> is that in another the test generating the same objects, it works.
>
> I will adapt the test to compare object differently.
>
> Charles Moulliard
> Senior Enterprise Architect
> Apache Camel Committer
>
> *****************************
> blog : http://cmoulliard.blogspot.com
> twitter : http://twitter.com/cmoulliard
>
>
>
> On Tue, Oct 20, 2009 at 7:48 PM, Claus Ibsen <cl...@gmail.com>
> wrote:
> > Hi
> >
> > If you are comparing objects it will use equals and it may not be able
> > to detect that they are identical.
> >
> > If they have a nice toString you can convert them to String and do a
> > string equals.
> >
> > At least their to string output in this mail looks as if they are
> identical.
> >
> > On Tue, Oct 20, 2009 at 4:48 PM, Charles Moulliard <cm...@gmail.com>
> wrote:
> >> Unit test return the following error :
> >>
> >> java.lang.AssertionError: mock://result Body of message: 0.
> >>
> >> Expected:
> >>
> >> <[{org.apache.camel.dataformat.bindy.model.fix.simple.Header=Model :
> >> org.apache.camel.dataformat.bindy.model.fix.simple.Header, FIX 4.1,
> >> 20, 10, INVMGR, BRKR,
> >> org.apache.camel.dataformat.bindy.model.fix.simple.Order=Model :
> >> org.apache.camel.dataformat.bindy.model.fix.simple.Order, BE.CHM.001,
> >> CHM0001-01, 4, BE0001245678, 1, this is a camel - bindy test,
> >> org.apache.camel.dataformat.bindy.model.fix.simple.Trailer=Model :
> >> org.apache.camel.dataformat.bindy.model.fix.simple.Trailer, 220}]>
> >>
> >> but was:
> >>
> >> <[{org.apache.camel.dataformat.bindy.model.fix.simple.Header=Model :
> >> org.apache.camel.dataformat.bindy.model.fix.simple.Header, FIX.4.1,
> >> 20, 10, INVMGR, BRKR,
> >> org.apache.camel.dataformat.bindy.model.fix.simple.Order=Model :
> >> org.apache.camel.dataformat.bindy.model.fix.simple.Order, BE.CHM.001,
> >> CHM0001-01, 4, BE0001245678, 1, this is a camel - bindy test,
> >> org.apache.camel.dataformat.bindy.model.fix.simple.Trailer=Model :
> >> org.apache.camel.dataformat.bindy.model.fix.simple.Trailer, 220}]>
> >>
> >> I don't understand why test fail because comparison of both is the same
> !!!
> >>
> >> Here is the method used to compare what I receive :
> >> result.expectedBodiesReceived()
> >>
> >> result = result endpoint
> >>
> >> Regards,
> >>
> >> Charles Moulliard
> >> Senior Enterprise Architect
> >> Apache Camel Committer
> >>
> >> *****************************
> >> blog : http://cmoulliard.blogspot.com
> >> twitter : http://twitter.com/cmoulliard
> >>
> >
> >
> >
> > --
> > Claus Ibsen
> > Apache Camel Committer
> >
> > Open Source Integration: http://fusesource.com
> > Blog: http://davsclaus.blogspot.com/
> > Twitter: http://twitter.com/davsclaus
> >
>
Re: Camel assertion error
Posted by Charles Moulliard <cm...@gmail.com>.
I have customized the toString method of each Class. What is strange
is that in another the test generating the same objects, it works.
I will adapt the test to compare object differently.
Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer
*****************************
blog : http://cmoulliard.blogspot.com
twitter : http://twitter.com/cmoulliard
On Tue, Oct 20, 2009 at 7:48 PM, Claus Ibsen <cl...@gmail.com> wrote:
> Hi
>
> If you are comparing objects it will use equals and it may not be able
> to detect that they are identical.
>
> If they have a nice toString you can convert them to String and do a
> string equals.
>
> At least their to string output in this mail looks as if they are identical.
>
> On Tue, Oct 20, 2009 at 4:48 PM, Charles Moulliard <cm...@gmail.com> wrote:
>> Unit test return the following error :
>>
>> java.lang.AssertionError: mock://result Body of message: 0.
>>
>> Expected:
>>
>> <[{org.apache.camel.dataformat.bindy.model.fix.simple.Header=Model :
>> org.apache.camel.dataformat.bindy.model.fix.simple.Header, FIX 4.1,
>> 20, 10, INVMGR, BRKR,
>> org.apache.camel.dataformat.bindy.model.fix.simple.Order=Model :
>> org.apache.camel.dataformat.bindy.model.fix.simple.Order, BE.CHM.001,
>> CHM0001-01, 4, BE0001245678, 1, this is a camel - bindy test,
>> org.apache.camel.dataformat.bindy.model.fix.simple.Trailer=Model :
>> org.apache.camel.dataformat.bindy.model.fix.simple.Trailer, 220}]>
>>
>> but was:
>>
>> <[{org.apache.camel.dataformat.bindy.model.fix.simple.Header=Model :
>> org.apache.camel.dataformat.bindy.model.fix.simple.Header, FIX.4.1,
>> 20, 10, INVMGR, BRKR,
>> org.apache.camel.dataformat.bindy.model.fix.simple.Order=Model :
>> org.apache.camel.dataformat.bindy.model.fix.simple.Order, BE.CHM.001,
>> CHM0001-01, 4, BE0001245678, 1, this is a camel - bindy test,
>> org.apache.camel.dataformat.bindy.model.fix.simple.Trailer=Model :
>> org.apache.camel.dataformat.bindy.model.fix.simple.Trailer, 220}]>
>>
>> I don't understand why test fail because comparison of both is the same !!!
>>
>> Here is the method used to compare what I receive :
>> result.expectedBodiesReceived()
>>
>> result = result endpoint
>>
>> Regards,
>>
>> Charles Moulliard
>> Senior Enterprise Architect
>> Apache Camel Committer
>>
>> *****************************
>> blog : http://cmoulliard.blogspot.com
>> twitter : http://twitter.com/cmoulliard
>>
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>
Re: Camel assertion error
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
If you are comparing objects it will use equals and it may not be able
to detect that they are identical.
If they have a nice toString you can convert them to String and do a
string equals.
At least their to string output in this mail looks as if they are identical.
On Tue, Oct 20, 2009 at 4:48 PM, Charles Moulliard <cm...@gmail.com> wrote:
> Unit test return the following error :
>
> java.lang.AssertionError: mock://result Body of message: 0.
>
> Expected:
>
> <[{org.apache.camel.dataformat.bindy.model.fix.simple.Header=Model :
> org.apache.camel.dataformat.bindy.model.fix.simple.Header, FIX 4.1,
> 20, 10, INVMGR, BRKR,
> org.apache.camel.dataformat.bindy.model.fix.simple.Order=Model :
> org.apache.camel.dataformat.bindy.model.fix.simple.Order, BE.CHM.001,
> CHM0001-01, 4, BE0001245678, 1, this is a camel - bindy test,
> org.apache.camel.dataformat.bindy.model.fix.simple.Trailer=Model :
> org.apache.camel.dataformat.bindy.model.fix.simple.Trailer, 220}]>
>
> but was:
>
> <[{org.apache.camel.dataformat.bindy.model.fix.simple.Header=Model :
> org.apache.camel.dataformat.bindy.model.fix.simple.Header, FIX.4.1,
> 20, 10, INVMGR, BRKR,
> org.apache.camel.dataformat.bindy.model.fix.simple.Order=Model :
> org.apache.camel.dataformat.bindy.model.fix.simple.Order, BE.CHM.001,
> CHM0001-01, 4, BE0001245678, 1, this is a camel - bindy test,
> org.apache.camel.dataformat.bindy.model.fix.simple.Trailer=Model :
> org.apache.camel.dataformat.bindy.model.fix.simple.Trailer, 220}]>
>
> I don't understand why test fail because comparison of both is the same !!!
>
> Here is the method used to compare what I receive :
> result.expectedBodiesReceived()
>
> result = result endpoint
>
> Regards,
>
> Charles Moulliard
> Senior Enterprise Architect
> Apache Camel Committer
>
> *****************************
> blog : http://cmoulliard.blogspot.com
> twitter : http://twitter.com/cmoulliard
>
--
Claus Ibsen
Apache Camel Committer
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus