org.apache.myfaces.test.mock
Class MockedJsfTestContainer

java.lang.Object
  extended by org.apache.myfaces.test.mock.MockedJsfTestContainer
All Implemented Interfaces:
EventListener, javax.servlet.http.HttpSessionListener

public class MockedJsfTestContainer
extends Object
implements javax.servlet.http.HttpSessionListener


Field Summary
protected  MockApplication application
           
protected  MockServletConfig config
           
protected  MockExternalContext externalContext
           
protected  MockFacesContext facesContext
           
protected  MockFacesContextFactory facesContextFactory
           
protected  MockHttpSession lastSession
           
protected  MockLifecycle lifecycle
           
protected  MockLifecycleFactory lifecycleFactory
           
protected  MockRenderKit renderKit
           
protected  MockHttpServletRequest request
           
protected  boolean requestInitializedCalled
           
protected  MockHttpServletResponse response
           
protected  MockServletContext servletContext
           
 
Constructor Summary
MockedJsfTestContainer()
          Construct a new instance of this test case.
 
Method Summary
protected  void doRequestDestroyed()
           
protected  void doRequestInitialized()
           
 void endRequest()
          This method call doRequestDestroyed() and then tearDownRequest().
 void endSession()
           
 MockApplication getApplication()
           
 MockExternalContext getExternalContext()
           
 MockFacesContext getFacesContext()
           
protected  Locale getLocale()
           
 MockHttpServletRequest getRequest()
           
 MockHttpServletResponse getResponse()
           
 MockServletContext getServletContext()
           
 MockWebContainer getWebContainer()
           
 void sessionCreated(javax.servlet.http.HttpSessionEvent se)
           
 void sessionDestroyed(javax.servlet.http.HttpSessionEvent se)
           
protected  void setFactories()
          Set JSF factories using FactoryFinder method setFactory.
 void setUp()
          Set up instance variables required by this test case.
 void setUpAll()
           
protected  void setUpApplication()
          Setup the application variable and before the end by default it is assigned to the facesContext variable, calling facesContext.setApplication(application)
protected  void setUpDefaultView()
          By default, create an instance of UIViewRoot, set its viewId as "/viewId" and assign it to the current facesContext.
protected  void setUpFacesContext()
          Setup the facesContextFactory and facesContext variable.
protected  void setUpJSFObjects()
          Setup JSF object used for the test.
protected  void setUpLifecycle()
          Setup the lifecycle and lifecycleFactory variables.
protected  void setUpRenderKit()
          Setup the renderKit variable.
protected  void setUpRequest()
          Setup servlet objects that will be used for the test:
protected  void setUpServletContext()
          Setup servlet objects that will be used for the test:
 void startRequest()
           
 void startSession()
           
 void tearDown()
          Tear down instance variables required by this test case.
 void tearDownAll()
           
protected  void tearDownRequest()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

application

protected MockApplication application

config

protected MockServletConfig config

externalContext

protected MockExternalContext externalContext

facesContext

protected MockFacesContext facesContext

facesContextFactory

protected MockFacesContextFactory facesContextFactory

lifecycle

protected MockLifecycle lifecycle

lifecycleFactory

protected MockLifecycleFactory lifecycleFactory

renderKit

protected MockRenderKit renderKit

request

protected MockHttpServletRequest request

requestInitializedCalled

protected boolean requestInitializedCalled

response

protected MockHttpServletResponse response

lastSession

protected MockHttpSession lastSession

servletContext

protected MockServletContext servletContext
Constructor Detail

MockedJsfTestContainer

public MockedJsfTestContainer()

Construct a new instance of this test case.

Parameters:
name - Name of this test case
Method Detail

setUp

public void setUp()

Set up instance variables required by this test case.


setUpAll

public void setUpAll()

tearDownAll

public void tearDownAll()

setUpJSFObjects

protected void setUpJSFObjects()

Setup JSF object used for the test. By default it calls to the following methods in this order:

Throws:
Exception

setUpServletContext

protected void setUpServletContext()

Setup servlet objects that will be used for the test:

Throws:
Exception

setUpRequest

protected void setUpRequest()

Setup servlet objects that will be used for the test:

Throws:
Exception

doRequestInitialized

protected void doRequestInitialized()

startRequest

public void startRequest()

startSession

public void startSession()

endSession

public void endSession()

sessionCreated

public void sessionCreated(javax.servlet.http.HttpSessionEvent se)
Specified by:
sessionCreated in interface javax.servlet.http.HttpSessionListener

sessionDestroyed

public void sessionDestroyed(javax.servlet.http.HttpSessionEvent se)
Specified by:
sessionDestroyed in interface javax.servlet.http.HttpSessionListener

setFactories

protected void setFactories()

Set JSF factories using FactoryFinder method setFactory.

Throws:
Exception

setUpLifecycle

protected void setUpLifecycle()
Setup the lifecycle and lifecycleFactory variables.

Throws:
Exception

setUpFacesContext

protected void setUpFacesContext()
Setup the facesContextFactory and facesContext variable. Before end, by default it override externalContext variable from the value retrieved from facesContext.getExternalContext(), because sometimes it is possible facesContext overrides externalContext internally.

Throws:
Exception

setUpDefaultView

protected void setUpDefaultView()
By default, create an instance of UIViewRoot, set its viewId as "/viewId" and assign it to the current facesContext.

Throws:
Exception

getLocale

protected Locale getLocale()

setUpApplication

protected void setUpApplication()
Setup the application variable and before the end by default it is assigned to the facesContext variable, calling facesContext.setApplication(application)

Throws:
Exception

setUpRenderKit

protected void setUpRenderKit()
Setup the renderKit variable. This is a good place to use ConfigParser to register converters, validators, components or renderkits.

Throws:
Exception

getApplication

public MockApplication getApplication()

getExternalContext

public MockExternalContext getExternalContext()

getFacesContext

public MockFacesContext getFacesContext()

getRequest

public MockHttpServletRequest getRequest()

getResponse

public MockHttpServletResponse getResponse()

getServletContext

public MockServletContext getServletContext()

getWebContainer

public MockWebContainer getWebContainer()
Returns:
the webContainer

endRequest

public final void endRequest()
This method call doRequestDestroyed() and then tearDownRequest().


doRequestDestroyed

protected void doRequestDestroyed()

tearDownRequest

protected void tearDownRequest()

tearDown

public void tearDown()

Tear down instance variables required by this test case.



Copyright © 2014 The Apache Software Foundation. All Rights Reserved.