KickJava   Java API By Example, From Geeks To Geeks.

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


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_manac.java,v 1.7 2003/12/03 13:01:19 coqp Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas.stests.manac;
27
28
29 import org.objectweb.jonas.stests.util.JTestCase;
30
31
32 public abstract class A_manac extends JTestCase {
33
34     static final int initialValue = 1000;
35     public static boolean threadfail;
36
37     public A_manac(String JavaDoc name) {
38         super(name);
39     }
40
41     public abstract String JavaDoc getManagerHomeName();
42     public abstract Manager getManager();
43  
44    
45
46
47     /**
48      * Run a multithreaded client test
49      * Each "transaction" uses 4 accounts.
50      * @param accounts nb of accounts used to choose the 4 accounts
51      * @param delay nb of seconds added inside the "transaction".
52      * @param loops nb of loops done (each loop is a transaction)
53      * @param amount amount withdrawn in the transaction
54      * @param threads nb of threads executing a transaction concurrently.
55      * @param cl checking level
56      * @param tt transaction timeout
57      */

58     public void manac(int accounts, int delay, int loops, int amount, int threads, int cl, int tt) throws Exception JavaDoc {
59
60         // Set the transaction timeout
61
if (tt > 0) {
62             stopTxAt(tt);
63         }
64
65         // Create and start all threads
66
A_thread[] t_thr = new A_thread[threads];
67         for (int i = 0; i < threads; i++) {
68             t_thr[i] = new A_thread(getManagerHomeName(), i, ictx, accounts, delay, loops, amount, cl);
69             t_thr[i].start();
70         }
71
72         // Wait end of all threads
73
for (int p = 0; p < threads; p++) {
74             t_thr[p].join();
75         }
76
77         // Check if all threads run ok
78
if (threadfail) {
79             fail("Error in a thread");
80         }
81
82         // Check Accounts after each test
83
if (cl != 0 && ! getManager().checkAll()) {
84             fail("bad accounts");
85         }
86     }
87
88
89 }
90
Popular Tags