简体   繁体   中英

How to mock Apache Camel Route before CamelContext is started in CamelSpringBootTest

Maybe a rather uncommon issue, but I'd like to mock certain Camel routes, in the JUnit setup method

@BeforeEach
void setUp() {
}

before the

@Override
public void configure() throws Exception {

}

is executed , which seems to happen, as soon as the CamelContext is autowired

@Autowired
protected CamelContext camelContext;

What do I need to do, to prevent autostarting of the Camel Context, in order to be able to mock my routes in the setup method and start it manually?

You can enable advice with in the unit test - then you need to start Camel manually.

https://camel.apache.org/manual/advice-with.html#_enabling_advice_during_testing

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM