2 Replies Latest reply on Dec 17, 2007 6:58 PM by kragoth

    assert server.getCurrentViewID()

    kragoth

      I have the following test (just learning how to use it)

      public class JSFUnitTest extends org.apache.cactus.ServletTestCase {
      
       public static Test suite()
       {
       return new TestSuite( JSFUnitTest.class );
       }
      
       public void testInitialPage() throws IOException, SAXException
       {
       // Send an HTTP request for the initial page
       JSFClientSession client = new JSFClientSession("/web/index.jsf");
      
       // A JSFServerSession gives you access to JSF state
       JSFServerSession server = new JSFServerSession(client);
      
       // Test navigation to initial viewID
       assertEquals("/web/index.xhtml", server.getCurrentViewID());
      
       }
      }
      



      Why is it that I navigate to /web/index.jsf that I have to assert that my view is /web/index.xhtml.

      Why can't I assert that my view is the jsf page?

      If this is just how it works so be it.....but just seems a tad weird :)

        • 1. Re: assert server.getCurrentViewID()
          ssilvert

           

          "Kragoth" wrote:

          Why is it that I navigate to /web/index.jsf that I have to assert that my view is /web/index.xhtml.


          JSFClientSession is handling the client side of things. To a client (browser), the URL is /web/index.jsf.

          JSFServerSession looks at things from a JSF standpoint. To JSF, your view ID is indeed /web/index.xhtml. Note that this is how it looks to your navigation rules in faces-context.xml.

          JSFServerSession.getCurrentViewID() is really a shorthand for FacesContext.getViewRoot().getViewId(). As you use JSFUnit to go from page to page, getCurrentViewID() is used to test if your navigation rules are working as expected.

          See this wiki page for more tips on using the JSFUnit API:
          http://wiki.jboss.org/wiki/WritingJSFUnitTests

          Regards,

          Stan

          • 2. Re: assert server.getCurrentViewID()
            kragoth

            Thanks heaps for your help Stan :)