org.apache.struts.mock
Class MockMultipartRequestHandler

java.lang.Object
  extended by org.apache.struts.mock.MockMultipartRequestHandler
All Implemented Interfaces:
MultipartRequestHandler

public class MockMultipartRequestHandler
extends java.lang.Object
implements MultipartRequestHandler

Mock MultipartRequestHandler object for unit tests.

Version:
$Rev: 471754 $

Field Summary
 
Fields inherited from interface org.apache.struts.upload.MultipartRequestHandler
ATTRIBUTE_MAX_LENGTH_EXCEEDED
 
Constructor Summary
MockMultipartRequestHandler()
           
 
Method Summary
 void finish()
          Mock finish() method does nothing.
 java.util.Hashtable getAllElements()
          This method returns all elements of a multipart request.
 java.util.Hashtable getFileElements()
          This method is called on to retrieve all the FormFile input elements of the request.
 ActionMapping getMapping()
          Get the ActionMapping instance for this mock request.
 ActionServlet getServlet()
          Get the mock ActionServlet instance.
 java.util.Hashtable getTextElements()
          This method is called on to retrieve all the text input elements of the request.
 void handleRequest(javax.servlet.http.HttpServletRequest request)
          Mock parsing of the ServletInputStream.
 void rollback()
          Mock rollback() method does nothing.
 void setMapping(ActionMapping mapping)
          Convienience method to set a reference to a mock ActionMapping instance.
 void setServlet(ActionServlet servlet)
          Convienience method to set a reference to a mock ActionServlet instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MockMultipartRequestHandler

public MockMultipartRequestHandler()
Method Detail

setServlet

public void setServlet(ActionServlet servlet)
Convienience method to set a reference to a mock ActionServlet instance.

Specified by:
setServlet in interface MultipartRequestHandler
Parameters:
servlet - Mock servlet instance.

setMapping

public void setMapping(ActionMapping mapping)
Convienience method to set a reference to a mock ActionMapping instance.

Specified by:
setMapping in interface MultipartRequestHandler
Parameters:
mapping - Mock action mapping instance.

getServlet

public ActionServlet getServlet()
Get the mock ActionServlet instance.

Specified by:
getServlet in interface MultipartRequestHandler
Returns:
The mock servlet instance.

getMapping

public ActionMapping getMapping()
Get the ActionMapping instance for this mock request.

Specified by:
getMapping in interface MultipartRequestHandler
Returns:
The mock action mapping instance.

handleRequest

public void handleRequest(javax.servlet.http.HttpServletRequest request)
                   throws javax.servlet.ServletException

Mock parsing of the ServletInputStream.

Constructs a Hashtable of elements from the HttpServletRequest's parameters - no FormFile elements are created.

Specified by:
handleRequest in interface MultipartRequestHandler
Parameters:
request - Mock request instance.
Throws:
javax.servlet.ServletException - If there is a problem with processing the request.

getTextElements

public java.util.Hashtable getTextElements()
This method is called on to retrieve all the text input elements of the request.

Specified by:
getTextElements in interface MultipartRequestHandler
Returns:
A Hashtable where the keys and values are the names and values of the request input parameters

getFileElements

public java.util.Hashtable getFileElements()

This method is called on to retrieve all the FormFile input elements of the request.

Specified by:
getFileElements in interface MultipartRequestHandler
Returns:
This mock implementation returns an empty Hashtable
See Also:
FormFile

getAllElements

public java.util.Hashtable getAllElements()
This method returns all elements of a multipart request.

Specified by:
getAllElements in interface MultipartRequestHandler
Returns:
This mock implementation returns a Hashtable where the keys are input names and values are either Strings (no FormFile elements)

rollback

public void rollback()
Mock rollback() method does nothing.

Specified by:
rollback in interface MultipartRequestHandler

finish

public void finish()
Mock finish() method does nothing.

Specified by:
finish in interface MultipartRequestHandler


Copyright © 2000-2007 Apache Software Foundation. All Rights Reserved.