Felix Novovic
Felix Novovic

Reputation: 625

ElasticsearchIntegrationTest fails with a NullPointerException

I'm using elasticsearch for a project I'm working on but, unfortunately, having quite frustrating issues with the test setup.

I have a test class which looks like below

import org.elasticsearch.test.ElasticsearchIntegrationTest;
import org.junit.Test;

public class JavaTest extends ElasticsearchIntegrationTest {

    @Test
    public void testSomething() throws Exception {

    }
}

This is my build.sbt

  "org.elasticsearch" % "elasticsearch" % "1.7.2" % "test" classifier "tests",
  "com.carrotsearch.randomizedtesting" % "randomizedtesting-runner" % "2.1.17" % "test",
  "org.elasticsearch" % "elasticsearch" % "1.7.2",
  "org.apache.lucene" % "lucene-test-framework" % "4.10.4" % "test",
  "org.hamcrest" % "hamcrest-all" % "1.3"

This is the output from the console

Oct 21, 2015 4:20:27 PM com.carrotsearch.randomizedtesting.RandomizedRunner runSuite
SEVERE: Panic: RunListener hook shouldn't throw exceptions.
java.lang.NullPointerException
    at org.elasticsearch.test.junit.listeners.LoggingListener.testRunStarted(LoggingListener.java:50)
    at com.carrotsearch.randomizedtesting.RandomizedRunner.runSuite(RandomizedRunner.java:639)
    at com.carrotsearch.randomizedtesting.RandomizedRunner.access$200(RandomizedRunner.java:140)
    at com.carrotsearch.randomizedtesting.RandomizedRunner$2.run(RandomizedRunner.java:587)

I have no idea what is going on here, the documentation told me only to inherit the ElasticsearchIntegrationTest class and I'd be good to go.

Does anyone have any idea as to what's going on here? Information about this error is very scarce and I did not find anything useful.

Upvotes: 1

Views: 438

Answers (2)

stian
stian

Reputation: 2894

Is your test class by any chance located in the default package?

The NPE happens in LoggingListener.java:50 (as your stack trace shows). This line contains the following piece of code:

previousPackageLoggingMap = processTestLogging(description.getTestClass().getPackage().getAnnotation(TestLogging.class));

If your test class is in the default package (e.g. there's no package statement in your class), the call to getPackage() will return null - thus causing the NPE. Workaround is to move your test to a package.

Upvotes: 1

Russell Cohen
Russell Cohen

Reputation: 725

Judging by http://central.maven.org/maven2/org/elasticsearch/elasticsearch/1.7.2/elasticsearch-1.7.2.pom, I think you have the wrong version of carrotsearch. I think you need 2.1.2

Upvotes: 1

Related Questions