You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "Simmons Jr, Robert" <rs...@ea.com> on 2013/09/17 05:34:17 UTC

Is there a Method to Determine if Mock Endpoints are Real?

Greetings,

I have some camel tests using TestNG and CamelTestSupport. The problem I am having is that I can get mock endpoints that don't exist. This makes it a pain to debug the tests with complex routes. I was wondering if there is something like assertIsReal() to determine if a mock endpoint is actually connected to a real endpoint in the route. For example:


    this.context.getRouteDefinition(ROUTE_ID).adviceWith(this.context, new AdviceWithRouteBuilder() {

      @Override

      public void configure() throws Exception {

        // mock only log endpoints

        mockEndpointsAndSkip("activemq:*");

      }

    });

Then


    final MockEndpoint first = getMockEndpoint("mock:activemq:queue:escalated-cases");

    fifa.expectedBodiesReceived(gson.toJson(fc));

    final MockEndpoint xe = getMandatoryEndpoint("mock:activemq:queue:" + "blah", MockEndpoint.class);

In this case the "first" endpoint points to an actual node in the route but the xe one does not. The problem is if I get the URI slightly wrong, I spend 20 minutes chancing ghosts to figure out if the mock is real. It would be better if getMockEndpoint() would throw an exception if there is no backing component.

And then the code would throw exceptions if it didn't find the real component.


Robert Simmons Jr. MSc. | Lead Java Architect | EA - Worldwide Customer Experience


Re: Is there a Method to Determine if Mock Endpoints are Real?

Posted by kraythe <kr...@gmail.com>.
Wouldn't it make sense to check that in the getMockEndpoint method and
perhaps throw an assertion failure with a good message if the mock does
exist?



--
View this message in context: http://camel.465427.n5.nabble.com/Is-there-a-Method-to-Determine-if-Mock-Endpoints-are-Real-tp5739601p5739920.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Is there a Method to Determine if Mock Endpoints are Real?

Posted by Claus Ibsen <cl...@gmail.com>.
You can use the hasEndpoint method on CamelContext

On Tue, Sep 17, 2013 at 5:34 AM, Simmons Jr, Robert <rs...@ea.com> wrote:
> Greetings,
>
> I have some camel tests using TestNG and CamelTestSupport. The problem I am having is that I can get mock endpoints that don't exist. This makes it a pain to debug the tests with complex routes. I was wondering if there is something like assertIsReal() to determine if a mock endpoint is actually connected to a real endpoint in the route. For example:
>
>
>     this.context.getRouteDefinition(ROUTE_ID).adviceWith(this.context, new AdviceWithRouteBuilder() {
>
>       @Override
>
>       public void configure() throws Exception {
>
>         // mock only log endpoints
>
>         mockEndpointsAndSkip("activemq:*");
>
>       }
>
>     });
>
> Then
>
>
>     final MockEndpoint first = getMockEndpoint("mock:activemq:queue:escalated-cases");
>
>     fifa.expectedBodiesReceived(gson.toJson(fc));
>
>     final MockEndpoint xe = getMandatoryEndpoint("mock:activemq:queue:" + "blah", MockEndpoint.class);
>
> In this case the "first" endpoint points to an actual node in the route but the xe one does not. The problem is if I get the URI slightly wrong, I spend 20 minutes chancing ghosts to figure out if the mock is real. It would be better if getMockEndpoint() would throw an exception if there is no backing component.
>
> And then the code would throw exceptions if it didn't find the real component.
>
>
> Robert Simmons Jr. MSc. | Lead Java Architect | EA - Worldwide Customer Experience
>



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen