1 22 package org.jboss.test.naming.test; 23 24 import javax.naming.InitialContext ; 25 import javax.rmi.PortableRemoteObject ; 26 27 import junit.framework.Test; 28 import junit.framework.TestCase; 29 import junit.framework.TestSuite; 30 31 import org.jboss.test.JBossTestCase; 32 import org.jboss.test.naming.interfaces.TestEjbLinkHome; 33 import org.jboss.test.naming.interfaces.TestEjbLink; 34 35 40 public class EjbLinkUnitTestCase extends JBossTestCase 41 { 42 47 public EjbLinkUnitTestCase(String name) 48 { 49 super(name); 50 } 51 52 57 public void testEjbLinkNamed() throws Exception 58 { 59 Object obj = getInitialContext().lookup("naming/SessionB"); 60 obj = PortableRemoteObject.narrow(obj, TestEjbLinkHome.class); 61 TestEjbLinkHome home = (TestEjbLinkHome)obj; 62 getLog().debug("Found naming/SessionB"); 63 64 TestEjbLink bean = home.create(); 65 getLog().debug("Created the bean"); 66 assertEquals("Works", bean.testEjbLinkCaller("java:comp/env/ejb/SessionA")); 67 getLog().debug("Test succeeded"); 68 bean.remove(); 69 } 70 71 76 public void testEjbLinkRelative() throws Exception 77 { 78 Object obj = getInitialContext().lookup("naming/SessionB"); 79 obj = PortableRemoteObject.narrow(obj, TestEjbLinkHome.class); 80 TestEjbLinkHome home = (TestEjbLinkHome)obj; 81 getLog().debug("Found naming/SessionB"); 82 83 TestEjbLink bean = home.create(); 84 getLog().debug("Created the bean"); 85 assertEquals("Works", bean.testEjbLinkCaller("java:comp/env/ejb/RelativeSessionA")); 86 getLog().debug("Test succeeded"); 87 bean.remove(); 88 } 89 90 95 public void testEjbLinkLocalNamed() throws Exception 96 { 97 Object obj = getInitialContext().lookup("naming/SessionB"); 98 obj = PortableRemoteObject.narrow(obj, TestEjbLinkHome.class); 99 TestEjbLinkHome home = (TestEjbLinkHome)obj; 100 getLog().debug("Found naming/SessionB"); 101 102 TestEjbLink bean = home.create(); 103 getLog().debug("Created the bean"); 104 assertEquals("Works", bean.testEjbLinkCallerLocal("java:comp/env/ejb/LocalSessionA")); 105 getLog().debug("Test succeeded"); 106 bean.remove(); 107 } 108 109 114 public void testEjbLinkLocalRelative() throws Exception 115 { 116 Object obj = getInitialContext().lookup("naming/SessionB"); 117 obj = PortableRemoteObject.narrow(obj, TestEjbLinkHome.class); 118 TestEjbLinkHome home = (TestEjbLinkHome)obj; 119 getLog().debug("Found naming/SessionB"); 120 121 TestEjbLink bean = home.create(); 122 getLog().debug("Created the bean"); 123 assertEquals("Works", bean.testEjbLinkCallerLocal("java:comp/env/ejb/LocalRelativeSessionA")); 124 getLog().debug("Test succeeded"); 125 bean.remove(); 126 } 127 128 129 public void testEjbNoLinkLocal () throws Exception 130 { 131 Object obj = getInitialContext().lookup("naming/SessionB"); 132 obj = PortableRemoteObject.narrow(obj, TestEjbLinkHome.class); 133 TestEjbLinkHome home = (TestEjbLinkHome)obj; 134 getLog().debug("Found naming/SessionB"); 135 136 TestEjbLink bean = home.create(); 137 getLog().debug("Created the bean"); 138 assertEquals("Works", bean.testEjbLinkCallerLocal("java:comp/env/ejb/NoLinkLocalSessionA")); 139 getLog().debug("Test succeeded"); 140 bean.remove(); 141 } 142 143 144 public void testEjbNoLink () throws Exception 145 { 146 Object obj = getInitialContext().lookup("naming/SessionB"); 147 obj = PortableRemoteObject.narrow(obj, TestEjbLinkHome.class); 148 TestEjbLinkHome home = (TestEjbLinkHome)obj; 149 getLog().debug("Found naming/SessionB"); 150 151 TestEjbLink bean = home.create(); 152 getLog().debug("Created the bean"); 153 assertEquals("Works", bean.testEjbLinkCaller("java:comp/env/ejb/NoLinkSessionA")); 154 getLog().debug("Test succeeded"); 155 bean.remove(); 156 } 157 158 public void testEjbNames() throws Exception 159 { 160 Object obj = getInitialContext().lookup("naming/SessionB"); 161 obj = PortableRemoteObject.narrow(obj, TestEjbLinkHome.class); 162 TestEjbLinkHome home = (TestEjbLinkHome) obj; 163 getLog().debug("Found naming/SessionB home: "+home); 164 165 obj = getInitialContext().lookup("naming/SessionB1"); 166 obj = PortableRemoteObject.narrow(obj, TestEjbLinkHome.class); 167 home = (TestEjbLinkHome) obj; 168 getLog().debug("Found naming/SessionB1 home: "+home); 169 } 170 171 public static Test suite() throws Exception 172 { 173 return getDeploySetup(EjbLinkUnitTestCase.class, "naming.ear"); 174 } 175 } 176 | Popular Tags |