KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > oscache > web > TestLoadCompleteWeb


1 /*
2  * Copyright (c) 2002-2003 by OpenSymphony
3  * All rights reserved.
4  */

5 package com.opensymphony.oscache.web;
6
7 import com.clarkware.junitperf.LoadTest;
8 import com.clarkware.junitperf.RandomTimer;
9
10 import junit.extensions.RepeatedTest;
11
12 import junit.framework.Test;
13 import junit.framework.TestCase;
14 import junit.framework.TestSuite;
15
16 /**
17  * Test class for the com.opensymphony.oscache.web package.
18  * It invokes all the test suites of all the other classes of the package.
19  * The test methods will be invoked with many users and iterations to simulate
20  * load on request
21  *
22  * $Id: TestLoadCompleteWeb.java,v 1.1 2005/06/17 05:06:37 dres Exp $
23  * @version $Revision: 1.1 $
24  * @author <a HREF="mailto:abergevin@pyxis-tech.com">Alain Bergevin</a>
25  */

26 public final class TestLoadCompleteWeb extends TestCase {
27     /**
28      * Constructor for the osCache Cache project main test program
29      */

30     public TestLoadCompleteWeb(String JavaDoc str) {
31         super(str);
32     }
33
34     /**
35      * Main method which is called to perform the tests
36      * <p>
37      * @param args Arguments received
38      */

39     public static void main(String JavaDoc[] args) {
40         // Run the test suite
41
junit.swingui.TestRunner testRunner = new junit.swingui.TestRunner();
42         testRunner.setLoading(false);
43
44         String JavaDoc[] args2 = {TestLoadCompleteWeb.class.getName()};
45         testRunner.start(args2);
46     }
47
48     /**
49      * Test suite required to test this project
50      * <p>
51      * @return suite The test suite
52      */

53     public static Test suite() {
54         final int clientThreads = 10; // Simulate 10 client threads
55
final int iterations = 20; // Simulate each user doing 20 iterations
56

57         TestSuite suite = new TestSuite("Test all osCache web");
58
59         // Ramp up a thread each 500 ms (+-100ms) until total number of threads reached
60
RandomTimer tm = new RandomTimer(300, 100);
61
62         // JSP
63
Test repeatedTest = new RepeatedTest(new TestOscacheJsp("testOscacheBasicForLoad"), iterations);
64         Test loadTest = new LoadTest(repeatedTest, clientThreads, tm);
65         suite.addTest(loadTest);
66
67         // Servlet
68
repeatedTest = new RepeatedTest(new TestOscacheServlet("testOscacheServletBasicForLoad"), iterations);
69         loadTest = new LoadTest(repeatedTest, clientThreads, tm);
70         suite.addTest(loadTest);
71
72         // Filter
73
repeatedTest = new RepeatedTest(new TestOscacheFilter("testOscacheFilterBasicForLoad"), iterations);
74         loadTest = new LoadTest(repeatedTest, clientThreads, tm);
75         suite.addTest(loadTest);
76
77         return suite;
78     }
79 }
80
Popular Tags