Source Code Cross Referenced for BmtMdbAllowedOperationsTests.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 BmtMdbAllowedOperationsTests extends MdbTestClient {
067:            protected BasicMdbObject basicMdbObject;
068:
069:            public BmtMdbAllowedOperationsTests() {
070:                super ("AllowedOperations.");
071:            }
072:
073:            protected void setUp() throws Exception {
074:                super .setUp();
075:                Destination destination = (Destination) initialContext
076:                        .lookup("Basic BMT Mdb Bean");
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:             *                       |     - getUserTransaction,
128:             *                       |  JNDI access to java:comp/env
129:             * ______________________|__________________________________________________
130:             * </PRE>
131:             */
132:            public void test02_ejbCreate() {
133:                try {
134:                    OperationsPolicy policy = new OperationsPolicy();
135:                    policy.allow(OperationsPolicy.Context_lookup);
136:                    policy.allow(OperationsPolicy.Context_getUserTransaction);
137:                    policy.allow(OperationsPolicy.JNDI_access_to_java_comp_env);
138:
139:                    Object expected = policy;
140:                    Object actual = basicMdbObject
141:                            .getAllowedOperationsReport("ejbCreate");
142:
143:                    assertNotNull("The OperationsPolicy is null", actual);
144:                    assertEquals(expected, actual);
145:                } catch (Exception e) {
146:                    fail("Received Exception " + e.getClass() + " : "
147:                            + e.getMessage());
148:                }
149:            }
150:
151:            /**
152:             * <PRE>
153:             * Bean method           | Bean method can perform the following operations
154:             * ______________________|__________________________________________________
155:             *                       |
156:             * ejbCreate             |  SessionContext methods:
157:             * ejbRemove             |     - getEJBHome
158:             *                       |     - getEJBObject
159:             *                       |     - getUserTransaction,
160:             *                       |  JNDI access to java:comp/env
161:             * ______________________|__________________________________________________
162:             * </PRE>
163:             */
164:            public void TODO_test03_ejbRemove() {
165:                try {
166:                    /* TO DO:  This test needs unique functionality to work */
167:                    OperationsPolicy policy = new OperationsPolicy();
168:                    policy.allow(OperationsPolicy.Context_getEJBHome);
169:                    policy.allow(OperationsPolicy.Context_getEJBObject);
170:                    policy.allow(OperationsPolicy.Context_getUserTransaction);
171:                    policy.allow(OperationsPolicy.JNDI_access_to_java_comp_env);
172:
173:                    Object expected = policy;
174:                    Object actual = basicMdbObject
175:                            .getAllowedOperationsReport("ejbRemove");
176:
177:                    assertNotNull("The OperationsPolicy is null", actual);
178:                    assertEquals(expected, actual);
179:                } catch (Exception e) {
180:                    fail("Received Exception " + e.getClass() + " : "
181:                            + e.getMessage());
182:                }
183:            }
184:
185:            /**
186:             * <PRE>
187:             * Bean method           | Bean method can perform the following operations
188:             * ______________________|__________________________________________________
189:             *                       |
190:             * business method       |  SessionContext methods:
191:             * from remote interface |     - getCallerPrincipal
192:             *                       |     - getUserTransaction,
193:             *                       |     - getTimerService
194:             *                       |     - lookup
195:             *                       |  JNDI access to java:comp/env
196:             *                       |  Resource manager access
197:             *                       |  Enterprise bean access
198:             *                       |  EntityManagerFactory access
199:             * ______________________|__________________________________________________
200:             * </PRE>
201:             */
202:            public void test04_businessMethod() {
203:                try {
204:                    OperationsPolicy policy = new OperationsPolicy();
205:                    policy.allow(OperationsPolicy.Context_getUserTransaction);
206:                    policy.allow(OperationsPolicy.Context_getCallerPrincipal);
207:                    policy.allow(OperationsPolicy.Context_lookup);
208:                    policy.allow(OperationsPolicy.JNDI_access_to_java_comp_env);
209:
210:                    Object expected = policy;
211:                    Object actual = basicMdbObject
212:                            .getAllowedOperationsReport("businessMethod");
213:
214:                    assertNotNull("The OperationsPolicy is null", actual);
215:                    assertEquals(expected, actual);
216:                } catch (Exception e) {
217:                    fail("Received Exception " + e.getClass() + " : "
218:                            + e.getMessage());
219:                }
220:            }
221:            //
222:            // Test EJBContext allowed operations
223:            //=====================================
224:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.