1 17 18 package org.sape.carbon.services.ejb.local.test; 19 20 21 import javax.ejb.EJBHome ; 22 23 import org.sape.carbon.core.component.Lookup; 24 import org.sape.carbon.core.exception.ExceptionUtility; 25 import org.sape.carbon.services.ejb.remote.RemoteHomeFactory; 26 27 import junit.framework.Test; 28 import junit.framework.TestCase; 29 import junit.framework.TestSuite; 30 31 public class LocalHomeCachePerformanceTest extends TestCase { 32 33 36 public static final String TEST_REMOTE_HOME_FACTORY = 37 "/ejb/test/RemoteHomeFactoryTest"; 38 39 40 43 public static final String TEST_REMOTE_EJB = 44 "org.sape.carbon.services.ejb.local.test.LocalGateway"; 45 46 47 50 public static final long TEST_LOOKUP_ITERATIONS = 2000; 51 52 53 public LocalHomeCachePerformanceTest(String name) { 54 super(name); 55 } 56 57 58 public static void main(String args[]) throws Exception { 59 } 60 61 62 66 public void testLocalHomeCachePerformance() { 67 68 long startTime = 0; 69 long elapsedTime = 0; 70 71 RemoteHomeFactory homeFactory = (RemoteHomeFactory) 72 Lookup.getInstance().fetchComponent(TEST_REMOTE_HOME_FACTORY); 73 74 try { 76 EJBHome ejbHome = 77 homeFactory.lookup("org.sape.carbon.services.ejb.local.test.LocalGateway"); 78 79 LocalGateway gateway = ((LocalGatewayHome) ejbHome).create(); 80 81 gateway.testLocalHomeCachePerformance(); 82 } catch (Exception e) { 83 fail("Test of EJB home cache performance for LocalHomeFactory " 84 + "failed due to: " 85 + e 86 + ": " 87 + ExceptionUtility.printStackTracesToString(e)); 88 } 89 } 90 91 95 public static Test suite() { 96 97 TestSuite test = new TestSuite(); 98 99 test.addTest(new LocalHomeCachePerformanceTest( 100 "testLocalHomeCachePerformance")); 101 102 return test; 103 } 104 } 105 | Popular Tags |