KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openejb > test > entity > bmp > BmpAllowedOperationsTests


1 /**
2  * Redistribution and use of this software and associated documentation
3  * ("Software"), with or without modification, are permitted provided
4  * that the following conditions are met:
5  *
6  * 1. Redistributions of source code must retain copyright
7  * statements and notices. Redistributions must also contain a
8  * copy of this document.
9  *
10  * 2. Redistributions in binary form must reproduce the
11  * above copyright notice, this list of conditions and the
12  * following disclaimer in the documentation and/or other
13  * materials provided with the distribution.
14  *
15  * 3. The name "Exolab" must not be used to endorse or promote
16  * products derived from this Software without prior written
17  * permission of Exoffice Technologies. For written permission,
18  * please contact info@exolab.org.
19  *
20  * 4. Products derived from this Software may not be called "Exolab"
21  * nor may "Exolab" appear in their names without prior written
22  * permission of Exoffice Technologies. Exolab is a registered
23  * trademark of Exoffice Technologies.
24  *
25  * 5. Due credit should be given to the Exolab Project
26  * (http://www.exolab.org/).
27  *
28  * THIS SOFTWARE IS PROVIDED BY EXOFFICE TECHNOLOGIES AND CONTRIBUTORS
29  * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
30  * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
31  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
32  * EXOFFICE TECHNOLOGIES OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
33  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
34  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
35  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
37  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
38  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
39  * OF THE POSSIBILITY OF SUCH DAMAGE.
40  *
41  * Copyright 1999 (C) Exoffice Technologies Inc. All Rights Reserved.
42  *
43  * $Id: BmpAllowedOperationsTests.java 1096 2004-03-26 21:41:16Z dblevins $
44  */

45 package org.openejb.test.entity.bmp;
46
47 import org.openejb.test.object.OperationsPolicy;
48
49 /**
50  * [9] Should be run as the nineth test suite of the BasicBmpTestClients
51  *
52  * <PRE>
53  * =========================================================================
54  * Operations allowed in the methods of an entity bean
55  * =========================================================================
56  *
57  * Bean method | Bean method can perform the following operations
58  * ______________________|__________________________________________________
59  * |
60  * constructor | -
61  * ______________________|__________________________________________________
62  * |
63  * setEntityContext | EntityContext methods:
64  * unsetEntityContext | - getEJBHome
65  * | JNDI access to java:comp/env
66  * ______________________|__________________________________________________
67  * |
68  * ejbCreate | EntityContext methods:
69  * | - getEJBHome
70  * | - getCallerPrincipal
71  * | - getRollbackOnly
72  * | - isCallerInRole
73  * | - setRollbackOnly
74  * | JNDI access to java:comp/env
75  * | Resource manager access
76  * | Enterprise bean access
77  * ______________________|__________________________________________________
78  * |
79  * ejbPostCreate | EntityContext methods:
80  * | - getEJBHome
81  * | - getCallerPrincipal
82  * | - getRollbackOnly
83  * | - isCallerInRole
84  * | - setRollbackOnly
85  * | - getEJBObject
86  * | - getPrimaryKey
87  * | JNDI access to java:comp/env
88  * | Resource manager access
89  * | Enterprise bean access
90  * ______________________|__________________________________________________
91  * |
92  * ejbRemove | EntityContext methods:
93  * | - getEJBHome
94  * | - getCallerPrincipal
95  * | - getRollbackOnly
96  * | - isCallerInRole
97  * | - setRollbackOnly
98  * | - getEJBObject
99  * | - getPrimaryKey
100  * | JNDI access to java:comp/env
101  * | Resource manager access
102  * | Enterprise bean access
103  * ______________________|__________________________________________________
104  * |
105  * ejbFind* | EntityContext methods:
106  * ejbSelect* | - getEJBHome
107  * ejbHome | - getCallerPrincipal
108  * | - getRollbackOnly
109  * | - isCallerInRole
110  * | - setRollbackOnly
111  * | JNDI access to java:comp/env
112  * | Resource manager access
113  * | Enterprise bean access
114  * ______________________|__________________________________________________
115  * |
116  * ejbSelectInEntity* | EntityContext methods:
117  * | - getEJBHome
118  * | - getCallerPrincipal
119  * | - getRollbackOnly
120  * | - isCallerInRole
121  * | - setRollbackOnly
122  * | - getEJBObject
123  * | - getPrimaryKey
124  * | JNDI access to java:comp/env
125  * | Resource manager access
126  * | Enterprise bean access
127  * ______________________|__________________________________________________
128  * |
129  * ejbActivate | EntityContext methods:
130  * ejbPassivate | - getEJBHome
131  * | - getEJBObject
132  * | - getPrimaryKey
133  * | JNDI access to java:comp/env
134  * ______________________|__________________________________________________
135  * |
136  * ejbLoad | EntityContext methods:
137  * ejbStore | - getEJBHome
138  * | - getCallerPrincipal
139  * | - getRollbackOnly
140  * | - isCallerInRole
141  * | - setRollbackOnly
142  * | - getEJBObject
143  * | - getPrimaryKey
144  * | JNDI access to java:comp/env
145  * | Resource manager access
146  * | Enterprise bean access
147  * ______________________|__________________________________________________
148  * |
149  * business method | EntityContext methods:
150  * from remote interface | - getEJBHome
151  * | - getCallerPrincipal
152  * | - getRollbackOnly
153  * | - isCallerInRole
154  * | - setRollbackOnly
155  * | - getEJBObject
156  * | - getPrimaryKey
157  * | JNDI access to java:comp/env
158  * | Resource manager access
159  * | Enterprise bean access
160  * ______________________|__________________________________________________
161  * </PRE>
162  *
163  * @author <a HREF="mailto:david.blevins@visi.com">David Blevins</a>
164  * @author <a HREF="mailto:Richard@Monson-Haefel.com">Richard Monson-Haefel</a>
165  */

166 public class BmpAllowedOperationsTests extends BasicBmpTestClient{
167
168     public BmpAllowedOperationsTests(){
169         super("AllowedOperations.");
170     }
171
172     protected void setUp() throws Exception JavaDoc{
173         super.setUp();
174         Object JavaDoc 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         /* These tests will only work if the specified
179          * method has already been called by the container.
180          *
181          * TO DO:
182          * Implement a little application senario to ensure
183          * that all methods tested for below have been called
184          * by the container.
185          */

186          doScenario();
187          
188                   
189     }
190     
191     protected void tearDown() throws Exception JavaDoc{
192         ejbObject.remove();
193         super.tearDown();
194     }
195     
196     /**
197      * This method ensures that all thee bean methods have been invoked for correct behaviour
198      * of the tests.
199      *
200      */

201     private void doScenario() throws Exception JavaDoc{
202       
203       // Call the business method
204
ejbObject.businessMethod("Reverse Me");
205       
206       ejbHome.findByPrimaryKey(null);
207       
208       // TO BE FIXED LATER IN PROXIES
209
/*try {
210         ejbHome.sum(1, 2);
211       }catch( java.lang.Exception e ) {e.printStackTrace();} */

212                 
213       ejbObject = (BasicBmpObject)javax.rmi.PortableRemoteObject.narrow(ejbHandle.getEJBObject(), BasicBmpObject.class);
214      
215       ejbHome.findByPrimaryKey((Integer JavaDoc)ejbObject.getPrimaryKey());
216       ejbHome.remove((Integer JavaDoc)ejbObject.getPrimaryKey());
217       
218       ejbObject = ejbHome.create("Fourth Bean");
219       ejbHome.findEmptyCollection();
220     }
221
222     //=====================================
223
// Test EJBContext allowed operations
224
//
225
/**
226      * <PRE>
227      * Bean method | Bean method can perform the following operations
228      * ______________________|__________________________________________________
229      * |
230      * setEntityContext | EntityContext methods:
231      * unsetEntityContext | - getEJBHome
232      * | JNDI access to java:comp/env
233      * ______________________|__________________________________________________
234      * </PRE>
235      */

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 JavaDoc expected = policy;
244         Object JavaDoc actual = ejbObject.getAllowedOperationsReport("setEntityContext");
245         
246         assertNotNull("The OpperationsPolicy is null", actual );
247         assertEquals( expected, actual );
248   
249         } catch (Exception JavaDoc e){
250             fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
251         }
252     }
253     /**
254      * <PRE>
255      * Bean method | Bean method can perform the following operations
256      * ______________________|__________________________________________________
257      * |
258      * setEntityContext | EntityContext methods:
259      * unsetEntityContext | - getEJBHome
260      * | JNDI access to java:comp/env
261      * ______________________|__________________________________________________
262      * </PRE>
263      */

264     public void TODO_test02_unsetEntityContext(){
265         try{
266             
267         /* TO DO: This test needs unique functionality to work */
268         OperationsPolicy policy = new OperationsPolicy();
269         policy.allow( policy.Context_getEJBHome );
270         policy.allow( policy.JNDI_access_to_java_comp_env );
271         
272         Object JavaDoc expected = policy;
273         Object JavaDoc actual = ejbObject.getAllowedOperationsReport("unsetEntityContext");
274         
275         assertNotNull("The OpperationsPolicy is null", actual );
276         assertEquals( expected, actual );
277  
278         } catch (Exception JavaDoc e){
279             fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
280         }
281     }
282     /**
283      * <PRE>
284      * Bean method | Bean method can perform the following operations
285      * ______________________|__________________________________________________
286      * |
287      * ejbCreate | EntityContext methods:
288      * | - getEJBHome
289      * | - getCallerPrincipal
290      * | - getRollbackOnly
291      * | - isCallerInRole
292      * | - setRollbackOnly
293      * | JNDI access to java:comp/env
294      * | Resource manager access
295      * | Enterprise bean access
296      * ______________________|__________________________________________________
297      * </PRE>
298      */

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         //TODO:0:policy.allow( policy.Context_getRollbackOnly );
306
policy.allow( policy.Context_isCallerInRole );
307         //TODO:0:policy.allow( policy.Context_setRollbackOnly );
308
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 JavaDoc expected = policy;
313         Object JavaDoc actual = ejbObject.getAllowedOperationsReport("ejbCreate");
314         
315         assertNotNull("The OpperationsPolicy is null", actual );
316         assertEquals( expected, actual );
317   
318         } catch (Exception JavaDoc e){
319             fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
320         }
321     }
322     /**
323      * <PRE>
324      * Bean method | Bean method can perform the following operations
325      * ______________________|__________________________________________________
326      * |
327      * ejbPostCreate | EntityContext methods:
328      * | - getEJBHome
329      * | - getCallerPrincipal
330      * | - getRollbackOnly
331      * | - isCallerInRole
332      * | - setRollbackOnly
333      * | - getEJBObject
334      * | - getPrimaryKey
335      * | JNDI access to java:comp/env
336      * | Resource manager access
337      * | Enterprise bean access
338      * ______________________|__________________________________________________
339      * </PRE>
340      */

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         //TODO:0:policy.allow( policy.Context_getRollbackOnly );
348
policy.allow( policy.Context_isCallerInRole );
349         //TODO:0:policy.allow( policy.Context_setRollbackOnly );
350
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 JavaDoc expected = policy;
357         Object JavaDoc actual = ejbObject.getAllowedOperationsReport("ejbPostCreate");
358     
359         assertNotNull("The OpperationsPolicy is null", actual );
360         assertEquals( expected, actual );
361   
362         } catch (Exception JavaDoc e){
363             fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
364         }
365     }
366     /**
367      * <PRE>
368      * Bean method | Bean method can perform the following operations
369      * ______________________|__________________________________________________
370      * |
371      * ejbRemove | EntityContext methods:
372      * | - getEJBHome
373      * | - getCallerPrincipal
374      * | - getRollbackOnly
375      * | - isCallerInRole
376      * | - setRollbackOnly
377      * | - getEJBObject
378      * | - getPrimaryKey
379      * | JNDI access to java:comp/env
380      * | Resource manager access
381      * | Enterprise bean access
382      * ______________________|__________________________________________________
383      * </PRE>
384      */

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         //TODO:0:policy.allow( policy.Context_getRollbackOnly );
392
policy.allow( policy.Context_isCallerInRole );
393         //TODO:0:policy.allow( policy.Context_setRollbackOnly );
394
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 JavaDoc expected = policy;
401         Object JavaDoc actual = ejbObject.getAllowedOperationsReport("ejbRemove");
402     
403         assertNotNull("The OpperationsPolicy is null", actual );
404         assertEquals( expected, actual );
405   
406         } catch (Exception JavaDoc e){
407             fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
408         }
409     }
410     /**
411      * <PRE>
412      * Bean method | Bean method can perform the following operations
413      * ______________________|__________________________________________________
414      * |
415      * ejbFind* | EntityContext methods:
416      * ejbSelect* | - getEJBHome
417      * ejbHome | - getCallerPrincipal
418      * | - getRollbackOnly
419      * | - isCallerInRole
420      * | - setRollbackOnly
421      * | JNDI access to java:comp/env
422      * | Resource manager access
423      * | Enterprise bean access
424      * ______________________|__________________________________________________
425      * </PRE>
426      */

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         //TODO:0:policy.allow( policy.Context_getRollbackOnly );
434
policy.allow( policy.Context_isCallerInRole );
435         //TODO:0:policy.allow( policy.Context_setRollbackOnly );
436
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 JavaDoc expected = policy;
441         Object JavaDoc actual = ejbObject.getAllowedOperationsReport("ejbFind");
442         
443         assertNotNull("The OpperationsPolicy is null", actual );
444         assertEquals( expected, actual );
445  
446         } catch (Exception JavaDoc e){
447             fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
448         }
449     }
450     /**
451      * <PRE>
452      * Bean method | Bean method can perform the following operations
453      * ______________________|__________________________________________________
454      * |
455      * ejbFind* | EntityContext methods:
456      * ejbSelect* | - getEJBHome
457      * ejbHome | - getCallerPrincipal
458      * | - getRollbackOnly
459      * | - isCallerInRole
460      * | - setRollbackOnly
461      * | JNDI access to java:comp/env
462      * | Resource manager access
463      * | Enterprise bean access
464      * ______________________|__________________________________________________
465      * </PRE>
466      */

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         //TODO:0:policy.allow( policy.Context_getRollbackOnly );
474
policy.allow( policy.Context_isCallerInRole );
475         //TODO:0:policy.allow( policy.Context_setRollbackOnly );
476
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 JavaDoc expected = policy;
481         Object JavaDoc actual = ejbObject.getAllowedOperationsReport("ejbSelect");
482         
483         assertNotNull("The OpperationsPolicy is null", actual );
484         assertEquals( expected, actual );
485  
486         } catch (Exception JavaDoc e){
487             fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
488         }
489     }
490     /**
491      * <PRE>
492      * Bean method | Bean method can perform the following operations
493      * ______________________|__________________________________________________
494      * |
495      * ejbFind* | EntityContext methods:
496      * ejbSelect* | - getEJBHome
497      * ejbHome | - getCallerPrincipal
498      * | - getRollbackOnly
499      * | - isCallerInRole
500      * | - setRollbackOnly
501      * | JNDI access to java:comp/env
502      * | Resource manager access
503      * | Enterprise bean access
504      * ______________________|__________________________________________________
505      * </PRE>
506      */

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         //TODO:0:policy.allow( policy.Context_getRollbackOnly );
514
policy.allow( policy.Context_isCallerInRole );
515         //TODO:0:policy.allow( policy.Context_setRollbackOnly );
516
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 JavaDoc expected = policy;
521         Object JavaDoc actual = ejbObject.getAllowedOperationsReport("ejbHome");
522     
523         assertNotNull("The OpperationsPolicy is null", actual );
524         assertEquals( expected, actual );
525
526         } catch (Exception JavaDoc e){
527             fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
528         }
529     }
530     /**
531      * <PRE>
532      * Bean method | Bean method can perform the following operations
533      * ______________________|__________________________________________________
534      * |
535      * ejbSelectInEntity* | EntityContext methods:
536      * | - getEJBHome
537      * | - getCallerPrincipal
538      * | - getRollbackOnly
539      * | - isCallerInRole
540      * | - setRollbackOnly
541      * | - getEJBObject
542      * | - getPrimaryKey
543      * | JNDI access to java:comp/env
544      * | Resource manager access
545      * | Enterprise bean access
546      * ______________________|__________________________________________________
547      * </PRE>
548      */

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         //TODO:0:policy.allow( policy.Context_getRollbackOnly );
556
policy.allow( policy.Context_isCallerInRole );
557         //TODO:0:policy.allow( policy.Context_setRollbackOnly );
558
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 JavaDoc expected = policy;
565         Object JavaDoc actual = ejbObject.getAllowedOperationsReport("ejbSelectInEntity");
566     
567         assertNotNull("The OpperationsPolicy is null", actual );
568         assertEquals( expected, actual );
569    
570         } catch (Exception JavaDoc e){
571             fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
572         }
573     }
574     /**
575      * <PRE>
576      * Bean method | Bean method can perform the following operations
577      * ______________________|__________________________________________________
578      * |
579      * ejbActivate | EntityContext methods:
580      * ejbPassivate | - getEJBHome
581      * | - getEJBObject
582      * | - getPrimaryKey
583      * | JNDI access to java:comp/env
584      * ______________________|__________________________________________________
585      * </PRE>
586      */

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 JavaDoc expected = policy;
597         Object JavaDoc actual = ejbObject.getAllowedOperationsReport("ejbActivate");
598     
599         assertNotNull("The OpperationsPolicy is null", actual );
600         assertEquals( expected, actual );
601    
602         } catch (Exception JavaDoc e){
603             fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
604         }
605     }
606     /**
607      * <PRE>
608      * Bean method | Bean method can perform the following operations
609      * ______________________|__________________________________________________
610      * |
611      * ejbActivate | EntityContext methods:
612      * ejbPassivate | - getEJBHome
613      * | - getEJBObject
614      * | - getPrimaryKey
615      * | JNDI access to java:comp/env
616      * ______________________|__________________________________________________
617      * </PRE>
618      */

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 JavaDoc expected = policy;
629         Object JavaDoc actual = ejbObject.getAllowedOperationsReport("ejbPassivate");
630     
631         assertNotNull("The OpperationsPolicy is null", actual );
632         assertEquals( expected, actual );
633   
634         } catch (Exception JavaDoc e){
635             fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
636         }
637     }
638     /**
639      * <PRE>
640      * Bean method | Bean method can perform the following operations
641      * ______________________|__________________________________________________
642      * |
643      * ejbLoad | EntityContext methods:
644      * ejbStore | - getEJBHome
645      * | - getCallerPrincipal
646      * | - getRollbackOnly
647      * | - isCallerInRole
648      * | - setRollbackOnly
649      * | - getEJBObject
650      * | - getPrimaryKey
651      * | JNDI access to java:comp/env
652      * | Resource manager access
653      * | Enterprise bean access
654      * ______________________|__________________________________________________
655      * </PRE>
656      */

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         //TODO:0:policy.allow( policy.Context_getRollbackOnly );
664
policy.allow( policy.Context_isCallerInRole );
665         //TODO:0:policy.allow( policy.Context_setRollbackOnly );
666
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 JavaDoc expected = policy;
673         Object JavaDoc actual = ejbObject.getAllowedOperationsReport("ejbLoad");
674     
675         assertNotNull("The OpperationsPolicy is null", actual );
676         assertEquals( expected, actual );
677     
678         } catch (Exception JavaDoc e){
679             fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
680         }
681     }
682     /**
683      * <PRE>
684      * Bean method | Bean method can perform the following operations
685      * ______________________|__________________________________________________
686      * |
687      * ejbLoad | EntityContext methods:
688      * ejbStore | - getEJBHome
689      * | - getCallerPrincipal
690      * | - getRollbackOnly
691      * | - isCallerInRole
692      * | - setRollbackOnly
693      * | - getEJBObject
694      * | - getPrimaryKey
695      * | JNDI access to java:comp/env
696      * | Resource manager access
697      * | Enterprise bean access
698      * ______________________|__________________________________________________
699      * </PRE>
700      */

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         //TODO:0:policy.allow( policy.Context_getRollbackOnly );
708
policy.allow( policy.Context_isCallerInRole );
709         //TODO:0:policy.allow( policy.Context_setRollbackOnly );
710
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 JavaDoc expected = policy;
717         Object JavaDoc actual = ejbObject.getAllowedOperationsReport("ejbStore");
718     
719         assertNotNull( "The OperationsPolicy returned is null", actual);
720         assertEquals( expected, actual );
721     
722         } catch (Exception JavaDoc e){
723             fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
724         }
725     }
726     /**
727      * <PRE>
728      * Bean method | Bean method can perform the following operations
729      * ______________________|__________________________________________________
730      * |
731      * business method | EntityContext methods:
732      * from remote interface | - getEJBHome
733      * | - getCallerPrincipal
734      * | - getRollbackOnly
735      * | - isCallerInRole
736      * | - setRollbackOnly
737      * | - getEJBObject
738      * | - getPrimaryKey
739      * | JNDI access to java:comp/env
740      * | Resource manager access
741      * | Enterprise bean access
742      * ______________________|__________________________________________________
743      * </PRE>
744      */

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         //TODO:0:policy.allow( policy.Context_getRollbackOnly );
752
policy.allow( policy.Context_isCallerInRole );
753         //TODO:0:policy.allow( policy.Context_setRollbackOnly );
754
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 JavaDoc expected = policy;
761         Object JavaDoc actual = ejbObject.getAllowedOperationsReport("businessMethod");
762     
763         assertNotNull("The OpperationsPolicy is null", actual );
764         assertEquals( expected, actual );
765   
766         } catch (Exception JavaDoc e){
767             fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
768         }
769     }
770     //
771
// Test EJBContext allowed operations
772
//=====================================
773
}
774
775
776
Popular Tags