[英]Elasticsearch (Java) - Integration tests
我使用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 )
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.