From 137e9a50ab5a43b31788ed9f5220d0af19702082 Mon Sep 17 00:00:00 2001 From: Neil McErlean Date: Sat, 1 Dec 2012 12:02:16 +0000 Subject: [PATCH] Added proper Class-level javadoc for LoadTestRule. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@44225 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../util/test/junitrules/LoadTestRule.java | 48 ++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) 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 */