org.apache.struts2
Class StrutsTestCase

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by com.opensymphony.xwork2.XWorkTestCase
              extended by org.apache.struts2.StrutsTestCase
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
StrutsSpringTestCase

public abstract class StrutsTestCase
extends XWorkTestCase

Base test case for JUnit testing Struts.


Field Summary
protected  java.util.Map<java.lang.String,java.lang.String> dispatcherInitParams
           
protected  org.springframework.mock.web.MockPageContext pageContext
           
protected  org.springframework.mock.web.MockHttpServletRequest request
           
protected  org.springframework.core.io.DefaultResourceLoader resourceLoader
           
protected  org.springframework.mock.web.MockHttpServletResponse response
           
protected  org.springframework.mock.web.MockServletContext servletContext
           
 
Fields inherited from class com.opensymphony.xwork2.XWorkTestCase
actionProxyFactory, configuration, configurationManager, container
 
Constructor Summary
StrutsTestCase()
           
 
Method Summary
protected  java.lang.String executeAction(java.lang.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  java.lang.Object findValueAfterExecute(java.lang.String key)
          gets an object from the stack after an action is executed
protected  ActionMapping getActionMapping(javax.servlet.http.HttpServletRequest request)
          Finds an ActionMapping for a given request
protected  ActionMapping getActionMapping(java.lang.String url)
          Finds an ActionMapping for a given url
protected  ActionProxy getActionProxy(java.lang.String uri)
          Creates an action proxy for a request, and sets parameters of the ActionInvocation to the passed parameters.
protected  Dispatcher initDispatcher(java.util.Map<java.lang.String,java.lang.String> params)
           
protected  void initServletMockObjects()
           
protected  void injectStrutsDependencies(java.lang.Object object)
          Injects dependencies on an Object using Struts internal IoC container
protected  void setUp()
          Sets up the configuration settings, XWork configuration, and message resources
protected  void setupBeforeInitDispatcher()
           
protected  void tearDown()
           
 
Methods inherited from class com.opensymphony.xwork2.XWorkTestCase
loadButAdd, loadButAdd, loadConfigurationProviders
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame, format
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

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

protected java.util.Map<java.lang.String,java.lang.String> dispatcherInitParams

resourceLoader

protected org.springframework.core.io.DefaultResourceLoader resourceLoader
Constructor Detail

StrutsTestCase

public StrutsTestCase()
Method Detail

findValueAfterExecute

protected java.lang.Object findValueAfterExecute(java.lang.String key)
gets an object from the stack after an action is executed


executeAction

protected java.lang.String executeAction(java.lang.String uri)
                                  throws javax.servlet.ServletException,
                                         java.io.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:
javax.servlet.ServletException
java.io.UnsupportedEncodingException

getActionProxy

protected ActionProxy getActionProxy(java.lang.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.


getActionMapping

protected ActionMapping getActionMapping(javax.servlet.http.HttpServletRequest request)
Finds an ActionMapping for a given request


getActionMapping

protected ActionMapping getActionMapping(java.lang.String url)
Finds an ActionMapping for a given url


injectStrutsDependencies

protected void injectStrutsDependencies(java.lang.Object object)
Injects dependencies on an Object using Struts internal IoC container


setUp

protected void setUp()
              throws java.lang.Exception
Sets up the configuration settings, XWork configuration, and message resources

Overrides:
setUp in class XWorkTestCase
Throws:
java.lang.Exception

setupBeforeInitDispatcher

protected void setupBeforeInitDispatcher()
                                  throws java.lang.Exception
Throws:
java.lang.Exception

initServletMockObjects

protected void initServletMockObjects()

initDispatcher

protected Dispatcher initDispatcher(java.util.Map<java.lang.String,java.lang.String> params)

tearDown

protected void tearDown()
                 throws java.lang.Exception
Overrides:
tearDown in class XWorkTestCase
Throws:
java.lang.Exception


Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.