1 /* Reattore HTTP Server
2
3 Copyright (C) 2002 Michael Hope <michaelh@juju.net.nz>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19 $Id: TestSystem.java,v 1.4 2003/01/21 22:43:12 michaelh Exp $
20 */
21
22 package test.juju.reattore.loadtest.controller.impl;
23
24 import junit.framework.*;
25 import java.net.URL;
26 import juju.reattore.core.reactor.impl.CombinedReactor;
27 import juju.reattore.loadtest.controller.*;
28 import juju.reattore.loadtest.controller.impl.*;
29
30 public class TestSystem
31 extends TestCase {
32
33 private Controller controller;
34 private MockChooser chooser;
35 private CombinedReactor reactor;
36 private ReactorThread reactorThread;
37 private MockServer server;
38
39 protected void setUp()
40 throws Exception {
41
42 chooser = new MockChooser();
43 chooser.addTarget(new URL("http://localhost:8081/"));
44
45 reactor = new CombinedReactor();
46 controller = new BaseController(chooser, reactor);
47
48 server = new MockServer(8081);
49 server.start();
50
51 reactorThread = new ReactorThread(reactor);
52 reactorThread.start();
53 }
54
55 protected void tearDown() {
56 reactorThread.end();
57 server.end();
58 }
59
60 public void testGo() {
61 controller.go(10.0, 2.0);
62
63 reactorThread.end();
64 server.end();
65
66 assertEquals(20, chooser.getNumHits());
67 assertEquals(20, server.getNumHits());
68 }
69
70 public void testZeroRun() {
71 controller.go(10.0, 0.0);
72
73 reactorThread.end();
74 server.end();
75
76 assertEquals(1, chooser.getNumHits());
77 assertEquals(1, server.getNumHits());
78 }
79
80 public void testGo2() {
81 controller.go(5, 0.1);
82
83 reactorThread.end();
84 server.end();
85
86 assertEquals(5, chooser.getNumHits());
87 assertEquals(5, server.getNumHits());
88 }
89
90 public void testZeroRun2() {
91 controller.go(0, 0.0);
92
93 reactorThread.end();
94 server.end();
95
96 assertEquals(1, chooser.getNumHits());
97 assertEquals(1, server.getNumHits());
98 }
99
100 public void testOneRun() {
101 controller.go(1, 0.0);
102
103 reactorThread.end();
104 server.end();
105
106 assertEquals(1, chooser.getNumHits());
107 assertEquals(1, server.getNumHits());
108 }
109
110 public static Test suite() {
111 return new TestSuite(TestSystem.class);
112 }
113 }
This page was automatically generated by Maven