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_stress.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: * set of testCases used to load the EJBServer
034: */
035: public class F_stress extends A_stress {
036:
037: protected static ManagerHome home = null;
038: protected static Manager manager = null;
039: protected static boolean initialized = false;
040:
041: public F_stress(String name) {
042: super (name);
043: }
044:
045: public Manager getManager() {
046: return manager;
047: }
048:
049: public String getManagerHomeName() {
050: return "manacManagerHome";
051: }
052:
053: protected void setUp() throws Exception {
054: super .setUp();
055: if (home == null) {
056: useBeans("manac");
057: home = (ManagerHome) PortableRemoteObject.narrow(ictx
058: .lookup(getManagerHomeName()), ManagerHome.class);
059: }
060: if (manager == null) {
061: manager = home.create(initialValue);
062: }
063: if (!initialized) {
064: // Initializes the test by creating 20 accounts
065: System.out.println("creating " + accounts + " 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_stress.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_stress(testtorun));
101: }
102: }
103: }
|