public class WebMockObjectFactory extends Object
| Constructor and Description |
|---|
WebMockObjectFactory()
Creates a new set of mock objects.
|
WebMockObjectFactory(WebMockObjectFactory factory)
Creates a set of mock objects based on another one.
|
WebMockObjectFactory(WebMockObjectFactory factory,
boolean createNewSession)
Creates a set of mock objects based on another one.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addRequestWrapper(Class wrapper)
Can be used to add a request wrapper.
|
void |
addRequestWrapper(javax.servlet.http.HttpServletRequest wrapper)
Can be used to add a request wrapper.
|
void |
addResponseWrapper(Class wrapper)
Can be used to add a response wrapper.
|
void |
addResponseWrapper(javax.servlet.http.HttpServletResponse wrapper)
Can be used to add a response wrapper.
|
MockFilterChain |
createMockFilterChain()
Creates the
MockFilterChain using new. |
MockFilterConfig |
createMockFilterConfig()
Creates the
MockFilterConfig using new. |
MockJspFactory |
createMockJspFactory()
Creates the
MockJspFactory using new. |
MockPageContext |
createMockPageContext()
Creates the
MockPageContext using new. |
MockHttpServletRequest |
createMockRequest()
Creates the
MockHttpServletRequest using new. |
MockHttpServletResponse |
createMockResponse()
Creates the
MockHttpServletResponse using new. |
MockServletConfig |
createMockServletConfig()
Creates the
MockServletConfig using new. |
MockServletContext |
createMockServletContext()
Creates the
MockServletContext using new. |
MockHttpSession |
createMockSession()
Creates the
MockHttpSession using new. |
javax.servlet.jsp.JspFactory |
getJspFactory()
Returns the
JspFactory. |
MockFilterChain |
getMockFilterChain()
Returns the
MockFilterChain. |
MockFilterConfig |
getMockFilterConfig()
Returns the
MockFilterConfig. |
MockJspFactory |
getMockJspFactory()
Returns the
MockJspFactory. |
MockPageContext |
getMockPageContext()
Returns the
MockPageContext. |
MockHttpServletRequest |
getMockRequest()
Returns the
MockHttpServletRequest. |
MockHttpServletResponse |
getMockResponse()
Returns the
MockHttpServletResponse. |
MockServletConfig |
getMockServletConfig()
Returns the
MockServletConfig |
MockServletContext |
getMockServletContext()
Returns the
MockServletContext. |
MockHttpSession |
getMockSession()
Returns the
MockHttpSession. |
MockHttpSession |
getSession()
Deprecated.
use
getMockSession() |
javax.servlet.http.HttpServletRequest |
getWrappedRequest()
Returns the wrapped
HttpServletRequest. |
javax.servlet.http.HttpServletResponse |
getWrappedResponse()
Returns the wrapped
HttpServletResponse. |
void |
refresh()
Refreshes the mock objects dependencies.
|
void |
setDefaultJspFactory(javax.servlet.jsp.JspFactory jspFactory)
Sets the default
JspFactory by calling
JspFactory.setDefaultFactory(). |
public WebMockObjectFactory()
public WebMockObjectFactory(WebMockObjectFactory factory)
ServletContext.factory - the other factoryBaseTestCasepublic WebMockObjectFactory(WebMockObjectFactory factory, boolean createNewSession)
ServletContext anyway.factory - the other factorycreateNewSession - true creates a new session,
false uses the session from factoryBaseTestCasepublic void setDefaultJspFactory(javax.servlet.jsp.JspFactory jspFactory)
JspFactory by calling
JspFactory.setDefaultFactory().jspFactory - the JspFactorypublic void refresh()
public MockServletContext createMockServletContext()
MockServletContext using new.
This method can be overridden to return a subclass of MockServletContext.MockServletContextpublic MockServletConfig createMockServletConfig()
MockServletConfig using new.
This method can be overridden to return a subclass of MockServletConfig.MockServletConfigpublic MockHttpServletResponse createMockResponse()
MockHttpServletResponse using new.
This method can be overridden to return a subclass of MockHttpServletResponse.MockHttpServletResponsepublic MockHttpServletRequest createMockRequest()
MockHttpServletRequest using new.
This method can be overridden to return a subclass of MockHttpServletRequest.MockHttpServletRequestpublic MockHttpSession createMockSession()
MockHttpSession using new.
This method can be overridden to return a subclass of MockHttpSession.MockHttpSessionpublic MockPageContext createMockPageContext()
MockPageContext using new.
This method can be overridden to return a subclass of MockPageContext.MockPageContextpublic MockFilterConfig createMockFilterConfig()
MockFilterConfig using new.
This method can be overridden to return a subclass of MockFilterConfig.MockFilterConfigpublic MockFilterChain createMockFilterChain()
MockFilterChain using new.
This method can be overridden to return a subclass of MockFilterChain.MockFilterChainpublic MockJspFactory createMockJspFactory()
MockJspFactory using new.
This method can be overridden to return a subclass of MockJspFactory.MockJspFactorypublic MockServletConfig getMockServletConfig()
MockServletConfigMockServletConfigpublic MockServletContext getMockServletContext()
MockServletContext.MockServletContextpublic MockHttpServletRequest getMockRequest()
MockHttpServletRequest.MockHttpServletRequestpublic MockHttpServletResponse getMockResponse()
MockHttpServletResponse.MockHttpServletResponsepublic javax.servlet.http.HttpServletRequest getWrappedRequest()
HttpServletRequest. If no
wrapper is specified, this method returns the mock request itself.HttpServletRequestpublic javax.servlet.http.HttpServletResponse getWrappedResponse()
HttpServletResponse. If no
wrapper is specified, this method returns the mock response itself.HttpServletRequestpublic MockHttpSession getMockSession()
MockHttpSession.MockHttpSessionpublic MockHttpSession getSession()
getMockSession()MockHttpSession.MockHttpSessionpublic MockPageContext getMockPageContext()
MockPageContext.MockPageContextpublic MockFilterConfig getMockFilterConfig()
MockFilterConfig.MockFilterConfigpublic MockFilterChain getMockFilterChain()
MockFilterChain.MockFilterChainpublic MockJspFactory getMockJspFactory()
MockJspFactory.
If the current JspFactory is not an instance
of MockJspFactory, null
will be returned.MockJspFactorypublic javax.servlet.jsp.JspFactory getJspFactory()
JspFactory.JspFactorypublic void addRequestWrapper(Class wrapper)
getWrappedRequest(). The method getMockRequest()
returns the mock request without any wrapper.
Usually the wrapper is of type javax.servlet.http.HttpServletRequestWrapper.
That's not absolutely necessary but the wrapper must define a constructor
that takes a single javax.servlet.http.HttpServletRequest argument
and must implement javax.servlet.http.HttpServletRequest.wrapper - the wrapper classpublic void addRequestWrapper(javax.servlet.http.HttpServletRequest wrapper)
getWrappedRequest(). The method getMockRequest()
returns the mock request without any wrapper. Usually the wrapper is
an instance of javax.servlet.http.HttpServletRequestWrapper
and wraps the current request but that's not absolutely necessary.
However, be careful if you want to add custom mock versions of
javax.servlet.http.HttpServletRequest.wrapper - the request wrapperpublic void addResponseWrapper(Class wrapper)
getWrappedResponse(). The method getMockResponse()
returns the mock response without any wrapper.
Usually the wrapper is of type javax.servlet.http.HttpServletResponseWrapper.
That's not absolutely necessary but the wrapper must define a constructor
that takes a single javax.servlet.http.HttpServletResponse argument
and must implement javax.servlet.http.HttpServletResponse.wrapper - the wrapper classpublic void addResponseWrapper(javax.servlet.http.HttpServletResponse wrapper)
getWrappedResponse(). The method getMockResponse()
returns the mock response without any wrapper. Usually the wrapper is
an instance of javax.servlet.http.HttpServletResponseWrapper
and wraps the current response but that's not absolutely necessary.
However, be careful if you want to add custom mock versions of
javax.servlet.http.HttpServletResponse.wrapper - the wrapperCopyright © 2003-2015. All Rights Reserved.