问题标签 [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 回答
1559 浏览

java - Camel Spring Boot CXF 端点测试

我有以下端点和路线。

我想测试一下。各种输入数据应路由到各种路由。

但在这种情况下,我有以下错误:

引起:java.net.ConnectException:ConnectException 调用 http://myurl:连接被拒绝(连接被拒绝)

这是合乎逻辑的,我没有运行该应用程序。

然后我尝试替换 cxf 端点来模拟:

我得到了

断言:mock://direct:route1 满足 - 失败

和异常(java.lang.AssertionError: mock://direct:route1 Received message count. Expected: <1> but was: <0> ),因为我的路由代码没有被调用。

如何正确测试路线?我想尝试两种有趣的方式:

1) 使用真实的 http 端点进行测试(这允许您测试请求的早期阶段 - 例如 - 带有无效 xml 的请求)

2)POJO有效负载在消息体中时的隔离测试。

如果我的问题有解决方案,我将不胜感激

0 投票
0 回答
1704 浏览

java - 使用模拟端点进行骆驼路线测试

使用 Springboot、Activemq 和模拟端点进行骆驼路线测试

我有一条骆驼路线,它从 activemq 中读取并传递给处理器,该处理器进行进一步的处理和业务逻辑。

我正在尝试通过 ProducerTemplate 生成和发送消息来进行测试,创建模拟端点“mock:result”并编织作为路由的最后一个节点并对其进行断言。它不满足断言。

骆驼路线:

测试类:

结果:

0 投票
1 回答
2485 浏览

spring-boot - 在 SpringBoot 应用程序中为骆驼路由编写单元测试 - 获取 messageCount 0

我正在尝试为骆驼路线编写单元测试 - 它用于导入和处理文件

下面是单元测试:

我总是得到消息计数为 0。这是错误

java.lang.AssertionError: mock://success_result 收到的消息计数。预期:<1> 但为:<0> 预期:<1> 实际:<0>

我在这里做错了什么?如您所见,我有 2 条路线 - 第一条路线实际上是第二条路线,所以在单元测试中我也应该有 2 条路线吗?我没有添加 2 条路线,因为如果我进行调试,我可以看到它实际上通过了处理器并返回了正确的结果。

0 投票
1 回答
212 浏览

apache-camel - 骆驼路线测试期间的 NPE

我正在尝试测试骆驼路线,以下是我的测试类的注释。

我的测试通过了,但在控制台上我不断收到以下错误消息。

如何解决此错误?这是我的路线处理过程中的错误吗?

0 投票
0 回答
280 浏览

apache-camel - 如何使用 Apache Camel Routes 执行 Arquillian 测试

我是 Apache Camel 的新手。我编写了简单的程序来使用骆驼路线将文件放置到另一个位置。我为此编写了 Junit 和 Mock 测试。

这是我的 simpleCamelRoute.java

这是 SimpleCamelRouteTest.java

这是我的 application.yml 文件

就像我通过 MockEndPoints 尝试使用模拟测试一样。

我已经浏览了 Apache Camel 官方网站:https : //camel.apache.org/cdi-testing.html 但我不明白通过 Camel Arquillian 集成测试进行测试的流程。

如何通过 Arquillian 测试我的项目。

0 投票
2 回答
261 浏览

apache-camel - 骆驼测试直接在原始路线中替换 seda

骆驼测试,直接用 seda 代替。

例如,在我的骆驼路线测试中,我想用直接替换 seda 呼叫

而不是“seda:Second_route_id”我的消费者应该是“直接:Second_route_id”进行测试

以下是我原来的路线

我试着做一些事情,比如

0 投票
1 回答
200 浏览

apache-camel - 使用 CamelBlueprintTestSupport 从端点测试某些组件失败

我想测试用 Blueprint-XML 实现的骆驼路线。当尝试使用简单的“直接”端点测试路由时,一切正常。

但是将“from”端点更改为 netty 或 jetty 组件,测试失败,但出现以下异常:

java.lang.RuntimeException:放弃等待来自 bundle 'MyRouteTest' 的 BlueprintContainer

我的路线如下所示:

我扩展 CamelBlueprintTestSupport 的测试类如下所示:

修改路由到

通过将 from 部分从 jetty 替换为 direct 可以正常工作(例如,测试运行没有错误,当然由于 assert(true) 检查而最终是肯定的)

有谁能够帮我?

mvn test 的输出是

0 投票
1 回答
314 浏览

apache-camel - Mocking OSGi reference in CamelBlueprintTest does not work

I'm currently setting up tests with CamelBlueprintTestSupport.

In my blueprint.xml, I tried the following implementation:

<reference id="foo" interface="com.myexample.FooInterface" />

Mocking FooInterface in my test class with

works fine (where FooImpl implements FooInterface, of course), e.g. executing the test (the test simply contains assert(true) cause I'd only like to check the test configuration) ends up positive.

But in my real implementation, I do not have an interface as service. Instead, it is a class referenced this way:

My mock configuration in the test is this one:

Executing the test now fails with the following exception:

java.lang.RuntimeException: Gave up waiting for BlueprintContainer from bundle "FooTest" at com.myexample.test.FooTest.setUp(FooTest.java:49)

I cannot see what's actually wrong. By the way, the implementation of the camel route on Karaf runs without any problems. I don't know if my test set up is wrong or if it's a bug in the CamelBlueprintTestSupport.

0 投票
1 回答
165 浏览

apache-camel - 使用 CamelTestSupport 在 Karaf 4.2.7 中测试骆驼 2.24.x 路线

我想在 Karaf 4.2.x 中测试 Camel 2.24.x 路线。我使用 Pax-Exam 4.13.1 来运行 Karaf。骆驼测试手册不包括卡拉夫测试。对于较旧的 Karaf 和 Camel 版本,有博客文章演示了如何通过扩展测试类来做到这一点CamelTestSupport

但是,它们太旧了,以至于代码在没有调整的情况下不再运行。前者非常绝望,我已经停止尝试修复它。对于后者,我能够让它在使用 Camel 2.12.1 on JDK 8 的 Karaf 2.4 上工作,但不能在当前使用 Camel 2.24.2 的 Karaf 4.2.7上工作。

CamelTestSupport使用当前的 Karaf 4 和 Camel 2.24 在尝试创建JndiContextin时收到以下错误消息CamelTestSupport#createRegistry

缺少的类在camel-core并且它曾经与旧版本的 Camel 和 Karaf 一起使用,所以我不知道为什么在使用最新的 Karaf 和 Camel 时该类不可用。

找不到的原因可能是什么CamelInitialContextFactory?与旧版本一样,我安装camel-blueprintcamel-test在我的测试中,所以我希望camel-core应该包括在内。

CamelTestSupport与Karaf合作仍然是一个好主意吗?虽然有一个CamelKarafTestSupport似乎证明了这种方法,但我找不到这样一个测试的工作示例,我自己也无法让它工作。我收到CamelKarafTestSupport一条错误消息,告诉我ProbeInvoker从未出现过:

我应该走一条不同的路线,也许AbstractFeatureTestfrom camel-test-karaf,它被camel-itest-karaf广泛使用?

0 投票
1 回答
301 浏览

junit - 带有 spring DSL 和 Junit Coverage 的 Apache camel

我对apache camel完全陌生。我对它有了一些基本的了解。

现在,我正在浏览一些视频和文档,以获得一些想法,为基于apache camel spring DSLspring boot 应用程序实现junit测试用例,但我不清楚,因为有很多方法可以实现或非常高水平。

我很困惑..跟随哪一个以及那些junits中实际发生的事情

有没有人有示例链接视频来解释基于apache camel spring DSLspring boot 应用程序的junit覆盖范围?

我特别在寻找junits。另外,如果您知道有关 apache camel 的好教程,请告诉我。