1 22 package org.jboss.test.excepiiop.test; 23 24 25 import javax.ejb.*; 26 import javax.naming.*; 27 import javax.rmi.PortableRemoteObject ; 28 29 import org.jboss.test.excepiiop.interfaces.*; 30 31 import junit.framework.Test; 32 import junit.framework.TestCase; 33 import junit.framework.TestSuite; 34 import org.jboss.test.JBossTestCase; 35 import org.jboss.test.JBossIIOPTestCase; 36 37 38 public class ExceptionTimingStressTestCase 39 extends JBossIIOPTestCase 40 { 41 43 45 47 public ExceptionTimingStressTestCase(String name) 49 { 50 super(name); 51 } 52 53 55 public void testNoException() 56 throws Exception 57 { 58 ExceptionThrowerHome home = 59 (ExceptionThrowerHome)PortableRemoteObject.narrow( 60 getInitialContext().lookup(ExceptionThrowerHome.JNDI_NAME), 61 ExceptionThrowerHome.class); 62 ExceptionThrower exceptionThrower = home.create(); 63 exceptionThrower.throwException(0); 64 exceptionThrower.remove(); 65 } 66 67 public void testJavaException() 68 throws Exception 69 { 70 ExceptionThrowerHome home = 71 (ExceptionThrowerHome)PortableRemoteObject.narrow( 72 getInitialContext().lookup(ExceptionThrowerHome.JNDI_NAME), 73 ExceptionThrowerHome.class); 74 ExceptionThrower exceptionThrower = home.create(); 75 try 76 { 77 exceptionThrower.throwException(1); 78 } 79 catch (JavaException e) 80 { 81 System.out.println("JavaException: " + e.i + ", " + e.s); 82 } 83 exceptionThrower.remove(); 84 } 85 86 public void testIdlException() 87 throws Exception 88 { 89 ExceptionThrowerHome home = 90 (ExceptionThrowerHome)PortableRemoteObject.narrow( 91 getInitialContext().lookup(ExceptionThrowerHome.JNDI_NAME), 92 ExceptionThrowerHome.class); 93 ExceptionThrower exceptionThrower = home.create(); 94 try 95 { 96 exceptionThrower.throwException(-1); 97 } 98 catch (IdlException e) 99 { 100 System.out.println("IdlException: " + e.i + ", " + e.s); 101 } 102 exceptionThrower.remove(); 103 } 104 105 110 public void testSpeedNoException() 111 throws Exception 112 { 113 long start = System.currentTimeMillis(); 114 ExceptionThrowerHome home = 115 (ExceptionThrowerHome)PortableRemoteObject.narrow( 116 getInitialContext().lookup(ExceptionThrowerHome.JNDI_NAME), 117 ExceptionThrowerHome.class); 118 ExceptionThrower exceptionThrower = home.create(); 119 for (int i = 0 ; i < getIterationCount(); i++) 120 { 121 exceptionThrower.throwException(0); 122 } 123 long end = System.currentTimeMillis(); 124 getLog().debug("Avg. time/call(ms):"+((end-start)/getIterationCount())); 125 exceptionThrower.remove(); 126 } 127 128 133 public void testSpeedJavaException() 134 throws Exception 135 { 136 long start = System.currentTimeMillis(); 137 ExceptionThrowerHome home = 138 (ExceptionThrowerHome)PortableRemoteObject.narrow( 139 getInitialContext().lookup(ExceptionThrowerHome.JNDI_NAME), 140 ExceptionThrowerHome.class); 141 ExceptionThrower exceptionThrower = home.create(); 142 for (int i = 0 ; i < getIterationCount(); i++) 143 { 144 try 145 { 146 exceptionThrower.throwException(i + 1); 147 } 148 catch (JavaException e) 149 { 150 System.out.println("JavaException: " + e.i + ", " + e.s); 151 } 152 } 153 long end = System.currentTimeMillis(); 154 getLog().debug("Avg. time/call(ms):"+((end-start)/getIterationCount())); 155 exceptionThrower.remove(); 156 } 157 158 163 public void testSpeedIdlException() 164 throws Exception 165 { 166 long start = System.currentTimeMillis(); 167 ExceptionThrowerHome home = 168 (ExceptionThrowerHome)PortableRemoteObject.narrow( 169 getInitialContext().lookup(ExceptionThrowerHome.JNDI_NAME), 170 ExceptionThrowerHome.class); 171 ExceptionThrower exceptionThrower = home.create(); 172 for (int i = 0 ; i < getIterationCount(); i++) 173 { 174 try 175 { 176 exceptionThrower.throwException(-1 - i); 177 } 178 catch (IdlException e) 179 { 180 System.out.println("IdlException: " + e.i + ", " + e.s); 181 } 182 } 183 long end = System.currentTimeMillis(); 184 getLog().debug("Avg. time/call(ms):"+((end-start)/getIterationCount())); 185 exceptionThrower.remove(); 186 } 187 188 public static Test suite() throws Exception 189 { 190 return getDeploySetup(ExceptionTimingStressTestCase.class, "excepiiop.jar"); 191 } 192 193 } 194 | Popular Tags |