001: /*
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 1999 Bull S.A.
004: * Contact: jonas-team@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: A_remove.java 2834 2003-07-18 06:13:01Z durieuxp $
023: * --------------------------------------------------------------------------
024: */
025:
026: package org.objectweb.jonas.stests.manac;
027:
028: import javax.rmi.PortableRemoteObject;
029: import org.objectweb.jonas.stests.util.JTestCase;
030:
031: /**
032: * This test suite tests remove operations in a multithreading environment.
033: */
034: public abstract class A_remove extends JTestCase {
035:
036: static final int initialValue = 1000;
037: protected static ManagerHome home = null;
038: protected static Manager manager = null;
039:
040: int accounts = 100;
041: int loops = 1;
042: int threads = 1;
043:
044: public static boolean threadfail;
045:
046: public A_remove(String name) {
047: super (name);
048: }
049:
050: public abstract String getManagerHomeName();
051:
052: protected void setUp() throws Exception {
053: super .setUp();
054: if (home == null) {
055: useBeans("manac");
056: home = (ManagerHome) PortableRemoteObject.narrow(ictx
057: .lookup(getManagerHomeName()), ManagerHome.class);
058: }
059: if (manager == null) {
060: manager = home.create(initialValue);
061: }
062: threadfail = false;
063: }
064:
065: protected void tearDown() throws Exception {
066: super .tearDown();
067: }
068:
069: /**
070: * Run a multithreaded client test. Common part to all test cases.
071: */
072: public void remac(int accounts, int loops, int threads)
073: throws Exception {
074:
075: // Create and start all threads
076: A_remthread[] t_thr = new A_remthread[threads];
077: for (int i = 0; i < threads; i++) {
078: t_thr[i] = new A_remthread(getManagerHomeName(), i, ictx,
079: accounts, loops);
080: t_thr[i].start();
081: }
082:
083: // Wait end of all threads
084: for (int p = 0; p < threads; p++) {
085: t_thr[p].join();
086: }
087:
088: // Check if all threads run ok
089: if (threadfail) {
090: fail("Error in a thread");
091: }
092: }
093:
094: public void testBasic() throws Exception {
095: remac(accounts, loops, threads);
096: }
097:
098: public void testConc() throws Exception {
099: int accounts = 10;
100: int threads = 12;
101: int loops = 4;
102: remac(accounts, loops, threads);
103: }
104:
105: public void testL100() throws Exception {
106: int loops = 100;
107: remac(accounts, loops, threads);
108: }
109:
110: public void testL50T2() throws Exception {
111: int loops = 50;
112: int threads = 2;
113: remac(accounts, loops, threads);
114: }
115:
116: public void testL20T5() throws Exception {
117: int loops = 20;
118: int threads = 5;
119: remac(accounts, loops, threads);
120: }
121:
122: public void testL10T8() throws Exception {
123: int accounts = 1000;
124: int loops = 10;
125: int threads = 8;
126: remac(accounts, loops, threads);
127: }
128:
129: }
|