1 45 package org.openejb.test.stateful; 46 47 import org.openejb.test.object.OperationsPolicy; 48 49 118 public class StatefulAllowedOperationsTests extends BasicStatefulTestClient{ 119 120 public StatefulAllowedOperationsTests(){ 121 super("AllowedOperations."); 122 } 123 124 protected void setUp() throws Exception { 125 super.setUp(); 126 Object obj = initialContext.lookup("client/tests/stateful/BasicStatefulHome"); 127 ejbHome = (BasicStatefulHome)javax.rmi.PortableRemoteObject.narrow( obj, BasicStatefulHome.class); 128 ejbObject = ejbHome.create("Fourth Bean"); 129 ejbHandle = ejbObject.getHandle(); 130 138 } 139 140 protected void tearDown() throws Exception { 141 ejbObject.remove(); 142 super.tearDown(); 143 } 144 145 159 public void test01_setSessionContext(){ 160 try{ 161 OperationsPolicy policy = new OperationsPolicy(); 162 policy.allow( policy.Context_getEJBHome ); 163 policy.allow( policy.JNDI_access_to_java_comp_env ); 164 165 Object expected = policy; 166 Object actual = ejbObject.getAllowedOperationsReport("setSessionContext"); 167 168 assertNotNull("The OperationsPolicy is null", actual ); 169 assertEquals( expected, actual ); 170 } catch (Exception e){ 171 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 172 } 173 174 } 175 191 public void test02_ejbCreate(){ 192 try{ 193 OperationsPolicy policy = new OperationsPolicy(); 194 policy.allow( policy.Context_getEJBHome ); 195 policy.allow( policy.Context_getCallerPrincipal ); 196 policy.allow( policy.Context_isCallerInRole ); 197 policy.allow( policy.Context_getEJBObject ); 198 policy.allow( policy.JNDI_access_to_java_comp_env ); 199 policy.allow( policy.Resource_manager_access ); 200 policy.allow( policy.Enterprise_bean_access ); 201 202 Object expected = policy; 203 Object actual = ejbObject.getAllowedOperationsReport("ejbCreate"); 204 205 assertNotNull("The OperationsPolicy is null", actual ); 206 assertEquals( expected, actual ); 207 208 } catch (Exception e){ 209 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 210 } 211 } 212 228 public void test03_ejbRemove(){ 229 try{ 230 231 OperationsPolicy policy = new OperationsPolicy(); 232 policy.allow( policy.Context_getEJBHome ); 233 policy.allow( policy.Context_getCallerPrincipal ); 234 policy.allow( policy.Context_isCallerInRole ); 235 policy.allow( policy.Context_getEJBObject ); 236 policy.allow( policy.JNDI_access_to_java_comp_env ); 237 policy.allow( policy.Resource_manager_access ); 238 policy.allow( policy.Enterprise_bean_access ); 239 240 Object expected = policy; 241 Object actual = ejbObject.getAllowedOperationsReport("ejbRemove"); 242 243 assertNotNull("The OperationsPolicy is null", actual ); 244 assertEquals( expected, actual ); 245 246 } catch (Exception e){ 247 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 248 } 249 } 250 266 public void test04_ejbActivate(){ 267 try{ 268 269 OperationsPolicy policy = new OperationsPolicy(); 270 policy.allow( policy.Context_getEJBHome ); 271 policy.allow( policy.Context_getCallerPrincipal ); 272 policy.allow( policy.Context_isCallerInRole ); 273 policy.allow( policy.Context_getEJBObject ); 274 policy.allow( policy.JNDI_access_to_java_comp_env ); 275 policy.allow( policy.Resource_manager_access ); 276 policy.allow( policy.Enterprise_bean_access ); 277 278 Object expected = policy; 279 Object actual = ejbObject.getAllowedOperationsReport("ejbActivate"); 280 281 assertNotNull("The OperationsPolicy is null", actual ); 282 assertEquals( expected, actual ); 283 284 } catch (Exception e){ 285 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 286 } 287 } 288 304 public void test05_ejbPassivate(){ 305 try{ 306 307 OperationsPolicy policy = new OperationsPolicy(); 308 policy.allow( policy.Context_getEJBHome ); 309 policy.allow( policy.Context_getCallerPrincipal ); 310 policy.allow( policy.Context_isCallerInRole ); 311 policy.allow( policy.Context_getEJBObject ); 312 policy.allow( policy.JNDI_access_to_java_comp_env ); 313 policy.allow( policy.Resource_manager_access ); 314 policy.allow( policy.Enterprise_bean_access ); 315 316 Object expected = policy; 317 Object actual = ejbObject.getAllowedOperationsReport("ejbPassivate"); 318 319 assertNotNull("The OperationsPolicy is null", actual ); 320 assertEquals( expected, actual ); 321 322 } catch (Exception e){ 323 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 324 } 325 } 326 327 345 public void test06_businessMethod(){ 346 try{ 347 OperationsPolicy policy = new OperationsPolicy(); 348 policy.allow( policy.Context_getEJBHome ); 349 policy.allow( policy.Context_getCallerPrincipal ); 350 policy.allow( policy.Context_getRollbackOnly ); 351 policy.allow( policy.Context_isCallerInRole ); 352 policy.allow( policy.Context_setRollbackOnly ); 353 policy.allow( policy.Context_getEJBObject ); 354 policy.allow( policy.JNDI_access_to_java_comp_env ); 355 policy.allow( policy.Resource_manager_access ); 356 policy.allow( policy.Enterprise_bean_access ); 357 358 Object expected = policy; 359 Object actual = ejbObject.getAllowedOperationsReport("businessMethod"); 360 361 assertNotNull("The OperationsPolicy is null", actual ); 362 assertEquals( expected, actual ); 363 364 } catch (Exception e){ 365 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 366 } 367 368 } 369 387 public void test07_afterBegin(){ 388 try{ 389 390 OperationsPolicy policy = new OperationsPolicy(); 391 policy.allow( policy.Context_getEJBHome ); 392 policy.allow( policy.Context_getCallerPrincipal ); 393 policy.allow( policy.Context_getRollbackOnly ); 394 policy.allow( policy.Context_isCallerInRole ); 395 policy.allow( policy.Context_setRollbackOnly ); 396 policy.allow( policy.Context_getEJBObject ); 397 policy.allow( policy.JNDI_access_to_java_comp_env ); 398 policy.allow( policy.Resource_manager_access ); 399 policy.allow( policy.Enterprise_bean_access ); 400 401 Object expected = policy; 402 Object actual = ejbObject.getAllowedOperationsReport("afterBegin"); 403 404 assertNotNull("The OperationsPolicy is null", actual ); 405 assertEquals( expected, actual ); 406 407 } catch (Exception e){ 408 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 409 } 410 } 411 412 430 public void test08_beforeCompletion(){ 431 try{ 432 433 OperationsPolicy policy = new OperationsPolicy(); 434 policy.allow( policy.Context_getEJBHome ); 435 policy.allow( policy.Context_getCallerPrincipal ); 436 policy.allow( policy.Context_getRollbackOnly ); 437 policy.allow( policy.Context_isCallerInRole ); 438 policy.allow( policy.Context_setRollbackOnly ); 439 policy.allow( policy.Context_getEJBObject ); 440 policy.allow( policy.JNDI_access_to_java_comp_env ); 441 policy.allow( policy.Resource_manager_access ); 442 policy.allow( policy.Enterprise_bean_access ); 443 444 Object expected = policy; 445 Object actual = ejbObject.getAllowedOperationsReport("beforeCompletion"); 446 447 assertNotNull("The OperationsPolicy is null", actual ); 448 assertEquals( expected, actual ); 449 450 } catch (Exception e){ 451 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 452 } 453 } 454 470 public void test09_afterCompletion(){ 471 try{ 472 473 OperationsPolicy policy = new OperationsPolicy(); 474 policy.allow( policy.Context_getEJBHome ); 475 policy.allow( policy.Context_getCallerPrincipal ); 476 policy.allow( policy.Context_isCallerInRole ); 477 policy.allow( policy.Context_getEJBObject ); 478 policy.allow( policy.JNDI_access_to_java_comp_env ); 479 policy.allow( policy.Resource_manager_access ); 480 policy.allow( policy.Enterprise_bean_access ); 481 482 Object expected = policy; 483 Object actual = ejbObject.getAllowedOperationsReport("afterCompletion"); 484 485 assertNotNull("The OperationsPolicy is null", actual ); 486 assertEquals( expected, actual ); 487 488 } catch (Exception e){ 489 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 490 } 491 } 492 } 496 497 498 | Popular Tags |