【发布时间】:2020-07-07 21:54:55
【问题描述】:
// custom exception
public class customexception () {
log.error("exception);
}
--- apache camel consumer app which has custom exception
public consumer app implements Processor {
//process & validate
@override
public process(message) {
if(condition met)
throw customexception();
}
}
// my junit test class
@runwith(CamelSpringBootRunner)
@springboottest
public mytestclass {
@Autowired
ProducerTemplate producer;
@Test
public testexception () {
producer.sendbody("invalid message");
//??? assert customexception is thrown by consumer
}
}
这里 Junit 的 expectedCondition 将不起作用,因为我在测试中没有遇到异常,但是正在侦听我的测试产生的消息的独立消费者应用程序正在引发异常。
【问题讨论】:
-
junit4? junit5?另外,您已经尝试过什么?请给我们看。
-
junit4.我添加了可能有用的代码片段
标签: java spring-boot exception junit apache-camel