Source Code Cross Referenced for Complex2EjbHomeTests.java in  » J2EE » openejb3 » org » apache » openejb » test » entity » cmp2 » 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.cmp2 
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.cmp2;
018:
019:        import org.apache.openejb.test.entity.cmp.ComplexCmpHome;
020:        import org.apache.openejb.test.entity.cmp.ComplexCmpBeanPk;
021:
022:        import javax.ejb.EJBMetaData;
023:        import javax.ejb.ObjectNotFoundException;
024:
025:        /**
026:         * [3] Should be run as the third test suite of the BasicCmpTestClients
027:         */
028:        public class Complex2EjbHomeTests extends ComplexCmp2TestClient {
029:
030:            public Complex2EjbHomeTests() {
031:                super ("EJBHome.");
032:            }
033:
034:            protected void setUp() throws Exception {
035:                super .setUp();
036:                Object obj = initialContext
037:                        .lookup("client/tests/entity/cmp2/ComplexCmpHome");
038:                ejbHome = (ComplexCmpHome) javax.rmi.PortableRemoteObject
039:                        .narrow(obj, ComplexCmpHome.class);
040:                ejbObject = ejbHome.createObject("Second Bean");
041:                ejbPrimaryKey = ejbObject.getPrimaryKey();
042:            }
043:
044:            //===============================
045:            // Test ejb home methods
046:            //
047:            public void test01_getEJBMetaData() {
048:                try {
049:                    EJBMetaData ejbMetaData = ejbHome.getEJBMetaData();
050:                    assertNotNull("The EJBMetaData is null", ejbMetaData);
051:                } catch (Exception e) {
052:                    fail("Received Exception " + e.getClass() + " : "
053:                            + e.getMessage());
054:                }
055:            }
056:
057:            public void test02_getHomeHandle() {
058:                try {
059:                    ejbHomeHandle = ejbHome.getHomeHandle();
060:                    assertNotNull("The HomeHandle is null", ejbHomeHandle);
061:                } catch (Exception e) {
062:                    fail("Received Exception " + e.getClass() + " : "
063:                            + e.getMessage());
064:                }
065:            }
066:
067:            public void test03_removeByPrimaryKey() {
068:                try {
069:                    // remove the ejb
070:                    ejbHome.remove(ejbPrimaryKey);
071:
072:                    // verify that the ejb was actually removed
073:                    try {
074:                        ejbHome
075:                                .findByPrimaryKey((ComplexCmpBeanPk) ejbPrimaryKey);
076:                        fail("Entity was not actually removed");
077:                    } catch (ObjectNotFoundException e) {
078:                    }
079:
080:                    // verify the proxy is dead
081:                    try {
082:                        ejbObject.businessMethod("Should throw an exception");
083:                        assertTrue(
084:                                "Calling business method after removing the EJBObject does not throw an exception",
085:                                false);
086:                    } catch (Exception e) {
087:                    }
088:
089:                    // create a new ejb for the next test
090:                    ejbObject = ejbHome.createObject("Second Bean");
091:                    ejbPrimaryKey = ejbObject.getPrimaryKey();
092:                } catch (Exception e) {
093:                    fail("Received Exception " + e.getClass() + " : "
094:                            + e.getMessage());
095:                }
096:            }
097:
098:            public void test04_removeByPrimaryHandle() {
099:                try {
100:                    // remove the ejb
101:                    ejbHome.remove(ejbObject.getHandle());
102:
103:                    // verify that the ejb was actually removed
104:                    try {
105:                        ejbHome
106:                                .findByPrimaryKey((ComplexCmpBeanPk) ejbPrimaryKey);
107:                        fail("Entity was not actually removed");
108:                    } catch (ObjectNotFoundException e) {
109:                    }
110:
111:                    // verify the proxy is dead
112:                    try {
113:                        ejbObject.businessMethod("Should throw an exception");
114:                        assertTrue(
115:                                "Calling business method after removing the EJBObject does not throw an exception",
116:                                false);
117:                    } catch (Exception e) {
118:                    }
119:
120:                    // create a new ejb for the next test
121:                    ejbObject = ejbHome.createObject("Second Bean");
122:                    ejbPrimaryKey = ejbObject.getPrimaryKey();
123:                } catch (Exception e) {
124:                    e.printStackTrace();
125:                    fail("Received Exception " + e.getClass() + " : "
126:                            + e.getMessage());
127:                }
128:            }
129:
130:            public void test05_ejbHomeMethod() {
131:                try {
132:                    assertEquals(8 + 9, ejbHome.sum(8, 9));
133:                } catch (Throwable e) {
134:                    e.printStackTrace();
135:                    fail("Received Exception " + e.getClass() + " : "
136:                            + e.getMessage());
137:                }
138:            }
139:            //
140:            // Test ejb home methods
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.