camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kevin Jackson <foamd...@gmail.com>
Subject Re: Integration testing a route before production
Date Mon, 08 Feb 2010 08:37:18 GMT
Hi,

Thanks for the responses.

> [1] http://camel.apache.org/spring-testing.html

I have read this and it doesn't really answer my question.

I already do integration testing using fluent dsl for :
direct-> processor/bean -> mock

I have integration tests in Camel using Camel test framework for these
simple integrations.  The problem is that I want to test the spring
config and also test the memory consumption of a single route before
integrating the route into my main context (which is also Spring).

So for each part of the route I have classic JUnit tests and also
Camel Tests, now I want an end-to-end test :

from fileconsumer via processing pojos to persistence

>> Then the next thing is to feed the data into the route.
>> If you want to keep your file endpoint you could copy files into the
>> directory it listens to.

This needs to be repeatable, so manually copying a file into a directory is out.

>> I normally use a producer (see
>> http://camel.apache.org/pojo-producing.html). For this aproach you need to
>> start the route with a direct endpoint.

This is the part I don't get - I have already configured the from
endpoint in Spring, I need to kickstart the route from within the
context of JUnit's TestRunner.  This works fine with direct:start

So I can get this route to work :
<camel:route id="mock-integration-test">
  <camel:from uri="direct:start"/>
  <camel:bean ref="Unmarshaller" method="unmarshall"/>
  <camel:bean ref="Transformer" method="transform"/>
  <camel:to uri="mock:result"/>
</camel:route>

by using:
@Produce(uri = "direct:start")
private ProducerTemplate template;

@Test
@DirtiesContext
public void testIntegrated() throws Exception {
  resultEndpoint.expectedBodiesReceived(result);
  template.sendBody(test);
  resultEndpoint.assertIsSatisfied();
}

but this only has a subset of test data (hardcoded in the Test class),

So I need to be able to consume a representative sample of test data:
<camel:route id="integration-test">
  <camel:from uri="direct:file"/>
  <camel:to ref="file-consumer"/>
  <camel:split streaming="true">
    <camel:tokenize token="\n"/>
    <camel:bean ref="Unmarshaller" method="unmarshall"/>
    <camel:bean ref="Transformer" method="transform"/>
    <camel:to uri="mock:result"/>
  </camel:split>
</camel:route>

How can I trigger this?

Thanks,
Kev

Mime
View raw message