1 Reply Latest reply on Feb 16, 2011 2:00 PM by Stan Silvert

    Nullpointer at org.jboss.jsfunit.framework.FaceletsErrorPageException.isFaceletsErrorPage(FaceletsErrorPageException.java:55)

    Irineu Ruiz Newbie

      Hi everybody,

       

      I am trying to use JSFUnit with my application, but an error has ocurred in JSFUnit and i don't know the reason:

       

      {{{

      testLoginSucessoErrornull

       

      java.lang.NullPointerException
      at org.jboss.jsfunit.framework.FaceletsErrorPageException.isFaceletsErrorPage(FaceletsErrorPageException.java:55)
      at org.jboss.jsfunit.framework.FaceletsErrorPageDetector.afterRequest(FaceletsErrorPageDetector.java:39)
      at org.jboss.jsfunit.framework.JSFUnitWebConnection.notifyListenersAfter(JSFUnitWebConnection.java:101)
      at org.jboss.jsfunit.framework.JSFUnitWebConnection.getResponse(JSFUnitWebConnection.java:83)
      at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseFromWebConnection(WebClient.java:1405)
      at com.gargoylesoftware.htmlunit.WebClient.loadWebResponse(WebClient.java:1324)
      at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:303)
      at com.gargoylesoftware.htmlunit.html.BaseFrame.loadInnerPageIfPossible(BaseFrame.java:141)
      at com.gargoylesoftware.htmlunit.html.BaseFrame.loadInnerPage(BaseFrame.java:100)
      at com.gargoylesoftware.htmlunit.html.HtmlPage.loadFrames(HtmlPage.java:1763)
      at com.gargoylesoftware.htmlunit.html.HtmlPage.initialize(HtmlPage.java:204)
      at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:436)
      at com.gargoylesoftware.htmlunit.WebClient.loadDownloadedResponses(WebClient.java:2127)
      at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.doProcessPostponedActions(JavaScriptEngine.java:627)
      at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.processPostponedActions(JavaScriptEngine.java:705)
      at com.gargoylesoftware.htmlunit.html.HtmlElement.click(HtmlElement.java:1265)
      at com.gargoylesoftware.htmlunit.html.HtmlElement.click(HtmlElement.java:1214)
      at com.gargoylesoftware.htmlunit.html.HtmlElement.click(HtmlElement.java:1177)
      at com.gargoylesoftware.htmlunit.html.HtmlImageInput.click(HtmlImageInput.java:138)
      at com.gargoylesoftware.htmlunit.html.HtmlImageInput.click(HtmlImageInput.java:101)
      at br.com.ymf.amplis.jsfunit.JSFLoginTest.testLoginSucesso(JSFLoginTest.java:65)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at org.apache.cactus.server.runner.ServletTestRunner.run(ServletTestRunner.java:308)
      at org.apache.cactus.server.runner.ServletTestRunner.doGet_aroundBody0(ServletTestRunner.java:186)
      at org.apache.cactus.server.runner.ServletTestRunner.doGet_aroundBody1$advice(ServletTestRunner.java:224)
      at org.apache.cactus.server.runner.ServletTestRunner.doGet(ServletTestRunner.java)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.jboss.jsfunit.framework.JSFUnitFilter.doFilter(JSFUnitFilter.java:119)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at br.com.ymf.amplis.base.view.ThreadLocalCacheFilter.doFilter(ThreadLocalCacheFilter.java:26)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at br.com.ymf.amplis.base.view.LoginFilter.doFilter(LoginFilter.java:156)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
      at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
      at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
      at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
      at java.lang.Thread.run(Thread.java:619)

      }}}

       

      Here is my code:

       

       

      {code}

      public void testLoginSucesso() throws IOException    {

        // Send an HTTP request for the initial page      

        JSFSession jsfSession = new JSFSession("/default.jsf?menuForm:transactionIDHidden=br.com.ymf.amplis.security.view.SEC_00001");             

        // A JSFClientSession emulates the browser and lets you test HTML      

        JSFClientSession client = jsfSession.getJSFClientSession();             

        System.out.print(client.getPageAsText());

        FrameWindow frame = ((HtmlPage) client.getContentPage()).getFrameByName("applicationMainFrame");
        HtmlPage paginaLogin = (HtmlPage) frame.getEnclosedPage();
        HtmlInput login = paginaLogin.getHtmlElementById("loginForm:userLoginInput");

        paginaLogin = (HtmlPage)login.setValueAttribute("AMPLIS");

        HtmlInput senha = paginaLogin.getHtmlElementById("loginForm:userPasswordInput");

        paginaLogin = (HtmlPage)senha.setValueAttribute("123456");

        HtmlImageInput botao = paginaLogin.getHtmlElementById("loginForm:loginButton");

        paginaLogin = (HtmlPage) botao.click();
         
        assertTrue(paginaLogin.asText().contains("Mensagens Corporativas"));
      }
      {code}

       

       
      The problem ocurrs in:
      paginaLogin = (HtmlPage) botao.click();

      But in the same class I also have the test:

      {code}

      public void testSemSenha() throws IOException  {

        // Send an HTTP request for the initial page      

        JSFSession jsfSession = new JSFSession("/default.jsf?menuForm:transactionIDHidden=br.com.ymf.amplis.security.view.SEC_00001");             

        // A JSFClientSession emulates the browser and lets you test HTML      

        JSFClientSession client = jsfSession.getJSFClientSession();             

        System.out.print(client.getPageAsText());

        FrameWindow frame = ((HtmlPage) client.getContentPage()).getFrameByName("applicationMainFrame");
        HtmlPage paginaLogin = (HtmlPage) frame.getEnclosedPage();
        HtmlInput login = paginaLogin.getHtmlElementById("loginForm:userLoginInput");

        paginaLogin = (HtmlPage)login.setValueAttribute("AMPLIS");

        HtmlImageInput botao = paginaLogin.getHtmlElementById("loginForm:loginButton");

        paginaLogin = (HtmlPage) botao.click();
         
        assertEquals("Informe o Usuário e a Senha", paginaLogin.getHtmlElementById("detailMessageListBoxId").getTextContent());
       
      }
      {code}

       

       
      And this test works fine, the difference is that the first test makes a sucessfull login 
      and the second one informs a missing password.

      Other important point is that if I migrate to JSFUnit 1.2 and HTMLUnit 2.7 then
      both tests works correctly.

      Anyone knows the reason?