|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.mockrunner.mock.web.WebMockObjectFactory
public class WebMockObjectFactory
Used to create all types of web mock objects. Maintains the necessary dependencies between the mock objects. If you use the mock objects returned by this factory in your tests you can be sure that they are all up to date.
Constructor Summary | |
---|---|
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. |
Method Summary | |
---|---|
void |
addRequestWrapper(java.lang.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(java.lang.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() . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public WebMockObjectFactory()
public WebMockObjectFactory(WebMockObjectFactory factory)
ServletContext
.
factory
- the other factoryBaseTestCase.createWebMockObjectFactory(WebMockObjectFactory)
public WebMockObjectFactory(WebMockObjectFactory factory, boolean createNewSession)
ServletContext
anyway.
factory
- the other factorycreateNewSession
- true
creates a new session,
false
uses the session from factoryBaseTestCase.createWebMockObjectFactory(WebMockObjectFactory, boolean)
Method Detail |
---|
public void setDefaultJspFactory(javax.servlet.jsp.JspFactory jspFactory)
JspFactory
by calling
JspFactory.setDefaultFactory()
.
jspFactory
- the JspFactory
public void refresh()
public MockServletContext createMockServletContext()
MockServletContext
using new
.
This method can be overridden to return a subclass of MockServletContext
.
MockServletContext
public MockServletConfig createMockServletConfig()
MockServletConfig
using new
.
This method can be overridden to return a subclass of MockServletConfig
.
MockServletConfig
public MockHttpServletResponse createMockResponse()
MockHttpServletResponse
using new
.
This method can be overridden to return a subclass of MockHttpServletResponse
.
MockHttpServletResponse
public MockHttpServletRequest createMockRequest()
MockHttpServletRequest
using new
.
This method can be overridden to return a subclass of MockHttpServletRequest
.
MockHttpServletRequest
public MockHttpSession createMockSession()
MockHttpSession
using new
.
This method can be overridden to return a subclass of MockHttpSession
.
MockHttpSession
public MockPageContext createMockPageContext()
MockPageContext
using new
.
This method can be overridden to return a subclass of MockPageContext
.
MockPageContext
public MockFilterConfig createMockFilterConfig()
MockFilterConfig
using new
.
This method can be overridden to return a subclass of MockFilterConfig
.
MockFilterConfig
public MockFilterChain createMockFilterChain()
MockFilterChain
using new
.
This method can be overridden to return a subclass of MockFilterChain
.
MockFilterChain
public MockJspFactory createMockJspFactory()
MockJspFactory
using new
.
This method can be overridden to return a subclass of MockJspFactory
.
MockJspFactory
public MockServletConfig getMockServletConfig()
MockServletConfig
MockServletConfig
public MockServletContext getMockServletContext()
MockServletContext
.
MockServletContext
public MockHttpServletRequest getMockRequest()
MockHttpServletRequest
.
MockHttpServletRequest
public MockHttpServletResponse getMockResponse()
MockHttpServletResponse
.
MockHttpServletResponse
public javax.servlet.http.HttpServletRequest getWrappedRequest()
HttpServletRequest
. If no
wrapper is specified, this method returns the mock request itself.
HttpServletRequest
public javax.servlet.http.HttpServletResponse getWrappedResponse()
HttpServletResponse
. If no
wrapper is specified, this method returns the mock response itself.
HttpServletRequest
public MockHttpSession getMockSession()
MockHttpSession
.
MockHttpSession
public MockHttpSession getSession()
getMockSession()
MockHttpSession
.
MockHttpSession
public MockPageContext getMockPageContext()
MockPageContext
.
MockPageContext
public MockFilterConfig getMockFilterConfig()
MockFilterConfig
.
MockFilterConfig
public MockFilterChain getMockFilterChain()
MockFilterChain
.
MockFilterChain
public MockJspFactory getMockJspFactory()
MockJspFactory
.
If the current JspFactory
is not an instance
of MockJspFactory
, null
will be returned.
MockJspFactory
public javax.servlet.jsp.JspFactory getJspFactory()
JspFactory
.
JspFactory
public void addRequestWrapper(java.lang.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(java.lang.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 wrapper
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |