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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidfinish()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.ActionMappingGet the ActionMapping instance for this mock request.org.apache.struts.action.ActionServletGet the mock ActionServlet instance.This method is called on to retrieve all the text input elements of the request.voidhandleRequest(HttpServletRequest request) Mock parsing of the ServletInputStream.voidrollback()Mockrollback()method does nothing.voidsetMapping(org.apache.struts.action.ActionMapping mapping) Convenience method to set a reference to a mock ActionMapping instance.voidsetServlet(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:
setServletin 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:
setMappingin 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:
getServletin 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:
getMappingin interfaceorg.apache.struts.upload.MultipartRequestHandler- Returns:
- The mock action mapping instance.
-
handleRequest
Mock parsing of the ServletInputStream.Constructs a
HashMapof elements from the HttpServletRequest's parameters - noFormFileelements are created.- Specified by:
handleRequestin 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:
getTextElementsin 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:
getFileElementsin 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:
getAllElementsin 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:
rollbackin interfaceorg.apache.struts.upload.MultipartRequestHandler
-
finish
public void finish()Mockfinish()method does nothing.- Specified by:
finishin interfaceorg.apache.struts.upload.MultipartRequestHandler
-