KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > stests > manac > A_remove


1 /*
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: A_remove.java,v 1.4 2003/07/18 06:13:01 durieuxp Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas.stests.manac;
27
28 import javax.rmi.PortableRemoteObject JavaDoc;
29 import org.objectweb.jonas.stests.util.JTestCase;
30
31 /**
32  * This test suite tests remove operations in a multithreading environment.
33  */

34 public abstract class A_remove extends JTestCase {
35
36     static final int initialValue = 1000;
37     protected static ManagerHome home = null;
38     protected static Manager manager = null;
39
40     int accounts = 100;
41     int loops = 1;
42     int threads = 1;
43
44     public static boolean threadfail;
45
46     public A_remove(String JavaDoc name) {
47         super(name);
48     }
49
50     public abstract String JavaDoc getManagerHomeName();
51
52     protected void setUp() throws Exception JavaDoc {
53         super.setUp();
54         if (home == null) {
55             useBeans("manac");
56             home = (ManagerHome) PortableRemoteObject.narrow(ictx.lookup(getManagerHomeName()),
57                                                              ManagerHome.class);
58         }
59         if (manager == null) {
60             manager = home.create(initialValue);
61         }
62         threadfail = false;
63     }
64
65     protected void tearDown() throws Exception JavaDoc {
66         super.tearDown();
67     }
68
69     /**
70      * Run a multithreaded client test. Common part to all test cases.
71      */

72     public void remac(int accounts, int loops, int threads) throws Exception JavaDoc {
73
74         // Create and start all threads
75
A_remthread[] t_thr = new A_remthread[threads];
76         for (int i = 0; i < threads; i++) {
77             t_thr[i] = new A_remthread(getManagerHomeName(), i, ictx, accounts, loops);
78             t_thr[i].start();
79         }
80
81         // Wait end of all threads
82
for (int p = 0; p < threads; p++) {
83             t_thr[p].join();
84         }
85
86         // Check if all threads run ok
87
if (threadfail) {
88             fail("Error in a thread");
89         }
90     }
91
92     public void testBasic() throws Exception JavaDoc {
93         remac(accounts, loops, threads);
94     }
95
96     public void testConc() throws Exception JavaDoc {
97         int accounts = 10;
98         int threads = 12;
99         int loops = 4;
100         remac(accounts, loops, threads);
101     }
102
103     public void testL100() throws Exception JavaDoc {
104         int loops = 100;
105         remac(accounts, loops, threads);
106     }
107
108     public void testL50T2() throws Exception JavaDoc {
109         int loops = 50;
110         int threads = 2;
111         remac(accounts, loops, threads);
112     }
113
114     public void testL20T5() throws Exception JavaDoc {
115         int loops = 20;
116         int threads = 5;
117         remac(accounts, loops, threads);
118     }
119
120     public void testL10T8() throws Exception JavaDoc {
121         int accounts = 1000;
122         int loops = 10;
123         int threads = 8;
124         remac(accounts, loops, threads);
125     }
126
127 }
128
Popular Tags