1 Reply Latest reply on Dec 12, 2008 8:34 AM by Stan Silvert

    Jsunit Beta 3 : how to test panelMenuItem

    Adrien Adrien Apprentice

      Hi,
      Is it possible to test panelMenuItem with jsfunit beta 3?
      in server mode?
      in ajax mode?
      Thanks


      <h:form id="fddorm">
       <rich:panelMenu id="pm" mode="server" iconExpandedGroup="disc" iconCollapsedGroup="disc"
       iconExpandedTopGroup="chevronUp" iconGroupTopPosition="right" iconCollapsedTopGroup="chevronDown">
       <rich:panelMenuGroup id="g" label="#{bm.msg_title}" expanded="true" >
       <rich:panelMenuItem id="mnew" label="#{bm.msg_new}" action="#{ctrlMessagesSearch.search}" >
       <f:param name="page" value="p_msgs_new" />
       <f:param name="search" value="getNewMsg" />
       </rich:panelMenuItem>
      </rich:panelMenu>
      </form>


        • 1. Re: Jsunit Beta 3 : how to test panelMenuItem
          Stan Silvert Master

          Yes, but you might run into this HtmlUnit bug. It seems to work on Tomcat/JBoss but not Jetty:
          http://sourceforge.net/tracker/index.php?func=detail&aid=2250910&group_id=47038&atid=448266

          From the RichFaces demo:

          <h:form id="form1">
           <h:panelGrid columns="2" columnClasses="cols" width="100%">
           <rich:panelMenu id="ajaxPanelMenu" style="width:200px" mode="ajax"
           iconExpandedGroup="disc" iconCollapsedGroup="disc"
           iconExpandedTopGroup="chevronUp" iconGroupTopPosition="right"
           iconCollapsedTopGroup="chevronDown" iconCollapsedTopPosition="right" >
           <rich:panelMenuGroup id="Group1" label="Group 1">
           <rich:panelMenuItem id="Item_1_1" label="Item 1.1" action="#{panelMenu.updateCurrent}">
           <f:param name="current" value="Item 1.1"/>
           </rich:panelMenuItem>
           <rich:panelMenuItem id="Item_1_2" label="Item 1.2" action="#{panelMenu.updateCurrent}">
           <f:param name="current" value="Item 1.2"/>
           </rich:panelMenuItem>
           <rich:panelMenuItem id="Item_1_3" label="Item 1.3" action="#{panelMenu.updateCurrent}">
           <f:param name="current" value="Item 1.3"/>
           </rich:panelMenuItem>
           </rich:panelMenuGroup>
           <rich:panelMenuGroup id="Group2" label="Group 2">
           <rich:panelMenuItem id="Item_2_1" label="Item 2.1" action="#{panelMenu.updateCurrent}">
           <f:param name="current" value="Item 2.1"/>
           </rich:panelMenuItem>
           <rich:panelMenuItem id="Item_2_2" label="Item 2.2" action="#{panelMenu.updateCurrent}">
           <f:param name="current" value="Item 2.2"/>
           </rich:panelMenuItem>
           <rich:panelMenuItem id="Item_2_3" label="Item 2.3" action="#{panelMenu.updateCurrent}">
           <f:param name="current" value="Item 2.3"/>
           </rich:panelMenuItem>
           <rich:panelMenuGroup label="Group 2.4">
           <rich:panelMenuItem id="Item_2_4_1" label="Item 2.4.1" action="#{panelMenu.updateCurrent}">
           <f:param name="current" value="Item 2.4.1"/>
           </rich:panelMenuItem>
           <rich:panelMenuItem id="Item_2_4_2" label="Item 2.4.2" action="#{panelMenu.updateCurrent}">
           <f:param name="current" value="Item 2.4.2"/>
           </rich:panelMenuItem>
           <rich:panelMenuItem id="Item_2_4_3" label="Item 2.4.3" action="#{panelMenu.updateCurrent}">
           <f:param name="current" value="Item 2.4.3"/>
           </rich:panelMenuItem>
           </rich:panelMenuGroup>
           <rich:panelMenuItem id="Item_2_5" label="Item 2.5" action="#{panelMenu.updateCurrent}">
           <f:param name="current" value="Item 2.5"/>
           </rich:panelMenuItem>
           </rich:panelMenuGroup>
           <rich:panelMenuGroup id="Group3" label="Group 3">
           <rich:panelMenuItem id="Item_3_1" label="Item 3.1" action="#{panelMenu.updateCurrent}">
           <f:param name="current" value="Item 3.1"/>
           </rich:panelMenuItem>
           <rich:panelMenuItem id="Item_3_2" label="Item 3.2" action="#{panelMenu.updateCurrent}">
           <f:param name="current" value="Item 3.2"/>
           </rich:panelMenuItem>
           <rich:panelMenuItem id="Item_3_3" label="Item 3.3" action="#{panelMenu.updateCurrent}">
           <f:param name="current" value="Item 3.3"/>
           </rich:panelMenuItem>
           </rich:panelMenuGroup>
           </rich:panelMenu>
           <rich:panel>
           <a4j:outputPanel ajaxRendered="true">
           <h:outputText value="#{panelMenu.current} selected" id="current"/>
           </a4j:outputPanel>
           </rich:panel>
           </h:panelGrid>
           <h:commandButton id="submit" value="submit" type="submit"/>
           </h:form>


          Sample code:
          JSFSession jsfSession = new JSFSession("/richfaces/panelMenu.jsf");
           JSFClientSession client = jsfSession.getJSFClientSession();
           JSFServerSession server = jsfSession.getJSFServerSession();
          
           client.click("form1:Group1");
           client.click("form1:Item_1_1");
           client.click("submit");
           String selection = (String)server.getManagedBeanValue("#{panelMenu.current}");
           assertEquals("Item 1.1", selection);
          
           client.click("form1:Item_1_3");
           client.click("submit");
           selection = (String)server.getManagedBeanValue("#{panelMenu.current}");
           assertEquals("Item 1.3", selection);
          
           client.click("form1:Item_2_4_2");
           client.click("submit");
           selection = (String)server.getManagedBeanValue("#{panelMenu.current}");
           assertEquals("Item 2.4.2", selection);