Package com.adobe.cq.testing.junit.rules
Class TemporaryUser
- java.lang.Object
-
- org.junit.rules.ExternalResource
-
- com.adobe.cq.testing.junit.rules.TemporaryUser
-
- All Implemented Interfaces:
org.junit.rules.TestRule
public class TemporaryUser extends org.junit.rules.ExternalResourceTemporaryUser creates a user and deletes it at the end of the test. Whether the delete is successful or not is not checked. The create operation is retried until a timeout is reached. The total wait time in thebeforemethod can be up to 30s.
-
-
Constructor Summary
Constructors Constructor Description TemporaryUser(Supplier<org.apache.sling.testing.clients.SlingClient> creatorSupplier, String... groups)Instantiate a new TemporaryUser rule, to be used with the@Ruleannotation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidafter()protected voidbefore()protected voiddeleteUsers()Delete all the created users.protected StringgenerateName()Generate a unique name for the user.protected StringgeneratePassword()Generate a unique password for the user.CQClientgetClient()Supplier<org.apache.sling.testing.clients.SlingClient>getClientSupplier()
-
-
-
Constructor Detail
-
TemporaryUser
public TemporaryUser(Supplier<org.apache.sling.testing.clients.SlingClient> creatorSupplier, String... groups)
Instantiate a new TemporaryUser rule, to be used with the@Ruleannotation.- Parameters:
creatorSupplier- supplier for the client used to create the temporary usergroups- groups to which the temporary user is assigned
-
-
Method Detail
-
getClient
public CQClient getClient()
- Returns:
- the CQClient matching the temporary user
-
getClientSupplier
public Supplier<org.apache.sling.testing.clients.SlingClient> getClientSupplier()
- Returns:
- a
SlingClientSupplier matching the temporary user
-
before
protected void before() throws Throwable- Overrides:
beforein classorg.junit.rules.ExternalResource- Throws:
Throwable
-
after
protected void after()
- Overrides:
afterin classorg.junit.rules.ExternalResource
-
generateName
protected String generateName()
Generate a unique name for the user. Can be overridden if anther pattern is needed.- Returns:
- a unique username
-
generatePassword
protected String generatePassword()
Generate a unique password for the user. Can be overridden if another pattern is needed.- Returns:
- a unique, random password
-
deleteUsers
protected void deleteUsers()
Delete all the created users. The delete operation is not retried and exceptions are ignored.
-
-