org.apache.struts2

## Class StrutsRestTestCase<T>

- java.lang.Object
- - com.opensymphony.xwork2.XWorkJUnit4TestCase
  - - org.apache.struts2.StrutsJUnit4TestCase<T>
    - - org.apache.struts2.StrutsRestTestCase<T>

-     public class StrutsRestTestCase<T>
      extends StrutsJUnit4TestCase<T>

- - ### Field Summary

    - ### Fields inherited from class org.apache.struts2.StrutsJUnit4TestCase

      `dispatcher, dispatcherInitParams, pageContext, request, resourceLoader, response, servletContext`

    - ### Fields inherited from class com.opensymphony.xwork2.XWorkJUnit4TestCase

      `actionProxyFactory, configuration, configurationManager, container`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `StrutsRestTestCase()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected String` | `executeAction(String uri)` Executes an action and returns it's output (not the result returned from execute()), but the actual output that would be written to the response.
    `protected String` | `executeAction(String httpMethod, String uri)` Executes an action and returns it's output (not the result returned from execute()), but the actual output that would be written to the response.
    `protected ActionProxy` | `getActionProxy(String uri)` Creates an action proxy for a request, and sets parameters of the ActionInvocation to the passed parameters.
    `protected ActionProxy` | `getActionProxy(String httpMethod, String uri)` Creates an action proxy for a request, and sets parameters of the ActionInvocation to the passed parameters.
    `protected void` | `initServletMockObjects()`

    - ### Methods inherited from class org.apache.struts2.StrutsJUnit4TestCase

      `containsErrors, findValueAfterExecute, finishExecution, getAction, getActionMapping, getActionMapping, getConfigPath, initActionContext, initDispatcher, initDispatcherParams, initSession, injectStrutsDependencies, setUp, setupBeforeInitDispatcher, tearDown`

    - ### Methods inherited from class com.opensymphony.xwork2.XWorkJUnit4TestCase

      `loadButAdd, loadButAdd, loadConfigurationProviders`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### StrutsRestTestCase

          public StrutsRestTestCase()

  - ### Method Detail

    - #### executeAction

          protected String executeAction(String uri)
                                  throws javax.servlet.ServletException,
                                         UnsupportedEncodingException

      Executes an action and returns it's output (not the result returned from execute()), but the actual output that would be written to the response. For this to work the configured result for the action needs to be JSON, FreeMarker, or Velocity (JSPs can be used with the Embedded JSP plugin)
      Overrides:
        `executeAction` in class `StrutsJUnit4TestCase<T>`
      Parameters:
        `uri` - action uri to test
      Returns:
        execution result
      Throws:
        `javax.servlet.ServletException` - in case of servlet errors
        `UnsupportedEncodingException` - in case of unsupported encoding

    - #### executeAction

          protected String executeAction(String httpMethod,
                             String uri)
                                  throws javax.servlet.ServletException,
                                         UnsupportedEncodingException

      Executes an action and returns it's output (not the result returned from execute()), but the actual output that would be written to the response. For this to work the configured result for the action needs to be JSON, FreeMarker, or Velocity (JSPs can be used with the Embedded JSP plugin)
      Parameters:
        `httpMethod` - HTTP method of request like GET, POST, PUT or DELETE
        `uri` - action uri to test
      Returns:
        execution result
      Throws:
        `javax.servlet.ServletException` - in case of servlet errors
        `UnsupportedEncodingException` - in case of unsupported encoding

    - #### getActionProxy

          protected ActionProxy getActionProxy(String uri)

      Creates an action proxy for a request, and sets parameters of the ActionInvocation to the passed parameters. Make sure to set the request parameters in the protected "request" object before calling this method.
      Overrides:
        `getActionProxy` in class `StrutsJUnit4TestCase<T>`
      Parameters:
        `uri` - request uri to test
      Returns:
        action proxy found for this request uri

    - #### getActionProxy

          protected ActionProxy getActionProxy(String httpMethod,
                                   String uri)

      Creates an action proxy for a request, and sets parameters of the ActionInvocation to the passed parameters. Make sure to set the request parameters in the protected "request" object before calling this method.
      Parameters:
        `httpMethod` - HTTP method of request like GET, POST, PUT or DELETE
        `uri` - request uri to test
      Returns:
        action proxy found for this request uri

    - #### initServletMockObjects

          protected void initServletMockObjects()

      Overrides:
        `initServletMockObjects` in class `StrutsJUnit4TestCase<T>`

Copyright © 2000–2020 Apache Software Foundation. All rights reserved.