1

I try to write an end to end test for my Apache Camel process that goes through a pipeline consisting of many routes. But I have got stuck on the very first one.

My route definition looks like following

@Override
public void config() {
 rest("/admin/k2/employee")
 .post()
 .routeId(ROUTE_BUILDER_ID)
 .to(SEDA + K2EmployeesRouteBuilder.ROUTE_BUILDER_ID);
}

In my unit test i mock everything ad to the testing in isolation.

Buit for my e2e test I want to perform a REAL http post call to the /admin/k2/employee endpoint.

The trouble is that my application contains 50+ RouteBuilders and hundreds of other Components not related with my route under test.

If I try to use

@CamelSpringBootTest
@SpringBootTest

the entire SpringBoot context is loaded with all those 50+ routes that need to be fully configured or mocked - otherwise the context fail to load and the test fails.

I can load only my RouteBuilder (+ eventualy related dependencies) using

@SpringBootTest( classes= { ... })

This works fine for my integration tests where i call direct endpoint to start the test.

But for my e2e test the problem is that the embeded Tomcat server does not start and I cannot do the real http request.

If I add Application.java to the classes then all the routes try to load into context again.

So the question is: Is it possible to run a route(s) with a rest producer together with embeded Tomcat server but in isolation without the rest of the application?

asked May 1, 2025 at 17:00
2
  • Are the routes in separate packages such that you can load only one (or small number of) packages, leaving out all except the one route you want to test? Commented May 2, 2025 at 0:38
  • Yes, in general I keep one RouteBulider with related classes per package Commented May 2, 2025 at 9:52

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.