Source Code Cross Referenced for MdbAllowedOperationsTests.java in  » J2EE » openejb3 » org » apache » openejb » test » mdb » 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.mdb 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         *
003:         * Licensed to the Apache Software Foundation (ASF) under one or more
004:         * contributor license agreements.  See the NOTICE file distributed with
005:         * this work for additional information regarding copyright ownership.
006:         * The ASF licenses this file to You under the Apache License, Version 2.0
007:         * (the "License"); you may not use this file except in compliance with
008:         * the License.  You may obtain a copy of the License at
009:         *
010:         *     http://www.apache.org/licenses/LICENSE-2.0
011:         *
012:         *  Unless required by applicable law or agreed to in writing, software
013:         *  distributed under the License is distributed on an "AS IS" BASIS,
014:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015:         *  See the License for the specific language governing permissions and
016:         *  limitations under the License.
017:         */package org.apache.openejb.test.mdb;
018:
019:        import org.apache.openejb.test.object.OperationsPolicy;
020:
021:        import javax.jms.Destination;
022:
023:        /**
024:         *
025:         * [9] Should be run as the nineth test suite of the BasicStatelessTestClients
026:         *
027:         * <PRE>
028:         * =========================================================================
029:         * Operations allowed in the methods of a stateless SessionBean with
030:         * container-managed transaction demarcation
031:         * =========================================================================
032:         *
033:         * Bean method           | Bean method can perform the following operations
034:         * ______________________|__________________________________________________
035:         *                       |
036:         * constructor           | -
037:         * ______________________|__________________________________________________
038:         *                       |
039:         * setSessionContext     |  SessionContext methods:
040:         *                       |     - getEJBHome
041:         *                       |  JNDI access to java:comp/env
042:         * ______________________|__________________________________________________
043:         *                       |
044:         * ejbCreate             |  SessionContext methods:
045:         * ejbRemove             |     - getEJBHome
046:         *                       |     - getEJBObject
047:         *                       |  JNDI access to java:comp/env
048:         * ______________________|__________________________________________________
049:         *                       |
050:         * business method       |  SessionContext methods:
051:         * from remote interface |     - getEJBHome
052:         *                       |     - getCallerPrincipal
053:         *                       |     - getRollbackOnly
054:         *                       |     - isCallerInRole
055:         *                       |     - setRollbackOnly
056:         *                       |     - getEJBObject
057:         *                       |  JNDI access to java:comp/env
058:         *                       |  Resource manager access
059:         *                       |  Enterprise bean access
060:         * ______________________|__________________________________________________
061:         * </PRE>
062:         *
063:         * @author <a href="mailto:david.blevins@visi.com">David Blevins</a>
064:         * @author <a href="mailto:Richard@Monson-Haefel.com">Richard Monson-Haefel</a>
065:         */
066:        public class MdbAllowedOperationsTests extends MdbTestClient {
067:            protected BasicMdbObject basicMdbObject;
068:
069:            public MdbAllowedOperationsTests() {
070:                super ("AllowedOperations.");
071:            }
072:
073:            protected void setUp() throws Exception {
074:                super .setUp();
075:                Destination destination = (Destination) initialContext
076:                        .lookup("client/tests/messagedriven/mdb/BasicMdb");
077:                basicMdbObject = MdbProxy.newProxyInstance(
078:                        BasicMdbObject.class, connectionFactory, destination);
079:                basicMdbObject.businessMethod("foo");
080:            }
081:
082:            protected void tearDown() throws Exception {
083:                MdbProxy.destroyProxy(basicMdbObject);
084:                super .tearDown();
085:            }
086:
087:            //=====================================
088:            // Test EJBContext allowed operations
089:            //
090:            /**
091:             * <PRE>
092:             * Bean method           | Bean method can perform the following operations
093:             * ______________________|__________________________________________________
094:             *                       |
095:             * dependency injection  |  MessageDrivenContext methods:lookup
096:             * methods (e.g., setMes-|
097:             * sageDrivenContext)    |  JNDI access to java:comp/env
098:             * ______________________|__________________________________________________
099:             * </PRE>
100:             */
101:            public void test01_setSessionContext() {
102:                try {
103:                    OperationsPolicy policy = new OperationsPolicy();
104:                    policy.allow(OperationsPolicy.Context_lookup);
105:                    policy.allow(OperationsPolicy.JNDI_access_to_java_comp_env);
106:
107:                    Object expected = policy;
108:                    Object actual = basicMdbObject
109:                            .getAllowedOperationsReport("setMessageDrivenContext");
110:
111:                    assertNotNull("The OperationsPolicy is null", actual);
112:                    assertEquals(expected, actual);
113:                } catch (Exception e) {
114:                    fail("Received Exception " + e.getClass() + " : "
115:                            + e.getMessage());
116:                }
117:            }
118:
119:            /**
120:             * <PRE>
121:             * Bean method           | Bean method can perform the following operations
122:             * ______________________|__________________________________________________
123:             *                       |
124:             * ejbCreate             |  SessionContext methods:
125:             * ejbRemove             |     - getTimerService
126:             *                       |     - lookup
127:             *                       |  JNDI access to java:comp/env
128:             * ______________________|__________________________________________________
129:             * </PRE>
130:             */
131:            public void test02_ejbCreate() {
132:                try {
133:                    OperationsPolicy policy = new OperationsPolicy();
134:                    policy.allow(OperationsPolicy.Context_lookup);
135:                    policy.allow(OperationsPolicy.JNDI_access_to_java_comp_env);
136:
137:                    Object expected = policy;
138:                    Object actual = basicMdbObject
139:                            .getAllowedOperationsReport("ejbCreate");
140:
141:                    assertNotNull("The OperationsPolicy is null", actual);
142:                    assertEquals(expected, actual);
143:                } catch (Exception e) {
144:                    fail("Received Exception " + e.getClass() + " : "
145:                            + e.getMessage());
146:                }
147:            }
148:
149:            /**
150:             * <PRE>
151:             * Bean method           | Bean method can perform the following operations
152:             * ______________________|__________________________________________________
153:             *                       |
154:             * ejbCreate             |  SessionContext methods:
155:             * ejbRemove             |     - getEJBHome
156:             *                       |     - getEJBObject
157:             *                       |  JNDI access to java:comp/env
158:             * ______________________|__________________________________________________
159:             * </PRE>
160:             */
161:            public void TODO_test03_ejbRemove() {
162:                try {
163:                    /* TO DO:  This test needs unique functionality to work */
164:                    OperationsPolicy policy = new OperationsPolicy();
165:                    policy.allow(OperationsPolicy.Context_getEJBHome);
166:                    policy.allow(OperationsPolicy.Context_getEJBObject);
167:                    policy.allow(OperationsPolicy.JNDI_access_to_java_comp_env);
168:
169:                    Object expected = policy;
170:                    Object actual = basicMdbObject
171:                            .getAllowedOperationsReport("ejbRemove");
172:
173:                    assertNotNull("The OperationsPolicy is null", actual);
174:                    assertEquals(expected, actual);
175:                } catch (Exception e) {
176:                    fail("Received Exception " + e.getClass() + " : "
177:                            + e.getMessage());
178:                }
179:            }
180:
181:            /**
182:             * <PRE>
183:             * Bean method           | Bean method can perform the following operations
184:             * ______________________|__________________________________________________
185:             *                       |
186:             * business method       |  SessionContext methods:
187:             * from remote interface |     - getRollbackOnly
188:             *                       |     - setRollbackOnly
189:             *                       |     - getCallerPrincipal
190:             *                       |     - getTimerService
191:             *                       |     - lookup
192:             *                       |  JNDI access to java:comp/env
193:             *                       |  Resource manager access
194:             *                       |  Enterprise bean access
195:             *                       |  EntityManagerFactory access
196:             * ______________________|__________________________________________________
197:             * </PRE>
198:             */
199:            public void TODO_test04_businessMethod() {
200:                try {
201:                    OperationsPolicy policy = new OperationsPolicy();
202:                    policy.allow(OperationsPolicy.Context_getRollbackOnly);
203:                    // policy.allow( OperationsPolicy.Context_setRollbackOnly );
204:                    policy.allow(OperationsPolicy.Context_getCallerPrincipal);
205:                    policy.allow(OperationsPolicy.Context_lookup);
206:                    policy.allow(OperationsPolicy.JNDI_access_to_java_comp_env);
207:
208:                    Object expected = policy;
209:                    Object actual = basicMdbObject
210:                            .getAllowedOperationsReport("businessMethod");
211:
212:                    assertNotNull("The OperationsPolicy is null", actual);
213:                    assertEquals(expected, actual);
214:                } catch (Exception e) {
215:                    fail("Received Exception " + e.getClass() + " : "
216:                            + e.getMessage());
217:                }
218:            }
219:            //
220:            // Test EJBContext allowed operations
221:            //=====================================
222:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.