6 Replies Latest reply on Oct 1, 2010 7:47 AM by ssilvert

    Testing https pages with JSFUnit

    marti

      Hi. whenever I try to test any "https" page i face an error.

      i have xml file that defines which pages should be in https scheme. once i turn it to http the problem is solved.

      a part of the xml  file : <page view-id="/sign-up.xhtml" scheme="https" />

       

      error:

      testSecureHTTPSErrornulljava.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.download(WebClient.java:2082)
      at com.gargoylesoftware.htmlunit.html.HtmlAnchor.doClickAction(HtmlAnchor.java:109)
      at com.gargoylesoftware.htmlunit.html.HtmlAnchor.doClickAction(HtmlAnchor.java:124)
      at com.gargoylesoftware.htmlunit.html.HtmlElement.click(HtmlElement.java:1263)
      at com.gargoylesoftware.htmlunit.html.HtmlElement.click(HtmlElement.java:1214)
      at com.gargoylesoftware.htmlunit.html.HtmlElement.click(HtmlElement.java:1177)
      at org.jboss.jsfunit.jsfsession.JSFClientSession.click(JSFClientSession.java:225)
      at com.printer.test.Vtest2.testSecureHTTPS(Vtest2.java:61)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      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)
      at  org.apache.cactus.internal.server.AbstractWebTestController.handleRequest_aroundBody1$advice(AbstractWebTestController.java:224)
      at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest(AbstractWebTestController.java)
      at org.apache.cactus.server.ServletTestRedirector.doPost_aroundBody2(ServletTestRedirector.java:101)
      at org.apache.cactus.server.ServletTestRedirector.doPost_aroundBody3$advice(ServletTestRedirector.java:224)
      at org.apache.cactus.server.ServletTestRedirector.doPost(ServletTestRedirector.java)
      at org.jboss.jsfunit.framework.JSFUnitServletRedirector.doPost(JSFUnitServletRedirector.java:46)
      at org.apache.cactus.server.ServletTestRedirector.doGet_aroundBody0(ServletTestRedirector.java:72)
      at org.apache.cactus.server.ServletTestRedirector.doGet_aroundBody1$advice(ServletTestRedirector.java:224)
      at org.apache.cactus.server.ServletTestRedirector.doGet(ServletTestRedirector.java)
      at org.jboss.jsfunit.framework.JSFUnitServletRedirector.doGet(JSFUnitServletRedirector.java:52)
      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 com.printer.filter.RequestSchemeFilter.doFilter(RequestSchemeFilter.java:56)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at com.printer.filter.IE8CompatibilityFilter.doFilter(IE8CompatibilityFilter.java:38)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at com.printer.filter.Utf8Filter.doFilter(Utf8Filter.java:34)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at com.printer.filter.ThreadCacheFilter.doFilter(ThreadCacheFilter.java:43)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at com.printer.filter.TimerFilter.doFilter(TimerFilter.java:38)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      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 org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:470)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
      at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
      at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:291)
      at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:774)
      at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:703)
      at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:896)
      at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690)
      at java.lang.Thread.run(Unknown Source)

       

      Thanks for help.

        • 1. Re: Testing https pages with JSFUnit
          kragoth

          Hey Marti,

           

          Whenever posting these problems it would really help if you posted your code for your test as well. (At least the relevant parts).

          What I don't know from this exception is how far through the test is the error happening. Have you been able to access the https page and do stuff or is this the first action you have tried to perform on a https connection. Posting your code would help.

           

          Remember when posting code if you click on the "Use advanced editor" link in the top right of the reply panel you can add code sections to your reply by clicking on the button that looks like ">>" and then selecting "Syntax highlighting" -> Java or xml for your xhtml files.

           

          Looking at that stack trace I have an idea. I just need to go check something and I'll get back to you.

           

          Cheers,

          Tim

          • 2. Re: Testing https pages with JSFUnit
            marti

            Thanks for replying...

             

            sure here is the code , i'll explain below it.

             

            // JUnit suite() method
                public static Test suite() {
                    System.out.println("Started");
                    return new TestSuite(Vtest2.class);
                }
            
                @Override
                public void setUp() throws IOException {
                    fileCreator();
                    final WebClientSpec webSpec = new WebClientSpec("/home.html", BrowserVersion.FIREFOX_3);
                    webSpec.addCookie("cookie2", "cookie2value");
                    webSpec.getWebClient().setRedirectEnabled(true);
            
                    final JSFSession jsfSession = new JSFSession(webSpec);
            
                    client = jsfSession.getJSFClientSession();
                    server = jsfSession.getJSFServerSession();
                }
            
                @Override
                public void tearDown() {
                    System.out.println("End Of Test Case...");
                }
            
                // one or more JUnit test methods
                public void testSecureHTTPS() throws IOException {
                    HtmlPage page;
            
                    //Navigating to log in page which is https
                    client.click("loginLink");
                    logThis(server, "Log In page accessed "); //my log method, similar to yours
                    page = getCurrentPage();
                    System.out.println("page title: " + page.getTitleText());
                 }
            

             

            when i run the test , i see "started", and then suddenly "End of test case".

            this is first time that im trying to test https.

            Is this again because of different filters and the security i have? the error is very similar to that case.

             

            tnx.

            • 3. Re: Testing https pages with JSFUnit
              kragoth

              I'm pretty sure if you put a log message above the line where you do client.click("loginLink") you will see it get executed. The idea that this is a filter/security problem is probably correct as your exception stack trace doesn't look quite right.

               

              I'll be able to give a better answer soon, but I've broken our project's build and have to fix that first

              • 4. Re: Testing https pages with JSFUnit
                marti

                before clicking on the link there is no face message exists.

                server returns nothing and log file is clear. i tried it.

                and after click error emerged and the log after it does not come in action.

                • 5. Re: Testing https pages with JSFUnit
                  kragoth

                  JSFUnit relies on a bunch of other libraries one of which is cactus.

                   

                   

                  From the Cactus FAQ:

                  Does Cactus support HTTPS?

                  No, Cactus doesn't support HTTPS. The reason is that we don't think it's necessary. Whether you use HTTP or HTTPS should be transparent to the tested code. And you should run the tests in a test environment anyway, which doesn't necessarily need to be HTTPS just because the production environment is. Of course, if you have good arguments for HTTPS support and a patch, we might change our collective mind :-)

                   

                  So, I'm wondering if this is the basic problem. The fact that the underlying library doesn't support https would probably be a pretty good reason for it to fail. It would be really nice to hear from someone who has the knowledge to answer this question properly.

                   

                  I guess the next question here is how do you make your app not use https in the test environment. This is something I have absolutely no experience with so...maybe someone else can shed some light

                  • 6. Re: Testing https pages with JSFUnit
                    ssilvert

                    Tim,

                     

                    Thanks for pointing out that FAQ.  I had forgotten that Cactus doesn't support https.  If you want more detail then the person to contact is Petar Tachiev who leads the Cactus project.

                     

                    They do have a point that https is not relevant to your tests.  But I understand that you still want to test in an environment that is as close to production as possible.

                     

                    Stan