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:
023: * --------------------------------------------------------------------------
024: */
025:
026: package org.objectweb.jonas.jtests.clients.distribution;
027:
028: import java.rmi.RemoteException;
029: import java.util.Enumeration;
030: import javax.ejb.CreateException;
031: import javax.ejb.DuplicateKeyException;
032: import javax.ejb.FinderException;
033: import javax.ejb.RemoveException;
034: import javax.naming.NamingException;
035: import javax.rmi.PortableRemoteObject;
036: import junit.framework.Test;
037: import junit.framework.TestSuite;
038: import org.objectweb.jonas.jtests.beans.ffolder.Folder;
039: import org.objectweb.jonas.jtests.beans.ffolder.FolderHome;
040: import org.objectweb.jonas.jtests.beans.ffolder.FileHome;
041: import org.objectweb.jonas.jtests.beans.ffolder.File;
042: import org.objectweb.jonas.jtests.util.JTestCase;
043:
044: /**
045: * Test a session bean remote accessing entities local.
046: * Beans used: ffolder
047: * @author Philippe Durieux
048: */
049: public class G_Frontal extends JTestCase {
050:
051: protected static FolderHome fhome = null;
052: protected Folder folder = null;
053:
054: public G_Frontal(String name) {
055: super (name);
056: }
057:
058: public void testEmpty() throws Exception {
059: }
060:
061: protected void setUp() {
062: super .setUp();
063: if (fhome == null) {
064: useBeans("ffolder", true);
065: try {
066: fhome = (FolderHome) PortableRemoteObject.narrow(ictx
067: .lookup("FolderSYHome"), FolderHome.class);
068: assertNotNull(fhome);
069: } catch (NamingException e) {
070: fail("Cannot get bean home");
071: }
072: }
073: if (folder == null) {
074: try {
075: folder = fhome.create();
076: assertNotNull(folder);
077: } catch (Exception e) {
078: fail("Cannot create folder session " + e);
079: }
080: }
081: }
082:
083: /**
084: * send a reference as argument
085: */
086: public void testSendRef() throws Exception {
087: for (int i = 0; i < 100; i++) {
088: folder.sendRef(folder);
089: }
090: }
091:
092: /**
093: * send an int as argument
094: */
095: public void testSendInt() throws Exception {
096: for (int i = 0; i < 100; i++) {
097: folder.sendInt(1);
098: }
099: }
100:
101: /**
102: * send and get a reference as argument
103: */
104: public void testGetRef() throws Exception {
105: for (int i = 0; i < 100; i++) {
106: folder.getRef(folder);
107: }
108: }
109:
110: /**
111: * send and get an int as argument
112: */
113: public void testGetInt() throws Exception {
114: for (int i = 0; i < 100; i++) {
115: folder.getInt(1);
116: }
117: }
118:
119: /**
120: * send a reference as argument
121: */
122: public void testSendRefTS() throws Exception {
123: for (int i = 0; i < 100; i++) {
124: folder.sendRefTS(folder);
125: }
126: }
127:
128: /**
129: * send an int as argument
130: */
131: public void testSendIntTS() throws Exception {
132: for (int i = 0; i < 100; i++) {
133: folder.sendIntTS(1);
134: }
135: }
136:
137: /**
138: * send and get a reference as argument
139: */
140: public void testGetRefTS() throws Exception {
141: for (int i = 0; i < 100; i++) {
142: folder.getRefTS(folder);
143: }
144: }
145:
146: /**
147: * send and get an int as argument
148: */
149: public void testGetIntTS() throws Exception {
150: for (int i = 0; i < 100; i++) {
151: folder.getIntTS(1);
152: }
153: }
154:
155: public static Test suite() {
156: return new TestSuite(G_Frontal.class);
157: }
158:
159: public static void main(String args[]) {
160: String testtorun = null;
161: // Get args
162: for (int argn = 0; argn < args.length; argn++) {
163: String s_arg = args[argn];
164: Integer i_arg;
165: if (s_arg.equals("-n")) {
166: testtorun = args[++argn];
167: }
168: }
169: if (testtorun == null) {
170: junit.textui.TestRunner.run(suite());
171: } else {
172: junit.textui.TestRunner.run(new G_Frontal(testtorun));
173: }
174: }
175: }
|