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 CollaborativeEditingHelperprotected ConfluenceUserprotected ContentPermissionManagerprotected com.atlassian.user.Grouporg.mockito.junit.MockitoRuleprotected PageServiceprotected Personprotected org.springframework.mock.web.MockHttpServletRequestprotected Spaceprotected SpacePermissionManagerprotected SpaceServiceprotected Rendererprotected com.atlassian.struts.xsrf.XsrfTokenGeneratorFields inherited from class it.com.atlassian.confluence.AbstractInjectableStateTest
admin, initThreadLocalCacheRule, otherUser, stateFields inherited from class it.com.atlassian.confluence.AbstractInjectableConfluenceSingleContextSpringPersistenceTest
executorService -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidprotected voidprotected voidprotected ConfluenceUsercreateUserInGroup(String username, com.atlassian.user.Group group) protected final ACTIONprotected org.apache.struts2.ActionProxyprotected abstract Stringprotected Stringprotected voidprotected voidsetParameters(AbstractPage page) protected voidsetParameters(Comment comment) protected voidsetParameters(Space space) protected voidsetParameters(Map<String, ?> parameters) protected voidfinal voidsetup()Methods inherited from class it.com.atlassian.confluence.AbstractInjectableStateTest
initPlugins, initUsers, resetJournal, resetStateMethods 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
-