Source Code Cross Referenced for ComplexEjbObjectTests.java in  » J2EE » openejb3 » org » apache » openejb » test » entity » cmp » 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.cmp 
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.entity.cmp;
018:
019:        import javax.ejb.EJBHome;
020:        import javax.ejb.ObjectNotFoundException;
021:        import javax.rmi.PortableRemoteObject;
022:
023:        /**
024:         * [4] Should be run as the fourth test suite of the ComplexCmpTestClients
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:         */
029:        public class ComplexEjbObjectTests extends ComplexCmpTestClient {
030:
031:            public ComplexEjbObjectTests() {
032:                super ("EJBObject.");
033:            }
034:
035:            protected void setUp() throws Exception {
036:                super .setUp();
037:                Object obj = initialContext
038:                        .lookup("client/tests/entity/cmp/ComplexCmpHome");
039:                ejbHome = (ComplexCmpHome) PortableRemoteObject.narrow(obj,
040:                        ComplexCmpHome.class);
041:                ejbObject = ejbHome.createObject("Third Bean");
042:            }
043:
044:            protected void tearDown() throws Exception {
045:                // set to null by test05_remove() method
046:                if (ejbObject != null) {
047:                    try {
048:                        ejbObject.remove();
049:                    } catch (Exception e) {
050:                        throw e;
051:                    }
052:                }
053:                super .tearDown();
054:            }
055:
056:            //===============================
057:            // Test ejb object methods
058:            //
059:            public void test01_getHandle() {
060:                try {
061:                    ejbHandle = ejbObject.getHandle();
062:                    assertNotNull("The Handle is null", ejbHandle);
063:                } catch (Exception e) {
064:                    fail("Received Exception " + e.getClass() + " : "
065:                            + e.getMessage());
066:                }
067:            }
068:
069:            public void test02_getPrimaryKey() {
070:                try {
071:                    ejbPrimaryKey = ejbObject.getPrimaryKey();
072:                    assertNotNull("The primary key is null", ejbPrimaryKey);
073:                    assertTrue(
074:                            "Expected (ejbPrimaryKey instanceof ComplexCmpBeanPk) but was instanceof "
075:                                    + ejbPrimaryKey.getClass().getName(),
076:                            ejbPrimaryKey instanceof  ComplexCmpBeanPk);
077:                } catch (Exception e) {
078:                    e.printStackTrace();
079:                    fail("Received Exception " + e.getClass() + " : "
080:                            + e.getMessage());
081:                }
082:            }
083:
084:            public void test03_isIdentical() {
085:                try {
086:                    assertTrue("The EJBObjects are not equal", ejbObject
087:                            .isIdentical(ejbObject));
088:                } catch (Exception e) {
089:                    fail("Received Exception " + e.getClass() + " : "
090:                            + e.getMessage());
091:                }
092:            }
093:
094:            public void test04_getEjbHome() {
095:                try {
096:                    EJBHome home = ejbObject.getEJBHome();
097:                    assertNotNull("The EJBHome is null", home);
098:                } catch (Exception e) {
099:                    fail("Received Exception " + e.getClass() + " : "
100:                            + e.getMessage());
101:                }
102:            }
103:
104:            public void test05_remove() {
105:                try {
106:                    // remove the ejb
107:                    ejbObject.remove();
108:
109:                    // verify that the ejb was actually removed
110:                    try {
111:                        ejbHome
112:                                .findByPrimaryKey((ComplexCmpBeanPk) ejbPrimaryKey);
113:                        fail("Entity was not actually removed");
114:                    } catch (ObjectNotFoundException e) {
115:                    }
116:
117:                    // verify the proxy is dead
118:                    try {
119:                        ejbObject.businessMethod("Should throw an exception");
120:                        assertTrue(
121:                                "Calling business method after removing the EJBObject does not throw an exception",
122:                                false);
123:                    } catch (Exception e) {
124:                    }
125:                } catch (Exception e) {
126:                    fail("Received Exception " + e.getClass() + " : "
127:                            + e.getMessage());
128:                } finally {
129:                    ejbObject = null;
130:                }
131:            }
132:            //
133:            // Test ejb object methods
134:            //===============================
135:
136:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.