Source Code Cross Referenced for StatelessPojoEjbObjectTests.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 javax.ejb.EJBHome;
019:
020:        /**
021:         * This class tests that all javax.ejb.EJBObject methods work as expected on the EJB 2.1 compatible remote interface
022:         * of an ejb3 stateless bean.
023:         * <br>
024:         * [4] Should be run as the fourth test suite of the BasicStatelessTestClients
025:         *
026:         * @author <a href="mailto:david.blevins@visi.com">David Blevins</a>
027:         * @author <a href="mailto:Richard@Monson-Haefel.com">Richard Monson-Haefel</a>
028:         * @version $Rev: 607077 $ $Date: 2007-12-27 06:55:23 -0800 $
029:         */
030:        public class StatelessPojoEjbObjectTests extends
031:                BasicStatelessTestClient {
032:
033:            public StatelessPojoEjbObjectTests() {
034:                super ("PojoEJBObject.");
035:            }
036:
037:            protected void setUp() throws Exception {
038:                super .setUp();
039:                Object obj = initialContext
040:                        .lookup("client/tests/stateless/BasicStatelessPojoHome");
041:                ejbHome = (BasicStatelessHome) javax.rmi.PortableRemoteObject
042:                        .narrow(obj, BasicStatelessHome.class);
043:                ejbObject = ejbHome.createObject();
044:            }
045:
046:            // ===============================
047:            // Start EJBObject methods test
048:            //
049:
050:            /**
051:             * According to the EJB3.0 "Core Contracts and Requirements" specs, section
052:             * 3.6.4, a session EJBObject supports:
053:             * 1. Get the session object's remote home interface.
054:             * 2. Get the session object's handle.
055:             * 3. Test if the session object is identical with another session object.
056:             * 4. Remove the session object.
057:             */
058:
059:            /**
060:             * A method to test retrieving the EJBHome interface of a session bean using its EJBObject reference.
061:             */
062:            public void test01_getEjbHome() {
063:                try {
064:                    EJBHome home = ejbObject.getEJBHome();
065:                    assertNotNull("The EJBHome is null", home);
066:                } catch (Exception e) {
067:                    fail("Received Exception " + e.getClass() + " : "
068:                            + e.getMessage());
069:                }
070:            }
071:
072:            /**
073:             * A method to test retrieving a Handle of a session bean using its EJBObject reference.
074:             */
075:            public void test02_getHandle() {
076:                try {
077:                    ejbHandle = ejbObject.getHandle();
078:                    assertNotNull("The Handle is null", ejbHandle);
079:                } catch (Exception e) {
080:                    fail("Received Exception " + e.getClass() + " : "
081:                            + e.getMessage());
082:                }
083:            }
084:
085:            /**
086:             * A method to test the implementation of Stateless Session Bean identity check.
087:             * See EJB3.0 "Core Contracts and Requirements" specification, section 3.4.5.2
088:             */
089:            public void test03_isIdentical() {
090:                BasicStatelessObject otherEJBObject = null;
091:                try {
092:                    /**
093:                     * This EJBObject reference is created to validate the identity if different EJBObject references
094:                     * of the same interface type of the same session bean.
095:                     */
096:                    otherEJBObject = ejbHome.createObject();
097:                    assertTrue("The EJBObjects are not identical", ejbObject
098:                            .isIdentical(ejbObject));
099:                    assertTrue(
100:                            "The EJBObject and the OtherEJBObject are not identical",
101:                            ejbObject.isIdentical(otherEJBObject));
102:                } catch (Exception e) {
103:                    fail("Received Exception " + e.getClass() + " : "
104:                            + e.getMessage());
105:                }
106:            }
107:
108:            /**
109:             * This test is 2 in 1, it tests calling remove() on an EJBObject reference and then calling a business method on the
110:             * same reference after the remove() is successfuly called.
111:             */
112:            public void test04_remove() {
113:                try {
114:                    ejbObject.remove();
115:                    // you can't really remove a stateless handle
116:                    ejbObject.businessMethod("Should not throw an exception");
117:                } catch (Exception e) {
118:                    fail("Received Exception " + e.getClass() + " : "
119:                            + e.getMessage());
120:                }
121:            }
122:
123:            /**
124:             * See EJB3.0 "Core Contracts and Requirements" specification, section : 3.6.8.3 .
125:             */
126:            public void test05_getPrimaryKey() {
127:                try {
128:                    Object key = ejbObject.getPrimaryKey();
129:                } catch (java.rmi.RemoteException e) {
130:                    assertTrue(true);
131:                    return;
132:                } catch (Exception e) {
133:                    fail("A RuntimeException should have been thrown.  Received Exception "
134:                            + e.getClass() + " : " + e.getMessage());
135:                }
136:                fail("A RuntimeException should have been thrown.");
137:            }
138:
139:            //
140:            // End EJBObject methods test
141:            // ===============================
142:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.