【问题标题】:Junit 5 with CamelTestSupportJunit 5 与 CamelTestSupport
【发布时间】:2018-06-25 20:25:46
【问题描述】:

我正在尝试使用 JUnit 5 和 Camel 支持编写单元测试。

  1. JUnit 5 (5.0.0) 在 A 类中使用以下注解 @ 方法级别:
@Test
@ParameterizedTest(name = "Test case [{index}] name={3}")
@MethodSource("data")
@IfEnvProfile(profiles = {"preprod"}) (Customized Annotation)
  1. A 类扩展了使用 Junit 4 的 CamelTestSupport。尝试使用以下代码访问服务:
protected ResponseDto  getReponse(String testFile) throws Exception {
    Transaction tx= new Transaction ();
    final Map<String,Object> headers= setAllHeader(tx);
    // enter code here
    ResponseDto response =
        (RatingResponseDto) template.sendBodyAndHeaders("{{.location.enricher.uri}}",
            ExchangePattern.InOut, tx, headers);
}

location.enricher.uri - http://localhost/rating-service/api/v1/rate/d155446421121/location/(已启动并运行)。

但是当我运行它时,我总是收到Nullpointer 响应异常。

疑问:

  1. 是否可以将 A 类中的 JUnit 5 和扩展 A 类的 CamelSupport 中的 JUnit 4 结合起来?

  2. 我们有 JUnit 5 的 CamelTestSupportClass 吗?

有人可以帮忙吗?

谢谢, 拉杰什S

【问题讨论】:

    标签: spring-boot junit5


    【解决方案1】:

    目前 Camel 支持 Junit 5。您只需将其包含在您的 pom.xml 中

    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-test-junit5</artifactId>
    </dependency>
    

    并导入类:

    import org.apache.camel.test.junit5.CamelTestSupport;
    

    更多信息请参见here

    【讨论】:

      【解决方案2】:
      1. 否:org.apache.camel.test.junit4.CamelTestSupport 类仅适用于 JUnit 4。
      2. 否:Camel 尚不支持 JUnit Jupiter(即 JUnit 5),但他们有一个 open issue 以在以后的版本中添加此类支持。

      【讨论】:

      • 感谢山姆的回复。
      猜你喜欢
      • 2016-11-11
      • 2019-10-06
      • 2020-08-13
      • 2017-09-02
      • 1970-01-01
      • 2018-07-25
      • 2017-11-09
      • 1970-01-01
      • 2020-04-07
      相关资源
      最近更新 更多