Apache Camel 中是否有注释可以在测试期间加载特定的 RouteBuilder?

发布于 2024-12-24 21:18:48 字数 657 浏览 2 评论 0原文

假设我在同一个 RouteBuilder 上有多个测试,每个测试的配置都不同。

现在,Spring 测试应该:

  • 扩展像 AbstractJUnit4SpringContextTests 这样的东西,
  • 用 @ContextConfiguration(locations="test-context.xml") 进行注释,
  • 在上下文中包含 RouteBuilder: ;

这意味着每个测试类必须具有指向所需 RouteBuilder 的特定上下文 xml 文件(即正在测试的 RouteBuilder 的版本,但经过专门配置)

如果我希望在同一上下文 xml 中测试所有版本的 RouteBuilders 该怎么办(或者甚至不这样,只需注释它们使用 @Component 而不是将它们放入 xml 中),并且在每个测试中指定要测试的 RouteBuilder 的实际实现?

在camel spring测试中是否有这样的注释(告诉测试哪个bean作为RouteBuilder运行)?

Suppose I have several tests on the same RouteBuilder that is configured differently for each test.

Now, a Spring test is supposed to:

  • extend something like AbstractJUnit4SpringContextTests
  • be annotated with @ContextConfiguration(locations="test-context.xml")
  • include the RouteBuilder in the context: <camel:camelContext id="whatever"><camel:routeBuilder ref="routeBuilderUnderTesting" /></camel:camelContext>

This implies that each test class must have a specific context xml file pointing to the wanted RouteBuilder (that is a version of the RouteBuilder under testing, but configured specifically)

What if I want all the versions of RouteBuilders under testing in the same context xml (or not even that, just annotate them with @Component instead of putting them in an xml) and, in each test, to specify the actual implementation of the RouteBuilder to test?

Is there such an annotation in camel spring test (to tell a test which bean to run as RouteBuilder)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

凉城 2024-12-31 21:18:48

请参阅此页面如何使用
http://camel.apache.org/spring.html

然后你可以注释你的单元测试带有 Spring @Component 注释的 RouteBuilder 类。

See this page how to use the <camel:contextScan/>
http://camel.apache.org/spring.html

Then you can just annotate your unit test RouteBuilder classes with the Spring @Component annotation.

向日葵 2024-12-31 21:18:48

为什么不使用没有 spring 的普通骆驼 TestSupport 类?在那里,您只需使用 new 实例化 RouteBuilder,而不必关心注释。

Why don´t you use the normal camel TestSupport classses without spring? There you just instantiate the RouteBuilder with new and do not have to care about annotations.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文