Reputation: 2249
Very new to dropwizard, I am trying to create an integration test "exactly" how they have it as an example:
https://dropwizard.github.io/dropwizard/manual/testing.html
public class LoginAcceptanceTest {
@ClassRule
public static final DropwizardAppRule<TestConfiguration> RULE =
new DropwizardAppRule<TestConfiguration>(MyApp.class, ResourceHelpers.resourceFilePath("dev-config.yml"));
@Test
public void loginHandlerRedirectsAfterPost() {
//Client client = new JerseyClientBuilder(RULE.getEnvironment()).build("test client");
}
}
so far having 2 issues: first of all when I run the test from intellij it fails with following exception:
Caused by: java.lang.IllegalArgumentException: resource dev-config.yml not found.
full stacktrace:
java.lang.ExceptionInInitializerError
at sun.misc.Unsafe.ensureClassInitialized(Native Method)
at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:43)
at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:140)
at java.lang.reflect.Field.acquireFieldAccessor(Field.java:1057)
at java.lang.reflect.Field.getFieldAccessor(Field.java:1038)
at java.lang.reflect.Field.get(Field.java:379)
at org.junit.runners.model.FrameworkField.get(FrameworkField.java:73)
at org.junit.runners.model.TestClass.getAnnotatedFieldValues(TestClass.java:230)
at org.junit.runners.ParentRunner.classRules(ParentRunner.java:255)
at org.junit.runners.ParentRunner.withClassRules(ParentRunner.java:244)
at org.junit.runners.ParentRunner.classBlock(ParentRunner.java:194)
at org.junit.runners.ParentRunner.run(ParentRunner.java:362)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:211)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
Caused by: java.lang.RuntimeException: java.lang.IllegalArgumentException: resource dev-config.yml not found.
at io.dropwizard.testing.ResourceHelpers.resourceFilePath(ResourceHelpers.java:23)
at com.amplify.ckla.resources.TeacherConfigResourceIntegrationTest.<clinit>(TeacherConfigResourceIntegrationTest.java:12)
... 21 more
Caused by: java.lang.IllegalArgumentException: resource dev-config.yml not found.
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:145)
at com.google.common.io.Resources.getResource(Resources.java:197)
at io.dropwizard.testing.ResourceHelpers.resourceFilePath(ResourceHelpers.java:21)
... 22 more
the dev-config.yml is definitely there:
ls -a
. .idea build.sh pom.xml
.. CKLA.iml dev-config.yml src
.git README.md target
.gitignore develop.sh
Upvotes: 2
Views: 2399
Reputation: 1157
Change the run directory of the program to be the root of the project (the one with the output of the ls -a
command). Most likely currently you are running it from ./target
directory.
Or if you want/need to run from .target
change the command line options to refer the configuration file to: ../dev-config.yml
Edit:
As @nightograph commented the exact thing to do in IntelliJ is to right click on the project folder and mark directory as "Resources Root"
Upvotes: 3