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_bankRO.java 5834 2004-12-01 16:40:58Z durieuxp $
023: * --------------------------------------------------------------------------
024: */
025:
026: package org.objectweb.jonas.jtests.clients.distribution;
027:
028: import javax.rmi.PortableRemoteObject;
029:
030: import org.objectweb.jonas.jtests.beans.bank.Manager;
031: import org.objectweb.jonas.jtests.beans.bank.ManagerHome;
032: import org.objectweb.jonas.jtests.util.JTestCase;
033:
034: import junit.framework.Test;
035: import junit.framework.TestSuite;
036:
037: public class F_bankRO extends A_bankRead {
038:
039: protected static ManagerHome homecs = null;
040: protected static Manager managercs = null;
041: public static boolean threadfail;
042:
043: public F_bankRO(String name) {
044: super (name);
045: }
046:
047: public String getManagerHomeName() {
048: return "bankManagerROHome";
049: }
050:
051: public boolean getPrefetch() {
052: return false;
053: }
054:
055: protected void setUp() {
056: try {
057: if (home == null) {
058: useBeans("bank", false);
059: home = (ManagerHome) PortableRemoteObject.narrow(ictx
060: .lookup(getManagerHomeName()),
061: ManagerHome.class);
062: }
063: if (manager == null) {
064: manager = home.create(initialValue, getPrefetch());
065: }
066: } catch (Exception e) {
067: fail("Exception raised in setup: " + e);
068: }
069: try {
070: // Create all accounts with another manager (not the read-only one)
071: if (homecs == null) {
072: homecs = (ManagerHome) PortableRemoteObject
073: .narrow(ictx.lookup("bankManagerCSHome"),
074: ManagerHome.class);
075: }
076: if (managercs == null) {
077: managercs = homecs.create(initialValue, false);
078: }
079: // Initializes the test by creating accounts
080: managercs.createAll(accountNb);
081: threadfail = false;
082: } catch (Exception e) {
083: fail("Exception raised in setup: " + e);
084: }
085: }
086:
087: public static Test suite() {
088: return new TestSuite(F_bankRO.class);
089: }
090:
091: public static void main(String args[]) {
092: String testtorun = null;
093: // Get args
094: for (int argn = 0; argn < args.length; argn++) {
095: String sarg = args[argn];
096: if (sarg.equals("-n")) {
097: testtorun = args[++argn];
098: }
099: }
100: if (testtorun == null) {
101: junit.textui.TestRunner.run(suite());
102: } else {
103: junit.textui.TestRunner.run(new F_bankRO(testtorun));
104: }
105: }
106: }
|