【问题标题】:Howto use testcontainers with bnd如何在 bnd 中使用测试容器
【发布时间】:2021-07-01 09:13:58
【问题描述】:

我是 bndtools 的新手。我想使用 testcontainers (https://www.testcontainers.org/) 来测试应该连接到 MQTT 代理的 osgi 包。所以我可以测试连接、连接丢失等策略。 我不明白 maven 和 bnd 存储库是如何一起工作的,所以在我理解之前,我不使用 maven。然后我尝试通过将其添加到 build.bnd 来“导入”测试容器:

-plugin.6.junit: \
    aQute.bnd.repository.maven.pom.provider.BndPomRepository; \
        releaseUrl=https://repo.maven.apache.org/maven2/; \
        readOnly=true; \
        name="Maven Central JUNIT";\
        revision="org.osgi:org.osgi.test.junit5:0.10.0,\
        org.osgi:org.osgi.test.junit4:0.10.0", \
        org.testcontainers:testcontainers:1.15.2

但是 bnd 说“无法加载插件 org.testcontainers:testcontainers:1.15.2。” 我迷路了……

【问题讨论】:

标签: testing osgi bnd testcontainers-junit5


【解决方案1】:

您使用的语法是错误的...'revision' 参数采用带引号的字符串。该字符串以junit4:0.10.0", \ 结尾。在引用的字符串关闭后添加测试容器参数。所以以下应该工作:

-plugin.6.junit: \
    aQute.bnd.repository.maven.pom.provider.BndPomRepository; \
        releaseUrl=https://repo.maven.apache.org/maven2/; \
        readOnly=true; \
        name="Maven Central JUNIT";\
        revision="org.osgi:org.osgi.test.junit5:0.10.0,\
            org.osgi:org.osgi.test.junit4:0.10.0, \
            org.testcontainers:testcontainers:1.15.2"

Maven Bnd 存储库更易于使用,因为它允许您在文本文件中指定 GAV,每行一个。

【讨论】:

    猜你喜欢
    • 2022-06-29
    • 1970-01-01
    • 2020-10-09
    • 2020-01-18
    • 1970-01-01
    • 2015-12-12
    • 1970-01-01
    • 1970-01-01
    • 2020-10-08
    相关资源
    最近更新 更多