Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Wiki Markup
{snippet:lang=java|id=example|url=activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/patterns/FilterTest.java}

Notice that we use @DirtiesContext on the test methods to force Spring Test to automatically reload the CamelContext after each test method - this ensures that the tests don't clash with each other (e.g. one test method sending to an endpoint that is then reused in another test method).

Also notice the use of @ContextConfiguration to indicate that by default we should look for the FilterTest-context.xml on the classpath to configure the test case which looks like this

...

This is similar to the XML Config example above except that there is no XML file and instead the nested ContextConfig class does all of the configuration. We currently have to reference by class name this class in the @ContextConfiguration which is a bit ugly. Please vote for SJC-238 to address this and make Spring Test work more cleanly with Spring JavaConfig.

Testing endpoints

Camel provides a number of endpoints which can make testing easier.

...