JsfUnit testing with Richfaces
hmashruf Jan 24, 2011 1:26 PMHi All, I am using Sun Jsf 2.0, Richfaces 4.0, Spring 2.5.x; have setup JsfUnit as a seperate maven project with war overlays. When I deploy this war to the Tomcat server, it runs good. But when run with JsfUnit, I am getting this error while calling new JSFSession(wcSpec);. Here is the code. I see this error reported on many forurms, gave them a try but not of help. Do I miss any steps?
Thanks in advance.
----
public class JSFUnitTest extends ServletTestCase {
private JSFClientSession client;
private JSFServerSession server;
public JSFUnitTest() {
System.out.println("**** JSFUnitTest ****");
}
public static TestSuite suite() {
return new TestSuite( JSFUnitTest.class );
}
/**
* Start a JSFUnit session by getting the /index.faces page.
*/
@Override
public void setUp() throws IOException {
try{
// Initial JSF request
String mainPageURI = "/faces/web/main/main.xhtml?ID=MyId";
WebClientSpec wcSpec = new WebClientSpec(mainPageURI, BrowserVersion.INTERNET_EXPLORER_8);
WebClient wc = wcSpec.getWebClient();
wc.setJavaScriptEnabled(true);
wc.setCssEnabled(false);
wc.setAjaxController(new NicelyResynchronizingAjaxController());
wc.setThrowExceptionOnScriptError(false);
wc.setCssErrorHandler(new SilentCssErrorHandler());
wc.setUseInsecureSSL(false);
JSFSession jsfSession = new JSFSession(wcSpec); //***
client = jsfSession.getJSFClientSession();
server = jsfSession.getJSFServerSession();
} catch (Exception e) {
e.printStackTrace();
}
}
----
...
2011-01-24 10:12:12,311 DEBUG [java.sql.Connection] - {conn-100105} Preparing Statement: SELECT COUNT(*) FROM HDR hdr WHERE hdr.type_entry_cd = ? AND hdr.edoc_stat_cd = ?
2011-01-24 10:12:12,311 DEBUG [java.sql.PreparedStatement] - {pstm-100106} Executing Statement: SELECT COUNT(*) FROM HDR hdr WHERE hdr.type_entry_cd = ? AND hdr.edoc_stat_cd = ?
2011-01-24 10:12:12,311 DEBUG [java.sql.PreparedStatement] - {pstm-100106} Parameters: [54, AP]
2011-01-24 10:12:12,311 DEBUG [java.sql.PreparedStatement] - {pstm-100106} Types: [java.lang.String, java.lang.String]
2011-01-24 10:12:12,311 DEBUG [java.sql.ResultSet] - {rset-100107} ResultSet
2011-01-24 10:12:12,311 DEBUG [java.sql.ResultSet] - {rset-100107} Header: [1]
2011-01-24 10:12:12,311 DEBUG [java.sql.ResultSet] - {rset-100107} Result: [19]
2011-01-24 10:12:12,404 DEBUG [java.sql.Connection] - {conn-100108} Connection
2011-01-24 10:12:12,498 DEBUG [java.sql.Connection] - {conn-100109} Connection
2011-01-24 10:07:06,110 ERROR [com.gargoylesoftware.htmlunit.javascript.StrictErrorReporter] - runtimeError: message=[The data necessary to complete this operation is not yet available.] sourceName=[http://localhost:9090/myapp/faces/javax.faces.resource/jquery.js] line=[767] lineSource=[null] lineOffset=[0]
2011-01-24 10:07:06,360 DEBUG [java.sql.Connection] - {conn-100053} Connection
2011-01-24 10:07:06,641 DEBUG [java.sql.Connection] - {conn-100054} Connection
2011-01-24 10:07:07,610 DEBUG [java.sql.Connection] - {conn-100055} Connection
java.lang.IllegalStateException
at org.mortbay.jetty.servlet.AbstractSessionManager$Session.getAttribute(AbstractSessionManager.java:781)
at org.jboss.jsfunit.framework.FacesContextBridge.getCurrentInstance(FacesContextBridge.java:56)
at org.jboss.jsfunit.jsfsession.JSFServerSession.pageCreated(JSFServerSession.java:214)
at org.jboss.jsfunit.jsfsession.JSFServerSession.<init>(JSFServerSession.java:57)
at org.jboss.jsfunit.jsfsession.JSFSession.<init>(JSFSession.java:83)
at edu.ucla.ais.nonpear.test.JSFUnitTest.setUp(JSFUnitTest.java:60)
at junit.framework.TestCase.runBare(TestCase.java:132)
at org.apache.cactus.internal.AbstractCactusTestCase.runBareServer(AbstractCactusTestCase.java:153)
at org.apache.cactus.internal.server.AbstractWebTestCaller.doTest(AbstractWebTestCaller.java:119)
at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest_aroundBody0(AbstractWebTestController.java:93)...