KickJava   Java API By Example, From Geeks To Geeks.

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


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 T3PassSerializableTestCase
42    extends JBossTestCase
43 {
44    // Constants -----------------------------------------------------
45

46    // Attributes ----------------------------------------------------
47
private java.util.Properties JavaDoc cosnamingJndiProps;
48    Foo foo = new Foo(7, "This is a serializable object.");
49    CMFoo cmfoo = new CMFoo(7, "This is a serializable object.");
50    Zoo zoo = new Zoo("Outer", "This is the outer serializable object.",
51                      new Zoo("Inner", "This is the inner serializable object."));
52    
53    // Static --------------------------------------------------------
54

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

69    InitialContext getInitialContext(java.util.Properties JavaDoc jndiProps)
70        throws Exception JavaDoc
71    {
72       return new InitialContext(jndiProps);
73    }
74
75    // Public --------------------------------------------------------
76

77    /**
78     * This tests the speed of JRMP sendSimpleSerializable invocations
79     *
80     * @exception Exception
81     */

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

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

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

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

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

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

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

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

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

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

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

339    public void testIIOPSendReceiveSimpleCustomMarshalledSerializable()
340       throws Exception JavaDoc
341    {
342       SessionHome home = (SessionHome)PortableRemoteObject.narrow(
343             getInitialContext(cosnamingJndiProps).lookup(SessionHome.JNDI_NAME),
344             SessionHome.class);
345       Session session = home.create();
346       int n = getIterationCount();
347       long start = System.currentTimeMillis();
348       for (int i = 0 ; i < n; i++)
349       {
350          session.sendReceiveSimpleCustomMarshalledSerializable(cmfoo);
351       }
352       long end = System.currentTimeMillis();
353       getLog().info("IIOP sendReceiveSimpleCustomMarshalledSerializable: " +
354                     ((end - start) / (double)n) + " ms/call");
355    }
356    
357    /**
358     * This tests the speed of JRMP sendNestedSerializable invocations
359     *
360     * @exception Exception
361     */

362    public void testJRMPSendNestedSerializable()
363       throws Exception JavaDoc
364    {
365       SessionHome home = (SessionHome)PortableRemoteObject.narrow(
366             getInitialContext().lookup(SessionHome.JNDI_NAME),
367             SessionHome.class);
368       Session session = home.create();
369       int n = getIterationCount();
370       long start = System.currentTimeMillis();
371       for (int i = 0 ; i < n; i++)
372       {
373          session.sendNestedSerializable(zoo);
374       }
375       long end = System.currentTimeMillis();
376       getLog().info("JRMP sendNestedSerializable: " +
377                     ((end - start) / (double)n) + " ms/call");
378    }
379    
380    /**
381     * This tests the speed of IIOP sendNestedSerializable invocations
382     *
383     * @exception Exception
384     */

385    public void testIIOPSendNestedSerializable()
386       throws Exception JavaDoc
387    {
388       SessionHome home = (SessionHome)PortableRemoteObject.narrow(
389             getInitialContext(cosnamingJndiProps).lookup(SessionHome.JNDI_NAME),
390             SessionHome.class);
391       Session session = home.create();
392       int n = getIterationCount();
393       long start = System.currentTimeMillis();
394       for (int i = 0 ; i < n; i++)
395       {
396          session.sendNestedSerializable(zoo);
397       }
398       long end = System.currentTimeMillis();
399       getLog().info("IIOP sendNestedSerializable: " +
400                     ((end - start) / (double)n) + " ms/call");
401    }
402    
403    /**
404     * This tests the speed of JRMP receiveNestedSerializable invocations
405     *
406     * @exception Exception
407     */

408    public void testJRMPReceiveNestedSerializable()
409       throws Exception JavaDoc
410    {
411       SessionHome home = (SessionHome)PortableRemoteObject.narrow(
412             getInitialContext().lookup(SessionHome.JNDI_NAME),
413             SessionHome.class);
414       Session session = home.create();
415       session.sendNestedSerializable(zoo);
416       int n = getIterationCount();
417       long start = System.currentTimeMillis();
418       for (int i = 0 ; i < n; i++)
419       {
420          session.receiveNestedSerializable();
421       }
422       long end = System.currentTimeMillis();
423       getLog().info("JRMP receiveNestedSerializable: " +
424                     ((end - start) / (double)n) + " ms/call");
425    }
426    
427    /**
428     * This tests the speed of IIOP receiveNestedSerializable invocations
429     *
430     * @exception Exception
431     */

432    public void testIIOPReceiveNestedSerializable()
433       throws Exception JavaDoc
434    {
435       SessionHome home = (SessionHome)PortableRemoteObject.narrow(
436             getInitialContext(cosnamingJndiProps).lookup(SessionHome.JNDI_NAME),
437             SessionHome.class);
438       Session session = home.create();
439       session.sendNestedSerializable(zoo);
440       int n = getIterationCount();
441       long start = System.currentTimeMillis();
442       for (int i = 0 ; i < n; i++)
443       {
444          session.receiveNestedSerializable();
445       }
446       long end = System.currentTimeMillis();
447       getLog().info("IIOP receiveNestedSerializable: " +
448                     ((end - start) / (double)n) + " ms/call");
449    }
450    
451    /**
452     * This tests the speed of JRMP sendReceiveNestedSerializable invocations
453     *
454     * @exception Exception
455     */

456    public void testJRMPSendReceiveNestedSerializable()
457       throws Exception JavaDoc
458    {
459       SessionHome home = (SessionHome)PortableRemoteObject.narrow(
460             getInitialContext().lookup(SessionHome.JNDI_NAME),
461             SessionHome.class);
462       Session session = home.create();
463       int n = getIterationCount();
464       long start = System.currentTimeMillis();
465       for (int i = 0 ; i < n; i++)
466       {
467          session.sendReceiveNestedSerializable(zoo);
468       }
469       long end = System.currentTimeMillis();
470       getLog().info("JRMP sendReceiveNestedSerializable: " +
471                     ((end - start) / (double)n) + " ms/call");
472    }
473    
474    /**
475     * This tests the speed of IIOP sendReceiveNestedSerializable invocations
476     *
477     * @exception Exception
478     */

479    public void testIIOPSendReceiveNestedSerializable()
480       throws Exception JavaDoc
481    {
482       SessionHome home = (SessionHome)PortableRemoteObject.narrow(
483             getInitialContext(cosnamingJndiProps).lookup(SessionHome.JNDI_NAME),
484             SessionHome.class);
485       Session session = home.create();
486       int n = getIterationCount();
487       long start = System.currentTimeMillis();
488       for (int i = 0 ; i < n; i++)
489       {
490          session.sendReceiveNestedSerializable(zoo);
491       }
492       long end = System.currentTimeMillis();
493       getLog().info("IIOP sendReceiveNestedSerializable: " +
494                     ((end - start) / (double)n) + " ms/call");
495    }
496
497    public static Test suite() throws Exception JavaDoc
498    {
499       return getDeploySetup(T3PassSerializableTestCase.class, "iiopperf.jar");
500    }
501
502 }
503
Popular Tags