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 <[email protected]>wrote: > 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. > > > >
