Source Code Cross Referenced for BMTStatelessAllowedOperationsTests.java in  » J2EE » openejb3 » org » apache » openejb » test » stateless » 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.stateless 
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.stateless;
017:
018:        import org.apache.openejb.test.object.OperationsPolicy;
019:        import org.apache.openejb.test.beans.TimerSync;
020:
021:        /**
022:         * 
023:         * [10] Should be run as the nineth test suite of the BasicStatelessTestClients
024:         * 
025:         * <PRE>
026:         * =========================================================================
027:         * Operations allowed in the methods of a stateless SessionBean with 
028:         * bean-managed transaction demarcation
029:         * =========================================================================
030:         * 
031:         * Bean method           | Bean method can perform the following operations
032:         * ______________________|__________________________________________________
033:         *                       |
034:         * constructor           | -
035:         * ______________________|__________________________________________________
036:         *                       |
037:         * setSessionContext     |  SessionContext methods:
038:         *                       |     - getEJBHome
039:         *                       |  JNDI access to java:comp/env
040:         * ______________________|__________________________________________________
041:         *                       |
042:         * ejbCreate             |  SessionContext methods:
043:         * ejbRemove             |     - getEJBHome
044:         *                       |     - getEJBObject
045:         *                       |     - getUserTransaction
046:         *                       |  JNDI access to java:comp/env
047:         * ______________________|__________________________________________________
048:         *                       |
049:         * business method       |  SessionContext methods:
050:         * from remote interface |     - getEJBHome        
051:         *                       |     - getCallerPrincipal
052:         *                       |     - isCallerInRole    
053:         *                       |     - getEJBObject      
054:         *                       |     - getUserTransaction
055:         *                       |  JNDI access to java:comp/env
056:         *                       |  Resource manager access
057:         *                       |  Enterprise bean access
058:         * ______________________|__________________________________________________
059:         * </PRE>
060:         * 
061:         * @author <a href="mailto:david.blevins@visi.com">David Blevins</a>
062:         * @author <a href="mailto:Richard@Monson-Haefel.com">Richard Monson-Haefel</a>
063:         */
064:        public class BMTStatelessAllowedOperationsTests extends
065:                BasicStatelessTestClient {
066:            protected TimerSync timerSync;
067:
068:            public BMTStatelessAllowedOperationsTests() {
069:                super ("BMTAllowedOperations.");
070:            }
071:
072:            protected void setUp() throws Exception {
073:                super .setUp();
074:                Object obj = initialContext
075:                        .lookup("client/tests/stateless/BeanManagedBasicStatelessHome");
076:                ejbHome = (BasicStatelessHome) javax.rmi.PortableRemoteObject
077:                        .narrow(obj, BasicStatelessHome.class);
078:                ejbObject = ejbHome.createObject();
079:                ejbHandle = ejbObject.getHandle();
080:                timerSync = (TimerSync) initialContext
081:                        .lookup("TimerSyncBeanBusinessRemote");
082:
083:                /* These tests will only work if the specified
084:                 * method has already been called by the container.
085:                 *
086:                 * TO DO:
087:                 * Implement a little application senario to ensure
088:                 * that all methods tested for below have been called
089:                 * by the container.
090:                 */
091:                ejbObject.businessMethod("let's go!");
092:            }
093:
094:            protected void tearDown() throws Exception {
095:                try {
096:                    ejbObject.remove();
097:                } catch (Exception e) {
098:                    throw e;
099:                } finally {
100:                    super .tearDown();
101:                }
102:            }
103:
104:            //=====================================
105:            // Test EJBContext allowed operations       
106:            //
107:            /**
108:             * <PRE>
109:             * Bean method           | Bean method can perform the following operations
110:             * ______________________|__________________________________________________
111:             *                       |
112:             * setSessionContext     |  SessionContext methods:
113:             *                       |     - getEJBHome
114:             *                       |     - lookup
115:             *                       |  JNDI access to java:comp/env
116:             * ______________________|__________________________________________________
117:             * </PRE>
118:             */
119:            public void test01_setSessionContext() {
120:                try {
121:                    OperationsPolicy policy = new OperationsPolicy();
122:                    policy.allow(policy.Context_getEJBHome);
123:                    policy.allow(policy.Context_lookup);
124:                    policy.allow(policy.JNDI_access_to_java_comp_env);
125:
126:                    Object expected = policy;
127:                    Object actual = ejbObject
128:                            .getAllowedOperationsReport("setSessionContext");
129:
130:                    assertNotNull("The OperationsPolicy is null", actual);
131:                    assertEquals(expected, actual);
132:                } catch (Exception e) {
133:                    fail("Received Exception " + e.getClass() + " : "
134:                            + e.getMessage());
135:                }
136:            }
137:
138:            /**
139:             * <PRE>
140:             * Bean method           | Bean method can perform the following operations
141:             * ______________________|__________________________________________________
142:             *                       |
143:             * ejbCreate             |  SessionContext methods:
144:             * ejbRemove             |     - getEJBHome
145:             *                       |     - getEJBObject
146:             *                       |     - getUserTransaction
147:             *                       |     - getTimerService
148:             *                       |     - lookup
149:             *                       |  JNDI access to java:comp/env
150:             * ______________________|__________________________________________________
151:             * </PRE>
152:             */
153:            public void test02_ejbCreate() {
154:                try {
155:                    OperationsPolicy policy = new OperationsPolicy();
156:                    policy.allow(policy.Context_getEJBHome);
157:                    policy.allow(policy.Context_getEJBObject);
158:                    policy.allow(policy.Context_getUserTransaction);
159:                    policy.allow(policy.Context_getTimerService);
160:                    policy.allow(policy.Context_lookup);
161:                    policy.allow(policy.JNDI_access_to_java_comp_env);
162:
163:                    Object expected = policy;
164:                    Object actual = ejbObject
165:                            .getAllowedOperationsReport("ejbCreate");
166:
167:                    assertNotNull("The OperationsPolicy is null", actual);
168:                    assertEquals(expected, actual);
169:                } catch (Exception e) {
170:                    fail("Received Exception " + e.getClass() + " : "
171:                            + e.getMessage());
172:                }
173:            }
174:
175:            /**
176:             * <PRE>
177:             * Bean method           | Bean method can perform the following operations
178:             * ______________________|__________________________________________________
179:             *                       |
180:             * ejbCreate             |  SessionContext methods:
181:             * ejbRemove             |     - getEJBHome
182:             *                       |     - getEJBObject
183:             *                       |     - getUserTransaction
184:             *                       |     - getTimerService
185:             *                       |     - lookup
186:             *                       |  JNDI access to java:comp/env
187:             * ______________________|__________________________________________________
188:             * </PRE>
189:             */
190:            public void TODO_test03_ejbRemove() {
191:                try {
192:                    /* TO DO:  This test needs unique functionality to work */
193:                    OperationsPolicy policy = new OperationsPolicy();
194:                    policy.allow(policy.Context_getEJBHome);
195:                    policy.allow(policy.Context_getEJBObject);
196:                    policy.allow(policy.Context_getUserTransaction);
197:                    policy.allow(policy.Context_getTimerService);
198:                    policy.allow(policy.Context_lookup);
199:                    policy.allow(policy.JNDI_access_to_java_comp_env);
200:
201:                    Object expected = policy;
202:                    Object actual = ejbObject
203:                            .getAllowedOperationsReport("ejbRemove");
204:
205:                    assertNotNull("The OperationsPolicy is null", actual);
206:                    assertEquals(expected, actual);
207:                } catch (Exception e) {
208:                    fail("Received Exception " + e.getClass() + " : "
209:                            + e.getMessage());
210:                }
211:            }
212:
213:            /**
214:             * <PRE>
215:             * Bean method           | Bean method can perform the following operations
216:             * ______________________|__________________________________________________
217:             *                       |
218:             * business method       |  SessionContext methods:
219:             * from remote interface |     - getEJBHome
220:             *                       |     - getCallerPrincipal
221:             *                       |     - isCallerInRole
222:             *                       |     - getEJBObject
223:             *                       |     - getUserTransaction
224:             *                       |     - getTimerService
225:             *                       |     - lookup
226:             *                       |  JNDI access to java:comp/env
227:             *                       |  Resource manager access
228:             *                       |  Enterprise bean access
229:             * ______________________|__________________________________________________
230:             * </PRE>
231:             */
232:            public void test04_businessMethod() {
233:                try {
234:                    OperationsPolicy policy = new OperationsPolicy();
235:                    policy.allow(policy.Context_getEJBHome);
236:                    policy.allow(policy.Context_getCallerPrincipal);
237:                    policy.allow(policy.Context_isCallerInRole);
238:                    policy.allow(policy.Context_getEJBObject);
239:                    policy.allow(policy.Context_getUserTransaction);
240:                    policy.allow(policy.Context_getTimerService);
241:                    policy.allow(policy.Context_lookup);
242:                    policy.allow(policy.JNDI_access_to_java_comp_env);
243:
244:                    Object expected = policy;
245:                    Object actual = ejbObject
246:                            .getAllowedOperationsReport("businessMethod");
247:
248:                    assertNotNull("The OperationsPolicy is null", actual);
249:                    assertEquals(expected, actual);
250:                } catch (Exception e) {
251:                    fail("Received Exception " + e.getClass() + " : "
252:                            + e.getMessage());
253:                }
254:            }
255:
256:            public void _test05_ejbTimeout() {
257:                try {
258:                    ejbObject
259:                            .scheduleTimer("BmtStatelessAllowedOperationsTests");
260:                    timerSync.waitFor("BmtStatelessAllowedOperationsTests");
261:
262:                    OperationsPolicy policy = new OperationsPolicy();
263:                    policy.allow(policy.Context_getEJBHome);
264:                    policy.allow(policy.Context_getCallerPrincipal);
265:                    policy.allow(policy.Context_isCallerInRole);
266:                    policy.allow(policy.Context_getEJBObject);
267:                    policy.allow(policy.Context_getUserTransaction);
268:                    policy.allow(policy.Context_getTimerService);
269:                    policy.allow(policy.Context_lookup);
270:                    policy.allow(policy.JNDI_access_to_java_comp_env);
271:
272:                    Object expected = policy;
273:                    Object actual = ejbObject
274:                            .getAllowedOperationsReport("ejbTimeout");
275:
276:                    assertNotNull("The OperationsPolicy is null", actual);
277:                    assertEquals(expected, actual);
278:                } catch (Exception e) {
279:                    fail("Received Exception " + e.getClass() + " : "
280:                            + e.getMessage());
281:                }
282:            }
283:            //
284:            // Test EJBContext allowed operations       
285:            //=====================================
286:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.