Source Code Cross Referenced for Cmp2AllowedOperationsTests.java in  » J2EE » openejb3 » org » apache » openejb » test » entity » cmp2 » 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.cmp2 
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.cmp2;
017:
018:        import org.apache.openejb.test.object.OperationsPolicy;
019:        import org.apache.openejb.test.entity.cmp.BasicCmpHome;
020:        import org.apache.openejb.test.entity.cmp.BasicCmpObject;
021:
022:        /**
023:         * [9] Should be run as the nineth test suite of the BasicCmpTestClients
024:         * <p/>
025:         * <PRE>
026:         * =========================================================================
027:         * Operations allowed in the methods of an entity bean
028:         * =========================================================================
029:         * <p/>
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:        public class Cmp2AllowedOperationsTests extends BasicCmp2TestClient {
137:            public Cmp2AllowedOperationsTests() {
138:                super ("AllowedOperations.");
139:            }
140:
141:            protected void setUp() throws Exception {
142:                super .setUp();
143:                Object obj = initialContext
144:                        .lookup("client/tests/entity/cmp2/allowed_operations/EntityHome");
145:                ejbHome = (BasicCmpHome) javax.rmi.PortableRemoteObject.narrow(
146:                        obj, BasicCmpHome.class);
147:                ejbObject = ejbHome.createObject("Fourth Bean");
148:                ejbHandle = ejbObject.getHandle();
149:                /* These tests will only work if the specified
150:                 * method has already been called by the container.
151:                 *
152:                 * TO DO:
153:                 * Implement a little application senario to ensure
154:                 * that all methods tested for below have been called
155:                 * by the container.
156:                 */
157:                doScenario();
158:
159:            }
160:
161:            protected void tearDown() throws Exception {
162:                try {
163:                    ejbObject.remove();
164:                } catch (Throwable e) {
165:                    // todo this throws an exception for an unrelated reason....
166:                }
167:                super .tearDown();
168:            }
169:
170:            /**
171:             * This method ensures that all thee bean methods have been invoked for correct behaviour
172:             * of the tests.
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 = (BasicCmpObject) ejbHandle.getEJBObject();
182:
183:                ejbHome.findByPrimaryKey((Integer) ejbObject.getPrimaryKey());
184:                ejbHome.remove(ejbObject.getPrimaryKey());
185:
186:                ejbObject = ejbHome.createObject("Fourth Bean");
187:                ejbHome.findEmptyCollection();
188:            }
189:
190:            //=====================================
191:            // Test EJBContext allowed operations       
192:            //
193:            /**
194:             * <PRE>
195:             * Bean method           | Bean method can perform the following operations
196:             * ______________________|__________________________________________________
197:             * |
198:             * setEntityContext      |  EntityContext methods:
199:             * unsetEntityContext    |     - getEJBHome
200:             * |  JNDI access to java:comp/env
201:             * ______________________|__________________________________________________
202:             * </PRE>
203:             */
204:            public void test01_setEntityContext() {
205:                try {
206:
207:                    OperationsPolicy policy = new OperationsPolicy();
208:                    policy.allow(OperationsPolicy.Context_getEJBHome);
209:                    policy.allow(OperationsPolicy.JNDI_access_to_java_comp_env);
210:
211:                    Object expected = policy;
212:                    Object actual = ejbObject
213:                            .getAllowedOperationsReport("setEntityContext");
214:
215:                    assertNotNull("The OperationsPolicy is null", actual);
216:                    assertEquals(expected, actual);
217:
218:                } catch (Exception e) {
219:                    fail("Received Exception " + e.getClass() + " : "
220:                            + e.getMessage());
221:                }
222:            }
223:
224:            /**
225:             * <PRE>
226:             * Bean method           | Bean method can perform the following operations
227:             * ______________________|__________________________________________________
228:             * |
229:             * setEntityContext      |  EntityContext methods:
230:             * unsetEntityContext    |     - getEJBHome
231:             * |  JNDI access to java:comp/env
232:             * ______________________|__________________________________________________
233:             * </PRE>
234:             */
235:            public void TODO_test02_unsetEntityContext() {
236:                try {
237:
238:                    /* TO DO:  This test needs unique functionality to work */
239:                    OperationsPolicy policy = new OperationsPolicy();
240:                    policy.allow(OperationsPolicy.Context_getEJBHome);
241:                    policy.allow(OperationsPolicy.JNDI_access_to_java_comp_env);
242:
243:                    Object expected = policy;
244:                    Object actual = ejbObject
245:                            .getAllowedOperationsReport("unsetEntityContext");
246:
247:                    assertNotNull("The OperationsPolicy is null", actual);
248:                    assertEquals(expected, actual);
249:
250:                } catch (Exception e) {
251:                    fail("Received Exception " + e.getClass() + " : "
252:                            + e.getMessage());
253:                }
254:            }
255:
256:            /**
257:             * <PRE>
258:             * Bean method           | Bean method can perform the following operations
259:             * ______________________|__________________________________________________
260:             * |
261:             * ejbCreate             |  EntityContext methods:
262:             * |     - getEJBHome
263:             * |     - getCallerPrincipal
264:             * |     - getRollbackOnly
265:             * |     - isCallerInRole
266:             * |     - setRollbackOnly
267:             * |  JNDI access to java:comp/env
268:             * |  Resource manager access
269:             * |  Enterprise bean access
270:             * ______________________|__________________________________________________
271:             * </PRE>
272:             */
273:            public void test03_ejbCreate() {
274:                try {
275:
276:                    OperationsPolicy policy = new OperationsPolicy();
277:                    policy.allow(OperationsPolicy.Context_getEJBHome);
278:                    policy.allow(OperationsPolicy.Context_getCallerPrincipal);
279:                    policy.allow(OperationsPolicy.Context_isCallerInRole);
280:                    policy.allow(OperationsPolicy.Context_getRollbackOnly);
281:                    //        policy.allow( OperationsPolicy.Context_setRollbackOnly );
282:                    policy.allow(OperationsPolicy.JNDI_access_to_java_comp_env);
283:
284:                    Object expected = policy;
285:                    Object actual = ejbObject
286:                            .getAllowedOperationsReport("ejbCreate");
287:
288:                    assertNotNull("The OperationsPolicy is null", actual);
289:                    assertEquals(expected, actual);
290:
291:                } catch (Exception e) {
292:                    fail("Received Exception " + e.getClass() + " : "
293:                            + e.getMessage());
294:                }
295:            }
296:
297:            /**
298:             * <PRE>
299:             * Bean method           | Bean method can perform the following operations
300:             * ______________________|__________________________________________________
301:             * |
302:             * ejbPostCreate         |  EntityContext methods:
303:             * |     - getEJBHome
304:             * |     - getCallerPrincipal
305:             * |     - getRollbackOnly
306:             * |     - isCallerInRole
307:             * |     - setRollbackOnly
308:             * |     - getEJBObject
309:             * |     - getPrimaryKey
310:             * |  JNDI access to java:comp/env
311:             * |  Resource manager access
312:             * |  Enterprise bean access
313:             * ______________________|__________________________________________________
314:             * </PRE>
315:             */
316:            public void test04_ejbPostCreate() {
317:                try {
318:
319:                    OperationsPolicy policy = new OperationsPolicy();
320:                    policy.allow(OperationsPolicy.Context_getEJBHome);
321:                    policy.allow(OperationsPolicy.Context_getCallerPrincipal);
322:                    policy.allow(OperationsPolicy.Context_getRollbackOnly);
323:                    policy.allow(OperationsPolicy.Context_isCallerInRole);
324:                    //        policy.allow( OperationsPolicy.Context_setRollbackOnly );
325:                    policy.allow(OperationsPolicy.Context_getEJBObject);
326:                    policy.allow(OperationsPolicy.Context_getPrimaryKey);
327:                    policy.allow(OperationsPolicy.JNDI_access_to_java_comp_env);
328:
329:                    Object expected = policy;
330:                    Object actual = ejbObject
331:                            .getAllowedOperationsReport("ejbPostCreate");
332:
333:                    assertNotNull("The OperationsPolicy is null", actual);
334:                    assertEquals(expected, actual);
335:
336:                } catch (Exception e) {
337:                    fail("Received Exception " + e.getClass() + " : "
338:                            + e.getMessage());
339:                }
340:            }
341:
342:            /**
343:             * <PRE>
344:             * Bean method           | Bean method can perform the following operations
345:             * ______________________|__________________________________________________
346:             * |
347:             * ejbRemove             |  EntityContext methods:
348:             * |     - getEJBHome
349:             * |     - getCallerPrincipal
350:             * |     - getRollbackOnly
351:             * |     - isCallerInRole
352:             * |     - setRollbackOnly
353:             * |     - getEJBObject
354:             * |     - getPrimaryKey
355:             * |  JNDI access to java:comp/env
356:             * |  Resource manager access
357:             * |  Enterprise bean access
358:             * ______________________|__________________________________________________
359:             * </PRE>
360:             */
361:            public void test05_ejbRemove() {
362:                try {
363:
364:                    OperationsPolicy policy = new OperationsPolicy();
365:                    policy.allow(OperationsPolicy.Context_getEJBHome);
366:                    policy.allow(OperationsPolicy.Context_getCallerPrincipal);
367:                    policy.allow(OperationsPolicy.Context_getRollbackOnly);
368:                    policy.allow(OperationsPolicy.Context_isCallerInRole);
369:                    //        policy.allow( OperationsPolicy.Context_setRollbackOnly );
370:                    policy.allow(OperationsPolicy.Context_getEJBObject);
371:                    policy.allow(OperationsPolicy.Context_getPrimaryKey);
372:                    policy.allow(OperationsPolicy.JNDI_access_to_java_comp_env);
373:
374:                    Object expected = policy;
375:                    Object actual = ejbObject
376:                            .getAllowedOperationsReport("ejbRemove");
377:
378:                    assertNotNull("The OperationsPolicy is null", actual);
379:                    assertEquals(expected, actual);
380:
381:                } catch (Exception e) {
382:                    fail("Received Exception " + e.getClass() + " : "
383:                            + e.getMessage());
384:                }
385:            }
386:
387:            /**
388:             * <PRE>
389:             * Bean method           | Bean method can perform the following operations
390:             * ______________________|__________________________________________________
391:             * |
392:             * ejbFind*              |  EntityContext methods:
393:             * ejbSelect*            |     - getEJBHome
394:             * ejbHome               |     - getCallerPrincipal
395:             * |     - getRollbackOnly
396:             * |     - isCallerInRole
397:             * |     - setRollbackOnly
398:             * |  JNDI access to java:comp/env
399:             * |  Resource manager access
400:             * |  Enterprise bean access
401:             * ______________________|__________________________________________________
402:             * </PRE>
403:             */
404:            public void test08_ejbHome() {
405:                try {
406:
407:                    OperationsPolicy policy = new OperationsPolicy();
408:                    policy.allow(OperationsPolicy.Context_getEJBHome);
409:                    policy.allow(OperationsPolicy.Context_getCallerPrincipal);
410:                    policy.allow(OperationsPolicy.Context_getRollbackOnly);
411:                    policy.allow(OperationsPolicy.Context_isCallerInRole);
412:                    //        policy.allow( OperationsPolicy.Context_setRollbackOnly );
413:                    policy.allow(OperationsPolicy.JNDI_access_to_java_comp_env);
414:
415:                    Object expected = policy;
416:                    Object actual = ejbObject
417:                            .getAllowedOperationsReport("ejbHome");
418:
419:                    assertNotNull("The OperationsPolicy is null", actual);
420:                    assertEquals(expected, actual);
421:
422:                } catch (Exception e) {
423:                    fail("Received Exception " + e.getClass() + " : "
424:                            + e.getMessage());
425:                }
426:            }
427:
428:            /**
429:             * <PRE>
430:             * Bean method           | Bean method can perform the following operations
431:             * ______________________|__________________________________________________
432:             * |
433:             * ejbActivate           |  EntityContext methods:
434:             * ejbPassivate          |     - getEJBHome
435:             * |     - getEJBObject
436:             * |     - getPrimaryKey
437:             * |  JNDI access to java:comp/env
438:             * ______________________|__________________________________________________
439:             * </PRE>
440:             */
441:            public void test10_ejbActivate() {
442:                try {
443:
444:                    OperationsPolicy policy = new OperationsPolicy();
445:                    policy.allow(OperationsPolicy.Context_getEJBHome);
446:                    policy.allow(OperationsPolicy.Context_getEJBObject);
447:                    policy.allow(OperationsPolicy.Context_getPrimaryKey);
448:                    policy.allow(OperationsPolicy.JNDI_access_to_java_comp_env);
449:
450:                    Object expected = policy;
451:                    Object actual = ejbObject
452:                            .getAllowedOperationsReport("ejbActivate");
453:
454:                    assertNotNull("The OperationsPolicy is null", actual);
455:                    assertEquals(expected, actual);
456:
457:                } catch (Exception e) {
458:                    fail("Received Exception " + e.getClass() + " : "
459:                            + e.getMessage());
460:                }
461:            }
462:
463:            /**
464:             * <PRE>
465:             * Bean method           | Bean method can perform the following operations
466:             * ______________________|__________________________________________________
467:             * |
468:             * ejbActivate           |  EntityContext methods:
469:             * ejbPassivate          |     - getEJBHome
470:             * |     - getEJBObject
471:             * |     - getPrimaryKey
472:             * |  JNDI access to java:comp/env
473:             * ______________________|__________________________________________________
474:             * </PRE>
475:             */
476:            public void TODO_test11_ejbPassivate() {
477:                try {
478:
479:                    OperationsPolicy policy = new OperationsPolicy();
480:                    policy.allow(OperationsPolicy.Context_getEJBHome);
481:                    policy.allow(OperationsPolicy.Context_getEJBObject);
482:                    policy.allow(OperationsPolicy.Context_getPrimaryKey);
483:                    policy.allow(OperationsPolicy.JNDI_access_to_java_comp_env);
484:
485:                    Object expected = policy;
486:                    Object actual = ejbObject
487:                            .getAllowedOperationsReport("ejbPassivate");
488:
489:                    assertNotNull("The OperationsPolicy is null", actual);
490:                    assertEquals(expected, actual);
491:
492:                } catch (Exception e) {
493:                    fail("Received Exception " + e.getClass() + " : "
494:                            + e.getMessage());
495:                }
496:            }
497:
498:            /**
499:             * <PRE>
500:             * Bean method           | Bean method can perform the following operations
501:             * ______________________|__________________________________________________
502:             * |
503:             * ejbLoad               |  EntityContext methods:
504:             * ejbStore              |     - getEJBHome
505:             * |     - getCallerPrincipal
506:             * |     - getRollbackOnly
507:             * |     - isCallerInRole
508:             * |     - setRollbackOnly
509:             * |     - getEJBObject
510:             * |     - getPrimaryKey
511:             * |  JNDI access to java:comp/env
512:             * |  Resource manager access
513:             * |  Enterprise bean access
514:             * ______________________|__________________________________________________
515:             * </PRE>
516:             */
517:            public void test12_ejbLoad() {
518:                try {
519:
520:                    OperationsPolicy policy = new OperationsPolicy();
521:                    policy.allow(OperationsPolicy.Context_getEJBHome);
522:                    policy.allow(OperationsPolicy.Context_getCallerPrincipal);
523:                    policy.allow(OperationsPolicy.Context_getRollbackOnly);
524:                    policy.allow(OperationsPolicy.Context_isCallerInRole);
525:                    //        policy.allow( OperationsPolicy.Context_setRollbackOnly );
526:                    policy.allow(OperationsPolicy.Context_getEJBObject);
527:                    policy.allow(OperationsPolicy.Context_getPrimaryKey);
528:                    policy.allow(OperationsPolicy.JNDI_access_to_java_comp_env);
529:
530:                    Object expected = policy;
531:                    Object actual = ejbObject
532:                            .getAllowedOperationsReport("ejbLoad");
533:
534:                    assertNotNull("The OperationsPolicy is null", actual);
535:                    assertEquals(expected, actual);
536:
537:                } catch (Exception e) {
538:                    fail("Received Exception " + e.getClass() + " : "
539:                            + e.getMessage());
540:                }
541:            }
542:
543:            /**
544:             * <PRE>
545:             * Bean method           | Bean method can perform the following operations
546:             * ______________________|__________________________________________________
547:             * |
548:             * ejbLoad               |  EntityContext methods:
549:             * ejbStore              |     - getEJBHome
550:             * |     - getCallerPrincipal
551:             * |     - getRollbackOnly
552:             * |     - isCallerInRole
553:             * |     - setRollbackOnly
554:             * |     - getEJBObject
555:             * |     - getPrimaryKey
556:             * |  JNDI access to java:comp/env
557:             * |  Resource manager access
558:             * |  Enterprise bean access
559:             * ______________________|__________________________________________________
560:             * </PRE>
561:             */
562:            public void test13_ejbStore() {
563:                try {
564:
565:                    OperationsPolicy policy = new OperationsPolicy();
566:                    policy.allow(OperationsPolicy.Context_getEJBHome);
567:                    policy.allow(OperationsPolicy.Context_getCallerPrincipal);
568:                    policy.allow(OperationsPolicy.Context_getRollbackOnly);
569:                    policy.allow(OperationsPolicy.Context_isCallerInRole);
570:                    //        policy.allow( OperationsPolicy.Context_setRollbackOnly );
571:                    policy.allow(OperationsPolicy.Context_getEJBObject);
572:                    policy.allow(OperationsPolicy.Context_getPrimaryKey);
573:                    policy.allow(OperationsPolicy.JNDI_access_to_java_comp_env);
574:
575:                    Object expected = policy;
576:                    Object actual = ejbObject
577:                            .getAllowedOperationsReport("ejbStore");
578:
579:                    assertNotNull("The OperationsPolicy is null", actual);
580:                    assertEquals(expected, actual);
581:
582:                } catch (Exception e) {
583:                    fail("Received Exception " + e.getClass() + " : "
584:                            + e.getMessage());
585:                }
586:            }
587:
588:            /**
589:             * <PRE>
590:             * Bean method           | Bean method can perform the following operations
591:             * ______________________|__________________________________________________
592:             * |
593:             * business method       |  EntityContext methods:
594:             * from remote interface |     - getEJBHome
595:             * |     - getCallerPrincipal
596:             * |     - getRollbackOnly
597:             * |     - isCallerInRole
598:             * |     - setRollbackOnly
599:             * |     - getEJBObject
600:             * |     - getPrimaryKey
601:             * |  JNDI access to java:comp/env
602:             * |  Resource manager access
603:             * |  Enterprise bean access
604:             * ______________________|__________________________________________________
605:             * </PRE>
606:             */
607:            public void test14_businessMethod() {
608:                try {
609:
610:                    OperationsPolicy policy = new OperationsPolicy();
611:                    policy.allow(OperationsPolicy.Context_getEJBHome);
612:                    policy.allow(OperationsPolicy.Context_getCallerPrincipal);
613:                    policy.allow(OperationsPolicy.Context_getRollbackOnly);
614:                    policy.allow(OperationsPolicy.Context_isCallerInRole);
615:                    //        policy.allow( OperationsPolicy.Context_setRollbackOnly );
616:                    policy.allow(OperationsPolicy.Context_getEJBObject);
617:                    policy.allow(OperationsPolicy.Context_getPrimaryKey);
618:                    policy.allow(OperationsPolicy.JNDI_access_to_java_comp_env);
619:
620:                    Object expected = policy;
621:                    Object actual = ejbObject
622:                            .getAllowedOperationsReport("businessMethod");
623:
624:                    assertNotNull("The OperationsPolicy is null", actual);
625:                    assertEquals(expected, actual);
626:
627:                } catch (Exception e) {
628:                    fail("Received Exception " + e.getClass() + " : "
629:                            + e.getMessage());
630:                }
631:            }
632:            //
633:            // Test EJBContext allowed operations       
634:            //=====================================
635:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.