Class ServletRunner

java.lang.Object
com.meterware.servletunit.ServletRunner

public class ServletRunner extends Object
This class acts as a test environment for servlets.
Author:
Russell Gold
  • Field Details

  • Constructor Details

  • Method Details

    • registerServlet

      public void registerServlet(String resourceName, String servletClassName)
      Registers a servlet class to be run.
    • registerServlet

      public void registerServlet(String resourceName, String servletClassName, Hashtable initParameters)
      Registers a servlet class to be run, specifying initialization parameters.
    • getResponse

      public WebResponse getResponse(WebRequest request) throws MalformedURLException, IOException, SAXException
      Returns the response from the specified servlet.
      Throws:
      SAXException - thrown if there is an error parsing the response
      MalformedURLException
      IOException
    • getResponse

      Returns the response from the specified servlet using GET.
      Throws:
      SAXException - thrown if there is an error parsing the response
      MalformedURLException
      IOException
    • getSession

      public javax.servlet.http.HttpSession getSession(boolean create)
      Returns the session to be used by the next request.
      Parameters:
      create - if true, will create a new session if no valid session is defined.
      Since:
      1.6
    • getContextParameter

      public String getContextParameter(String name)
      Returns the value of the named context parameter found in the application definition.
      Parameters:
      name - - the name of the parameter to get
      Returns:
      - the context parameter with the given name
    • setContextParameter

      public void setContextParameter(String name, Object value)
      Deprecated.
      - test case for this function deactivated wf 2007-12-30
      Sets a application context parameter.
      Parameters:
      name - - the name of the parameter to set
      value - - the value of the parameter to set
    • shutDown

      public void shutDown()
      Shuts down the servlet container, returning any resources held by it. Calls the destroy method of each active servlet, then notifies ContextListeners of server shutdown.
    • newClient

      public ServletUnitClient newClient()
      Creates and returns a new web client that communicates with this servlet runner.