2 Replies Latest reply on Dec 1, 2008 3:02 PM by Vitor Isaia

    Very strange URL from WebResponse

    Vitor Isaia Newbie

      Hello folks!

      Here I am again...

      I'm facing this strange problem:

      I access a page this way:

      
       JSFSession jsfSession = new JSFSession("/myPage.jsp");
       this.client = jsfSession.getJSFClientSession();
      
      


      Then I need to login with the following credentials and, if they're ok, finally I'm redirected to "/myPage.jsp" (assume those constants exist).

       this.client.setValue(USERNAME_FIELD, USERNAME_VALUE);
       this.client.setValue(PASSWORD_FIELD, PASSWORD_VALUE);
       this.client.click(LOGIN_BUTTON);
      


      Ok, so now I'm redirected to "/myPage.jsp".

      Then I want to do some verification in the page I was just redirected, like checking labels values and stuff, and of course I want to set some input data in text and select fields.

      But every time I try to do that I get a ClassCastException.

      java.lang.ClassCastException: com.gargoylesoftware.htmlunit.UnexpectedPage


      So I checked the response URL like this (after being redirected to "/myPage.jsp"):

       this.client.getContentPage().getWebResponse().getUrl().toString()
      


      And what I have returned is this weird thing:

       http://localhost:9090/myapp/a4j/g/3_2_2.GAorg/richfaces/renderkit/html/images/spacer.gif.jsp
      


      What the heck does /a4j/g/3_2_2.GAorg/richfaces/renderkit/html/images/spacer.gif.jsp mean? I was expecting to get something like:
      http://localhost:9090/myapp/myPage.jsp


      Actually almost every interaction I try to do I have the same error.

      The only things I'm able to do now is to check the state of managed beans (through EL expressions) and getting some info from the server (like server.getCurrentViewID()).

      Since I'm a newbie in JSFUnit, I'm pretty lost about this.

      Any help would be appreciated... may be with your help I can explain my problem in a better way..

      thanks!

      Vitor

        • 1. Re: Very strange URL from WebResponse
          Stan Silvert Master

          I think your problem may be related to this known issue:
          https://jira.jboss.org/jira/browse/JSFUNIT-175

          I made a change to try to fix it, but I'm not sure if the change works. You can try it yourself if you want to try the latest snapshot:

          <repository>
           <id>snapshots.jboss.org</id>
           <url>http://snapshots.jboss.org/maven2</url>
           <releases>
           <enabled>false</enabled>
           </releases>
           <snapshots>
           </snapshots>
           </repository>
          
           <dependency>
           <groupId>org.jboss.jsfunit</groupId>
           <artifactId>jboss-jsfunit-core</artifactId>
           <version>1.0.0.GA-SNAPSHOT</version>
           <scope>compile</scope>
           </dependency>


          Also, are you aware of this feature to aid with login?
          http://www.jboss.org/community/docs/DOC-10974

          And this one to help debugging HtmlUnit behavor? The snapshot version will allow you to enable the snooper.
          http://www.jboss.org/community/docs/DOC-12845

          Lastly, it is a bit odd that you would start your test with
          JSFSession jsfSession = new JSFSession("/myPage.jsp");


          The only way that would work is if you are using a path-mapping for the FacesServlet and you map your web app to the root context. Most people use extension mapping and start their tests like this:
          JSFSession jsfSession = new JSFSession("/myPage.faces");


          Stan

          • 2. Re: Very strange URL from WebResponse
            Vitor Isaia Newbie

            Thanks Stan,

            Actually I wasn't aware about you just showed... I started to work with JSFUnit a few days ago and maybe I didn't search enough yet.... I'll check out the links you said.

            I agree with you about the "/myPage.faces" instead of "/myPage.jsp"... I didn't design this system I'm working now, but this is definitely something to refactor asap.

            I'll post the results here later.

            Thanks a lot for your help.

            Vitor