1 22 23 package org.jboss.ejb3.test.localcall.unit; 24 25 import javax.naming.InitialContext ; 26 import org.jboss.ejb3.test.localcall.ServiceRemote; 27 import org.jboss.ejb3.test.localcall.StatefulClustered; 28 import org.jboss.ejb3.test.localcall.StatefulRemote; 29 import org.jboss.ejb3.test.localcall.StatelessClustered; 30 import org.jboss.ejb3.test.localcall.StatelessRemote; 31 import org.jboss.test.JBossTestCase; 32 import junit.framework.Test; 33 34 39 public class TestLocalCallsTestCase extends JBossTestCase 40 { 41 public TestLocalCallsTestCase(String name) 42 { 43 super(name); 44 45 } 46 47 public void testRemoteIfLocalCalls() throws Exception 48 { 49 System.out.println("Testing local"); 50 InitialContext ctx = getInitialContext(); 51 StatefulRemote stateful1 = (StatefulRemote)ctx.lookup("StatefulBean/remote"); 52 StatefulRemote stateful2 = (StatefulRemote)ctx.lookup("StatefulBean/remote"); 53 54 StatefulClustered statefulClustered1 = (StatefulClustered)ctx.lookup("StatefulClusteredBean/remote"); 55 StatefulClustered statefulClustered2 = (StatefulClustered)ctx.lookup("StatefulClusteredBean/remote"); 56 57 StatelessRemote stateless1 = (StatelessRemote)ctx.lookup("StatelessBean/remote"); 58 StatelessRemote stateless2 = (StatelessRemote)ctx.lookup("StatelessBean/remote"); 59 60 StatelessClustered statelessClustered1 = (StatelessClustered)ctx.lookup("StatelessClusteredBean/remote"); 61 StatelessClustered statelessClustered2 = (StatelessClustered)ctx.lookup("StatelessClusteredBean/remote"); 62 63 ServiceRemote service1 = (ServiceRemote)ctx.lookup("ServiceBean/remote"); 64 ServiceRemote service2 = (ServiceRemote)ctx.lookup("ServiceBean/remote"); 65 66 stateful1.test(); 67 stateful2.test(); 68 statefulClustered1.test(); 69 statefulClustered2.test(); 70 stateless1.test(); 71 stateless2.test(); 72 statelessClustered1.test(); 73 statelessClustered2.test(); 74 service1.test(); 75 service2.test(); 76 77 assertFalse(stateful1.hashCode() == stateful2.hashCode()); 78 assertFalse(statefulClustered1.hashCode() == statefulClustered2.hashCode()); 79 assertTrue(stateless1.hashCode() == stateless2.hashCode()); 80 assertTrue(statelessClustered1.hashCode() == statelessClustered2.hashCode()); 81 assertTrue(service1.hashCode() == service2.hashCode()); 82 83 assertFalse(stateful1.equals(stateful2)); 84 assertFalse(statefulClustered1.equals(statefulClustered2)); 85 assertTrue(stateless1.equals(stateless2)); 86 assertTrue(statelessClustered1.equals(statelessClustered2)); 87 assertTrue(service1.equals(service2)); 88 89 } 90 91 public void testLocalIfLocalCalls() throws Exception 92 { 93 System.out.println("TESTING LOCAL CALLS"); 94 InitialContext ctx = getInitialContext(); 95 ServiceRemote service = (ServiceRemote)ctx.lookup("ServiceBean/remote"); 96 service.testLocal(); 97 } 98 99 public static Test suite() throws Exception 100 { 101 return getDeploySetup(TestLocalCallsTestCase.class, "localcall-test.jar"); 102 } 103 } 104 | Popular Tags |