Version 8

    Workaround needed for WebSphere users

    WebSphere prepends a cache ID to the jsessionid.  The cache ID is used for session affinity and it is enabled by default.  As of now, it is unknown how this behavior can be changed.

     

    So to use WebSphere with JSFUnit, you will need to create a class that extends one of the InitialRequestStrategy classes.  See JSFUnitTestingSecurePages for other examples, but the following should work for non-secure pages:

    public class WebSphereRequestStrategy extends org.jboss.jsfunit.framework.SimpleInitialRequestStrategy {
       public Page doInitialRequest(WebClientSpec wcSpec) throws IOException {
          String jsessionid = wcSpec.removeCookie("JSESSIONID");
          wcSpec.addCookie("JSESSIONID", "0000" + jsessionid); // cache ID is 0000 by default
          return super.doInitialRequest(wcSpec);
       }
    }
    

     

    Then you will use this code to start your test:

    WebClientSpec wcSpec = new WebClientSpec("/index.jsf");
    wcSpec.setInitialRequestStrategy(new WebSphereRequestStrategy());
    JSFSession jsfSession = new JSFSession(wcSpec);
    JSFClientSession client = jsfSession.getJSFClientSession();
    JSFServerSession server = jsfSession.getJSFServerSession();
    

     

     

     

     

    Further Information on this Issue

    If you are a WebSphere expert who knows how to manipulate the cache ID, or if you know how to obtain the cache ID from an API, please post to the JSFUnit forums.

     

    Here are some links that shed further light on the problem:

     

    http://www.informit.com/articles/article.aspx?p=332851&seqNum=4

     

    http://www.jboss.com/index.html?module=bb&op=viewtopic&t=125918&postdays=0&postorder=asc&start=0

     

    https://jira.jboss.org/jira/browse/JSFUNIT-68