1 22 package org.jboss.test.iiopperf.test; 23 24 25 import javax.ejb.*; 26 import javax.naming.*; 27 import javax.rmi.PortableRemoteObject ; 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 41 public class T2PassRemoteRefTestCase 42 extends JBossTestCase 43 { 44 46 private java.util.Properties cosnamingJndiProps; 48 49 51 public T2PassRemoteRefTestCase(String name) 53 throws java.io.IOException 54 { 55 super(name); 56 java.net.URL url; 57 58 url = ClassLoader.getSystemResource("cosnaming.jndi.properties"); 59 cosnamingJndiProps = new java.util.Properties (); 60 cosnamingJndiProps.load(url.openStream()); 61 } 62 63 65 InitialContext getInitialContext(java.util.Properties jndiProps) 66 throws Exception 67 { 68 return new InitialContext(jndiProps); 69 } 70 71 73 78 public void testJRMPSendRemote() 79 throws Exception 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 101 public void testIIOPSendRemote() 102 throws Exception 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 124 public void testJRMPReceiveRemote() 125 throws Exception 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 148 public void testIIOPReceiveRemote() 149 throws Exception 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 172 public void testJRMPSendReceiveRemote() 173 throws Exception 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 195 public void testIIOPSendReceiveRemote() 196 throws Exception 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 218 public void testJRMPSendSessionRef() 219 throws Exception 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 241 public void testIIOPSendSessionRef() 242 throws Exception 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 264 public void testJRMPReceiveSessionRef() 265 throws Exception 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 288 public void testIIOPReceiveSessionRef() 289 throws Exception 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 312 public void testJRMPSendReceiveSessionRef() 313 throws Exception 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 335 public void testIIOPSendReceiveSessionRef() 336 throws Exception 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 354 { 355 return getDeploySetup(T2PassRemoteRefTestCase.class, "iiopperf.jar"); 356 } 357 358 } 359 | Popular Tags |