3 Replies Latest reply on Oct 20, 2009 7:37 AM by ssilvert

    I'm confused about JSFUnit and maven.

    pucky

      Hi all,

      I have a seam application that I'd like to do some JSFUnit against and I've come across some issues.

      First my application is distributed so I know that there was an issue with serializing the jsfsession. The error I was getting is below:

      java.lang.IllegalArgumentException: setAttribute: Non-serializable attribute

      So I turned off distributed and it worked.

      So I've got JSFUnit configured within my war which is deployed as part of an ear.

      Should I just create a unittest.war and deploy it within my ear and then test it that way?

      I've tried to do the above but my unittest.war can't access the pages of the main app.


      =======ear layout=======

      ear/
      /META-INF/...
      /ejb.jar
      /mywebap.war <--root context /
      /unittest.war <-- root context /unittest

      ====================

      Step 4 of http://www.jboss.org/community/wiki/JSFUnitWithMaven is the part that is confusing me.

      How am I suppose to configure my unittest.war to access my .seam files in the mywebapp.war?

      here's my test JSFUnit maybe the issue is here:

      ======Basic Test=======

      import org.apache.cactus.ServletTestCase;
      import org.jboss.jsfunit.jsfsession.JSFSession;
      import org.jboss.jsfunit.jsfsession.*;
      import org.jboss.jsfunit.framework.WebClientSpec;
      import org.jboss.jsfunit.richclient.RichFacesClient;
      import junit.framework.*;
      import java.io.IOException;

      public class BasicTest extends ServletTestCase {

      private JSFSession jsfSession;
      private JSFClientSession client;
      private RichFacesClient richClient;
      private JSFServerSession server;

      public void setUp() throws IOException
      {
      WebClientSpec wcSpec = new WebClientSpec("/login.seam");
      this.jsfSession = new JSFSession(wcSpec);
      this.client = jsfSession.getJSFClientSession();
      this.richClient = new RichFacesClient(client);
      this.server = jsfSession.getJSFServerSession();
      }

      public static Test suite() {
      return new TestSuite(BasicTest.class);
      }

      public void testInitialPage() throws Exception {



      assertEquals("/login.xhtml",server.getCurrentViewID().toString());




      }

      public void testLoginPageAdmin() throws Exception
      {
      assertEquals("/login.xhtml",server.getCurrentViewID().toString());
      client.setValue("login:username","username");
      client.setValue("login:password","password");

      client.click("loginBtn");


      assert(((Boolean)server.getManagedBeanValue("#{identity.loggedIn}")).booleanValue());


      }

      public void testLogoutAdmin() throws Exception
      {
      assert(((Boolean)server.getManagedBeanValue("#{identity.loggedIn}")).booleanValue());

      client.click("logoutBtn");


      assertFalse(((Boolean)server.getManagedBeanValue("#{identity.loggedIn}")).booleanValue());

      }
      }



      ====================

      So mainly what I'm trying to do is keep my application distributed but have the unittest.war not distributed so that I can get past the Serialization error. Will this work? Am I way off course here, I pretty much feel that way.

      Thanks
      Pucky

        • 1. Re: I'm confused about JSFUnit and maven.
          ssilvert

          From you other post, I see you got this working. I'll answer in case someone else sees this post and has the same problem.

          One WAR cannot access pages in another WAR. So you need to make your build create a "JSFUnitfied" WAR for testing and just use that one WAR only. For your JSFUnit testing, should be turned off.

          Stan

          • 2. Re: I'm confused about JSFUnit and maven.
            pucky

            Hi Stan,

            Just to clarify when you say "JSFUnitfied" your meaning duplicating the actual working war with the JSFUnit/Cactus additions and using that specifically for JSFUnit tests is that correct?

            Thanks so much.

            • 3. Re: I'm confused about JSFUnit and maven.
              ssilvert

               

              "pucky" wrote:
              Hi Stan,

              Just to clarify when you say "JSFUnitfied" your meaning duplicating the actual working war with the JSFUnit/Cactus additions and using that specifically for JSFUnit tests is that correct?

              Thanks so much.

              Exactly.

              Stan