2 Replies Latest reply on Apr 3, 2008 3:44 AM by Tim Evers

    Production/Testing configuration?

    Stephan B Newbie

      Hi there,

      I am about to get started with JSFUnit and already running into the first problem. I created my web app with the JBoss Seam Wizard (from JBoss Tools, so I got projects myproject, myproject-ear, myproject-ejb and myproject-test).

      Obviously I want JSFUnit to run in myproject-test and not in my deployment project; however, I can only have one web.xml and if I add the necessary filters to that, I needs the cactus and jsfunit jars of course. But I don't want to deploy those to my production system.

      How can I solve that issue?

        • 1. Re: Production/Testing configuration?
          Stan Silvert Master

          How you solve this problem depends on your build process.

          For the JSFUnit project, you can look at the "HelloJSF" example and see how we solve this for Maven. We have the main build of the WAR that is the "production version" called "HelloJSF Example App". It has no dependency on JSFUnit. Then we have another submodule that depends on the production version of the WAR called "HelloJSF JSFUnit Integration Test". This is where we put a dependency on JSFUnit and use a different copy of web.xml. The only problem with this approach is that you do need to maintain two versions of web.xml.

          A possible way to avoid having two web.xml files is to have the same setup as above but use Maven's filtering capability to parameterize web.xml in the production version. Then you build web.xml on the fly depending on whether you are building the production version or the test version.

          Note that Servlet 2.0 should make this problem disappear, because you will be able to split web.xml into pieces instead of having only one file.

          For an Ant build, you could take the same kind of approach, but it's a little more work.


          • 2. Re: Production/Testing configuration?
            Tim Evers Master

            It is relatively simple with ant and possibly with mavern I'm not sure.

            I just use an ant task that is called only when a particular property is set (or not set depends on what you prefer) but it's like this.

            <target name="create.jsfunit.exploded.dir" depends="compile.test"
             <property name="force.jsfunit.run" value="=${gekko.web.run.jsftests}"></property>
             <path id="jsfunit.classpath">
             <fileset dir="${lib.dir}/jsf-unit">
             <include name="**/*.jar"/>
             <fileset dir="${gekko-shared.lib.test.dir}">
             <include name="junit/*.jar"/>
             <fileset dir="${gekko-shared.lib.prod.dir}">
             <include name="aspectj/*.jar"/>
             <jsfunitwar srcfile="${exploded.dir}"
             <classes dir="${classes.test}"

            This way my prod code never has the jsfunit stuff in it including the filters!

            Works really well