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_mono.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 test with only 1 thread at a time.
034: */
035: public class F_mono extends A_mono {
036:
037: protected static ManagerHome home = null;
038: protected static Manager manager = null;
039: protected static boolean initialized = false;
040:
041: public F_mono(String name) {
042: super (name);
043: }
044:
045: protected void setUp() throws Exception {
046: super .setUp();
047: if (home == null) {
048: useBeans("manac");
049: home = (ManagerHome) PortableRemoteObject.narrow(ictx
050: .lookup(getManagerHomeName()), ManagerHome.class);
051: }
052: if (manager == null) {
053: manager = home.create(initialValue);
054: }
055: if (!initialized) {
056: // Initializes the test by creating 20 accounts
057: System.out.println("creating " + accounts + " accounts");
058: getManager().createAll(accounts);
059: initialized = true;
060: }
061: threadfail = false;
062: }
063:
064: protected void tearDown() throws Exception {
065: super .tearDown();
066: if (threadfail) {
067: initialized = false;
068: }
069: if (manager != null) {
070: manager.reinitAll();
071: manager.remove();
072: manager = null;
073: }
074: }
075:
076: public Manager getManager() {
077: return manager;
078: }
079:
080: public String getManagerHomeName() {
081: return "manacManagerHome";
082: }
083:
084: public static Test suite() {
085: return new TestSuite(F_mono.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_mono(testtorun));
101: }
102: }
103:
104: }
|