ESSingleNodeTestCase - Java 11 - Does not start Elastic

Hi,

I am trying to test the messages that I would post to our Elastic Search server and decided to use: ESSingleNodeTestCase.

After sorting out the dependencies I was able to compile and start the test.

As far as I understand from extending the ESSingleNodeTestCase in my test it should automatically call the setup() ?

When I try to manually call it I get:

No context information for thread: Thread[id=16, name=Test worker, state=RUNNABLE, group=main]. 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).
java.lang.IllegalStateException: No context information for thread: Thread[id=16, name=Test worker, state=RUNNABLE, group=main]. 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:249)

My sample test looks like this:

import com.carrotsearch.randomizedtesting.RandomizedRunner;
import org.elasticsearch.test.ESSingleNodeTestCase;
import org.junit.Before;

import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;

@RunWith(RandomizedRunner.class)
public class ElasticSearchTest extends ESSingleNodeTestCase {

    @Before
    public void setupNew() throws Exception {
        System.out.println("hello");
    }

    @Test
    void  testElastic () throws Exception{
        setUpClass();
        setUp();
        assertEquals("1", "1");
    }
}

I tried to use @BeforeClass and call setup() but it does not even run. Please help. Thanks

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.