Re: CamelTestSupport Needs a New Method
Hi Yeah the getMockEndpoint with the 2nd boolean is much better On Fri, Sep 27, 2013 at 3:16 PM, Jan Matèrne (jhm) apa...@materne.de wrote: Instead of overloading the method I would prefer another one: - getMockEndpoint will return the endpoint or null - createMockEndpoint will return the endpoint and create one if required But that would change the existing API of getMockEndpoint() :( Having a 2nd argument would result in getMockEndpoint(uri) { // use 'false' as it is the current implementation return getMockEndpoint(uri,false) } getMockEndpoint(uri,boolean create) ... Maybe it is just enough to improve the javadoc of getMockEndpoint(), describe the auto-creation behaviour and link to context.hasEndpoint(uri) ... Jan -Ursprüngliche Nachricht- Von: Raul Kripalani [mailto:r...@evosent.com] Gesendet: Freitag, 27. September 2013 15:36 An: users@camel.apache.org Betreff: Re: CamelTestSupport Needs a New Method I would prefer to add another signature for that method such that it accepts a 2nd argument create which is a boolean. If true, it will create the endpoint; else it will return null. I don't think CamelTestSupport should make the assertion; it should be the user's code, if that's what he/she is after. Regards, *Raúl Kripalani* Apache Camel PMC Member Committer | Enterprise Architect, Open Source Integration specialist http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani http://blog.raulkr.net | twitter: @raulvk On Fri, Sep 27, 2013 at 9:11 AM, Willem jiang willem.ji...@gmail.comwrote: Yeah, it's a good suggestion. Please feel free to fill a JIRA[1] for it :) [1]http://issues.apache.org/jira/browse/CAMEL -- Willem Jiang Red Hat, Inc. Web: http://www.redhat.com Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English) http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese) Twitter: willemjiang Weibo: 姜宁willem On Friday, September 27, 2013 at 7:54 AM, kraythe . wrote: There is a problem with the CamelTestSupport class in that if you call getMockEndpoint on an endpoint that doesnt exist, it blithely returns you an endpoint connected to nothing. The problem is you end up chasing endless test failures when the fact is your endpoint is not even there. So I suggest a method I added to my subclass of CamelTestSupport which is: protected MockEndpoint assertAndGetMockEndpoint(final String uri) { assertNotNull(context.hasEndpoint(uri)); return getMockEndpoint(uri); } This method will make sure that the endpoint is there before returning it and it will make tests easier to write. -- Claus Ibsen - Red Hat, Inc. Email: cib...@redhat.com Twitter: davsclaus Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen
Re: CamelTestSupport Needs a New Method
As long as it throws an exception (as I see you did in the jira) it will be perfect. I just dont want to perpretually have to say: final MockEndpoint xx = getMockEndpoint(mock:direct:xx, false); assertNotNull(xx); That adds an unnecessary line to every call. If the method throws a runtime exception I can just let it percolate and get caught by the testng framework. *Robert Simmons Jr. MSc. - Lead Java Architect @ EA* *Author of: Hardcore Java (2003) and Maintainable Java (2012)* *LinkedIn: **http://www.linkedin.com/pub/robert-simmons/40/852/a39* On Sat, Sep 28, 2013 at 3:40 AM, Claus Ibsen claus.ib...@gmail.com wrote: Hi Yeah the getMockEndpoint with the 2nd boolean is much better On Fri, Sep 27, 2013 at 3:16 PM, Jan Matèrne (jhm) apa...@materne.de wrote: Instead of overloading the method I would prefer another one: - getMockEndpoint will return the endpoint or null - createMockEndpoint will return the endpoint and create one if required But that would change the existing API of getMockEndpoint() :( Having a 2nd argument would result in getMockEndpoint(uri) { // use 'false' as it is the current implementation return getMockEndpoint(uri,false) } getMockEndpoint(uri,boolean create) ... Maybe it is just enough to improve the javadoc of getMockEndpoint(), describe the auto-creation behaviour and link to context.hasEndpoint(uri) ... Jan -Ursprüngliche Nachricht- Von: Raul Kripalani [mailto:r...@evosent.com] Gesendet: Freitag, 27. September 2013 15:36 An: users@camel.apache.org Betreff: Re: CamelTestSupport Needs a New Method I would prefer to add another signature for that method such that it accepts a 2nd argument create which is a boolean. If true, it will create the endpoint; else it will return null. I don't think CamelTestSupport should make the assertion; it should be the user's code, if that's what he/she is after. Regards, *Raúl Kripalani* Apache Camel PMC Member Committer | Enterprise Architect, Open Source Integration specialist http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani http://blog.raulkr.net | twitter: @raulvk On Fri, Sep 27, 2013 at 9:11 AM, Willem jiang willem.ji...@gmail.comwrote: Yeah, it's a good suggestion. Please feel free to fill a JIRA[1] for it :) [1]http://issues.apache.org/jira/browse/CAMEL -- Willem Jiang Red Hat, Inc. Web: http://www.redhat.com Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English) http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese) Twitter: willemjiang Weibo: 姜宁willem On Friday, September 27, 2013 at 7:54 AM, kraythe . wrote: There is a problem with the CamelTestSupport class in that if you call getMockEndpoint on an endpoint that doesnt exist, it blithely returns you an endpoint connected to nothing. The problem is you end up chasing endless test failures when the fact is your endpoint is not even there. So I suggest a method I added to my subclass of CamelTestSupport which is: protected MockEndpoint assertAndGetMockEndpoint(final String uri) { assertNotNull(context.hasEndpoint(uri)); return getMockEndpoint(uri); } This method will make sure that the endpoint is there before returning it and it will make tests easier to write. -- Claus Ibsen - Red Hat, Inc. Email: cib...@redhat.com Twitter: davsclaus Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen
Re: CamelTestSupport Needs a New Method
Patch submitted. https://issues.apache.org/jira/browse/CAMEL-6792 On Sat, Sep 28, 2013 at 4:40 AM, Claus Ibsen claus.ib...@gmail.com wrote: Hi Yeah the getMockEndpoint with the 2nd boolean is much better On Fri, Sep 27, 2013 at 3:16 PM, Jan Matèrne (jhm) apa...@materne.de wrote: Instead of overloading the method I would prefer another one: - getMockEndpoint will return the endpoint or null - createMockEndpoint will return the endpoint and create one if required But that would change the existing API of getMockEndpoint() :( Having a 2nd argument would result in getMockEndpoint(uri) { // use 'false' as it is the current implementation return getMockEndpoint(uri,false) } getMockEndpoint(uri,boolean create) ... Maybe it is just enough to improve the javadoc of getMockEndpoint(), describe the auto-creation behaviour and link to context.hasEndpoint(uri) ... Jan -Ursprüngliche Nachricht- Von: Raul Kripalani [mailto:r...@evosent.com] Gesendet: Freitag, 27. September 2013 15:36 An: users@camel.apache.org Betreff: Re: CamelTestSupport Needs a New Method I would prefer to add another signature for that method such that it accepts a 2nd argument create which is a boolean. If true, it will create the endpoint; else it will return null. I don't think CamelTestSupport should make the assertion; it should be the user's code, if that's what he/she is after. Regards, *Raúl Kripalani* Apache Camel PMC Member Committer | Enterprise Architect, Open Source Integration specialist http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani http://blog.raulkr.net | twitter: @raulvk On Fri, Sep 27, 2013 at 9:11 AM, Willem jiang willem.ji...@gmail.comwrote: Yeah, it's a good suggestion. Please feel free to fill a JIRA[1] for it :) [1]http://issues.apache.org/jira/browse/CAMEL -- Willem Jiang Red Hat, Inc. Web: http://www.redhat.com Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English) http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese) Twitter: willemjiang Weibo: 姜宁willem On Friday, September 27, 2013 at 7:54 AM, kraythe . wrote: There is a problem with the CamelTestSupport class in that if you call getMockEndpoint on an endpoint that doesnt exist, it blithely returns you an endpoint connected to nothing. The problem is you end up chasing endless test failures when the fact is your endpoint is not even there. So I suggest a method I added to my subclass of CamelTestSupport which is: protected MockEndpoint assertAndGetMockEndpoint(final String uri) { assertNotNull(context.hasEndpoint(uri)); return getMockEndpoint(uri); } This method will make sure that the endpoint is there before returning it and it will make tests easier to write. -- Claus Ibsen - Red Hat, Inc. Email: cib...@redhat.com Twitter: davsclaus Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen
CamelTestSupport Needs a New Method
There is a problem with the CamelTestSupport class in that if you call getMockEndpoint on an endpoint that doesnt exist, it blithely returns you an endpoint connected to nothing. The problem is you end up chasing endless test failures when the fact is your endpoint is not even there. So I suggest a method I added to my subclass of CamelTestSupport which is: protected MockEndpoint assertAndGetMockEndpoint(final String uri) { assertNotNull(context.hasEndpoint(uri)); return getMockEndpoint(uri); } This method will make sure that the endpoint is there before returning it and it will make tests easier to write.
Re: CamelTestSupport Needs a New Method
Yeah, it's a good suggestion. Please feel free to fill a JIRA[1] for it :) [1]http://issues.apache.org/jira/browse/CAMEL -- Willem Jiang Red Hat, Inc. Web: http://www.redhat.com Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English) http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese) Twitter: willemjiang Weibo: 姜宁willem On Friday, September 27, 2013 at 7:54 AM, kraythe . wrote: There is a problem with the CamelTestSupport class in that if you call getMockEndpoint on an endpoint that doesnt exist, it blithely returns you an endpoint connected to nothing. The problem is you end up chasing endless test failures when the fact is your endpoint is not even there. So I suggest a method I added to my subclass of CamelTestSupport which is: protected MockEndpoint assertAndGetMockEndpoint(final String uri) { assertNotNull(context.hasEndpoint(uri)); return getMockEndpoint(uri); } This method will make sure that the endpoint is there before returning it and it will make tests easier to write.
Re: CamelTestSupport Needs a New Method
I would prefer to add another signature for that method such that it accepts a 2nd argument create which is a boolean. If true, it will create the endpoint; else it will return null. I don't think CamelTestSupport should make the assertion; it should be the user's code, if that's what he/she is after. Regards, *Raúl Kripalani* Apache Camel PMC Member Committer | Enterprise Architect, Open Source Integration specialist http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani http://blog.raulkr.net | twitter: @raulvk On Fri, Sep 27, 2013 at 9:11 AM, Willem jiang willem.ji...@gmail.comwrote: Yeah, it's a good suggestion. Please feel free to fill a JIRA[1] for it :) [1]http://issues.apache.org/jira/browse/CAMEL -- Willem Jiang Red Hat, Inc. Web: http://www.redhat.com Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English) http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese) Twitter: willemjiang Weibo: 姜宁willem On Friday, September 27, 2013 at 7:54 AM, kraythe . wrote: There is a problem with the CamelTestSupport class in that if you call getMockEndpoint on an endpoint that doesnt exist, it blithely returns you an endpoint connected to nothing. The problem is you end up chasing endless test failures when the fact is your endpoint is not even there. So I suggest a method I added to my subclass of CamelTestSupport which is: protected MockEndpoint assertAndGetMockEndpoint(final String uri) { assertNotNull(context.hasEndpoint(uri)); return getMockEndpoint(uri); } This method will make sure that the endpoint is there before returning it and it will make tests easier to write.
AW: CamelTestSupport Needs a New Method
Instead of overloading the method I would prefer another one: - getMockEndpoint will return the endpoint or null - createMockEndpoint will return the endpoint and create one if required But that would change the existing API of getMockEndpoint() :( Having a 2nd argument would result in getMockEndpoint(uri) { // use 'false' as it is the current implementation return getMockEndpoint(uri,false) } getMockEndpoint(uri,boolean create) ... Maybe it is just enough to improve the javadoc of getMockEndpoint(), describe the auto-creation behaviour and link to context.hasEndpoint(uri) ... Jan -Ursprüngliche Nachricht- Von: Raul Kripalani [mailto:r...@evosent.com] Gesendet: Freitag, 27. September 2013 15:36 An: users@camel.apache.org Betreff: Re: CamelTestSupport Needs a New Method I would prefer to add another signature for that method such that it accepts a 2nd argument create which is a boolean. If true, it will create the endpoint; else it will return null. I don't think CamelTestSupport should make the assertion; it should be the user's code, if that's what he/she is after. Regards, *Raúl Kripalani* Apache Camel PMC Member Committer | Enterprise Architect, Open Source Integration specialist http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani http://blog.raulkr.net | twitter: @raulvk On Fri, Sep 27, 2013 at 9:11 AM, Willem jiang willem.ji...@gmail.comwrote: Yeah, it's a good suggestion. Please feel free to fill a JIRA[1] for it :) [1]http://issues.apache.org/jira/browse/CAMEL -- Willem Jiang Red Hat, Inc. Web: http://www.redhat.com Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English) http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese) Twitter: willemjiang Weibo: 姜宁willem On Friday, September 27, 2013 at 7:54 AM, kraythe . wrote: There is a problem with the CamelTestSupport class in that if you call getMockEndpoint on an endpoint that doesnt exist, it blithely returns you an endpoint connected to nothing. The problem is you end up chasing endless test failures when the fact is your endpoint is not even there. So I suggest a method I added to my subclass of CamelTestSupport which is: protected MockEndpoint assertAndGetMockEndpoint(final String uri) { assertNotNull(context.hasEndpoint(uri)); return getMockEndpoint(uri); } This method will make sure that the endpoint is there before returning it and it will make tests easier to write.
Re: CamelTestSupport Needs a New Method
https://issues.apache.org/jira/browse/CAMEL-6792 created. I disagree about the test support making assertions. If we are calling a method appropriately named, there is no reason it shouldn't make the assert call. This is, after all, a Camel*TestSupport* class. If we do it with a different signature and return null then every time I call mock = getMockEndpoint(), I need another line of code which is assertNotNull(mock). If I miss one, I am with a ghost endpoint and my tests give invalid results. If we dont want to use an assert, I would at least suggest an IllegalArgumentException which will have the same effect. In fact I cant conceive of a use case for getMockEndpoint that should create a ghost mock not attached to anything. I expected the existing method to throw if I gave it a wrong URI. On Fri, Sep 27, 2013 at 9:16 AM, Jan Matèrne (jhm) apa...@materne.dewrote: Instead of overloading the method I would prefer another one: - getMockEndpoint will return the endpoint or null - createMockEndpoint will return the endpoint and create one if required But that would change the existing API of getMockEndpoint() :( Having a 2nd argument would result in getMockEndpoint(uri) { // use 'false' as it is the current implementation return getMockEndpoint(uri,false) } getMockEndpoint(uri,boolean create) ... Maybe it is just enough to improve the javadoc of getMockEndpoint(), describe the auto-creation behaviour and link to context.hasEndpoint(uri) ... Jan -Ursprüngliche Nachricht- Von: Raul Kripalani [mailto:r...@evosent.com] Gesendet: Freitag, 27. September 2013 15:36 An: users@camel.apache.org Betreff: Re: CamelTestSupport Needs a New Method I would prefer to add another signature for that method such that it accepts a 2nd argument create which is a boolean. If true, it will create the endpoint; else it will return null. I don't think CamelTestSupport should make the assertion; it should be the user's code, if that's what he/she is after. Regards, *Raúl Kripalani* Apache Camel PMC Member Committer | Enterprise Architect, Open Source Integration specialist http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani http://blog.raulkr.net | twitter: @raulvk On Fri, Sep 27, 2013 at 9:11 AM, Willem jiang willem.ji...@gmail.comwrote: Yeah, it's a good suggestion. Please feel free to fill a JIRA[1] for it :) [1]http://issues.apache.org/jira/browse/CAMEL -- Willem Jiang Red Hat, Inc. Web: http://www.redhat.com Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English) http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese) Twitter: willemjiang Weibo: 姜宁willem On Friday, September 27, 2013 at 7:54 AM, kraythe . wrote: There is a problem with the CamelTestSupport class in that if you call getMockEndpoint on an endpoint that doesnt exist, it blithely returns you an endpoint connected to nothing. The problem is you end up chasing endless test failures when the fact is your endpoint is not even there. So I suggest a method I added to my subclass of CamelTestSupport which is: protected MockEndpoint assertAndGetMockEndpoint(final String uri) { assertNotNull(context.hasEndpoint(uri)); return getMockEndpoint(uri); } This method will make sure that the endpoint is there before returning it and it will make tests easier to write.