Class AbstractInjectableActionTest<ACTION extends org.apache.struts2.action.Action>
java.lang.Object
it.com.atlassian.confluence.AbstractInjectableConfluenceSingleContextSpringPersistenceTest
it.com.atlassian.confluence.AbstractInjectableStateTest
it.com.atlassian.confluence.struts.AbstractInjectableActionTest<ACTION>
- All Implemented Interfaces:
org.springframework.beans.factory.Aware
,org.springframework.context.ApplicationContextAware
public abstract class AbstractInjectableActionTest<ACTION extends org.apache.struts2.action.Action>
extends AbstractInjectableStateTest
Instructions for creating a test using this base class.
1: Decide which action you're testing.
2: Find that action in struts.xml by searching for the class name.
3: Check which method you should be calling on the action. (it'll be listed in struts.xml).
4: return the name of that method in getMethodName, and return that action's class in getActionClass
5: call getActionProxy().execute() to run the action, and check the string result of that call for success or failure.
If there is no method listed in struts.xml, then just return null in getMethodName, which will call the default method. Your action or an interceptor may expect certain query parameters or POST variables. To set these look at setParameters
- Since:
- 7.2.0
-
Nested Class Summary
Nested classes/interfaces inherited from class it.com.atlassian.confluence.AbstractInjectableConfluenceSingleContextSpringPersistenceTest
AbstractInjectableConfluenceSingleContextSpringPersistenceTest.InitThreadLocalCacheRule
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected CollaborativeEditingHelper
protected ConfluenceUser
protected ContentPermissionManager
protected com.atlassian.user.Group
org.mockito.junit.MockitoRule
protected PageService
protected Person
protected org.springframework.mock.web.MockHttpServletRequest
protected Space
protected SpacePermissionManager
protected SpaceService
protected Renderer
protected com.atlassian.struts.xsrf.XsrfTokenGenerator
Fields inherited from class it.com.atlassian.confluence.AbstractInjectableStateTest
admin, initThreadLocalCacheRule, otherUser, state
Fields inherited from class it.com.atlassian.confluence.AbstractInjectableConfluenceSingleContextSpringPersistenceTest
executorService
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
protected void
protected void
protected ConfluenceUser
createUserInGroup
(String username, com.atlassian.user.Group group) protected final ACTION
protected org.apache.struts2.ActionProxy
protected abstract String
protected String
protected void
protected void
setParameters
(AbstractPage page) protected void
setParameters
(Comment comment) protected void
setParameters
(Space space) protected void
setParameters
(Map<String, ?> parameters) protected void
final void
setup()
Methods inherited from class it.com.atlassian.confluence.AbstractInjectableStateTest
initPlugins, initUsers, resetJournal, resetState
Methods inherited from class it.com.atlassian.confluence.AbstractInjectableConfluenceSingleContextSpringPersistenceTest
configureContainerManager, deleteAll, doInIsolatedTransaction, doInIsolatedTransaction, doInReadOnlyTransaction, doInReadOnlyTransaction, doInTransaction, doInTransaction, findAll, getApplicationContext, getDataSource, getSession, getSessionFactory, getTransactionManager, initBaseUrl, initLicense, loadResource, logConnectionPoolState, setApplicationContext
-
Field Details
-
mockitoRule
public org.mockito.junit.MockitoRule mockitoRule -
contentPermissionManager
-
spacePermissionManager
-
pageService
-
spaceService
-
viewRenderer
-
collaborativeEditingHelper
-
xsrfTokenGenerator
@Inject protected com.atlassian.struts.xsrf.XsrfTokenGenerator xsrfTokenGenerator -
request
protected org.springframework.mock.web.MockHttpServletRequest request -
space
-
groupOfTestUser
protected com.atlassian.user.Group groupOfTestUser -
confluenceTestUser
-
person
-
-
Constructor Details
-
AbstractInjectableActionTest
public AbstractInjectableActionTest()
-
-
Method Details
-
setup
- Throws:
Exception
-
getMethodName
-
setParameters
-
setRequestXsrfToken
protected void setRequestXsrfToken() -
setParameters
-
setParameters
-
setParameters
-
getRemoteUserName
-
prepareContext
-
getAction
-
getActionProxy
protected org.apache.struts2.ActionProxy getActionProxy() -
becomeTestUser
protected void becomeTestUser() -
becomeAdmin
protected void becomeAdmin() -
becomeAnonymous
protected void becomeAnonymous() -
createUserInGroup
protected ConfluenceUser createUserInGroup(String username, com.atlassian.user.Group group) throws com.atlassian.user.EntityException - Throws:
com.atlassian.user.EntityException
-
installExpiredLicense
- Throws:
IOException
-