Reputation: 2149
I had code like this:
public class BaseTest {
@ClassRule
public static final DropwizardAppRule<FingageConfiguration> RULE;
protected static Client client;
static {
try {
RULE = new DropwizardAppRule<>(FingageApplication.class, ResourceHelpers.resourceFilePath(System.getProperty("config")));
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@BeforeClass
public static void beforeClass() throws IOException {
RULE.getConfiguration().getFlywayService().automigrateForTests();
client = RULE.getConfiguration().getClient();
client.property(ClientProperties.CONNECT_TIMEOUT, 10000);
client.property(ClientProperties.READ_TIMEOUT, 100000);
}
which was using an earlier version of dropwizard 2, and I'm trying to convert it to use Dropwizard extensions support:
@ExtendWith(DropwizardExtensionsSupport.class)
public class BaseTest {
protected static Client client;
public static DropwizardAppExtension<FingageConfiguration> RULE = new DropwizardAppExtension<>(
FingageApplication.class,
ResourceHelpers.resourceFilePath(System.getProperty("config")));
@BeforeClass
public static void beforeClass() throws IOException {
RULE.getConfiguration().getFlywayService().automigrateForTests();
client = RULE.getConfiguration().getClient();
client.property(ClientProperties.CONNECT_TIMEOUT, 10000);
client.property(ClientProperties.READ_TIMEOUT, 100000);
}
but now it fails with an error:
java.lang.NullPointerException: configuration
at java.base/java.util.Objects.requireNonNull(Objects.java:259)
at io.dropwizard.testing.DropwizardTestSupport.getConfiguration(DropwizardTestSupport.java:341)
at io.dropwizard.testing.junit5.DropwizardAppExtension.getConfiguration(DropwizardAppExtension.java:213)
at com.fingage.BaseTest.beforeClass(BaseTest.java:43)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
at org.junit.internal.runners.statements.RunBefores.invokeMethod(RunBefores.java:33)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:232)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:55)
any ideas on what I need to do here?
Upvotes: 0
Views: 27