0 Replies Latest reply: Jan 11, 2012 4:11 AM by hantsy bai RSS

    isUserInRole does not return the expected value.

    hantsy bai Master

      I used manul way to process login progress in my applciation, it worked well. but in the JSF test case, It can not detect the ROLE.

       

       

      @Test
          @InitialPage("/login.jsf")
          public void testLoginPage(JSFServerSession server, JSFClientSession client)
                  throws IOException {
              Assert.assertEquals("/login.xhtml", server.getCurrentViewID());
      
              client.setValue("loginForm:username", "user");
              client.setValue("loginForm:password", "user");
              client.click("loginForm:loginButton");
      
              Assert.assertEquals("/admin/unconfirmed.xhtml",
                      server.getCurrentViewID());
              Assert.assertEquals("user", server.getFacesContext()
                      .getExternalContext().getRemoteUser());
      
         //Assert.assertTrue(server.getFacesContext()
         //             .getExternalContext().isUserInRoles("ROLE_VIEWER");
              log.info("server.getFacesContext().getExternalContext().getUserPrincipal()@"
                      + server.getFacesContext().getExternalContext()
                              .getUserPrincipal());
      
              client.click("logoutForm:logoutButton");
              Assert.assertEquals("/login.xhtml", server.getCurrentViewID());
              Assert.assertNull(server.getFacesContext().getExternalContext()
                      .getRemoteUser());
          }
      

       

       

      //Assert.assertTrue(server.getFacesContext()

      //.getExternalContext().isUserInRoles("ROLE_VIEWER");

       

      This will cause test failed...any help here?