4 Replies Latest reply on Aug 6, 2013 8:27 PM by jrhite_boss

    Class.getResource returns odd path when running Arquillian and using ShrinkWrap

    jrhite_boss

      I'm having an issue resolving certain resources when running my ShrinkedWrapped war file in JBoss. I print the contents of my war file and it all looks good to me, but it brings up 2 questions:

       

      1. Currently, it's a little awkward because I'm adding a test data file to the war file for my tests so I can reconstruct Java objects from the json file (which is also used to populate the DB). That why I don't have to keep test data both in the json file and in the tests themselves. But I couldn't figure out the best place for such a file, so in ShrinkWrap I just added it to the war file like this:

       

      .addAsWebInfResource(new File("src/test/resources/datasets/testdata.json"),

                                          "datasets/cc.mc.database.UserAccessTest.json");

       

      is there a better place to put such a file...it ends up living in

       

      /WEB-INF/datasets/testdata.json

       

       

      2. And my second, more important question is, in my test code I try to get the resource with a call like:

       

                          URL url = testClass.getResource("/datasets/testdata.json");

       

      But this resolves to:

      vfs:/content/test.war/WEB-INF/lib/92aff46b-5c2a-41ac-b34c-62066f4c8475.jar/datasets/testdata.json

       

      And is not found. What I am doing wrong here and how can I correct this?

       

      Thanks!