Package org.apache.struts2.junit
Class StrutsJUnit4TestCase<T>
java.lang.Object
org.apache.struts2.XWorkJUnit4TestCase
org.apache.struts2.junit.XWorkJUnit4TestCase
org.apache.struts2.junit.StrutsJUnit4TestCase<T>
- Direct Known Subclasses:
StrutsRestTestCase,StrutsSpringJUnit4TestCase
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Dispatcherprotected org.springframework.mock.web.MockPageContextprotected org.springframework.mock.web.MockHttpServletRequestprotected org.springframework.core.io.DefaultResourceLoaderprotected org.springframework.mock.web.MockHttpServletResponseprotected org.springframework.mock.web.MockServletContextFields inherited from class org.apache.struts2.XWorkJUnit4TestCase
actionProxyFactory, configuration, configurationManager, container -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanprotected 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 Objectgets an object from the stack after an action is executedvoidprotected Tgets an object from the stack after an action is executedprotected ActionMappinggetActionMapping(jakarta.servlet.http.HttpServletRequest request) Finds an ActionMapping for a given requestprotected ActionMappinggetActionMapping(String url) Finds an ActionMapping for a given urlprotected ActionProxygetActionProxy(String uri) Creates an action proxy for a request, and sets parameters of the ActionInvocation to the passed parameters.protected StringOverride this method to return a comma separated list of paths to a configuration file.protected voidinitActionContext(ActionContext actionContext) protected DispatcherinitDispatcher(Map<String, String> params) protected voidprotected voidprotected voidinitSession(ActionContext actionContext) protected voidinjectStrutsDependencies(Object object) Injects dependencies on an Object using Struts internal IoC containervoidsetUp()Sets up the configuration settings, XWork configuration, and message resourcesprotected voidvoidtearDown()Methods inherited from class org.apache.struts2.XWorkJUnit4TestCase
loadButAdd, loadButAdd, loadConfigurationProviders
-
Field Details
-
response
protected org.springframework.mock.web.MockHttpServletResponse response -
request
protected org.springframework.mock.web.MockHttpServletRequest request -
pageContext
protected org.springframework.mock.web.MockPageContext pageContext -
servletContext
protected org.springframework.mock.web.MockServletContext servletContext -
dispatcherInitParams
-
dispatcher
-
resourceLoader
protected org.springframework.core.io.DefaultResourceLoader resourceLoader
-
-
Constructor Details
-
StrutsJUnit4TestCase
public StrutsJUnit4TestCase()
-
-
Method Details
-
findValueAfterExecute
gets an object from the stack after an action is executed -
getAction
gets an object from the stack after an action is executed- Returns:
- The executed action
-
containsErrors
protected boolean containsErrors() -
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 FreeMarker, or Velocity (JSPs can be used with the Embedded JSP plugin)- Throws:
jakarta.servlet.ServletExceptionUnsupportedEncodingException
-
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. -
initActionContext
-
initSession
-
getActionMapping
Finds an ActionMapping for a given request -
getActionMapping
Finds an ActionMapping for a given url -
injectStrutsDependencies
Injects dependencies on an Object using Struts internal IoC container -
setupBeforeInitDispatcher
- Throws:
Exception
-
initServletMockObjects
protected void initServletMockObjects() -
finishExecution
public void finishExecution() -
setUp
Sets up the configuration settings, XWork configuration, and message resources- Overrides:
setUpin classXWorkJUnit4TestCase- Throws:
Exception
-
initDispatcherParams
protected void initDispatcherParams() -
initDispatcher
-
getConfigPath
Override this method to return a comma separated list of paths to a configuration file.The default implementation simply returns
null.- Returns:
- a comma separated list of config locations
-
tearDown
- Overrides:
tearDownin classXWorkJUnit4TestCase- Throws:
Exception
-