You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Marco Westermann <Ma...@gmx.de> on 2015/08/26 15:04:45 UTC

Testing camel route via pax exam

Hi,

  I try to test a camel route via pax exam. In general I followed the 
tutorial by jb 
(http://blog.nanthrax.net/2014/08/testing-utest-and-itest-apache-camel-blueprint-route/)

The route I'd like to test sends a message to an activemq queue. 
Therefor I'd like to grab that message in my test and send it to the 
mock:result endpoint. But now I have the problem that my test fails with 
an error:

Failed to resolve endpoint: activemq://queue:qstep.order.sales due to: 
No component found with scheme: activemq

I thought I have to add the component to the camel context.. therefor I 
implemented the following method in the route builder:

@Override
publicModelCamelContextgetContext() {
     ModelCamelContext context =super.getContext();
     context.addComponent("activemq", newActiveMQComponent());
     returncontext;
}

But then I get the error: Cannot add component as its already previously 
added: activemq

Here is my test environment:

servicemix 4.5.2 as testcontainer

test class: http://pastebin.com/4zqdNtZC

thank you for any hints you could give.

regards, Marco





Re: Testing camel route via pax exam

Posted by Andrew Block <an...@gmail.com>.
Marco,

Instead of overriding the getContext in the RouteBuilder, try overriding the createCamelContext method of the CamelTestSupport class with the following

@Override
	protected CamelContext createCamelContext() throws Exception {
		CamelContext context = super.createCamelContext();
		context.addComponent("activemq", new ActiveMQComponent());
			
		return context;
	}

This should allow you to also remove attempting to add the component in your unit test method

- Andy

-- 
Andrew Block


On August 26, 2015 at 8:05:07 AM, Marco Westermann (marwestermann@gmx.de) wrote:

Hi,  

I try to test a camel route via pax exam. In general I followed the  
tutorial by jb  
(http://blog.nanthrax.net/2014/08/testing-utest-and-itest-apache-camel-blueprint-route/)  

The route I'd like to test sends a message to an activemq queue.  
Therefor I'd like to grab that message in my test and send it to the  
mock:result endpoint. But now I have the problem that my test fails with  
an error:  

Failed to resolve endpoint: activemq://queue:qstep.order.sales due to:  
No component found with scheme: activemq  

I thought I have to add the component to the camel context.. therefor I  
implemented the following method in the route builder:  

@Override  
publicModelCamelContextgetContext() {  
ModelCamelContext context =super.getContext();  
context.addComponent("activemq", newActiveMQComponent());  
returncontext;  
}  

But then I get the error: Cannot add component as its already previously  
added: activemq  

Here is my test environment:  

servicemix 4.5.2 as testcontainer  

test class: http://pastebin.com/4zqdNtZC  

thank you for any hints you could give.  

regards, Marco