1 45 package org.openejb.test.entity.bmp; 46 47 import org.openejb.test.object.OperationsPolicy; 48 49 166 public class BmpAllowedOperationsTests extends BasicBmpTestClient{ 167 168 public BmpAllowedOperationsTests(){ 169 super("AllowedOperations."); 170 } 171 172 protected void setUp() throws Exception { 173 super.setUp(); 174 Object obj = initialContext.lookup("client/tests/entity/bmp/allowed_operations/EntityHome"); 175 ejbHome = (BasicBmpHome)javax.rmi.PortableRemoteObject.narrow( obj, BasicBmpHome.class); 176 ejbObject = ejbHome.create("Fourth Bean"); 177 ejbHandle = ejbObject.getHandle(); 178 186 doScenario(); 187 188 189 } 190 191 protected void tearDown() throws Exception { 192 ejbObject.remove(); 193 super.tearDown(); 194 } 195 196 201 private void doScenario() throws Exception { 202 203 ejbObject.businessMethod("Reverse Me"); 205 206 ejbHome.findByPrimaryKey(null); 207 208 212 213 ejbObject = (BasicBmpObject)javax.rmi.PortableRemoteObject.narrow(ejbHandle.getEJBObject(), BasicBmpObject.class); 214 215 ejbHome.findByPrimaryKey((Integer )ejbObject.getPrimaryKey()); 216 ejbHome.remove((Integer )ejbObject.getPrimaryKey()); 217 218 ejbObject = ejbHome.create("Fourth Bean"); 219 ejbHome.findEmptyCollection(); 220 } 221 222 236 public void test01_setEntityContext(){ 237 try{ 238 239 OperationsPolicy policy = new OperationsPolicy(); 240 policy.allow( policy.Context_getEJBHome ); 241 policy.allow( policy.JNDI_access_to_java_comp_env ); 242 243 Object expected = policy; 244 Object actual = ejbObject.getAllowedOperationsReport("setEntityContext"); 245 246 assertNotNull("The OpperationsPolicy is null", actual ); 247 assertEquals( expected, actual ); 248 249 } catch (Exception e){ 250 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 251 } 252 } 253 264 public void TODO_test02_unsetEntityContext(){ 265 try{ 266 267 268 OperationsPolicy policy = new OperationsPolicy(); 269 policy.allow( policy.Context_getEJBHome ); 270 policy.allow( policy.JNDI_access_to_java_comp_env ); 271 272 Object expected = policy; 273 Object actual = ejbObject.getAllowedOperationsReport("unsetEntityContext"); 274 275 assertNotNull("The OpperationsPolicy is null", actual ); 276 assertEquals( expected, actual ); 277 278 } catch (Exception e){ 279 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 280 } 281 } 282 299 public void test03_ejbCreate(){ 300 try{ 301 302 OperationsPolicy policy = new OperationsPolicy(); 303 policy.allow( policy.Context_getEJBHome ); 304 policy.allow( policy.Context_getCallerPrincipal ); 305 policy.allow( policy.Context_isCallerInRole ); 307 policy.allow( policy.JNDI_access_to_java_comp_env ); 309 policy.allow( policy.Resource_manager_access ); 310 policy.allow( policy.Enterprise_bean_access ); 311 312 Object expected = policy; 313 Object actual = ejbObject.getAllowedOperationsReport("ejbCreate"); 314 315 assertNotNull("The OpperationsPolicy is null", actual ); 316 assertEquals( expected, actual ); 317 318 } catch (Exception e){ 319 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 320 } 321 } 322 341 public void TODO_test04_ejbPostCreate(){ 342 try{ 343 344 OperationsPolicy policy = new OperationsPolicy(); 345 policy.allow( policy.Context_getEJBHome ); 346 policy.allow( policy.Context_getCallerPrincipal ); 347 policy.allow( policy.Context_isCallerInRole ); 349 policy.allow( policy.Context_getEJBObject ); 351 policy.allow( policy.Context_getPrimaryKey ); 352 policy.allow( policy.JNDI_access_to_java_comp_env ); 353 policy.allow( policy.Resource_manager_access ); 354 policy.allow( policy.Enterprise_bean_access ); 355 356 Object expected = policy; 357 Object actual = ejbObject.getAllowedOperationsReport("ejbPostCreate"); 358 359 assertNotNull("The OpperationsPolicy is null", actual ); 360 assertEquals( expected, actual ); 361 362 } catch (Exception e){ 363 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 364 } 365 } 366 385 public void _test05_ejbRemove(){ 386 try{ 387 388 OperationsPolicy policy = new OperationsPolicy(); 389 policy.allow( policy.Context_getEJBHome ); 390 policy.allow( policy.Context_getCallerPrincipal ); 391 policy.allow( policy.Context_isCallerInRole ); 393 policy.allow( policy.Context_getEJBObject ); 395 policy.allow( policy.Context_getPrimaryKey ); 396 policy.allow( policy.JNDI_access_to_java_comp_env ); 397 policy.allow( policy.Resource_manager_access ); 398 policy.allow( policy.Enterprise_bean_access ); 399 400 Object expected = policy; 401 Object actual = ejbObject.getAllowedOperationsReport("ejbRemove"); 402 403 assertNotNull("The OpperationsPolicy is null", actual ); 404 assertEquals( expected, actual ); 405 406 } catch (Exception e){ 407 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 408 } 409 } 410 427 public void test06_ejbFind(){ 428 try{ 429 430 OperationsPolicy policy = new OperationsPolicy(); 431 policy.allow( policy.Context_getEJBHome ); 432 policy.allow( policy.Context_getCallerPrincipal ); 433 policy.allow( policy.Context_isCallerInRole ); 435 policy.allow( policy.JNDI_access_to_java_comp_env ); 437 policy.allow( policy.Resource_manager_access ); 438 policy.allow( policy.Enterprise_bean_access ); 439 440 Object expected = policy; 441 Object actual = ejbObject.getAllowedOperationsReport("ejbFind"); 442 443 assertNotNull("The OpperationsPolicy is null", actual ); 444 assertEquals( expected, actual ); 445 446 } catch (Exception e){ 447 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 448 } 449 } 450 467 public void TODO_test07_ejbSelect(){ 468 try{ 469 470 OperationsPolicy policy = new OperationsPolicy(); 471 policy.allow( policy.Context_getEJBHome ); 472 policy.allow( policy.Context_getCallerPrincipal ); 473 policy.allow( policy.Context_isCallerInRole ); 475 policy.allow( policy.JNDI_access_to_java_comp_env ); 477 policy.allow( policy.Resource_manager_access ); 478 policy.allow( policy.Enterprise_bean_access ); 479 480 Object expected = policy; 481 Object actual = ejbObject.getAllowedOperationsReport("ejbSelect"); 482 483 assertNotNull("The OpperationsPolicy is null", actual ); 484 assertEquals( expected, actual ); 485 486 } catch (Exception e){ 487 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 488 } 489 } 490 507 public void TODO_test08_ejbHome(){ 508 try{ 509 510 OperationsPolicy policy = new OperationsPolicy(); 511 policy.allow( policy.Context_getEJBHome ); 512 policy.allow( policy.Context_getCallerPrincipal ); 513 policy.allow( policy.Context_isCallerInRole ); 515 policy.allow( policy.JNDI_access_to_java_comp_env ); 517 policy.allow( policy.Resource_manager_access ); 518 policy.allow( policy.Enterprise_bean_access ); 519 520 Object expected = policy; 521 Object actual = ejbObject.getAllowedOperationsReport("ejbHome"); 522 523 assertNotNull("The OpperationsPolicy is null", actual ); 524 assertEquals( expected, actual ); 525 526 } catch (Exception e){ 527 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 528 } 529 } 530 549 public void TODO_test09_ejbSelectInEntity(){ 550 try{ 551 552 OperationsPolicy policy = new OperationsPolicy(); 553 policy.allow( policy.Context_getEJBHome ); 554 policy.allow( policy.Context_getCallerPrincipal ); 555 policy.allow( policy.Context_isCallerInRole ); 557 policy.allow( policy.Context_getEJBObject ); 559 policy.allow( policy.Context_getPrimaryKey ); 560 policy.allow( policy.JNDI_access_to_java_comp_env ); 561 policy.allow( policy.Resource_manager_access ); 562 policy.allow( policy.Enterprise_bean_access ); 563 564 Object expected = policy; 565 Object actual = ejbObject.getAllowedOperationsReport("ejbSelectInEntity"); 566 567 assertNotNull("The OpperationsPolicy is null", actual ); 568 assertEquals( expected, actual ); 569 570 } catch (Exception e){ 571 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 572 } 573 } 574 587 public void test10_ejbActivate(){ 588 try{ 589 590 OperationsPolicy policy = new OperationsPolicy(); 591 policy.allow( policy.Context_getEJBHome ); 592 policy.allow( policy.Context_getEJBObject ); 593 policy.allow( policy.Context_getPrimaryKey ); 594 policy.allow( policy.JNDI_access_to_java_comp_env ); 595 596 Object expected = policy; 597 Object actual = ejbObject.getAllowedOperationsReport("ejbActivate"); 598 599 assertNotNull("The OpperationsPolicy is null", actual ); 600 assertEquals( expected, actual ); 601 602 } catch (Exception e){ 603 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 604 } 605 } 606 619 public void test11_ejbPassivate(){ 620 try{ 621 622 OperationsPolicy policy = new OperationsPolicy(); 623 policy.allow( policy.Context_getEJBHome ); 624 policy.allow( policy.Context_getEJBObject ); 625 policy.allow( policy.Context_getPrimaryKey ); 626 policy.allow( policy.JNDI_access_to_java_comp_env ); 627 628 Object expected = policy; 629 Object actual = ejbObject.getAllowedOperationsReport("ejbPassivate"); 630 631 assertNotNull("The OpperationsPolicy is null", actual ); 632 assertEquals( expected, actual ); 633 634 } catch (Exception e){ 635 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 636 } 637 } 638 657 public void test12_ejbLoad(){ 658 try{ 659 660 OperationsPolicy policy = new OperationsPolicy(); 661 policy.allow( policy.Context_getEJBHome ); 662 policy.allow( policy.Context_getCallerPrincipal ); 663 policy.allow( policy.Context_isCallerInRole ); 665 policy.allow( policy.Context_getEJBObject ); 667 policy.allow( policy.Context_getPrimaryKey ); 668 policy.allow( policy.JNDI_access_to_java_comp_env ); 669 policy.allow( policy.Resource_manager_access ); 670 policy.allow( policy.Enterprise_bean_access ); 671 672 Object expected = policy; 673 Object actual = ejbObject.getAllowedOperationsReport("ejbLoad"); 674 675 assertNotNull("The OpperationsPolicy is null", actual ); 676 assertEquals( expected, actual ); 677 678 } catch (Exception e){ 679 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 680 } 681 } 682 701 public void BUG_test13_ejbStore(){ 702 try{ 703 704 OperationsPolicy policy = new OperationsPolicy(); 705 policy.allow( policy.Context_getEJBHome ); 706 policy.allow( policy.Context_getCallerPrincipal ); 707 policy.allow( policy.Context_isCallerInRole ); 709 policy.allow( policy.Context_getEJBObject ); 711 policy.allow( policy.Context_getPrimaryKey ); 712 policy.allow( policy.JNDI_access_to_java_comp_env ); 713 policy.allow( policy.Resource_manager_access ); 714 policy.allow( policy.Enterprise_bean_access ); 715 716 Object expected = policy; 717 Object actual = ejbObject.getAllowedOperationsReport("ejbStore"); 718 719 assertNotNull( "The OperationsPolicy returned is null", actual); 720 assertEquals( expected, actual ); 721 722 } catch (Exception e){ 723 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 724 } 725 } 726 745 public void test14_businessMethod(){ 746 try{ 747 748 OperationsPolicy policy = new OperationsPolicy(); 749 policy.allow( policy.Context_getEJBHome ); 750 policy.allow( policy.Context_getCallerPrincipal ); 751 policy.allow( policy.Context_isCallerInRole ); 753 policy.allow( policy.Context_getEJBObject ); 755 policy.allow( policy.Context_getPrimaryKey ); 756 policy.allow( policy.JNDI_access_to_java_comp_env ); 757 policy.allow( policy.Resource_manager_access ); 758 policy.allow( policy.Enterprise_bean_access ); 759 760 Object expected = policy; 761 Object actual = ejbObject.getAllowedOperationsReport("businessMethod"); 762 763 assertNotNull("The OpperationsPolicy is null", actual ); 764 assertEquals( expected, actual ); 765 766 } catch (Exception e){ 767 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 768 } 769 } 770 } 774 775 776 | Popular Tags |