diff --git a/source/java/org/alfresco/util/test/junitrules/LoadTestRule.java b/source/java/org/alfresco/util/test/junitrules/LoadTestRule.java index a312e13147..05eb2ce67a 100644 --- a/source/java/org/alfresco/util/test/junitrules/LoadTestRule.java +++ b/source/java/org/alfresco/util/test/junitrules/LoadTestRule.java @@ -31,12 +31,58 @@ import java.util.concurrent.CountDownLatch; import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.junit.ClassRule; import org.junit.rules.ErrorCollector; +import org.junit.rules.RuleChain; import org.junit.runner.Description; import org.junit.runners.model.Statement; /** - * TODO + * This JUnit rule can be used to turn existing test code into Load Tests. + * It does this in conjunction with the {@link AlfrescoPeople} JUnit rule. + * That rule is used to {@link AlfrescoPeople#AlfrescoPeople(ApplicationContextInit, int) create} a + * fixed number of Alfresco users. Then {@link LoadTestRule} will do the following for each of your JUnit 4 @Test methods: + * + *

+ * Example usage, where we have a 'normal' feature test and a load test for the same feature.: + *

+ * public class YourTestClass
+ * {
+ *     // We need to ensure that JUnit Rules in the same 'group' (in this case the 'static' group) execute in the correct
+ *     // order. To do this we do not annotate the JUnit Rule fields themselves, but instead wrap them up in a RuleChain.
+ *     
+ *     // Initialise the spring application context with a rule.
+ *     public static final ApplicationContextInit APP_CONTEXT_RULE = new ApplicationContextInit();
+ *     public static final AlfrescoPeople         TEST_USERS       = new AlfrescoPeople(APP_CONTEXT_RULE, 32);
+ *     
+ *     @ClassRule public static RuleChain STATIC_RULE_CHAIN = RuleChain.outerRule(APP_CONTEXT_RULE)
+ *                                                                     .around(TEST_USERS);
+ *                                                              
+ *     @Rule LoadTestRule loadTestRule = new LoadTestRule(TEST_USERS);
+ *     
+ *     @Test public void aNormalTestMethod()
+ *     {
+ *         ensureFeatureFooWorks()
+ *     }
+ *     
+ *     @LoadTest @Test public void aLoadTestMethod()
+ *     {
+ *         ensureFeatureFooWorks()
+ *     }
+ *     
+ *     public void ensureFeatureFooWorks() {}
+ * }
+ * 
* * @author Neil Mc Erlean */