1 22 package org.jboss.test.helloiiop.test; 23 24 25 import javax.naming.Context ; 26 import javax.rmi.PortableRemoteObject ; 27 28 import junit.framework.Test; 29 import org.jboss.test.JBossIIOPTestCase; 30 import org.jboss.test.helloiiop.interfaces.Hello; 31 import org.jboss.test.helloiiop.interfaces.HelloData; 32 import org.jboss.test.helloiiop.interfaces.HelloHome; 33 34 35 40 public class HelloTimingStressTestCase 41 extends JBossIIOPTestCase 42 { 43 45 47 49 public HelloTimingStressTestCase(String name) 51 { 52 super(name); 53 } 54 55 56 58 63 public void testHello() 64 throws Exception 65 { 66 HelloHome home = (HelloHome)PortableRemoteObject.narrow( 67 getInitialContext().lookup(HelloHome.JNDI_NAME), 68 HelloHome.class); 69 Hello hello = home.create(); 70 getLog().debug(hello.hello("World")); 71 hello.remove(); 72 } 73 74 79 public void testData() 80 throws Exception 81 { 82 HelloHome home = (HelloHome)PortableRemoteObject.narrow( 83 getInitialContext().lookup(HelloHome.JNDI_NAME), 84 HelloHome.class); 85 Hello hello = home.create(); 86 HelloData name = new HelloData(); 87 name.setName("World"); 88 getLog().debug(hello.howdy(name)); 89 hello.remove(); 90 } 91 92 97 public void testSpeed() 98 throws Exception 99 { 100 long start = System.currentTimeMillis(); 101 HelloHome home = (HelloHome)PortableRemoteObject.narrow( 102 getInitialContext().lookup(HelloHome.JNDI_NAME), 103 HelloHome.class); 104 Hello hello = home.create(); 105 for (int i = 0 ; i < getIterationCount(); i++) 106 { 107 hello.hello("Rickard"); 108 } 109 long end = System.currentTimeMillis(); 110 getLog().debug("Avg. time/call(ms):"+((end-start)/getIterationCount())); 111 } 112 113 118 public void testSpeed2() 119 throws Exception 120 { 121 long start = System.currentTimeMillis(); 122 long start2 = start; 123 HelloHome home = (HelloHome)PortableRemoteObject.narrow( 124 getInitialContext().lookup(HelloHome.JNDI_NAME), 125 HelloHome.class); 126 Hello hello = home.create(); 127 for (int i = 0 ; i < getIterationCount(); i++) 128 { 129 hello.helloHello(hello); 130 } 131 long end = System.currentTimeMillis(); 132 getLog().debug("Avg. time/call(ms):"+((end-start)/getIterationCount())); 133 } 134 135 140 public void testContextSpeed() 141 throws Exception 142 { 143 long start = System.currentTimeMillis(); 144 145 getLog().debug("Starting context lookup speed test"); 146 for (int i = 0; i < getIterationCount(); i++) 147 { 148 HelloHome home = (HelloHome)PortableRemoteObject.narrow( 149 getInitialContext().lookup(HelloHome.JNDI_NAME), 150 HelloHome.class); 151 } 152 long end = System.currentTimeMillis(); 153 getLog().debug("Avg. time/call(ms):"+((end-start)/getIterationCount())); 154 } 155 156 161 public void testReusedContextSpeed() 162 throws Exception 163 { 164 Context ctx = getInitialContext(); 165 long start = System.currentTimeMillis(); 166 167 getLog().debug("Starting context lookup speed test"); 168 for (int i = 0; i < getIterationCount(); i++) 169 { 170 HelloHome home = (HelloHome)PortableRemoteObject.narrow( 171 ctx.lookup(HelloHome.JNDI_NAME), 172 HelloHome.class); 173 } 174 long end = System.currentTimeMillis(); 175 getLog().debug("Avg. time/call(ms):"+((end-start)/getIterationCount())); 176 } 177 178 public static Test suite() throws Exception 179 { 180 return getDeploySetup(HelloTimingStressTestCase.class, "helloiiop.jar"); 181 } 182 183 } 184 | Popular Tags |