public class RunAsFullyAuthenticatedRule
extends java.lang.Object
implements org.junit.rules.TestRule
@Test
methods will be
run as that user.
Furthermore, if an individual test method is annotated like this @RunAsUser(userName="John")
than that
method (and only that method) will be run as "John".
Example usage:
public class YourTestClass { @ClassRule public static final ApplicationContextInit APP_CONTEXT_RULE = new ApplicationContextInit(); @Rule public RunAsFullyAuthenticatedRule runAsGuidPerson = new RunAsFullyAuthenticatedRule("NeilM"); @Test public void doSomething() throws Exception { // This will run as NeilM } @Test @RunAsUser(userName="DaveC") public void doSomething() throws Exception { // This will run as DaveC } }
Modifier and Type | Class and Description |
---|---|
static interface |
RunAsFullyAuthenticatedRule.RunAsUser
This annotation can be used to mark an individual
Test method for running as a named user. |
Constructor and Description |
---|
RunAsFullyAuthenticatedRule()
This constructs a rule where there is no specified user to run as.
|
RunAsFullyAuthenticatedRule(AlfrescoPerson personRule) |
RunAsFullyAuthenticatedRule(java.lang.String userName) |
Modifier and Type | Method and Description |
---|---|
org.junit.runners.model.Statement |
apply(org.junit.runners.model.Statement base,
org.junit.runner.Description description) |
java.lang.String |
getUsername()
Get the username which test methods will run as.
|
public RunAsFullyAuthenticatedRule()
RunAsFullyAuthenticatedRule.RunAsUser
.public RunAsFullyAuthenticatedRule(java.lang.String userName)
userName
- the username which all test methods should run as.public RunAsFullyAuthenticatedRule(AlfrescoPerson personRule)
personRule
- the rule which will provide the username which all test methods should run as.public java.lang.String getUsername()
public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description)
apply
in interface org.junit.rules.TestRule
Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.