6 Replies Latest reply on Oct 23, 2008 7:12 AM by Mikael Andersson

    Beginner: Should this test be able to work?

    Mikael Andersson Master

      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