1 25 26 package org.objectweb.jonas.jtests.clients.local; 27 28 import javax.ejb.EJBException ; 29 import javax.ejb.NoSuchObjectLocalException ; 30 import javax.ejb.RemoveException ; 31 import javax.rmi.PortableRemoteObject ; 32 33 import org.objectweb.jonas.jtests.beans.local.TargetLocal; 34 import org.objectweb.jonas.jtests.beans.local.TargetSLHome; 35 import org.objectweb.jonas.jtests.beans.local.TargetSLLocalHome; 36 import org.objectweb.jonas.jtests.util.JTestCase; 37 38 47 48 public abstract class A_ClientView extends JTestCase { 49 50 public A_ClientView(String name) { 51 super(name); 52 } 53 54 55 56 59 public abstract TargetSLLocalHome getLocalHome() throws Exception ; 60 61 62 63 69 70 public void testLocalLookup() throws Exception { 71 TargetSLLocalHome h = null; 72 h = getLocalHome(); 73 assertTrue(h != null); 74 } 75 76 77 83 public void testEjbRef() throws Exception { 84 85 TargetSLHome home = null; 86 String bName = "java:comp/env/ejb/targetremotelink"; 87 home = (TargetSLHome) PortableRemoteObject.narrow(ictx.lookup(bName), TargetSLHome.class); 88 assertTrue(home != null); 89 } 90 91 97 public void testEjbRefWithJonasEjbRef() throws Exception { 98 99 TargetSLHome home = null; 100 String bName = "java:comp/env/ejb/targetremotenolink"; 101 home = (TargetSLHome) PortableRemoteObject.narrow(ictx.lookup(bName), TargetSLHome.class); 102 assertTrue(home != null); 103 } 104 105 106 112 113 public void testEjbLocalRef() throws Exception { 114 115 TargetSLLocalHome home = null; 116 String bName = "java:comp/env/ejb/targetlocal"; 117 home = (TargetSLLocalHome) ictx.lookup(bName); 118 assertTrue(home != null); 119 } 120 121 122 123 126 public void testLocalCreateRemove() throws Exception { 127 TargetLocal tl = getLocalHome().create(); 128 tl.remove(); 129 } 130 131 132 137 public void testLocalBusinessMethod1() throws Exception { 138 TargetLocal tl = getLocalHome().create(); 139 assertEquals(20, tl.getTwenty()); 140 tl.remove(); 141 try { 142 tl.lmethod2("Bye"); 143 fail("NoSuchObjectLocalException must be raised"); 144 } catch (NoSuchObjectLocalException e) { 145 } 146 } 147 148 149 152 public void testLocalBusinessMethod2() throws Exception { 153 TargetLocal tl = getLocalHome().create(); 154 assertEquals(20, tl.getTwenty()); 155 assertEquals(20, tl.getTwenty()); 156 tl.remove(); 157 } 158 159 162 public void testLocalBusinessMethod3() throws Exception { 163 TargetLocal tl = getLocalHome().create(); 164 assertEquals(20, tl.getTwenty()); 165 tl.lmethod2("Hello"); 166 assertEquals(20, tl.getTwenty()); 167 tl.remove(); 168 } 169 170 171 174 public void testLocalIsIdenticalOnSameBean() throws Exception { 175 TargetLocal tl = getLocalHome().create(); 176 assertTrue(tl.isIdentical(tl)); 177 tl.remove(); 178 } 179 180 181 185 public void testLocalGetPrimaryKey() throws Exception { 186 TargetLocal tl = getLocalHome().create(); 187 try { 188 tl.getPrimaryKey(); 189 fail("getPrimaryKey should raise EJBException on a session bean"); 190 } catch (EJBException e) { 191 } finally { 192 tl.remove(); 193 } 194 } 195 196 197 198 202 public void testLocalRemoveByPK() throws Exception { 203 Object pk = null; 204 try { 205 getLocalHome().remove(pk); 206 fail("getPrimaryKey should raise Exception on a session bean"); 207 } catch (EJBException e) { 208 } catch (RemoveException e) { 209 } 210 } 211 212 213 } 214 | Popular Tags |