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_2.java 5249 2004-08-06 12:45:24Z durieuxp $
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_2 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_2(String name) {
043: super (name);
044: }
045:
046: public Manager getManager() {
047: return manager;
048: }
049:
050: public String getManagerHomeName() {
051: return "manacManager2Home";
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: getManager().createAll(accounts);
067: initialized = true;
068: }
069: threadfail = false;
070: }
071:
072: protected void tearDown() throws Exception {
073: super .tearDown();
074: if (threadfail) {
075: initialized = false;
076: }
077: if (manager != null) {
078: manager.reinitAll();
079: manager.remove();
080: manager = null;
081: }
082: }
083:
084: public static Test suite() {
085: return new TestSuite(F_multi_2.class);
086: }
087:
088: public static void main(String args[]) {
089: String testtorun = null;
090: // Get args
091: for (int argn = 0; argn < args.length; argn++) {
092: String sarg = args[argn];
093: if (sarg.equals("-n")) {
094: testtorun = args[++argn];
095: }
096: }
097: if (testtorun == null) {
098: junit.textui.TestRunner.run(suite());
099: } else {
100: junit.textui.TestRunner.run(new F_multi_2(testtorun));
101: }
102: }
103: }
|