4 Replies Latest reply on Mar 13, 2011 11:51 AM by yegor256

    How to replace a Managed Bean on-fly?

    yegor256

      This is what I'm trying to do:

       

       

      public void testAuthenticatesUser() throws Exception {
        JSFSession jsfSession = new JSFSession("/");
        JSFClientSession client = jsfSession.getJSFClientSession();
        JSFServerSession server = jsfSession.getJSFServerSession();
        server.getFacesContext()
          .getExternalContext()
          .getApplicationMap()
          .put("authenticator", new MockedAuthenticator());
        String url = WebConversationFactory.getWARURL() + "/auth?login=test&pwd=3737";
        WebClient web = jsfSession.getWebClient();
        web.getPage(url);
      }
      

       

      The idea is replace "authenticator" application-scoped managed bean with a mocked object. This object won't do real-life requests to LDAP, but will just return "true". The problem is that the example above doesn't work. Am I doing it right?