camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Costash <costache_v_v...@yahoo.com>
Subject Camel testing
Date Mon, 29 Jul 2013 16:15:33 GMT
Hi,

I've just started to use camel, and I'm trying to understand and create some
unit tests, but i don t understand how Mok is working or how unit tests
should look like (i've read the tutorials and documentation about camel
test).
What do i mean by not understanging is:

i have a defined route:
=========================
public class MyRouteBuilder extends RouteBuilder{
.....
@Override
	public void configure() throws Exception {
from("jms:queue:inputQueueName").process(new Processor()
{.........}).to("jms:queue:outputputQueueName");
======================

in all the examples found , a new Class extends CamelTestSupport {

and also creating the rounting inside, so it can be moked:
===============
   @Override
    protected RouteBuilder createRouteBuilder() {
        return new RouteBuilder() {
            public void configure() {
               
from("direct:start").filter(header("foo").isEqualTo("bar")).to("mock:result");
            }
        };
    }
================
so the route is defined exactly here, so it can be moked and get the
endpoints.

BUT, what about to test an allready created route?
I can't say .to("mock:result");

i suposed it should be:

=========
 @Override
    protected RouteBuilder createRouteBuilder() {
return new MyRouteBuilder();
}
==========


So my questions are:
1. how can i test a route? (i can't define the rules of routing inside the
test class by overwriting the createRouteBuilder() , because i already have
the route implementation => duplicate code)
2. Should my MyRouteBuilder have specific methods implemented so i can mok
it after in the test class?
3. is it there another way to test the output messages of a router besides
Mok?
      - I did it in one way, but i think is not the "correct" one:
               - In a Test Class, I've created a Connection factory to a jms
queue and creating a context
               - I've added the desired route to be tested into the context
(  context.addRoute(new MyRoutebuilder()))
               - Started the context (so my router is running in 
"backgroud" let s say)
               - i've put a message into the input queue of the router with
another test Router (from file to queue)
               - i've taken the message from output queue of the router with
a test router (From message to file)
               - compare the file with an expected one.
      
But this is bad as concept for unit tests (let s say Junits), i think.

4. Do you a link, or something to a generic test example of a camel route?

PS: Sorry if the are stupid questions

Thanks,
Vlad



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-testing-tp5736444.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message