KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > iiopperf > test > T2PassRemoteRefTestCase


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.test.iiopperf.test;
23
24
25 import javax.ejb.*;
26 import javax.naming.*;
27 import javax.rmi.PortableRemoteObject JavaDoc;
28
29 import org.jboss.test.iiopperf.interfaces.*;
30
31 import junit.framework.Test;
32 import junit.framework.TestCase;
33 import junit.framework.TestSuite;
34 import org.jboss.test.JBossTestCase;
35
36
37 /**
38  * @author Francisco.Reverbel@jboss.org
39  * @version $Revision: 37406 $
40  */

41 public class T2PassRemoteRefTestCase
42    extends JBossTestCase
43 {
44    // Constants -----------------------------------------------------
45

46    // Attributes ----------------------------------------------------
47
private java.util.Properties JavaDoc cosnamingJndiProps;
48
49    // Static --------------------------------------------------------
50

51    // Constructors --------------------------------------------------
52
public T2PassRemoteRefTestCase(String JavaDoc name)
53        throws java.io.IOException JavaDoc
54    {
55       super(name);
56       java.net.URL JavaDoc url;
57
58       url = ClassLoader.getSystemResource("cosnaming.jndi.properties");
59       cosnamingJndiProps = new java.util.Properties JavaDoc();
60       cosnamingJndiProps.load(url.openStream());
61    }
62    
63    // Package --------------------------------------------------------
64

65    InitialContext getInitialContext(java.util.Properties JavaDoc jndiProps)
66        throws Exception JavaDoc
67    {
68       return new InitialContext(jndiProps);
69    }
70
71    // Public --------------------------------------------------------
72

73    /**
74     * This tests the speed of JRMP sendRemote invocations
75     *
76     * @exception Exception
77     */

78    public void testJRMPSendRemote()
79       throws Exception JavaDoc
80    {
81       SessionHome home = (SessionHome)PortableRemoteObject.narrow(
82             getInitialContext().lookup(SessionHome.JNDI_NAME),
83             SessionHome.class);
84       Session session = home.create();
85       int n = getIterationCount();
86       long start = System.currentTimeMillis();
87       for (int i = 0 ; i < n; i++)
88       {
89          session.sendRemote(session);
90       }
91       long end = System.currentTimeMillis();
92       getLog().info("JRMP sendRemote: " +
93                     ((end - start) / (double)n) + " ms/call");
94    }
95    
96    /**
97     * This tests the speed of IIOP sendRemote invocations
98     *
99     * @exception Exception
100     */

101    public void testIIOPSendRemote()
102       throws Exception JavaDoc
103    {
104       SessionHome home = (SessionHome)PortableRemoteObject.narrow(
105             getInitialContext(cosnamingJndiProps).lookup(SessionHome.JNDI_NAME),
106             SessionHome.class);
107       Session session = home.create();
108       int n = getIterationCount();
109       long start = System.currentTimeMillis();
110       for (int i = 0 ; i < n; i++)
111       {
112          session.sendRemote(session);
113       }
114       long end = System.currentTimeMillis();
115       getLog().info("IIOP sendRemote: " +
116                     ((end - start) / (double)n) + " ms/call");
117    }
118    
119    /**
120     * This tests the speed of JRMP receiveRemote invocations
121     *
122     * @exception Exception
123     */

124    public void testJRMPReceiveRemote()
125       throws Exception JavaDoc
126    {
127       SessionHome home = (SessionHome)PortableRemoteObject.narrow(
128             getInitialContext().lookup(SessionHome.JNDI_NAME),
129             SessionHome.class);
130       Session session = home.create();
131       session.sendRemote(session);
132       int n = getIterationCount();
133       long start = System.currentTimeMillis();
134       for (int i = 0 ; i < n; i++)
135       {
136          session.receiveRemote();
137       }
138       long end = System.currentTimeMillis();
139       getLog().info("JRMP receiveRemote: " +
140                     ((end - start) / (double)n) + " ms/call");
141    }
142    
143    /**
144     * This tests the speed of IIOP receiveRemote invocations
145     *
146     * @exception Exception
147     */

148    public void testIIOPReceiveRemote()
149       throws Exception JavaDoc
150    {
151       SessionHome home = (SessionHome)PortableRemoteObject.narrow(
152             getInitialContext(cosnamingJndiProps).lookup(SessionHome.JNDI_NAME),
153             SessionHome.class);
154       Session session = home.create();
155       session.sendRemote(session);
156       int n = getIterationCount();
157       long start = System.currentTimeMillis();
158       for (int i = 0 ; i < n; i++)
159       {
160          session.receiveRemote();
161       }
162       long end = System.currentTimeMillis();
163       getLog().info("IIOP receiveRemote: " +
164                     ((end - start) / (double)n) + " ms/call");
165    }
166    
167    /**
168     * This tests the speed of JRMP sendReceiveRemote invocations
169     *
170     * @exception Exception
171     */

172    public void testJRMPSendReceiveRemote()
173       throws Exception JavaDoc
174    {
175       SessionHome home = (SessionHome)PortableRemoteObject.narrow(
176             getInitialContext().lookup(SessionHome.JNDI_NAME),
177             SessionHome.class);
178       Session session = home.create();
179       int n = getIterationCount();
180       long start = System.currentTimeMillis();
181       for (int i = 0 ; i < n; i++)
182       {
183          session.sendReceiveRemote(session);
184       }
185       long end = System.currentTimeMillis();
186       getLog().info("JRMP sendReceiveRemote: " +
187                     ((end - start) / (double)n) + " ms/call");
188    }
189    
190    /**
191     * This tests the speed of IIOP sendReceiveRemote invocations
192     *
193     * @exception Exception
194     */

195    public void testIIOPSendReceiveRemote()
196       throws Exception JavaDoc
197    {
198       SessionHome home = (SessionHome)PortableRemoteObject.narrow(
199             getInitialContext(cosnamingJndiProps).lookup(SessionHome.JNDI_NAME),
200             SessionHome.class);
201       Session session = home.create();
202       int n = getIterationCount();
203       long start = System.currentTimeMillis();
204       for (int i = 0 ; i < n; i++)
205       {
206          session.sendReceiveRemote(session);
207       }
208       long end = System.currentTimeMillis();
209       getLog().info("IIOP sendReceiveRemote: " +
210                     ((end - start) / (double)n) + " ms/call");
211    }
212    
213    /**
214     * This tests the speed of JRMP sendSessionRef invocations
215     *
216     * @exception Exception
217     */

218    public void testJRMPSendSessionRef()
219       throws Exception JavaDoc
220    {
221       SessionHome home = (SessionHome)PortableRemoteObject.narrow(
222             getInitialContext().lookup(SessionHome.JNDI_NAME),
223             SessionHome.class);
224       Session session = home.create();
225       int n = getIterationCount();
226       long start = System.currentTimeMillis();
227       for (int i = 0 ; i < n; i++)
228       {
229          session.sendSessionRef(session);
230       }
231       long end = System.currentTimeMillis();
232       getLog().info("JRMP sendSessionRef: " +
233                     ((end - start) / (double)n) + " ms/call");
234    }
235    
236    /**
237     * This tests the speed of IIOP sendSessionRef invocations
238     *
239     * @exception Exception
240     */

241    public void testIIOPSendSessionRef()
242       throws Exception JavaDoc
243    {
244       SessionHome home = (SessionHome)PortableRemoteObject.narrow(
245             getInitialContext(cosnamingJndiProps).lookup(SessionHome.JNDI_NAME),
246             SessionHome.class);
247       Session session = home.create();
248       int n = getIterationCount();
249       long start = System.currentTimeMillis();
250       for (int i = 0 ; i < n; i++)
251       {
252          session.sendSessionRef(session);
253       }
254       long end = System.currentTimeMillis();
255       getLog().info("IIOP sendSessionRef: " +
256                     ((end - start) / (double)n) + " ms/call");
257    }
258    
259    /**
260     * This tests the speed of JRMP receiveSessionRef invocations
261     *
262     * @exception Exception
263     */

264    public void testJRMPReceiveSessionRef()
265       throws Exception JavaDoc
266    {
267       SessionHome home = (SessionHome)PortableRemoteObject.narrow(
268             getInitialContext().lookup(SessionHome.JNDI_NAME),
269             SessionHome.class);
270       Session session = home.create();
271       session.sendSessionRef(session);
272       int n = getIterationCount();
273       long start = System.currentTimeMillis();
274       for (int i = 0 ; i < n; i++)
275       {
276          session.receiveSessionRef();
277       }
278       long end = System.currentTimeMillis();
279       getLog().info("JRMP receiveSessionRef: " +
280                     ((end - start) / (double)n) + " ms/call");
281    }
282    
283    /**
284     * This tests the speed of IIOP receiveSessionRef invocations
285     *
286     * @exception Exception
287     */

288    public void testIIOPReceiveSessionRef()
289       throws Exception JavaDoc
290    {
291       SessionHome home = (SessionHome)PortableRemoteObject.narrow(
292             getInitialContext(cosnamingJndiProps).lookup(SessionHome.JNDI_NAME),
293             SessionHome.class);
294       Session session = home.create();
295       session.sendSessionRef(session);
296       int n = getIterationCount();
297       long start = System.currentTimeMillis();
298       for (int i = 0 ; i < n; i++)
299       {
300          session.receiveSessionRef();
301       }
302       long end = System.currentTimeMillis();
303       getLog().info("IIOP receiveSessionRef: " +
304                     ((end - start) / (double)n) + " ms/call");
305    }
306    
307    /**
308     * This tests the speed of JRMP sendReceiveSessionRef invocations
309     *
310     * @exception Exception
311     */

312    public void testJRMPSendReceiveSessionRef()
313       throws Exception JavaDoc
314    {
315       SessionHome home = (SessionHome)PortableRemoteObject.narrow(
316             getInitialContext().lookup(SessionHome.JNDI_NAME),
317             SessionHome.class);
318       Session session = home.create();
319       int n = getIterationCount();
320       long start = System.currentTimeMillis();
321       for (int i = 0 ; i < n; i++)
322       {
323          session.sendReceiveSessionRef(session);
324       }
325       long end = System.currentTimeMillis();
326       getLog().info("JRMP sendReceiveSessionRef: " +
327                     ((end - start) / (double)n) + " ms/call");
328    }
329    
330    /**
331     * This tests the speed of IIOP sendReceiveSessionRef invocations
332     *
333     * @exception Exception
334     */

335    public void testIIOPSendReceiveSessionRef()
336       throws Exception JavaDoc
337    {
338       SessionHome home = (SessionHome)PortableRemoteObject.narrow(
339             getInitialContext(cosnamingJndiProps).lookup(SessionHome.JNDI_NAME),
340             SessionHome.class);
341       Session session = home.create();
342       int n = getIterationCount();
343       long start = System.currentTimeMillis();
344       for (int i = 0 ; i < n; i++)
345       {
346          session.sendReceiveSessionRef(session);
347       }
348       long end = System.currentTimeMillis();
349       getLog().info("IIOP sendReceiveSessionRef: " +
350                     ((end - start) / (double)n) + " ms/call");
351    }
352    
353    public static Test suite() throws Exception JavaDoc
354    {
355       return getDeploySetup(T2PassRemoteRefTestCase.class, "iiopperf.jar");
356    }
357
358 }
359
Popular Tags