1 22 package org.jboss.test.testbyvalue.test; 23 24 import java.rmi.*; 25 26 27 import javax.naming.Context ; 28 import javax.naming.InitialContext ; 29 import javax.ejb.DuplicateKeyException ; 30 import javax.ejb.Handle ; 31 import javax.ejb.EJBMetaData ; 32 import javax.ejb.EJBHome ; 33 import javax.ejb.HomeHandle ; 34 import javax.rmi.PortableRemoteObject ; 35 36 import java.util.Date ; 37 38 import junit.framework.Test; 39 import junit.framework.TestCase; 40 import junit.framework.TestSuite; 41 42 import org.jboss.test.JBossTestCase; 43 import org.jboss.test.testbyvalue.interfaces.RootStatelessSessionHome; 44 45 48 public class ByValueUnitTestCase 49 extends JBossTestCase 50 { 51 static boolean deployed = false; 52 static int test = 0; 53 static Date startDate = new Date (); 54 55 protected final String namingFactory = 56 System.getProperty(Context.INITIAL_CONTEXT_FACTORY); 57 58 protected final String providerURL = 59 System.getProperty(Context.PROVIDER_URL); 60 private static final int ITERATIONS = 1000; 61 62 public ByValueUnitTestCase(String name) { 63 super(name); 64 } 65 66 public void testByValue() throws Exception 67 { 68 InitialContext ctx = new InitialContext (); 69 Object obj = ctx.lookup("RootTestByValue"); 70 71 RootStatelessSessionHome home = (RootStatelessSessionHome) PortableRemoteObject.narrow(obj, RootStatelessSessionHome.class); 72 long time = home.create().doTestByValue(ITERATIONS); 73 System.out.println("Time spent into CallByValues over "+ITERATIONS+" iterations=" + time); 75 } 76 77 public void testByValueOnEntity() throws Exception 78 { 79 InitialContext ctx = new InitialContext (); 80 Object obj = ctx.lookup("RootTestByValue"); 81 82 RootStatelessSessionHome home = (RootStatelessSessionHome) PortableRemoteObject.narrow(obj, RootStatelessSessionHome.class); 83 long time = home.create().doTestEntity(ITERATIONS); 84 System.out.println("Time spent into CallByValues over "+ITERATIONS+" iterations=" + time); 86 } 87 88 public void testByReferenceOnEntity() throws Exception 89 { 90 InitialContext ctx = new InitialContext (); 91 Object obj = ctx.lookup("RootTestByValue"); 92 93 RootStatelessSessionHome home = (RootStatelessSessionHome) PortableRemoteObject.narrow(obj, RootStatelessSessionHome.class); 94 long time = home.create().doTestEntityByReference(ITERATIONS); 95 System.out.println("Time spent into CallByValues over "+ITERATIONS+" iterations=" + time); 97 } 98 99 public void testByReference() throws Exception 100 { 101 InitialContext ctx = new InitialContext (); 102 Object obj = ctx.lookup("RootTestByValue"); 103 104 RootStatelessSessionHome home = (RootStatelessSessionHome) PortableRemoteObject.narrow(obj, RootStatelessSessionHome.class); 105 long time = home.create().doTestByReference(ITERATIONS); 106 System.out.println("Time spent into CallByReferences over "+ITERATIONS+" iterations=" + time); 108 } 109 110 public static Test suite() throws Exception 111 { 112 Test t1 = getDeploySetup(ByValueUnitTestCase.class, "jar-byvalue.jar"); 113 return t1; 114 } 115 116 } 117 | Popular Tags |