Source Code Cross Referenced for CmpAllowedOperationsTests.java in  » J2EE » openejb3 » org » apache » openejb » test » entity » cmp » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » openejb3 » org.apache.openejb.test.entity.cmp 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */package org.apache.openejb.test.entity.cmp;
017:
018:        import org.apache.openejb.test.object.OperationsPolicy;
019:
020:        import javax.rmi.PortableRemoteObject;
021:
022:        /**
023:         * [9] Should be run as the nineth test suite of the BasicCmpTestClients
024:         * 
025:         * <PRE>
026:         * =========================================================================
027:         * Operations allowed in the methods of an entity bean
028:         * =========================================================================
029:         * 
030:         * Bean method           | Bean method can perform the following operations
031:         * ______________________|__________________________________________________
032:         *                       |
033:         * constructor           | -
034:         * ______________________|__________________________________________________
035:         *                       |
036:         * setEntityContext      |  EntityContext methods: 
037:         * unsetEntityContext    |     - getEJBHome
038:         *                       |  JNDI access to java:comp/env
039:         * ______________________|__________________________________________________
040:         *                       |
041:         * ejbCreate             |  EntityContext methods: 
042:         *                       |     - getEJBHome 
043:         *                       |     - getCallerPrincipal
044:         *                       |     - getRollbackOnly
045:         *                       |     - isCallerInRole
046:         *                       |     - setRollbackOnly
047:         *                       |  JNDI access to java:comp/env
048:         *                       |  Resource manager access
049:         *                       |  Enterprise bean access
050:         * ______________________|__________________________________________________
051:         *                       |
052:         * ejbPostCreate         |  EntityContext methods: 
053:         *                       |     - getEJBHome 
054:         *                       |     - getCallerPrincipal
055:         *                       |     - getRollbackOnly
056:         *                       |     - isCallerInRole
057:         *                       |     - setRollbackOnly
058:         *                       |     - getEJBObject
059:         *                       |     - getPrimaryKey
060:         *                       |  JNDI access to java:comp/env
061:         *                       |  Resource manager access
062:         *                       |  Enterprise bean access
063:         * ______________________|__________________________________________________
064:         *                       |
065:         * ejbRemove             |  EntityContext methods: 
066:         *                       |     - getEJBHome 
067:         *                       |     - getCallerPrincipal
068:         *                       |     - getRollbackOnly
069:         *                       |     - isCallerInRole
070:         *                       |     - setRollbackOnly
071:         *                       |     - getEJBObject
072:         *                       |     - getPrimaryKey
073:         *                       |  JNDI access to java:comp/env
074:         *                       |  Resource manager access
075:         *                       |  Enterprise bean access
076:         * ______________________|__________________________________________________
077:         *                       | 
078:         * ejbFind*              |  EntityContext methods: 
079:         * ejbSelect*            |     - getEJBHome                                                           
080:         * ejbHome               |     - getCallerPrincipal                                   
081:         *                       |     - getRollbackOnly                                      
082:         *                       |     - isCallerInRole                                       
083:         *                       |     - setRollbackOnly                                      
084:         *                       |  JNDI access to java:comp/env
085:         *                       |  Resource manager access
086:         *                       |  Enterprise bean access
087:         * ______________________|__________________________________________________
088:         *                       |
089:         * ejbSelectInEntity*    |  EntityContext methods:
090:         *                       |     - getEJBHome 
091:         *                       |     - getCallerPrincipal
092:         *                       |     - getRollbackOnly
093:         *                       |     - isCallerInRole
094:         *                       |     - setRollbackOnly
095:         *                       |     - getEJBObject
096:         *                       |     - getPrimaryKey
097:         *                       |  JNDI access to java:comp/env
098:         *                       |  Resource manager access
099:         *                       |  Enterprise bean access
100:         * ______________________|__________________________________________________
101:         *                       |
102:         * ejbActivate           |  EntityContext methods: 
103:         * ejbPassivate          |     - getEJBHome 
104:         *                       |     - getEJBObject
105:         *                       |     - getPrimaryKey
106:         *                       |  JNDI access to java:comp/env
107:         * ______________________|__________________________________________________
108:         *                       |
109:         * ejbLoad               |  EntityContext methods: 
110:         * ejbStore              |     - getEJBHome        
111:         *                       |     - getCallerPrincipal
112:         *                       |     - getRollbackOnly   
113:         *                       |     - isCallerInRole    
114:         *                       |     - setRollbackOnly   
115:         *                       |     - getEJBObject      
116:         *                       |     - getPrimaryKey     
117:         *                       |  JNDI access to java:comp/env
118:         *                       |  Resource manager access
119:         *                       |  Enterprise bean access
120:         * ______________________|__________________________________________________
121:         *                       |
122:         * business method       |  EntityContext methods:
123:         * from remote interface |     - getEJBHome           
124:         *                       |     - getCallerPrincipal
125:         *                       |     - getRollbackOnly   
126:         *                       |     - isCallerInRole    
127:         *                       |     - setRollbackOnly   
128:         *                       |     - getEJBObject      
129:         *                       |     - getPrimaryKey     
130:         *                       |  JNDI access to java:comp/env
131:         *                       |  Resource manager access
132:         *                       |  Enterprise bean access
133:         * ______________________|__________________________________________________
134:         * </PRE>                
135:         *                       
136:         * @author <a href="mailto:david.blevins@visi.com">David Blevins</a>
137:         * @author <a href="mailto:Richard@Monson-Haefel.com">Richard Monson-Haefel</a>
138:         */
139:        public class CmpAllowedOperationsTests extends BasicCmpTestClient {
140:
141:            public CmpAllowedOperationsTests() {
142:                super ("AllowedOperations.");
143:            }
144:
145:            protected void setUp() throws Exception {
146:                super .setUp();
147:                Object obj = initialContext
148:                        .lookup("client/tests/entity/cmp/allowed_operations/EntityHome");
149:                ejbHome = (BasicCmpHome) PortableRemoteObject.narrow(obj,
150:                        BasicCmpHome.class);
151:                ejbObject = ejbHome.createObject("Fourth Bean");
152:                ejbHandle = ejbObject.getHandle();
153:                /* These tests will only work if the specified
154:                 * method has already been called by the container.
155:                 *
156:                 * TO DO:
157:                 * Implement a little application senario to ensure
158:                 * that all methods tested for below have been called
159:                 * by the container.
160:                 */
161:                doScenario();
162:            }
163:
164:            protected void tearDown() throws Exception {
165:                ejbObject.remove();
166:                super .tearDown();
167:            }
168:
169:            /**
170:             * This method ensures that all thee bean methods have been invoked for correct behaviour
171:             * of the tests. 
172:             *
173:             */
174:            private void doScenario() throws Exception {
175:
176:                // Call the business method
177:                ejbObject.businessMethod("Reverse Me");
178:
179:                ejbHome.sum(1, 2);
180:
181:                ejbObject.remove();
182:
183:                ejbObject = ejbHome.createObject("Fourth Bean");
184:                ejbHome.findEmptyCollection();
185:
186:                ejbHome.voidSelect();
187:            }
188:
189:            //=====================================
190:            // Test EJBContext allowed operations       
191:            //
192:            /**
193:             * <PRE>
194:             * Bean method           | Bean method can perform the following operations
195:             * ______________________|__________________________________________________
196:             *                       |
197:             * setEntityContext      |  EntityContext methods:
198:             * unsetEntityContext    |     - getEJBHome
199:             *                       |  JNDI access to java:comp/env
200:             * ______________________|__________________________________________________
201:             * </PRE>
202:             */
203:            public void test01_setEntityContext() {
204:                try {
205:
206:                    OperationsPolicy policy = new OperationsPolicy();
207:                    policy.allow(OperationsPolicy.Context_getEJBHome);
208:                    policy.allow(OperationsPolicy.JNDI_access_to_java_comp_env);
209:
210:                    Object expected = policy;
211:                    Object actual = ejbObject
212:                            .getAllowedOperationsReport("setEntityContext");
213:
214:                    assertNotNull("The OperationsPolicy is null", actual);
215:                    assertEquals(expected, actual);
216:
217:                } catch (Exception e) {
218:                    fail("Received Exception " + e.getClass() + " : "
219:                            + e.getMessage());
220:                }
221:            }
222:
223:            /**
224:             * <PRE>
225:             * Bean method           | Bean method can perform the following operations
226:             * ______________________|__________________________________________________
227:             *                       |
228:             * setEntityContext      |  EntityContext methods: 
229:             * unsetEntityContext    |     - getEJBHome
230:             *                       |  JNDI access to java:comp/env
231:             * ______________________|__________________________________________________
232:             * </PRE>
233:             */
234:            public void TODO_test02_unsetEntityContext() {
235:                try {
236:
237:                    /* TO DO:  This test needs unique functionality to work */
238:                    OperationsPolicy policy = new OperationsPolicy();
239:                    policy.allow(OperationsPolicy.Context_getEJBHome);
240:                    policy.allow(OperationsPolicy.JNDI_access_to_java_comp_env);
241:
242:                    Object expected = policy;
243:                    Object actual = ejbObject
244:                            .getAllowedOperationsReport("unsetEntityContext");
245:
246:                    assertNotNull("The OperationsPolicy is null", actual);
247:                    assertEquals(expected, actual);
248:
249:                } catch (Exception e) {
250:                    fail("Received Exception " + e.getClass() + " : "
251:                            + e.getMessage());
252:                }
253:            }
254:
255:            /**
256:             * <PRE>
257:             * Bean method           | Bean method can perform the following operations
258:             * ______________________|__________________________________________________
259:             *                       |
260:             * ejbCreate             |  EntityContext methods:
261:             *                       |     - getEJBHome
262:             *                       |     - getCallerPrincipal
263:             *                       |     - getRollbackOnly
264:             *                       |     - isCallerInRole
265:             *                       |     - setRollbackOnly
266:             *                       |  JNDI access to java:comp/env
267:             *                       |  Resource manager access
268:             *                       |  Enterprise bean access
269:             * ______________________|__________________________________________________
270:             * </PRE>
271:             */
272:            public void test03_ejbCreate() {
273:                try {
274:
275:                    OperationsPolicy policy = new OperationsPolicy();
276:                    policy.allow(OperationsPolicy.Context_getEJBHome);
277:                    policy.allow(OperationsPolicy.Context_getCallerPrincipal);
278:                    //        policy.allow( OperationsPolicy.Context_getRollbackOnly );
279:                    policy.allow(OperationsPolicy.Context_isCallerInRole);
280:                    //        policy.allow( OperationsPolicy.Context_setRollbackOnly );
281:                    policy.allow(OperationsPolicy.JNDI_access_to_java_comp_env);
282:
283:                    Object expected = policy;
284:                    Object actual = ejbObject
285:                            .getAllowedOperationsReport("ejbCreate");
286:
287:                    assertNotNull("The OperationsPolicy is null", actual);
288:                    assertEquals(expected, actual);
289:
290:                } catch (Exception e) {
291:                    fail("Received Exception " + e.getClass() + " : "
292:                            + e.getMessage());
293:                }
294:            }
295:
296:            /**
297:             * <PRE>
298:             * Bean method           | Bean method can perform the following operations
299:             * ______________________|__________________________________________________
300:             *                       |
301:             * ejbPostCreate         |  EntityContext methods:
302:             *                       |     - getEJBHome
303:             *                       |     - getCallerPrincipal
304:             *                       |     - getRollbackOnly
305:             *                       |     - isCallerInRole
306:             *                       |     - setRollbackOnly
307:             *                       |     - getEJBObject
308:             *                       |     - getPrimaryKey
309:             *                       |  JNDI access to java:comp/env
310:             *                       |  Resource manager access
311:             *                       |  Enterprise bean access
312:             * ______________________|__________________________________________________
313:             * </PRE>
314:             */
315:            public void test04_ejbPostCreate() {
316:                try {
317:
318:                    OperationsPolicy policy = new OperationsPolicy();
319:                    policy.allow(OperationsPolicy.Context_getEJBHome);
320:                    policy.allow(OperationsPolicy.Context_getCallerPrincipal);
321:                    //        policy.allow( OperationsPolicy.Context_getRollbackOnly );
322:                    policy.allow(OperationsPolicy.Context_isCallerInRole);
323:                    //        policy.allow( OperationsPolicy.Context_setRollbackOnly );
324:                    policy.allow(OperationsPolicy.Context_getEJBObject);
325:                    policy.allow(OperationsPolicy.Context_getPrimaryKey);
326:                    policy.allow(OperationsPolicy.JNDI_access_to_java_comp_env);
327:
328:                    Object expected = policy;
329:                    Object actual = ejbObject
330:                            .getAllowedOperationsReport("ejbPostCreate");
331:
332:                    assertNotNull("The OperationsPolicy is null", actual);
333:                    assertEquals(expected, actual);
334:
335:                } catch (Exception e) {
336:                    fail("Received Exception " + e.getClass() + " : "
337:                            + e.getMessage());
338:                }
339:            }
340:
341:            /**
342:             * <PRE>
343:             * Bean method           | Bean method can perform the following operations
344:             * ______________________|__________________________________________________
345:             *                       |
346:             * ejbRemove             |  EntityContext methods:
347:             *                       |     - getEJBHome
348:             *                       |     - getCallerPrincipal
349:             *                       |     - getRollbackOnly
350:             *                       |     - isCallerInRole
351:             *                       |     - setRollbackOnly
352:             *                       |     - getEJBObject
353:             *                       |     - getPrimaryKey
354:             *                       |  JNDI access to java:comp/env
355:             *                       |  Resource manager access
356:             *                       |  Enterprise bean access
357:             * ______________________|__________________________________________________
358:             * </PRE>
359:             */
360:            public void test05_ejbRemove() {
361:                try {
362:
363:                    OperationsPolicy policy = new OperationsPolicy();
364:                    policy.allow(OperationsPolicy.Context_getEJBHome);
365:                    policy.allow(OperationsPolicy.Context_getCallerPrincipal);
366:                    policy.allow(OperationsPolicy.Context_getRollbackOnly);
367:                    policy.allow(OperationsPolicy.Context_isCallerInRole);
368:                    //        policy.allow( OperationsPolicy.Context_setRollbackOnly );
369:                    policy.allow(OperationsPolicy.Context_getEJBObject);
370:                    policy.allow(OperationsPolicy.Context_getPrimaryKey);
371:                    policy.allow(OperationsPolicy.JNDI_access_to_java_comp_env);
372:
373:                    Object expected = policy;
374:                    Object actual = ejbObject
375:                            .getAllowedOperationsReport("ejbRemove");
376:
377:                    assertNotNull("The OperationsPolicy is null", actual);
378:                    assertEquals(expected, actual);
379:
380:                } catch (Exception e) {
381:                    fail("Received Exception " + e.getClass() + " : "
382:                            + e.getMessage());
383:                }
384:            }
385:
386:            /**
387:             * <PRE>
388:             * Bean method           | Bean method can perform the following operations
389:             * ______________________|__________________________________________________
390:             *                       |
391:             * ejbFind*              |  EntityContext methods:
392:             * ejbSelect*            |     - getEJBHome
393:             * ejbHome               |     - getCallerPrincipal
394:             *                       |     - getRollbackOnly
395:             *                       |     - isCallerInRole
396:             *                       |     - setRollbackOnly
397:             *                       |  JNDI access to java:comp/env
398:             *                       |  Resource manager access
399:             *                       |  Enterprise bean access
400:             * ______________________|__________________________________________________
401:             * </PRE>
402:             */
403:            public void TODO_test07_ejbSelect() {
404:                try {
405:
406:                    OperationsPolicy policy = new OperationsPolicy();
407:                    policy.allow(OperationsPolicy.Context_getEJBHome);
408:                    policy.allow(OperationsPolicy.Context_getCallerPrincipal);
409:                    policy.allow(OperationsPolicy.Context_getRollbackOnly);
410:                    policy.allow(OperationsPolicy.Context_isCallerInRole);
411:                    //        policy.allow( OperationsPolicy.Context_setRollbackOnly );
412:                    policy.allow(OperationsPolicy.JNDI_access_to_java_comp_env);
413:
414:                    Object expected = policy;
415:                    Object actual = ejbObject
416:                            .getAllowedOperationsReport("ejbSelect");
417:
418:                    assertNotNull("The OperationsPolicy is null", actual);
419:                    assertEquals(expected, actual);
420:
421:                } catch (Exception e) {
422:                    fail("Received Exception " + e.getClass() + " : "
423:                            + e.getMessage());
424:                }
425:            }
426:
427:            /**
428:             * <PRE>
429:             * Bean method           | Bean method can perform the following operations
430:             * ______________________|__________________________________________________
431:             *                       |
432:             * ejbFind*              |  EntityContext methods:
433:             * ejbSelect*            |     - getEJBHome
434:             * ejbHome               |     - getCallerPrincipal
435:             *                       |     - getRollbackOnly
436:             *                       |     - isCallerInRole
437:             *                       |     - setRollbackOnly
438:             *                       |  JNDI access to java:comp/env
439:             *                       |  Resource manager access
440:             *                       |  Enterprise bean access
441:             * ______________________|__________________________________________________
442:             * </PRE>
443:             */
444:            public void test08_ejbHome() {
445:                try {
446:
447:                    OperationsPolicy policy = new OperationsPolicy();
448:                    policy.allow(OperationsPolicy.Context_getEJBHome);
449:                    policy.allow(OperationsPolicy.Context_getCallerPrincipal);
450:                    //        policy.allow( OperationsPolicy.Context_getRollbackOnly );
451:                    policy.allow(OperationsPolicy.Context_isCallerInRole);
452:                    //        policy.allow( OperationsPolicy.Context_setRollbackOnly );
453:                    policy.allow(OperationsPolicy.JNDI_access_to_java_comp_env);
454:
455:                    Object expected = policy;
456:                    Object actual = ejbObject
457:                            .getAllowedOperationsReport("ejbHome");
458:
459:                    assertNotNull("The OperationsPolicy is null", actual);
460:                    assertEquals(expected, actual);
461:
462:                } catch (Exception e) {
463:                    fail("Received Exception " + e.getClass() + " : "
464:                            + e.getMessage());
465:                }
466:            }
467:
468:            /**
469:             * <PRE>
470:             * Bean method           | Bean method can perform the following operations
471:             * ______________________|__________________________________________________
472:             *                       |
473:             * ejbSelectInEntity*    |  EntityContext methods:
474:             *                       |     - getEJBHome
475:             *                       |     - getCallerPrincipal
476:             *                       |     - getRollbackOnly
477:             *                       |     - isCallerInRole
478:             *                       |     - setRollbackOnly
479:             *                       |     - getEJBObject
480:             *                       |     - getPrimaryKey
481:             *                       |  JNDI access to java:comp/env
482:             *                       |  Resource manager access
483:             *                       |  Enterprise bean access
484:             * ______________________|__________________________________________________
485:             * </PRE>
486:             */
487:            public void TODO_test09_ejbSelectInEntity() {
488:                try {
489:
490:                    OperationsPolicy policy = new OperationsPolicy();
491:                    policy.allow(OperationsPolicy.Context_getEJBHome);
492:                    policy.allow(OperationsPolicy.Context_getCallerPrincipal);
493:                    policy.allow(OperationsPolicy.Context_getRollbackOnly);
494:                    policy.allow(OperationsPolicy.Context_isCallerInRole);
495:                    //        policy.allow( OperationsPolicy.Context_setRollbackOnly );
496:                    policy.allow(OperationsPolicy.Context_getEJBObject);
497:                    policy.allow(OperationsPolicy.Context_getPrimaryKey);
498:                    policy.allow(OperationsPolicy.JNDI_access_to_java_comp_env);
499:
500:                    Object expected = policy;
501:                    Object actual = ejbObject
502:                            .getAllowedOperationsReport("ejbSelectInEntity");
503:
504:                    assertNotNull("The OperationsPolicy is null", actual);
505:                    assertEquals(expected, actual);
506:
507:                } catch (Exception e) {
508:                    fail("Received Exception " + e.getClass() + " : "
509:                            + e.getMessage());
510:                }
511:            }
512:
513:            /**
514:             * <PRE>
515:             * Bean method           | Bean method can perform the following operations
516:             * ______________________|__________________________________________________
517:             *                       |
518:             * ejbActivate           |  EntityContext methods:
519:             * ejbPassivate          |     - getEJBHome
520:             *                       |     - getEJBObject
521:             *                       |     - getPrimaryKey
522:             *                       |  JNDI access to java:comp/env
523:             * ______________________|__________________________________________________
524:             * </PRE>
525:             */
526:            public void test10_ejbActivate() {
527:                try {
528:
529:                    OperationsPolicy policy = new OperationsPolicy();
530:                    policy.allow(OperationsPolicy.Context_getEJBHome);
531:                    policy.allow(OperationsPolicy.Context_getEJBObject);
532:                    policy.allow(OperationsPolicy.Context_getPrimaryKey);
533:                    policy.allow(OperationsPolicy.JNDI_access_to_java_comp_env);
534:
535:                    Object expected = policy;
536:                    Object actual = ejbObject
537:                            .getAllowedOperationsReport("ejbActivate");
538:
539:                    assertNotNull("The OperationsPolicy is null", actual);
540:                    assertEquals(expected, actual);
541:
542:                } catch (Exception e) {
543:                    fail("Received Exception " + e.getClass() + " : "
544:                            + e.getMessage());
545:                }
546:            }
547:
548:            /**
549:             * <PRE>
550:             * Bean method           | Bean method can perform the following operations
551:             * ______________________|__________________________________________________
552:             *                       |
553:             * ejbActivate           |  EntityContext methods:
554:             * ejbPassivate          |     - getEJBHome
555:             *                       |     - getEJBObject
556:             *                       |     - getPrimaryKey
557:             *                       |  JNDI access to java:comp/env
558:             * ______________________|__________________________________________________
559:             * </PRE>
560:             */
561:            public void TODO_test11_ejbPassivate() {
562:                try {
563:
564:                    OperationsPolicy policy = new OperationsPolicy();
565:                    policy.allow(OperationsPolicy.Context_getEJBHome);
566:                    policy.allow(OperationsPolicy.Context_getEJBObject);
567:                    policy.allow(OperationsPolicy.Context_getPrimaryKey);
568:                    policy.allow(OperationsPolicy.JNDI_access_to_java_comp_env);
569:
570:                    Object expected = policy;
571:                    Object actual = ejbObject
572:                            .getAllowedOperationsReport("ejbPassivate");
573:
574:                    assertNotNull("The OperationsPolicy is null", actual);
575:                    assertEquals(expected, actual);
576:
577:                } catch (Exception e) {
578:                    fail("Received Exception " + e.getClass() + " : "
579:                            + e.getMessage());
580:                }
581:            }
582:
583:            /**
584:             * <PRE>
585:             * Bean method           | Bean method can perform the following operations
586:             * ______________________|__________________________________________________
587:             *                       |
588:             * ejbLoad               |  EntityContext methods:
589:             * ejbStore              |     - getEJBHome
590:             *                       |     - getCallerPrincipal
591:             *                       |     - getRollbackOnly
592:             *                       |     - isCallerInRole
593:             *                       |     - setRollbackOnly
594:             *                       |     - getEJBObject
595:             *                       |     - getPrimaryKey
596:             *                       |  JNDI access to java:comp/env
597:             *                       |  Resource manager access
598:             *                       |  Enterprise bean access
599:             * ______________________|__________________________________________________
600:             * </PRE>
601:             */
602:            public void test12_ejbLoad() {
603:                try {
604:
605:                    OperationsPolicy policy = new OperationsPolicy();
606:                    policy.allow(OperationsPolicy.Context_getEJBHome);
607:                    policy.allow(OperationsPolicy.Context_getCallerPrincipal);
608:                    policy.allow(OperationsPolicy.Context_getRollbackOnly);
609:                    policy.allow(OperationsPolicy.Context_isCallerInRole);
610:                    //        policy.allow( OperationsPolicy.Context_setRollbackOnly );
611:                    policy.allow(OperationsPolicy.Context_getEJBObject);
612:                    policy.allow(OperationsPolicy.Context_getPrimaryKey);
613:                    policy.allow(OperationsPolicy.JNDI_access_to_java_comp_env);
614:
615:                    Object expected = policy;
616:                    Object actual = ejbObject
617:                            .getAllowedOperationsReport("ejbLoad");
618:
619:                    assertNotNull("The OperationsPolicy is null", actual);
620:                    assertEquals(expected, actual);
621:
622:                } catch (Exception e) {
623:                    fail("Received Exception " + e.getClass() + " : "
624:                            + e.getMessage());
625:                }
626:            }
627:
628:            /**
629:             * <PRE>
630:             * Bean method           | Bean method can perform the following operations
631:             * ______________________|__________________________________________________
632:             *                       |
633:             * ejbLoad               |  EntityContext methods:
634:             * ejbStore              |     - getEJBHome
635:             *                       |     - getCallerPrincipal
636:             *                       |     - getRollbackOnly
637:             *                       |     - isCallerInRole
638:             *                       |     - setRollbackOnly
639:             *                       |     - getEJBObject
640:             *                       |     - getPrimaryKey
641:             *                       |  JNDI access to java:comp/env
642:             *                       |  Resource manager access
643:             *                       |  Enterprise bean access
644:             * ______________________|__________________________________________________
645:             * </PRE>
646:             */
647:            public void test13_ejbStore() {
648:                try {
649:
650:                    OperationsPolicy policy = new OperationsPolicy();
651:                    policy.allow(OperationsPolicy.Context_getEJBHome);
652:                    policy.allow(OperationsPolicy.Context_getCallerPrincipal);
653:                    policy.allow(OperationsPolicy.Context_getRollbackOnly);
654:                    policy.allow(OperationsPolicy.Context_isCallerInRole);
655:                    //        policy.allow( OperationsPolicy.Context_setRollbackOnly );
656:                    policy.allow(OperationsPolicy.Context_getEJBObject);
657:                    policy.allow(OperationsPolicy.Context_getPrimaryKey);
658:                    policy.allow(OperationsPolicy.JNDI_access_to_java_comp_env);
659:
660:                    Object expected = policy;
661:                    Object actual = ejbObject
662:                            .getAllowedOperationsReport("ejbStore");
663:
664:                    assertNotNull("The OperationsPolicy is null", actual);
665:                    assertEquals(expected, actual);
666:
667:                } catch (Exception e) {
668:                    fail("Received Exception " + e.getClass() + " : "
669:                            + e.getMessage());
670:                }
671:            }
672:
673:            /**
674:             * <PRE>
675:             * Bean method           | Bean method can perform the following operations
676:             * ______________________|__________________________________________________
677:             *                       |
678:             * business method       |  EntityContext methods:
679:             * from remote interface |     - getEJBHome
680:             *                       |     - getCallerPrincipal
681:             *                       |     - getRollbackOnly
682:             *                       |     - isCallerInRole
683:             *                       |     - setRollbackOnly
684:             *                       |     - getEJBObject
685:             *                       |     - getPrimaryKey
686:             *                       |  JNDI access to java:comp/env
687:             *                       |  Resource manager access
688:             *                       |  Enterprise bean access
689:             * ______________________|__________________________________________________
690:             * </PRE>
691:             */
692:            public void test14_businessMethod() {
693:                try {
694:
695:                    OperationsPolicy policy = new OperationsPolicy();
696:                    policy.allow(OperationsPolicy.Context_getEJBHome);
697:                    policy.allow(OperationsPolicy.Context_getCallerPrincipal);
698:                    //        policy.allow( OperationsPolicy.Context_getRollbackOnly );
699:                    policy.allow(OperationsPolicy.Context_isCallerInRole);
700:                    //        policy.allow( OperationsPolicy.Context_setRollbackOnly );
701:                    policy.allow(OperationsPolicy.Context_getEJBObject);
702:                    policy.allow(OperationsPolicy.Context_getPrimaryKey);
703:                    policy.allow(OperationsPolicy.JNDI_access_to_java_comp_env);
704:
705:                    Object expected = policy;
706:                    Object actual = ejbObject
707:                            .getAllowedOperationsReport("businessMethod");
708:
709:                    assertNotNull("The OperationsPolicy is null", actual);
710:                    assertEquals(expected, actual);
711:
712:                } catch (Exception e) {
713:                    fail("Received Exception " + e.getClass() + " : "
714:                            + e.getMessage());
715:                }
716:            }
717:            //
718:            // Test EJBContext allowed operations       
719:            //=====================================
720:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.