JSFServerSession is null.
priyeshp Oct 14, 2008 9:18 PMI am trying to test my JSF/Icefaces based application. I am using Websphere 6.1 as my server. I want to test the navigation flow of the pages. I have read the article the JSFUnit on Websphere I have also followed the steps specified in the artcile but still no luck. JSFServerSession server = jsfSession.getJSFServerSession();
System.out.println(server.getCurrentViewID()); I get nullPointer Exception.
Below is my code please let me know if this is a known Issue.
import java.io.IOException;
import javax.faces.component.UIComponent;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.apache.cactus.ServletTestCase;
import org.jboss.jsfunit.framework.BasicAuthenticationStrategy;
import org.jboss.jsfunit.framework.WebClientSpec;
import org.jboss.jsfunit.jsfsession.JSFClientSession;
import org.jboss.jsfunit.jsfsession.JSFServerSession;
import org.jboss.jsfunit.jsfsession.JSFSession;
import org.xml.sax.SAXException;
public class JSFUnitTest extends ServletTestCase {
private JSFClientSession client;
public static Test Suite() {
return TestSuite(JSFUnit.class);
}
public void testInitialPage() throws IOException, SAXException {
WebClientSpec wcSpec = new WebClientSpec("/index.iface");
WebsphereRequestStrategy wrs = new WebSphereRequestStrategy();
wcSpec.setInitialRequestStrategy(wrs);
JSFSession jsfSession = new JSFSession(wcSpec);
JSFClientSession client = jsfSession.getJSFClientSession();
JSFServerSession server = jsfSession.getJSFServerSession();
System.out.println(server.getCurrentViewID());
assertEquals("/index.iface",server.getCurrentViewID());
}
}
import java.io.IOException;
import org.jboss.jsfunit.framework.WebClientSpec;
import com.gargoylesoftware.htmlunit.Page;
public class WebSphereRequestStrategy extends org.jboss.jsfunit.framework.SimpleInitialRequestStrategy {
public Page doInitialRequest(WebClientSpec wcSpec) throws IOException {
String jsessionId = wcSpec.removeCookie("JSESSIONID");
wcSpec.addCookie("JSFSESSIONID", "0000" +jsessionid);
return super.doInitialRequest(wcSpec);
}
}
Please let me what steps I need to take to solve this error.