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>
- 
Field SummaryFields inherited from class org.apache.struts2.junit.StrutsJUnit4TestCasedispatcher, dispatcherInitParams, pageContext, request, resourceLoader, response, servletContextFields inherited from class org.apache.struts2.XWorkJUnit4TestCaseactionProxyFactory, configuration, configurationManager, container
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected StringexecuteAction(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 StringexecuteAction(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 ActionProxygetActionProxy(String uri) Creates an action proxy for a request, and sets parameters of the ActionInvocation to the passed parameters.protected ActionProxygetActionProxy(String httpMethod, String uri) Creates an action proxy for a request, and sets parameters of the ActionInvocation to the passed parameters.protected voidMethods inherited from class org.apache.struts2.junit.StrutsJUnit4TestCasecontainsErrors, findValueAfterExecute, finishExecution, getAction, getActionMapping, getActionMapping, getConfigPath, initActionContext, initDispatcher, initDispatcherParams, initSession, injectStrutsDependencies, setUp, setupBeforeInitDispatcher, tearDownMethods inherited from class org.apache.struts2.XWorkJUnit4TestCaseloadButAdd, loadButAdd, loadConfigurationProviders
- 
Constructor Details- 
StrutsRestTestCasepublic StrutsRestTestCase()
 
- 
- 
Method Details- 
executeActionprotected 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:
- executeActionin 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
 
- 
executeActionprotected 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
 
- 
getActionProxyCreates 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:
- getActionProxyin class- StrutsJUnit4TestCase<T>
- Parameters:
- uri- request uri to test
- Returns:
- action proxy found for this request uri
 
- 
getActionProxyCreates 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
 
- 
initServletMockObjectsprotected void initServletMockObjects()- Overrides:
- initServletMockObjectsin class- StrutsJUnit4TestCase<T>
 
 
-