1 45 package org.openejb.test.stateful; 46 47 import org.openejb.test.object.OperationsPolicy; 48 49 96 public class BMTStatefulAllowedOperationsTests extends BasicStatefulTestClient{ 97 98 public BMTStatefulAllowedOperationsTests(){ 99 super("BMTAllowedOperations."); 100 } 101 102 protected void setUp() throws Exception { 103 super.setUp(); 104 Object obj = initialContext.lookup("client/tests/stateful/BeanManagedBasicStatefulHome"); 105 ejbHome = (BasicStatefulHome)javax.rmi.PortableRemoteObject.narrow( obj, BasicStatefulHome.class); 106 ejbObject = ejbHome.create("Fifth Bean"); 107 ejbHandle = ejbObject.getHandle(); 108 116 } 117 118 protected void tearDown() throws Exception { 119 ejbObject.remove(); 120 super.tearDown(); 121 } 122 123 137 public void test01_setSessionContext(){ 138 try{ 139 OperationsPolicy policy = new OperationsPolicy(); 140 policy.allow( policy.Context_getEJBHome ); 141 policy.allow( policy.JNDI_access_to_java_comp_env ); 142 143 Object expected = policy; 144 Object actual = ejbObject.getAllowedOperationsReport("setSessionContext"); 145 146 assertNotNull("The OperationsPolicy is null", actual ); 147 assertEquals( expected, actual ); 148 } catch (Exception e){ 149 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 150 } 151 } 152 169 public void test02_ejbCreate(){ 170 try{ 171 OperationsPolicy policy = new OperationsPolicy(); 172 policy.allow( policy.Context_getEJBHome ); 173 policy.allow( policy.Context_getCallerPrincipal ); 174 policy.allow( policy.Context_isCallerInRole ); 175 policy.allow( policy.Context_getEJBObject ); 176 policy.allow( policy.Context_getUserTransaction ); 177 policy.allow( policy.JNDI_access_to_java_comp_env ); 178 policy.allow( policy.Resource_manager_access ); 179 policy.allow( policy.Enterprise_bean_access ); 180 181 Object expected = policy; 182 Object actual = ejbObject.getAllowedOperationsReport("ejbCreate"); 183 184 assertNotNull("The OperationsPolicy is null", actual ); 185 assertEquals( expected, actual ); 186 } catch (Exception e){ 187 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 188 } 189 } 190 207 public void test03_ejbRemove(){ 208 try{ 209 210 OperationsPolicy policy = new OperationsPolicy(); 211 policy.allow( policy.Context_getEJBHome ); 212 policy.allow( policy.Context_getCallerPrincipal ); 213 policy.allow( policy.Context_isCallerInRole ); 214 policy.allow( policy.Context_getEJBObject ); 215 policy.allow( policy.Context_getUserTransaction ); 216 policy.allow( policy.JNDI_access_to_java_comp_env ); 217 policy.allow( policy.Resource_manager_access ); 218 policy.allow( policy.Enterprise_bean_access ); 219 220 Object expected = policy; 221 Object actual = ejbObject.getAllowedOperationsReport("ejbRemove"); 222 223 assertNotNull("The OperationsPolicy is null", actual ); 224 assertEquals( expected, actual ); 225 } catch (Exception e){ 226 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 227 } 228 } 229 246 public void test04_ejbActivate(){ 247 try{ 248 OperationsPolicy policy = new OperationsPolicy(); 249 policy.allow( policy.Context_getEJBHome ); 250 policy.allow( policy.Context_getCallerPrincipal ); 251 policy.allow( policy.Context_isCallerInRole ); 252 policy.allow( policy.Context_getEJBObject ); 253 policy.allow( policy.Context_getUserTransaction ); 254 policy.allow( policy.JNDI_access_to_java_comp_env ); 255 policy.allow( policy.Resource_manager_access ); 256 policy.allow( policy.Enterprise_bean_access ); 257 258 Object expected = policy; 259 Object actual = ejbObject.getAllowedOperationsReport("ejbActivate"); 260 261 assertNotNull("The OperationsPolicy is null", actual ); 262 assertEquals( expected, actual ); 263 } catch (Exception e){ 264 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 265 } 266 } 267 284 public void test05_ejbPassivate(){ 285 try{ 286 OperationsPolicy policy = new OperationsPolicy(); 287 policy.allow( policy.Context_getEJBHome ); 288 policy.allow( policy.Context_getCallerPrincipal ); 289 policy.allow( policy.Context_isCallerInRole ); 290 policy.allow( policy.Context_getEJBObject ); 291 policy.allow( policy.Context_getUserTransaction ); 292 policy.allow( policy.JNDI_access_to_java_comp_env ); 293 policy.allow( policy.Resource_manager_access ); 294 policy.allow( policy.Enterprise_bean_access ); 295 296 Object expected = policy; 297 Object actual = ejbObject.getAllowedOperationsReport("ejbPassivate"); 298 299 assertNotNull("The OperationsPolicy is null", actual ); 300 assertEquals( expected, actual ); 301 } catch (Exception e){ 302 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 303 } 304 } 305 306 323 public void test06_businessMethod(){ 324 try{ 325 OperationsPolicy policy = new OperationsPolicy(); 326 policy.allow( policy.Context_getEJBHome ); 327 policy.allow( policy.Context_getCallerPrincipal ); 328 policy.allow( policy.Context_isCallerInRole ); 329 policy.allow( policy.Context_getEJBObject ); 330 policy.allow( policy.Context_getUserTransaction ); 331 policy.allow( policy.JNDI_access_to_java_comp_env ); 332 policy.allow( policy.Resource_manager_access ); 333 policy.allow( policy.Enterprise_bean_access ); 334 335 Object expected = policy; 336 Object actual = ejbObject.getAllowedOperationsReport("businessMethod"); 337 338 assertNotNull("The OperationsPolicy is null", actual ); 339 assertEquals( expected, actual ); 340 } catch (Exception e){ 341 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 342 } 343 } 344 } 348 349 350 | Popular Tags |