01: /*
02: * Copyright (c) 2002-2003 by OpenSymphony
03: * All rights reserved.
04: */
05: package com.opensymphony.oscache.web;
06:
07: import com.clarkware.junitperf.LoadTest;
08: import com.clarkware.junitperf.RandomTimer;
09:
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 254 2005-06-17 05:07:38Z dres $
23: * @version $Revision: 254 $
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 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[] args) {
40: // Run the test suite
41: junit.swingui.TestRunner testRunner = new junit.swingui.TestRunner();
42: testRunner.setLoading(false);
43:
44: String[] 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(
64: "testOscacheBasicForLoad"), iterations);
65: Test loadTest = new LoadTest(repeatedTest, clientThreads, tm);
66: suite.addTest(loadTest);
67:
68: // Servlet
69: repeatedTest = new RepeatedTest(new TestOscacheServlet(
70: "testOscacheServletBasicForLoad"), iterations);
71: loadTest = new LoadTest(repeatedTest, clientThreads, tm);
72: suite.addTest(loadTest);
73:
74: // Filter
75: repeatedTest = new RepeatedTest(new TestOscacheFilter(
76: "testOscacheFilterBasicForLoad"), iterations);
77: loadTest = new LoadTest(repeatedTest, clientThreads, tm);
78: suite.addTest(loadTest);
79:
80: return suite;
81: }
82: }
|