Sunday, 15 March 2015

intellij idea - Dropwizard integration test cannot find resource file -


Very new to the dropwizard, I'm trying to create an integration test "actually" how this is an example As is:

  https://dropwizard.github.io/dropwizard/manual/testing.html Public Class Login SignupTest {@ClassRule Public Fixed Last DropwizardAppRule & lt; Test Configuration & gt; Rule = New Dropware AppRule & lt; Test Configuration & gt; (MyApp.class, ResourceHelpers.resourceFilePath ("dev-config.yml")); @Test Public Farewell LoginHandlerRadres AfterPost () {// Client Client = New Jersey Clink Builder (RULE.getEnvironment ()). Build ("test client"); }}  

There are 2 issues: First of all when I run a test with intellij, then it fails with the following exception:

  by reason : Java Lang.IllegalArgumentException: resource dev-config.yml not found.  

Full stacketrace:

  sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor at sun.misc.Unsafe.ensureClassInitialized (native resident method) java.lang .ExceptionInInitializerError (UnsafeFieldAccessorFactory.java:43) sun.reflect.ReflectionFactory.newFieldAccessor (ReflectionFactory.java:140) java.lang.reflect.Field.acquireFieldAccessor (Field.java:1057) on java.lang.reflect.Field.getFieldAccessor At (field .java: 1038) at org.junit.runners.model org.junit.runners.model.frameworkField.get (FrameworkField.java:73) on java.lang.reflect.Field.get (Field.java379) On. TestClass.getAnnotatedFieldValues ​​org.junit.runners.ParentRunner.classRules (ParentRunner.java:255) to (TestClass.java:230) org.junit.runners.ParentRunner.withClassRules on org.junit.runners (ParentRunner.java:244 ) on .ParentRunner.classBlock org.junit.runners.ParentRunner.run (ParentRunner.java:194) (ParentRunner.java:362) on org.junit.runner.JUnitCore.run (JUnitCore.java:137) on com.intellij On. Junit4.JUnit4Idea com intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart (JUnitStarter.java, 1111) at com.intellij.rt.execution.junit.JUnitStarter.main (JUnitStarter.java: testrunner.startRunnerWithArgs (JUnit4IdeaTestRunner.java) : 74) on) 67) SunkreflectkNativeMethodAccessorImplkinvoke (NativeMethodAccessorImplkjava:57) SunkreflectkNativeMethodAccessorImplkinvoke0 (Native method on com.intellij.rt.execution.application.AppMain.main) (AppMain .java: on 134) Reason: java.lang.RuntimeException: java.lang.IllegalArgumentException: Resource dev-config.yml not found. . Java.lang: clinit & gt; io.dropwizard.testing.ResourceHelpers.resourceFilePath (ResourceHelpers.java:23) is com.amplify.ckla.resources.TeacherConfigResourceIntegrationTest & (TeacherConfigResourceIntegrationTest.java:12) on lt ... 21 more due. IlegalArgumentException: Resource dev-config.yml not found. com.google.common.base.Preconditions.checkArgument (Preconditions.java:145) on com.google.common.io.Resources.getResource (Resources.java:197) on io.dropwizard.testing.ResourceHelpers.resourceFilePath (on ResourceHelpers .java: 21) ... 22 more  

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  

Change the program's run directory to be the root of the project (with the production of ls -a command). Most likely you are currently running from the ./ targets directory .

Or you want / .target to change the command line options to run from the configuration file to mention: ../de-conf Yml

Edit: Commented as the right thing to do in the @nightograph Click on the intelliase project folder and click < Code> "Resource Route"


No comments:

Post a Comment