问题标签 [camel-test]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
538 浏览

apache-camel - Spring Testing a Camel Content Based Router

I have the following Spring route:

I have the requirement to use Spring Testing (CamelSpringJUnit4ClassRunner), although I have found easy to understand examples on how to test the condition with Java DSL. My Test Class is like this:

I am struggling to understand how to test the actual condition dictated by the CBR, but more importantly I am doubting whether this is even the right way to test it. MyComponent.VALUEConstant is a property specified in my custom component and the above test is actually passing. However, if I instantiated the headerValue with a different property on my component and therefore the condition is supposed to fail, the test passes. Can you please help?

Thank you,

I

0 投票
1 回答
6722 浏览

java - Camel:模拟并从路由中的组件返回值

我的服务中有以下路线:

当我尝试对此进行测试时,它给了我一个错误,指出骆驼无法自动创建组件 mybatis。我对测试骆驼路线没有经验,所以我不完全确定该去哪里。第一个 mybatis 调用更新了表中的一行,该行不在测试中,所以我想做一些事情,比如当端点被命中时,返回值为 1 的 CamelMyBatisResult 标头。第二个 mybatis 端点应该返回一个 hashmap(第一次测试为空,第二次填充)。我如何通过骆驼测试实施一种何时/然后的机制?我查看了模拟端点骆驼文档,但我不知道如何应用它并让它返回一个值到交换,然后继续路由(测试的最终结果是检查一封电子邮件或不发送附件)

编辑:尝试同时使用 replace().set* 方法并通过调用内联处理器替换 mybatis 端点:

到目前为止,标题仍然为空,正文也是如此(TEST 变量是直接组件)

0 投票
1 回答
5799 浏览

java - 骆驼测试 - java.lang.IllegalArgumentException:必须指定 defaultEndpoint

我正在尝试使用http://camel.apache.org/mock.html为我的骆驼路线创建测试用例。我需要验证路线中的处理器。但是简单的测试对我不起作用。

堆栈跟踪:

0 投票
2 回答
5764 浏览

java - Camel 测试 - 如何从 FileConsumer/FTPConsumer 测试处理器?

我有一个骆驼路由,它从 ftp 服务器轮询文件并将文件发送到 s3。我在路由中有一些处理器,它们根据文件名计算/操作标头。我需要测试这条路线,如何注入我的处理器并在我的处理器中使用文件语言?

处理器:

我不想嘲笑我的处理器。我想模拟我的端点并测试我的处理器。

问题:

  1. 无法自动装配/注入我的处理器。

  2. 文件名被评估为空。如何使用 FileConsumer/FTPConsumer 而不是 ProducerTemplate?

0 投票
1 回答
633 浏览

apache-camel - 运行骆驼蓝图测试时加载属性文件

我正在使用property-placeholder标签加载属性,如下所示:

在 JBOSS Fuse 上部署我的项目时,它将camel.blueprint.cfg/etc/FUSE 目录加载,当我在结构配置文件上部署项目时,它将从配置文件中创建的属性文件中读取。

但是,当我运行camel blueprint test时,如何配置它以从特定位置加载属性文件?

0 投票
1 回答
277 浏览

apache-camel - 单元测试中的 Camel Stub 数据库交互

我是骆驼世界的新手。使用 camel-cxf,我实现了一个 web 服务(基于请求的 id,如果从响应中找到带有记录详细信息的响应,则查询数据库,否则返回静态响应),它具有一些非常基本的数据库交互和转换。

我正在尝试编写一些单元测试(独立于数据库即)存根数据库交互以形成静态响应)。有没有办法跳过发送到数据库端点并在交换(模仿数据库记录)上发送静态数据并验证转换结果?

问候, 尚卡尔

0 投票
4 回答
17286 浏览

spring-boot - Spring Boot Apache Camel 路由测试

我有一个 Springboot 应用程序,其中配置了一些 Camel 路由。

我想测试从activemq:testQueue到的这条路线queueEventHandler::handleQueueEvent。我尝试了这里提到的不同的东西http://camel.apache.org/camel-test.html,但似乎没有让它工作。

我正在尝试做这样的事情:

但我的 ProducerTemplate 始终是null. 我尝试了 auto-wiring CamelContext,但我得到一个异常,说它无法解析 camelContext。但这可以通过添加类SpringCamelContext.class来解决@SpringBootTest。但我ProducerTemplate的还在null

请建议。我正在使用 Camel 2.18 和 Spring Boot 1.4。

0 投票
2 回答
924 浏览

apache-camel - CamelTestSupport 从 yml 文件中读取占位符

我正在尝试使用 CamelTestSupport 测试我的骆驼路线。我在这样的类中定义了我的路线

}

我的测试课看起来像这样

这工作得很好。但我必须{{push.queue.name}}使用useOverridePropertiesWithPropertiesComponent函数设置占位符。但我希望从我的 .yml 文件中读取它。
我做不到。有人可以建议。

谢谢

0 投票
0 回答
741 浏览

java - 骆驼:测试期间的 DirectConsumerNotAvailable 异常

我有以下RouteBuilder:

MyRouteBuilder.java

}

注意:异常处理程序被定义为一个单独的 routeBuilder 类。我对 MyRouteBuilder 进行了以下单元测试。

MyRouteBuilderTest.java

堆栈跟踪

我已经阅读了一些解决方案,大多数答案都围绕未能启动骆驼上下文,或者使用第二个上下文而不是修改路线的上下文等,但我认为情况并非如此这里; 调试仅显示 1 个肯定启动的上下文,其中仅包含 MyRouteBuilder 的路由定义(与路由 + 异常处理路由相反)。

0 投票
3 回答
6931 浏览

spring-boot - Spring Boot 骆驼测试

我需要在 Spring Boot 应用程序中测试 Camel 路由。我有 Spring boot 主类,其中声明了所有必要的 bean。我正在使用 CamelSpringJUnit4ClassRunner.class。在 @ContextConfiguration 中添加了我的 Spring boot 主类,因为它包含所有配置。我没有单独的配置类。

我在我的测试类中自动装配了 CamelContext:

但是测试失败并出现错误:

引起:org.springframework.beans.factory.NoSuchBeanDefinitionException:

没有可用的“org.apache.camel.CamelContext”类型的合格 bean:预计至少有 1 个有资格作为自动装配候选者的 bean。

依赖注解:{@org.springframework.beans.factory.annotation.Autowired(required=true)}