5 Replies Latest reply on Oct 16, 2009 8:08 AM by ssilvert

    server.server.getManagedBeanValue always return null

      I got the majority of JUnit server and client functions working. However, I cannot get .server.getManagedBeanValue work. It always return null.

      client.setValue("username", "Daisy_test2");
      client.setValue("password", "Password2");

      client.click("submit");
      assertEquals("#{LoginBean.username}", "Daisy_test2");

      //It has static content to fill a select box. It definitely is not null
      assertNotNull( server.getManagedBeanValue("#{ProductBean.productTypes}");

      Why? Is it something to do with EL? Do I miss something?
      Thanks.

        • 1. Re: server.server.getManagedBeanValue always return null
          ssilvert

          Hi,

          Can you post your full source for the test and the xhtml or jsp pages?

          Also, I don't understand this line:
          assertEquals("#{LoginBean.username}", "Daisy_test2");

          In that line of code, "#{LoginBean.username}" is a string constant. The assertEquals() JUnit method doesn't know anything about EL.

          Stan

          • 2. Re: server.server.getManagedBeanValue always return null

            Hi Stan:

            Sorry for my typo. I means to say the followings:
            junit.framework.AssertionFailedError
            expected:<Daisy_test2> but was:

            assertEquals("/jsp/login.jsp", server.getCurrentViewID());
            client.setValue("username", "Daisy_test2");
            client.setValue("password", "Password2");
            client.click("submit");
            assertEquals("Daisy_test2", server.getManagedBeanValue("#{LoginBean.username}"));
            assertEquals("/jsp/home.jsp", server.getCurrentViewID());
            


            <div class="form_login">
             <div class="formItem">
             <label>username</label><h:inputText id="username"value="#{LoginBean.username}" styleClass="textbox"/> </div>
             <div class="formItem">
             <label>password</label><h:inputSecret id="password" value="#{LoginBean.password}" styleClass="textbox"/> </div>
             <div class="formItem buttonRow">
             <h:commandButton id="submit" action="#{LoginBean.authenticate}" value="" type="submit" styleClass="buttonL" />
             </div>
             </div>
            



            The other is
            junit.framework.AssertionFailedError, null
             assertEquals("/jsp/product_edit.jsp", server.getCurrentViewID());
             assertNotNull(server.getManagedBeanValue("#{ProductBean.productTypes}"));
             List<SelectItem> selectItems = (List<SelectItem>)obj;
            
            
            
            <h:selectOneListbox id="producttypeSelect" value="#{ProductBean.newMediaProduct.productType}" size="1" styleClass="dropdown simpleborder">
             <f:selectItems id="producttypeSelectItems" value="#{ProductBean.productTypes}"/>
             </h:selectOneListbox>
             [code/]
            
            Thanks for your help.
            
            


            • 3. Re: server.server.getManagedBeanValue always return null
              ssilvert

              I don't see anything wrong off hand.

              What kind of managed beans are these? Request, session, Seam/EJB, Spring, etc.?

              Stan

              • 4. Re: server.server.getManagedBeanValue always return null

                Both are managed beans of session scope

                • 5. Re: server.server.getManagedBeanValue always return null
                  ssilvert

                  I still don't see anything wrong, but you haven't posted all your source. If you want to send me a simple project to recreate this I'll take a look at it.

                  Stan