You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by eirilwan <ei...@gmail.com> on 2009/11/25 10:45:11 UTC

Bug in expectedBodiesReceived(List<>)

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.


Re: Bug in expectedBodiesReceived(List<>)

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Nov 25, 2009 at 11:23 AM, Claus Ibsen <cl...@gmail.com> wrote:
> On Wed, Nov 25, 2009 at 11:17 AM, Claus Ibsen <cl...@gmail.com> wrote:
>> 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.
>>
>
> Have created this ticket
> https://issues.apache.org/activemq/browse/CAMEL-2227
>

Its fixed now.


>>
>> On Wed, Nov 25, 2009 at 11:04 AM, eirilwan <ei...@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 <ei...@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
>>
>
>
>
> --
> 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
>



-- 
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

Re: Bug in expectedBodiesReceived(List<>)

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Nov 25, 2009 at 11:17 AM, Claus Ibsen <cl...@gmail.com> wrote:
> 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.
>

Have created this ticket
https://issues.apache.org/activemq/browse/CAMEL-2227

>
> On Wed, Nov 25, 2009 at 11:04 AM, eirilwan <ei...@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 <ei...@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
>



-- 
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

Re: Bug in expectedBodiesReceived(List<>)

Posted by Claus Ibsen <cl...@gmail.com>.
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 <ei...@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 <ei...@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

Re: Bug in expectedBodiesReceived(List<>)

Posted by eirilwan <ei...@gmail.com>.
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 <ei...@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.


Re: Bug in expectedBodiesReceived(List<>)

Posted by Claus Ibsen <cl...@gmail.com>.
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 <ei...@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