Package org.apache.struts.mock
Class MockMultipartRequestHandler
java.lang.Object
org.apache.struts.mock.MockMultipartRequestHandler
- All Implemented Interfaces:
org.apache.struts.upload.MultipartRequestHandler
public class MockMultipartRequestHandler
extends Object
implements org.apache.struts.upload.MultipartRequestHandler
Mock MultipartRequestHandler object for unit tests.
-
Field Summary
Fields inherited from interface org.apache.struts.upload.MultipartRequestHandler
ATTRIBUTE_MAX_BYTE_LENGTH_EXCEEDED, ATTRIBUTE_MAX_FILE_COUNT_EXCEEDED, ATTRIBUTE_MAX_LENGTH_EXCEEDED, ATTRIBUTE_MAX_STRING_LENGTH_EXCEEDED
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
finish()
Mockfinish()
method does nothing.This method returns all elements of a multipart request.This method is called on to retrieve all the FormFile input elements of the request.org.apache.struts.action.ActionMapping
Get the ActionMapping instance for this mock request.org.apache.struts.action.ActionServlet
Get the mock ActionServlet instance.This method is called on to retrieve all the text input elements of the request.void
handleRequest
(HttpServletRequest request) Mock parsing of the ServletInputStream.void
rollback()
Mockrollback()
method does nothing.void
setMapping
(org.apache.struts.action.ActionMapping mapping) Convenience method to set a reference to a mock ActionMapping instance.void
setServlet
(org.apache.struts.action.ActionServlet servlet) Convenience method to set a reference to a mock ActionServlet instance.
-
Constructor Details
-
MockMultipartRequestHandler
public MockMultipartRequestHandler()
-
-
Method Details
-
setServlet
public void setServlet(org.apache.struts.action.ActionServlet servlet) Convenience method to set a reference to a mock ActionServlet instance.- Specified by:
setServlet
in interfaceorg.apache.struts.upload.MultipartRequestHandler
- Parameters:
servlet
- Mock servlet instance.
-
setMapping
public void setMapping(org.apache.struts.action.ActionMapping mapping) Convenience method to set a reference to a mock ActionMapping instance.- Specified by:
setMapping
in interfaceorg.apache.struts.upload.MultipartRequestHandler
- Parameters:
mapping
- Mock action mapping instance.
-
getServlet
public org.apache.struts.action.ActionServlet getServlet()Get the mock ActionServlet instance.- Specified by:
getServlet
in interfaceorg.apache.struts.upload.MultipartRequestHandler
- Returns:
- The mock servlet instance.
-
getMapping
public org.apache.struts.action.ActionMapping getMapping()Get the ActionMapping instance for this mock request.- Specified by:
getMapping
in interfaceorg.apache.struts.upload.MultipartRequestHandler
- Returns:
- The mock action mapping instance.
-
handleRequest
Mock parsing of the ServletInputStream.Constructs a
HashMap
of elements from the HttpServletRequest's parameters - noFormFile
elements are created.- Specified by:
handleRequest
in interfaceorg.apache.struts.upload.MultipartRequestHandler
- Parameters:
request
- Mock request instance.- Throws:
ServletException
- If there is a problem with processing the request.
-
getTextElements
This method is called on to retrieve all the text input elements of the request.- Specified by:
getTextElements
in interfaceorg.apache.struts.upload.MultipartRequestHandler
- Returns:
- A HashMap where the keys and values are the names and values of the request input parameters
-
getFileElements
This method is called on to retrieve all the FormFile input elements of the request.- Specified by:
getFileElements
in interfaceorg.apache.struts.upload.MultipartRequestHandler
- Returns:
- This mock implementation returns an empty
HashMap
-
getAllElements
This method returns all elements of a multipart request.- Specified by:
getAllElements
in interfaceorg.apache.struts.upload.MultipartRequestHandler
- Returns:
- This mock implementation returns a HashMap where the keys are input names and values are either Strings (no FormFile elements)
-
rollback
public void rollback()Mockrollback()
method does nothing.- Specified by:
rollback
in interfaceorg.apache.struts.upload.MultipartRequestHandler
-
finish
public void finish()Mockfinish()
method does nothing.- Specified by:
finish
in interfaceorg.apache.struts.upload.MultipartRequestHandler
-