KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > jtests > clients > distribution > G_Frontal


1 /*
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: G_Frontal.java,v 1.6 2005/02/09 10:36:26 coqp Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas.jtests.clients.distribution;
27
28 import javax.naming.NamingException JavaDoc;
29 import javax.rmi.PortableRemoteObject JavaDoc;
30
31 import junit.framework.Test;
32 import junit.framework.TestSuite;
33
34 import org.objectweb.jonas.jtests.beans.folder.Folder;
35 import org.objectweb.jonas.jtests.beans.folder.FolderHome;
36 import org.objectweb.jonas.jtests.util.JTestCase;
37
38 /**
39  * Test a session bean remote accessing entities local.
40  * Beans used: folder
41  * @author Philippe Durieux
42  */

43 public class G_Frontal extends JTestCase {
44
45     protected static FolderHome fhome = null;
46     protected Folder folder = null;
47
48     public G_Frontal(String JavaDoc name) {
49         super(name);
50     }
51   
52     protected void setUp() {
53         super.setUp();
54         if (fhome == null) {
55             useBeans("folder", true);
56             try {
57                 fhome = (FolderHome) PortableRemoteObject.narrow(ictx.lookup("FolderSYHome"), FolderHome.class);
58                 assertNotNull(fhome);
59             } catch (NamingException JavaDoc e) {
60                 fail("Cannot get bean home");
61             }
62         }
63         if (folder == null) {
64             try {
65                 folder = fhome.create();
66                 assertNotNull(folder);
67             } catch (Exception JavaDoc e) {
68                 fail("Cannot create folder session " + e);
69             }
70         }
71     }
72
73  
74     /**
75      * send a reference as argument
76      */

77     public void testSendRef() throws Exception JavaDoc {
78         for (int i = 0; i < 100; i++) {
79             folder.sendRef(folder);
80         }
81     }
82
83     /**
84      * send an int as argument
85      */

86     public void testSendInt() throws Exception JavaDoc {
87         for (int i = 0; i < 100; i++) {
88             folder.sendInt(1);
89         }
90     }
91
92     /**
93      * send and get a reference as argument
94      */

95     public void testGetRef() throws Exception JavaDoc {
96         for (int i = 0; i < 100; i++) {
97             folder.getRef(folder);
98         }
99     }
100
101     /**
102      * send and get an int as argument
103      */

104     public void testGetInt() throws Exception JavaDoc {
105         for (int i = 0; i < 100; i++) {
106             folder.getInt(1);
107         }
108     }
109
110     /**
111      * send a reference as argument
112      */

113     public void testSendRefTS() throws Exception JavaDoc {
114         for (int i = 0; i < 100; i++) {
115             folder.sendRefTS(folder);
116         }
117     }
118
119     /**
120      * send an int as argument
121      */

122     public void testSendIntTS() throws Exception JavaDoc {
123         for (int i = 0; i < 100; i++) {
124             folder.sendIntTS(1);
125         }
126     }
127
128     /**
129      * send and get a reference as argument
130      */

131     public void testGetRefTS() throws Exception JavaDoc {
132         for (int i = 0; i < 100; i++) {
133             folder.getRefTS(folder);
134         }
135     }
136
137     /**
138      * send and get an int as argument
139      */

140     public void testGetIntTS() throws Exception JavaDoc {
141         for (int i = 0; i < 100; i++) {
142             folder.getIntTS(1);
143         }
144     }
145     
146     /**
147      * send and get an array of long as argument
148      */

149     public void testGetArray() throws Exception JavaDoc {
150         for (int i = 0; i < 100; i++) {
151             long[] arr = folder.getArray();
152         }
153     }
154     public void testSendArray() throws Exception JavaDoc {
155        for (int i = 0; i < 100; i++) {
156             long[] arr;
157             arr = new long[100];
158             for (int j = 0; j < 100; j++) {
159                 arr[j] = j;
160             }
161             folder.sendArray(arr);
162  
163        }
164     }
165     public static Test suite() {
166         return new TestSuite(G_Frontal.class);
167     }
168
169     public static void main (String JavaDoc args[]) {
170         String JavaDoc testtorun = null;
171         // Get args
172
for (int argn = 0; argn < args.length; argn++) {
173             String JavaDoc s_arg = args[argn];
174             Integer JavaDoc i_arg;
175             if (s_arg.equals("-n")) {
176                 testtorun = args[++argn];
177             }
178         }
179         if (testtorun == null) {
180             junit.textui.TestRunner.run(suite());
181         } else {
182             junit.textui.TestRunner.run(new G_Frontal(testtorun));
183         }
184     }
185 }
186
Popular Tags