5 Replies Latest reply on Mar 30, 2011 6:24 PM by Aslak Knutsen

    How to use Maven overlays in JSFUnit 2

    susmit Shukla Newbie

      Hi,

       

      I'm following the JSFUnit 2.0.0Beta1 example. I'm able to run the example JSFUnit tests with ShrinkWarpped war created and deployed to Jetty server.

      I want to have a separate JSFUnit maven module to test a existing JSF module. Since we are using shrinkwrap to create war on the fly, even if I use maven overlay, I can't use Shrinkwrap apis to add files to test war as parent war is added as maven dependency but those files do not exist on filesystem in test project.

      My question would be how to configure a separate test project for JSFUnit 2.0.0 using arquillian/jetty/shrinkwrap? An example would be great.

       

      I went through this article but it is geared towards JUnit 1.x:

      http://community.jboss.org/wiki/JSFUnitWithMaven

        • 1. How to use Maven overlays in JSFUnit 2
          Stan Silvert Master

          One of the nice things about using Arquillian with JSFUnit 2.0 is that you are no longer forced to use overlays.  With Cactus, you need to modify an existing WAR, so it makes sense to do the modifications in a seperate Maven module that depends on the regular WAR.  But with JSFUnit 2.0, you can easily keep everything in one Maven module and execute tests more naturally as you develop within the module.

           

          That being said, there are other valid reasons to use overlays, so I understand your problem.  One way I can think of to do what you want is to use the maven dependency plugin to copy the dependent WAR into a directory and then pull it in using Shrinkwrap.  But the Arquillian community might have a better idea so I'm moving this thread over to the Arquillian forum to get their feedback.

           

          Stan

          • 2. How to use Maven overlays in JSFUnit 2
            susmit Shukla Newbie

            Hi Stan,

             

            Thanks for your answer, I get your point, ShrinkWrap came in useful to manipulate the war under test. Right now I have copied the war into test project and used Shrinkwrap to add extra files (JSFUnit test and configs) and the tests are running fine. Given below is the api used to read an existing war and make additions to it before deploying to Jetty through arquillian:

             

            ZipFile existingZipFile = new ZipFile("JavaServerFaces.war");

            WebArchive war = ShrinkWrap.create(ZipImporter.class, "test.war")

                                     .importZip(existingZipFile)

                                     .as(WebArchive.class);

             

            Then manipulate the war file in usual way as in the example project.

            • 3. How to use Maven overlays in JSFUnit 2
              Aslak Knutsen Master

              One way would be to simply bind the test to the integration-test phase in Maven. At that point you have your finished packaged up war from maven, import that into a Arquillian test and manipulate away.  (if that works for you module setup)

               

              I'm not 100% clear on what you want to do with the War, that relates to manually adding JSFUnit stuff?

              • 4. How to use Maven overlays in JSFUnit 2
                susmit Shukla Newbie

                By Adding JUnit stuff I mean adding config files such as beans.xml, jetty-env.xml, JSFUnit test case to the original JSF application war.

                The JSF project is based on a OSGI build/development environment and maven is not being used in development setup so I have set up a separate maven project to test JSF with JSFUnit as proof of concept.

                • 5. How to use Maven overlays in JSFUnit 2
                  Aslak Knutsen Master

                  Aaa ic.. then I would go with what stan suggest. get hold of the file 'somehow' and import it as a WebArchive. Add and manipulate as you see fit and let Arquillian handle the rest (actually adding JSFUnit, Protocol executers etc)