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: F_multi.java 3813 2003-12-03 13:01:20Z coqp $
023: * --------------------------------------------------------------------------
024: */
025:
026: package org.objectweb.jonas.stests.manac;
027:
028: import junit.framework.Test;
029: import junit.framework.TestSuite;
030: import javax.rmi.PortableRemoteObject;
031:
032: /**
033: * This TestCase is a set of multithreaded clients accessing concurrently
034: * the set of accounts.
035: */
036: public class F_multi extends A_multi {
037:
038: protected static ManagerHome home = null;
039: protected static Manager manager = null;
040: protected static boolean initialized = false;
041:
042: public F_multi(String name) {
043: super (name);
044: }
045:
046: public Manager getManager() {
047: return manager;
048: }
049:
050: public String getManagerHomeName() {
051: return "manacManagerHome";
052: }
053:
054: protected void setUp() throws Exception {
055: super .setUp();
056: if (home == null) {
057: useBeans("manac");
058: home = (ManagerHome) PortableRemoteObject.narrow(ictx
059: .lookup(getManagerHomeName()), ManagerHome.class);
060: }
061: if (manager == null) {
062: manager = home.create(initialValue);
063: }
064: if (!initialized) {
065: // Initializes the test by creating 20 accounts
066: System.out.println("creating " + accounts + " accounts");
067: getManager().createAll(accounts);
068: initialized = true;
069: }
070: threadfail = false;
071: }
072:
073: protected void tearDown() throws Exception {
074: super .tearDown();
075: if (threadfail) {
076: initialized = false;
077: }
078: if (manager != null) {
079: manager.reinitAll();
080: manager.remove();
081: manager = null;
082: }
083: }
084:
085: public static Test suite() {
086: return new TestSuite(F_multi.class);
087: }
088:
089: public static void main(String args[]) {
090: String testtorun = null;
091: // Get args
092: for (int argn = 0; argn < args.length; argn++) {
093: String sarg = args[argn];
094: if (sarg.equals("-n")) {
095: testtorun = args[++argn];
096: }
097: }
098: if (testtorun == null) {
099: junit.textui.TestRunner.run(suite());
100: } else {
101: junit.textui.TestRunner.run(new F_multi(testtorun));
102: }
103: }
104: }
|