3 Replies Latest reply on Feb 11, 2010 11:29 AM by Daniel Lechner

    Maven and JSFUnit - module structure

    Daniel Lechner Novice



      I try to get some JSFUnit tests to run in our maven environment. But I don't know the best way how to put my tests into modules.


      Basically, we have several maven modules, with packaging type jar (or ejb) and one with type war (which produces a "skinny war"). All these modules are packaged together by a another module into an ear archive which is deployed on the application server.


      Now I tried to use JSFUnit as another testing framework for the application. As suggested in the JSFUnitWithMaven-HowTo, I created a new module with packaging type war. I can take this newly created "JSFUnified" war, put it into the EAR manually (replace the original war) and execute the tests via the browser. First of all, I have to say that JSFUnit is exactly what we were looking for. It seems to be a great framework and fits our requirements.


      But of course, this is not the way I want it to do after the prototyping phase.
      But the question is, what is the best way to do this with maven? To summarize the problem: I have to take the application-EAR, replace the WAR inside this EAR and deploy the modified EAR to the application server for testing. While creating the WAR and deploying an EAR isn't the problem, I struggle with the modification of the EAR.


      I could try to change the packaging type of the JSFUnit-module to pom and create the modified war and the ear of the application within this module and run the tests afterwards. So I have a single module with no output (except the test results). But it turns out that this is not that easy (maybe it is - but up to now I was not able to do so). Besides it seems that this is not best practice as suggested by maven.


      Does anyone have some experience on testing the webapplication which is deployed as EAR?

      Many Thanks!

        • 1. Re: Maven and JSFUnit - module structure
          Stan Silvert Master

          If you are using JBoss AS5.x or AS6.x you can use the JSFUnit Deployer.  That allows you to "JSFUnify" the EAR at deploy time without any changes to your WAR.  You don't even have to bundle the tests but instead put them in a seperate directory.  See JSFUnitWithASMicrocontainer.


          If you are using another container then my suggestion is to have a JSFUnit WAR module that depends on the regular WAR (I think you are already doing that).  Then use a profile in your EAR module to include the JSFUnit WAR only when you are testing.


          Hope that helps,



          • 2. Re: Maven and JSFUnit - module structure
            Daniel Lechner Novice

            Hi Stan!


            Thank you for your answer!

            I already saw the JSFUnit Deployer for JBoss 5 and got angry about my JBoss 4.2.2. Maybe we'll make an upgrade soon (I hope so)


            Nevertheless, your hint with the separate profile for my EAR profile is probably a suitable solution. Up to now, I've tried something "completely different": I created 3 maven modules, depending on each other. First, there is one module which implements the tests and creates the JSFUnified WAR (as you suggest in the HowTo). Another module is somehow a copy of my original EAR module which assembles the application to an EAR but using the JSFUnified WAR instead of the original one. And the third module is responsible for deploying the new EAR and executing the tests. This works pretty good (there are only some small issues with the cargo plugin - but this is just cosmetical).


            Maybe I will try the way of defining another profile (it sounds a bit better to me than my solution). And I'm looking forward to upgrade the JBoss.

            • 3. Re: Maven and JSFUnit - module structure
              Daniel Lechner Novice
              Hi again!

              stan.silvert@jboss.com schrieb:



              Then use a profile in your EAR module to include the JSFUnit WAR only when you are testing.


              Hope that helps,




              I just wanted to inform you that I tried this and maybe my insights are useful for someone else:


              I now tried to define another profile and use it in the EAR module to produce the modified EAR. Although it was basically working, it turned out that this is not a perfect solution:

              Since the produced EAR is different from the standard one, a classifier has to be added to the "module path" of the EAR in order to mark that there is something different. Thus the JSFUnit-tests are using the EAR with the classifier and the "normal" integration tests are using the standard EAR without the classifier. But since it is not possible to produce both EARs within one maven run, some problems arise when someone wants to build the application and run both the integration tests and the JSFUnit tests (either the JSFUnified EAR or the standard EAR is out of date).

              Another problem comes up when using Continuum. I tried to come up with a solution by defining custom builds in continuum, but none of the tried ways worked perfectly and everything sounds like an ugly hack (from the maven point of view).


              So I decided to go back to my 3-module-solution which still works fine.