1

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.

4
  • 1
    Possible duplicate of What is a Null Pointer Exception, and how do I fix it? Commented Oct 21, 2015 at 14:32
  • which line of code causes the issue? Commented Oct 21, 2015 at 14:44
  • are you just trying to run the JavaTest class? Commented Oct 21, 2015 at 14:44
  • Yes, this error appears when I simply run the test case. Commented Oct 21, 2015 at 19:30

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.