gpt4 book ai didi

java - Elasticsearch (Java) - 集成测试

转载 作者:太空宇宙 更新时间:2023-11-04 10:38:37 25 4
gpt4 key购买 nike

我使用 Java 8、Elasticsearch 高级客户端 6.1.1 和 Maven,想要编写一些集成测试。这是我用于测试的 java 类:

@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.SUITE, numDataNodes=1)
public class ElasticSearchServiceITest extends ESIntegTestCase {
}

我添加了依赖项:

<dependency>
<groupId>org.elasticsearch.test</groupId>
<artifactId>framework</artifactId>
<version>6.1.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-test-framework</artifactId>
<version>7.1.0</version>
<scope>test</scope>
</dependency>

当我尝试运行测试时 - 我看到错误:

java.lang.RuntimeException:在测试类路径中发现 jar hell

    at org.elasticsearch.bootstrap.BootstrapForTesting.<clinit>(BootstrapForTesting.java:92)
at org.elasticsearch.test.ESTestCase.<clinit>(ESTestCase.java:190)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at com.carrotsearch.randomizedtesting.RandomizedRunner$2.run(RandomizedRunner.java:592)
Caused by: java.lang.IllegalStateException: jar hell!
Exception in thread "Thread-6" java.lang.NoClassDefFoundError: Could not initialize class org.elasticsearch.test.ESTestCase
at java.lang.Thread.run(Thread.java:748)
Suppressed: java.lang.IllegalStateException: No context information for thread: Thread[id=29, name=Thread-6, state=RUNNABLE, group=TGRP-ElasticSearchServiceITest]. Is this thread running under a class com.carrotsearch.randomizedtesting.RandomizedRunner runner context? Add @RunWith(class com.carrotsearch.randomizedtesting.RandomizedRunner.class) to your test class. Make sure your code accesses random contexts within @BeforeClass and @AfterClass boundary (for example, static test class initializers are not permitted to access random contexts).
at com.carrotsearch.randomizedtesting.RandomizedContext.context(RandomizedContext.java:248)
at com.carrotsearch.randomizedtesting.RandomizedContext.current(RandomizedContext.java:134)
at com.carrotsearch.randomizedtesting.RandomizedRunner.augmentStackTrace(RandomizedRunner.java:1848)
at com.carrotsearch.randomizedtesting.RunnerThreadGroup.uncaughtException(RunnerThreadGroup.java:20)
at java.lang.Thread.dispatchUncaughtException(Thread.java:1959)

我做错了什么?我没有添加任何功能,但收到错误。

最佳答案

我遇到了同样的问题,并通过设置 tests.security.manager=false 运行测试来解决它。您还可以更新您的 java 策略文件(请参阅 https://github.com/elastic/elasticsearch/issues/22689 )

关于java - Elasticsearch (Java) - 集成测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49258688/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com