1 45 package org.openejb.test.stateless; 46 47 import javax.ejb.EJBObject ; 48 49 import org.openejb.test.object.OperationsPolicy; 50 51 94 public class StatelessAllowedOperationsTests extends BasicStatelessTestClient{ 95 96 public StatelessAllowedOperationsTests(){ 97 super("AllowedOperations."); 98 } 99 100 protected void setUp() throws Exception { 101 super.setUp(); 102 Object obj = initialContext.lookup("client/tests/stateless/BasicStatelessHome"); 103 ejbHome = (BasicStatelessHome)javax.rmi.PortableRemoteObject.narrow( obj, BasicStatelessHome.class); 104 ejbObject = ejbHome.create(); 105 ejbHandle = ejbObject.getHandle(); 106 108 116 ejbObject.businessMethod("activate me please"); 117 } 118 119 private void setUp_ejbActivate_Passivate() throws Exception { 120 121 124 EJBObject [] ejbObjects = new EJBObject [10]; 125 for (int i=0; i < ejbObjects.length; i++){ 126 ejbObjects[i] = ejbHome.create(); 127 } 128 ejbObject.businessMethod("activate me please"); 129 } 130 131 protected void tearDown() throws Exception { 132 try { 133 ejbObject.remove(); 134 } catch (Exception e){ 135 throw e; 136 } finally { 137 super.tearDown(); 138 } 139 } 140 141 155 public void test01_setSessionContext(){ 156 try { 157 OperationsPolicy policy = new OperationsPolicy(); 158 policy.allow( OperationsPolicy.Context_getEJBHome ); 159 policy.allow( OperationsPolicy.JNDI_access_to_java_comp_env ); 160 161 Object expected = policy; 162 Object actual = ejbObject.getAllowedOperationsReport("setSessionContext"); 163 164 assertNotNull("The OperationsPolicy is null", actual ); 165 assertEquals( expected, actual ); 166 } catch (Exception e){ 167 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 168 } 169 } 170 182 public void test02_ejbCreate() { 183 try { 187 OperationsPolicy policy = new OperationsPolicy(); 188 policy.allow( OperationsPolicy.Context_getEJBHome ); 189 policy.allow( OperationsPolicy.Context_getEJBObject ); 190 policy.allow( OperationsPolicy.JNDI_access_to_java_comp_env ); 191 192 Object expected = policy; 193 Object actual = ejbObject.getAllowedOperationsReport("ejbCreate"); 194 195 assertNotNull("The OperationsPolicy is null", actual ); 196 assertEquals( expected, actual ); 197 } catch (Exception e){ 198 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 199 } 200 } 201 213 public void TODO_test03_ejbRemove(){ 214 try { 215 216 OperationsPolicy policy = new OperationsPolicy(); 217 policy.allow( OperationsPolicy.Context_getEJBHome ); 218 policy.allow( OperationsPolicy.Context_getEJBObject ); 219 policy.allow( OperationsPolicy.JNDI_access_to_java_comp_env ); 220 221 Object expected = policy; 222 Object actual = ejbObject.getAllowedOperationsReport("ejbRemove"); 223 224 assertNotNull("The OperationsPolicy is null", actual ); 225 assertEquals( expected, actual ); 226 } catch (Exception e){ 227 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 228 } 229 } 230 231 249 public void TODO_test04_businessMethod(){ 250 try { 251 OperationsPolicy policy = new OperationsPolicy(); 252 policy.allow( OperationsPolicy.Context_getEJBHome ); 253 policy.allow( OperationsPolicy.Context_getCallerPrincipal ); 254 policy.allow( OperationsPolicy.Context_getRollbackOnly ); 255 policy.allow( OperationsPolicy.Context_isCallerInRole ); 256 policy.allow( OperationsPolicy.Context_setRollbackOnly ); 257 policy.allow( OperationsPolicy.Context_getEJBObject ); 258 policy.allow( OperationsPolicy.JNDI_access_to_java_comp_env ); 259 policy.allow( OperationsPolicy.Resource_manager_access ); 260 policy.allow( OperationsPolicy.Enterprise_bean_access ); 261 262 Object expected = policy; 263 Object actual = ejbObject.getAllowedOperationsReport("businessMethod"); 264 265 assertNotNull("The OperationsPolicy is null", actual ); 266 assertEquals( expected, actual ); 267 } catch (Exception e){ 268 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 269 } 270 } 271 } 275 276 277 | Popular Tags |