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.
WebMockObjectFactory(WebMockObjectFactory factory, boolean createNewSession) Creates a set of mock objects based on another one.
You can specify, if the created mock objects should
share the same session.
Creates a set of mock objects based on another one.
You can specify, if the created mock objects should
share the same session. They will share one
ServletContext anyway.
Parameters: factory - the other factory Parameters: createNewSession - true creates a new session,false uses the session from factory See Also:com.mockrunner.base.BaseTestCase.createWebMockObjectFactory(WebMockObjectFactoryboolean)
Method Detail
addRequestWrapper
public void addRequestWrapper(Class wrapper)(Code)
Can be used to add a request wrapper. All the
test modules are using the wrapped request returned by
WebMockObjectFactory.getWrappedRequest . The method
WebMockObjectFactory.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.
Parameters: wrapper - the wrapper class
Can be used to add a request wrapper.
All the test modules are using the wrapped request returned by
WebMockObjectFactory.getWrappedRequest . The method
WebMockObjectFactory.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.
Parameters: wrapper - the request wrapper
addResponseWrapper
public void addResponseWrapper(Class wrapper)(Code)
Can be used to add a response wrapper. All the
test modules are using the wrapped response returned by
WebMockObjectFactory.getWrappedResponse . The method
WebMockObjectFactory.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.
Parameters: wrapper - the wrapper class
Can be used to add a response wrapper.
All the test modules are using the wrapped response returned by
WebMockObjectFactory.getWrappedResponse . The method
WebMockObjectFactory.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.
Parameters: wrapper - the wrapper