2 Replies Latest reply on Mar 4, 2011 5:01 AM by Stephan Pabinger

    Exploded web archive - or how to access files in Arquillian

    Stephan Pabinger Newbie

      Hi,

       

      I'm testing my JEE 6 application with Arquillian using a JBoss-remote configuration.

       

      I created a test where I check the functionality of my bean which uploads and downloads files.

      Therefore, I need to access a file in my test and thought about putting it into the WAR which is deployed to the server. Since we are developing in a group I don't want to use an absolute path to a file. However, I cannot access it as the WAR is not exploded.

       

      1) Is there a way to tell Arquillian/ShrinkWrap to create an exploded WAR?

      2) What is the best way to access files in an Arquillian test?

       

      Thanks for your help,

      Stephan

        • 1. Re: Exploded web archive - or how to access files in Arquillian
          Karel Piwko Master

          Hi Stephan,

           

          1/ It is not possible at the moment

          2/ Maybe I missed your point with including a file into WAR, but from your test you can access files using relative path to the directory where you are running them, for instance with Maven

           

          mvn test
          

           

          you can access files using relative paths such as "src/test/resources/foo.bar".

           

          For accessing files in WAR, I would suggest using container related means, such as VFS for JBoss AS.

           

          If you want to solve absolute path problem by a quick workaround, you can pass path as a System property and let Surefire (your test system) populate it with absolute path based on project ${basedir}.

          1 of 1 people found this helpful
          • 2. Exploded web archive - or how to access files in Arquillian
            Stephan Pabinger Newbie

            Hi Karel,

             

            thanks for your reply.

             

            I'm now using the File.createTempFile method to create a new file and write the content of the file I've included in the WAR into that tmp file. So far this strategy works pretty good.