1 Reply Latest reply on Dec 3, 2007 10:29 AM by ssilvert

    Session access ...

      The scenario is having a session already of the normal web application. By user interaction the JSFUnit Tests are started... running in their own session, going through the whole application process automatically.

      Is there a way to write some parameters back to the "real" session that still is run.. and from where jsfunit has bene started from?

      The following code is from the unit file

      ((HttpSession)server.getFacesContext().getExternalContext().getSession(false)).setAttribute("foobar", "test");


      String param = (String)((HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(false)).getAttribute("foobar");

      Param however is null ...

      How would it be possible to exchange information between jsfunit testclasses and the outer httpsession?

        • 1. Re: Session access ...
          ssilvert

          You shouldn't use the HttpSession for this because the session is cleared (but not destroyed) each time you create a new JSFClientSession.

          I suggest using the application scope instead.

          ServletContext context = (ServletContext)server.getFacesContext().getExternalContext().getContext();
          context.setAttribute("foobar", "test");


          Also, this new wiki I just wrote might shed some light on JSFUnit's use of the HttpSession:
          http://wiki.jboss.org/wiki/JSFUnitSessionAndThreads

          Stan