camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: Bug in expectedBodiesReceived(List<>)
Date Wed, 25 Nov 2009 10:17:25 GMT
Hi

Thanks I have looked into it. Its in fact Java that picks the varargs
method always even if you drop in a List type.

So I am fixing it to detect this in the varargs and cater for that.


On Wed, Nov 25, 2009 at 11:04 AM, eirilwan <eirilwan@gmail.com> wrote:
>
> Very simple test:
>    @Produce(uri = "direct:start2")
>    protected ProducerTemplate start2Consumer;
>
>    @EndpointInject(uri = "mock:consumer")
>    private MockEndpoint registrationConsumer;
>
>    //this fails.
>    @Test
>    public void shouldAcceptListAsExpectedBodyButFails() throws
> InterruptedException {
>        List<String> list = new ArrayList<String>();
>        list.add("test1");
>        registrationConsumer.expectedBodiesReceived(list);
>        start2Consumer.sendBody("test1");
>        registrationConsumer.assertIsSatisfied();
>    }
>    //This is ok
>    @Test
>    public void shouldAcceptListAsExpectedBody() throws InterruptedException
> {
>        List<String> list = new ArrayList<String>();
>        list.add("test1");
>
> registrationConsumer.expectedBodiesReceived(list.toArray(String[list.size()]);
>        start2Consumer.sendBody("test1");
>        registrationConsumer.assertIsSatisfied();
>    }
>
> Route is simple:
>        from("direct:start2").to("mock:consumer");
>
>
> No real issue since I just rewrote the tests to use varargs. Just wanted to
> let you know :)
>
> regards
> Eirik L. Wang
>
>
> Claus Ibsen-2 wrote:
>>
>> Hi
>>
>> We have a gazillion unit tests with uses the mock component.
>> However many of them use the vararg variation.
>>
>> Maybe if you can post a bit more code what you do, can help identify your
>> issue.
>>
>>
>> On Wed, Nov 25, 2009 at 10:45 AM, eirilwan <eirilwan@gmail.com> wrote:
>>>
>>> When we started using 2.1-SNAPSHOT, a lot of existing unit-tests broke. I
>>> figured out why. We were setting up expectedBodiesReceived with a list,
>>> which caused a strange message (mock://registrationConsumer Body of
>>> message:
>>> 0. Expected: <[test0]> but was: <null)
>>>
>>> If I added a .toArray(new String[bodies.size()]), it started working
>>> again.
>>>
>>> registrationConsumer.expectedBodiesReceived(bodies.toArray(new
>>> String[bodies.size()]));
>>>
>>> --
>>> View this message in context:
>>> http://old.nabble.com/Bug-in-expectedBodiesReceived%28List%3C%3E%29-tp26509915p26509915.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Author of Camel in Action: http://www.manning.com/ibsen/
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
>>
>
> --
> View this message in context: http://old.nabble.com/Bug-in-expectedBodiesReceived%28List%3C%3E%29-tp26509915p26510164.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Mime
View raw message