0

我在 jsfunit 上工作,我正在使用 WebSphere6.1 应用程序服务器,所以任何人都可以给我答案,它是否与 JSFunit 兼容,或者我需要对我的服务器配置进行一些更改?如果可能的话,把例子发给我?

谢谢维诺德

4

1 回答 1

2

是的,

阅读JSFUnitOnWebSphere

因此,要将 WebSphere 与 JSFUnit 一起使用,您需要创建一个扩展 InitialRequestStrategy 类之一的类。有关其他示例,请参阅 JSFUnitTestingSecurePages,但以下内容适用于非安全页面

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);
   }
}

然后您将使用此代码开始您的测试:

WebClientSpec wcSpec = new WebClientSpec("/index.jsf");
wcSpec.setInitialRequestStrategy(new WebSphereRequestStrategy());
JSFSession jsfSession = new JSFSession(wcSpec);
JSFClientSession client = jsfSession.getJSFClientSession();
JSFServerSession server = jsfSession.getJSFServerSession();
于 2010-10-11T13:13:08.620 回答