Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source.
   * Copyright 2008, Red Hat Middleware LLC, and individual contributors
   * as indicated by the @author tags. See the copyright.txt file in the
   * distribution for a full listing of individual contributors.
   *
   * This is free software; you can redistribute it and/or modify it
   * under the terms of the GNU Lesser General Public License as
   * published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * This software is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
 
 package org.jboss.jsfunit.jsfsession;
 
 import java.util.Map;
This class starts and manages the JSF Session on both the client and server side.

Author(s):
Stan Silvert
Since:
1.0
 
 public class JSFSession
 {
    private WebClient webClient;
   
   
Creates a new session for testing the JSF application. This constructor will also clear the HttpSession. Note that the initialPage param should be something that maps into the FacesServlet. In the case where the FacesServlet is extension mapped in web.xml, this param will be something like "/index.jsf" or "/index.faces". If the FacesServlet is path-mapped then the initialPage param will be something like "/faces/index.jsp".

Parameters:
initialPage The page used to start a client session with JSF. Example: "/index.jsf"
Throws:
java.io.IOException If there is an error calling the JSF app
 
    public JSFSession(String initialPagethrows IOException
    {
       this(new WebClientSpec(initialPage));
    }
   
   
Creates a new session for testing the JSF application. This constructor will also clear the HttpSession. Note that the initialPage param should be something that maps into the FacesServlet. In the case where the FacesServlet is extension mapped in web.xml, this param will be something like "/index.jsf" or "/index.faces". If the FacesServlet is path-mapped then the initialPage param will be something like "/faces/index.jsp".

Parameters:
webClient An HtmlUnit WebClient containing custom attributes. Note that this WebClient instance should be created with the JSFUnit WebConversationFactory instead of the WebClient constructor.
initialPage The page used to start a client session with JSF. Example: "/index.jsf"
Throws:
java.io.IOException If there is an error calling the JSF app
 
    public JSFSession(WebClientSpec wcSpecthrows IOException
    {
       this. = wcSpec.getWebClient();
       
       wcSpec.doInitialRequest();
   
       this. = new JSFServerSession();
       
       JSFUnitWebConnection webConnection = (JSFUnitWebConnection)this..getWebConnection();
       webConnection.addListener(this.);
       
       if (HtmlUnitSnooper.enabled()) webConnection.addListener(new HtmlUnitSnooper());
    }
   
   
Get an immutable Map of all request params sent to the ServletRedirector or ServletTestRunner. Note that the Map returned is the same one returned from ServletRequest.getParameterMap(). This Map is defined with a key of type String and a value of type String array - not plain String.

Returns:
The Map of params.
Since:
1.1
   {
      return WebClientSpec.getRedirectorRequestParams();
   }
   
   
Get the WebClient instance used to control client side requests.

Returns:
The WebClient instance used to control client side requests.
   public WebClient getWebClient()
   {
      return this.;
   }
   
   
Get the JSFServerSession instance used to access server-side JSF artifacts.

Returns:
The JSFServerSession
   {
      return this.;
   }
   
   
Get the JSFClientSession instance used to access client-side JSF artifacts send requests to the server.

Parameters:
The JSFClientSession
   {
      return this.;
   }
New to GrepCode? Check out our FAQ X