Package org.apache.struts2.junit

# Class StrutsRestTestCase<T>

java.lang.Object
org.apache.struts2.XWorkJUnit4TestCase
org.apache.struts2.junit.XWorkJUnit4TestCase
org.apache.struts2.junit.StrutsJUnit4TestCase<T>
org.apache.struts2.junit.StrutsRestTestCase<T>

public class StrutsRestTestCase<T> extends StrutsJUnit4TestCase<T>

- ## Field Summary

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

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

  ### Fields inherited from class org.apache.struts2.XWorkJUnit4TestCase

  `actionProxyFactory, configuration, configurationManager, container`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `StrutsRestTestCase()`

- ## Method Summary

  Modifier and Type
  Method
  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.junit.StrutsJUnit4TestCase

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

  ### Methods inherited from class org.apache.struts2.XWorkJUnit4TestCase

  `loadButAdd, loadButAdd, loadConfigurationProviders`

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

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

- ## Constructor Details

  - ### StrutsRestTestCase

    public StrutsRestTestCase()

- ## Method Details

  - ### executeAction

    protected String executeAction(String uri) throws jakarta.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:
      `jakarta.servlet.ServletException` - in case of servlet errors
      `UnsupportedEncodingException` - in case of unsupported encoding

  - ### executeAction

    protected String executeAction(String httpMethod, String uri) throws jakarta.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:
      `jakarta.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>`