01: /*
02: * JOnAS: Java(TM) Open Application Server
03: * Copyright (C) 1999 Bull S.A.
04: * Contact: jonas-team@objectweb.org
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * 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 3813 2003-12-03 13:01:20Z coqp $
23: * --------------------------------------------------------------------------
24: */
25:
26: package org.objectweb.jonas.stests.manac;
27:
28: import org.objectweb.jonas.stests.util.JTestCase;
29:
30: public abstract class A_manac extends JTestCase {
31:
32: static final int initialValue = 1000;
33: public static boolean threadfail;
34:
35: public A_manac(String name) {
36: super (name);
37: }
38:
39: public abstract String getManagerHomeName();
40:
41: public abstract Manager getManager();
42:
43: /**
44: * Run a multithreaded client test
45: * Each "transaction" uses 4 accounts.
46: * @param accounts nb of accounts used to choose the 4 accounts
47: * @param delay nb of seconds added inside the "transaction".
48: * @param loops nb of loops done (each loop is a transaction)
49: * @param amount amount withdrawn in the transaction
50: * @param threads nb of threads executing a transaction concurrently.
51: * @param cl checking level
52: * @param tt transaction timeout
53: */
54: public void manac(int accounts, int delay, int loops, int amount,
55: int threads, int cl, int tt) throws Exception {
56:
57: // Set the transaction timeout
58: if (tt > 0) {
59: stopTxAt(tt);
60: }
61:
62: // Create and start all threads
63: A_thread[] t_thr = new A_thread[threads];
64: for (int i = 0; i < threads; i++) {
65: t_thr[i] = new A_thread(getManagerHomeName(), i, ictx,
66: accounts, delay, loops, amount, cl);
67: t_thr[i].start();
68: }
69:
70: // Wait end of all threads
71: for (int p = 0; p < threads; p++) {
72: t_thr[p].join();
73: }
74:
75: // Check if all threads run ok
76: if (threadfail) {
77: fail("Error in a thread");
78: }
79:
80: // Check Accounts after each test
81: if (cl != 0 && !getManager().checkAll()) {
82: fail("bad accounts");
83: }
84: }
85:
86: }
|