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 Summary
Fields inherited from class org.apache.struts2.junit.StrutsJUnit4TestCase
dispatcher, dispatcherInitParams, pageContext, request, resourceLoader, response, servletContextFields inherited from class org.apache.struts2.XWorkJUnit4TestCase
actionProxyFactory, configuration, configurationManager, container -
Constructor Summary
Constructors -
Method Summary
Modifier 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.StrutsJUnit4TestCase
containsErrors, findValueAfterExecute, finishExecution, getAction, getActionMapping, getActionMapping, getConfigPath, initActionContext, initDispatcher, initDispatcherParams, initSession, injectStrutsDependencies, setUp, setupBeforeInitDispatcher, tearDownMethods inherited from class org.apache.struts2.XWorkJUnit4TestCase
loadButAdd, loadButAdd, loadConfigurationProviders
-
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:
executeActionin classStrutsJUnit4TestCase<T>- Parameters:
uri- action uri to test- Returns:
- execution result
- Throws:
jakarta.servlet.ServletException- in case of servlet errorsUnsupportedEncodingException- 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 DELETEuri- action uri to test- Returns:
- execution result
- Throws:
jakarta.servlet.ServletException- in case of servlet errorsUnsupportedEncodingException- in case of unsupported encoding
-
getActionProxy
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:
getActionProxyin classStrutsJUnit4TestCase<T>- Parameters:
uri- request uri to test- Returns:
- action proxy found for this request uri
-
getActionProxy
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 DELETEuri- request uri to test- Returns:
- action proxy found for this request uri
-
initServletMockObjects
protected void initServletMockObjects()- Overrides:
initServletMockObjectsin classStrutsJUnit4TestCase<T>
-