6 Replies Latest reply on Oct 23, 2008 7:12 AM by mail.micke

    Beginner: Should this test be able to work?

    mail.micke

      Hi,
      I'm playing around with jsfunit and wonder if the test below should be able to work.

      I'm using the latest snapshot available today.

      public class PersonEditJsfUnitTest extends ServletTestCase{
       private JSFClientSession client;
       private JSFServerSession server;
      
       public static Test suite(){
       return new TestSuite(PersonEditJsfUnitTest.class);
       }
      
       public void setUp() throws Exception{
       super.setUp();
       //WebClientSpec wcSpec = new WebClientSpec("/detailEdit/index.jsf", BrowserVersion.INTERNET_EXPLORER_6_0);
       //JSFSession jsfSession = new JSFSession(wcSpec);
      
       this.client = new JSFClientSession("/detailEdit/index.jsf");
       this.server = new JSFServerSession(client);
      
       }
      
       public void testNavigation() throws Exception{
      
       assertEquals("/detailEdit/index.xhtml", server.getCurrentViewID());
       //Edit first entry in the list
      
       System.out.println("===================="+server.getManagedBeanValue("#{detailEdit}"));
      
       client.clickCommandLink("editForm:listTable:0:link");
      
       //Check that we navigated to correct page
       assertEquals("/detailEdit/editPerson.xhtml",server.getCurrentViewID());
      
       System.out.println("===================="+server.getManagedBeanValue("#{detailEdit}"));
      
       assertEquals("Mikael", server.getManagedBeanValue("#{detailEdit.selected.firstName}"));
       assertEquals("Andersson", server.getManagedBeanValue("#{detailEdit.selected.lastName}"));
       }
      
      }
      


      Currently I get an assertion error that for the firstName managed bean value. Saying it is null.

      The commandLink is like this:

      <h:commandLink
       id="link"
       value="Edit"
       action="#{detailEdit.setSelected(person)}"/>
      


      The System.out.println statements both produce null.

      Cheers,
      Micke

        • 1. Re: Beginner: Should this test be able to work?
          ssilvert

          First off, it looks like you are using the old org.jboss.jsfunit.facade.JSFClientSession. The whole facade package will be removed for GA. It was only left in Beta 3 to allow Beta 2 users to migrate to the new org.jboss.jsfunit.jsfsession package, which uses HtmlUnit instead of HttpUnit.

          Are you using Seam? It looks like you are using JBossEL or some other EL extension that allows params to be sent to a MethodExpression. So using the old facade package would keep Seam from getting initialized properly.

          Stan

          • 2. Re: Beginner: Should this test be able to work?
            mail.micke

            Hi Stan

            Yes using Seam.

            I downloaded the latest builds from Hudson and installed them locally, do they contain the old Facade classes?
            Was a bit confused about this because other posts in the forum had the ClientFacade classes, figured they'd been renamed :)

            Should the new facades be in the jsfunit-core jar?
            I have that and the seam and analysis jars in my local repo.

            If I use the jboss snapshot repo, should I be able to get the latest snapshots? Or should I use nightly builds?

            Thanks

            • 3. Re: Beginner: Should this test be able to work?
              ssilvert

              Right now, JSFUnit includes both packages, but the facade package will go away for GA.

              So for now you have both:
              org.jboss.jsfunit.facade.JSFClientSession
              org.jboss.jsfunit.jsfsession.JSFClientSession

              But you should only use org.jboss.jsfunit.jsfsession.JSFClientSession. Also, you should no longer use the Seam jar. Seam support is built into JSFUnit core as long as you are using the jsfsession package.

              See http://www.jboss.org/community/docs/DOC-10966

              We don't have nightly snapshots set up for JSFUnit yet. So if you want the very latest you will need to build it yourself from SVN. Since you are using Seam this might be a good idea because there have been a few Seam-related fixes since Beta 3.

              Stan

              • 4. Re: Beginner: Should this test be able to work?
                mail.micke

                Thanks

                Modifed the test to use the classes in the jsfsession package.

                Not using a local build yet, waiting for the repo to get added to artifactory.

                The test still fails, and the system.out.println statements are as follows:

                ====================com.dkib.riskit.sandbox.person.backing.DetailEditBacking@a70acd
                ====================com.dkib.riskit.sandbox.person.backing.DetailEditBacking@1c5cdac
                


                Two different instances of the backing bean, do you know why this is?
                Are there issues with working with non-long-running Seam conversations?

                Cheers,
                Micke

                • 5. Re: Beginner: Should this test be able to work?
                  ssilvert

                   

                  ====================com.dkib.riskit.sandbox.person.backing.DetailEditBacking@a70acd
                  ====================com.dkib.riskit.sandbox.person.backing.DetailEditBacking@1c5cdac

                  As I understand it, the instances of the backing bean won't always be the same from request to request. A Seam conversation is torn down and restored between requests, so what you seen in the System.out messages is probably correct.

                  Without more information, I have no way to tell why your assertion is failing. Perhaps "person" is not set correctly?

                  Here are the Seam bugs that have been fixed after Beta 3. I don't know of any other Seam issues:
                  https://jira.jboss.org/jira/browse/JSFUNIT-172
                  https://jira.jboss.org/jira/browse/JSFUNIT-163
                  https://jira.jboss.org/jira/browse/JSFUNIT-170
                  https://jira.jboss.org/jira/browse/JSFUNIT-171
                  https://jira.jboss.org/jira/browse/JSFUNIT-173

                  Stan

                  • 6. Re: Beginner: Should this test be able to work?
                    mail.micke

                    Hmm,
                    when just using the page in the browser it works just fine.

                    I'll keep trying this and post here what I find.

                    Many thanks,
                    Micke