4 Replies Latest reply on Aug 19, 2010 1:23 AM by Bernard Labno

    JSFUnit with Maven

    Bernard Labno Master

      After reading wiki article on JSFUnit with Maven, I understand, that I need to have exact copy of original application, am I right?

      My spring project has lots of faces-config* and applicationContext-* files, that are filtered, so copying all filters, and configs makes project hard to maintain. Am I missing something?

        • 1. Re: JSFUnit with Maven
          Stan Silvert Master

          You don't need to make a copy of the original applicaiton.  You just need to create a new submodule that depends on the original WAR.


          I use war overlays as described here: http://maven.apache.org/plugins/maven-war-plugin/overlays.html


          If you are using JBoss AS5 then you can use the JSFUnitWithASMicrocontainer and avoid all that.  You just install the deployer and it will add JSFUnit to your WAR at deploy time.



          • 2. Re: JSFUnit with Maven
            Bernard Labno Master

            So why should I copy web.xml from original project? Shouldn't all the spring and jsf configs be copied as well?

            The problem is that web.xml contains properties filtered by maven.

            • 3. Re: JSFUnit with Maven
              Stan Silvert Master

              If you are using a Servlet 3.0 container then you won't need to have a different web.xml in the JSFUnit submodule.  The JSFUnit/Cactus servlets and filters will be added automatically at deploy time.


              If you are not using a Servlet 3.0 container then you do need a copy web.xml in the JSFUnit submodule.  However, you could probably use Maven filtering to add that stuff when the JSFUnit submodule WAR is created.  I've never tried that approach but it would probably work out nicely.


              I don't understand your question about spring and jsf configs.  Everything from the dependent WAR should be copied over.  You just overlay the things you want to change for JSFUnit.



              1 of 1 people found this helpful
              • 4. Re: JSFUnit with Maven
                Bernard Labno Master

                Ok, Now i see how it works. Original WAR is exploded, and all the configs are copied to xxx-jsfunit module.

                So all the spring files were filtered during build of original module and now they get copied.

                Problem remains with web.xml. Duplicating it in xxx-jsfunit module makes it harder to maintain,

                cause modifications need to be done in both places.


                I will try today to add property to web.xml which will be defined in jsfunit-filter.properties. That property will contain cactus filters and servlets definitions that is required by JSFUnit, thus web.xml will have it only if jsfunit profile is activated.

                All the testing will be done in main modul, so xxx-jsfunit module will not be necessary. That will make testing with maven piece of cake. But, we shall see if it works.