首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Elasticsearch (Java) -集成测试

Elasticsearch (Java) -集成测试
EN

Stack Overflow用户
提问于 2018-03-13 22:24:42
回答 1查看 778关注 0票数 1

我使用Java 8,Elasticsearch High level client 6.1.1和Maven,并想写一些集成测试。下面是我用于测试的java类:

代码语言:javascript
复制
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.SUITE, numDataNodes=1)
public class ElasticSearchServiceITest extends ESIntegTestCase {
}

我已经添加了依赖项:

代码语言:javascript
复制
<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>

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

java.lang.RuntimeException:在测试类路径中找到jar地狱

代码语言:javascript
复制
    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)

我哪里做错了?我没有添加任何功能,但得到了错误。

EN

回答 1

Stack Overflow用户

发布于 2018-12-22 08:14:17

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49258688

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档