1 22 package org.jboss.test.hello.test; 23 24 25 import javax.ejb.*; 26 import javax.naming.*; 27 28 import org.jboss.test.hello.interfaces.*; 29 30 import junit.framework.Test; 31 import junit.framework.TestCase; 32 import junit.framework.TestSuite; 33 import org.jboss.test.JBossTestCase; 34 35 36 41 public class HelloTimingStressTestCase 42 extends JBossTestCase 43 { 44 46 48 static boolean deployed = false; 50 51 public HelloTimingStressTestCase(String name) 53 { 54 super(name); 55 } 56 57 59 64 public void testHello() 65 throws Exception 66 { 67 HelloHome home = (HelloHome)getInitialContext().lookup(HelloHome.JNDI_NAME); 68 Hello hello = home.create(); 69 getLog().debug(hello.hello("World")); 70 hello.remove(); 71 } 72 73 78 public void testData() 79 throws Exception 80 { 81 HelloHome home = (HelloHome)getInitialContext().lookup(HelloHome.JNDI_NAME); 82 Hello hello = home.create(); 83 HelloData name = new HelloData(); 84 name.setName("World"); 85 getLog().debug(hello.howdy(name)); 86 hello.remove(); 87 } 88 89 94 public void testSpeed() 95 throws Exception 96 { 97 long start = System.currentTimeMillis(); 98 HelloHome home = (HelloHome)getInitialContext().lookup(HelloHome.JNDI_NAME); 99 Hello hello = home.create(); 100 for (int i = 0 ; i < getIterationCount(); i++) 101 { 102 hello.hello("Rickard"); 103 } 104 long end = System.currentTimeMillis(); 105 getLog().debug("Avg. time/call(ms):"+((end-start)/getIterationCount())); 106 } 107 108 113 public void testSpeed2() 114 throws Exception 115 { 116 long start = System.currentTimeMillis(); 117 long start2 = start; 118 HelloHome home = (HelloHome)getInitialContext().lookup(HelloHome.JNDI_NAME); 119 Hello hello = home.create(); 120 for (int i = 0 ; i < getIterationCount(); i++) 121 { 122 hello.helloHello(hello); 123 } 124 long end = System.currentTimeMillis(); 125 getLog().debug("Avg. time/call(ms):"+((end-start)/getIterationCount())); 126 } 127 128 133 public void testContextSpeed() 134 throws Exception 135 { 136 long start = System.currentTimeMillis(); 137 138 getLog().debug("Starting context lookup speed test"); 139 for (int i = 0; i < getIterationCount(); i++) 140 { 141 HelloHome home = (HelloHome)new InitialContext().lookup(HelloHome.JNDI_NAME); 142 } 143 long end = System.currentTimeMillis(); 144 getLog().debug("Avg. time/call(ms):"+((end-start)/getIterationCount())); 145 } 146 147 152 public void testReusedContextSpeed() 153 throws Exception 154 { 155 Context ctx = getInitialContext(); 156 long start = System.currentTimeMillis(); 157 158 getLog().debug("Starting context lookup speed test"); 159 for (int i = 0; i < getIterationCount(); i++) 160 { 161 HelloHome home = (HelloHome)ctx.lookup(HelloHome.JNDI_NAME); 162 } 163 long end = System.currentTimeMillis(); 164 getLog().debug("Avg. time/call(ms):"+((end-start)/getIterationCount())); 165 } 166 167 168 public static Test suite() throws Exception 169 { 170 return getDeploySetup(HelloTimingStressTestCase.class, "hello.jar"); 171 } 172 173 } 174 | Popular Tags |