Source Code Cross Referenced for A_ClientView.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas » jtests » clients » session » 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 » JOnAS 4.8.6 » org.objectweb.jonas.jtests.clients.session 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * JOnAS: Java(TM) Open Application Server
003:         * Copyright (C) 1999 Bull S.A.
004:         * Contact: jonas-team@objectweb.org
005:         *
006:         * This library is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU Lesser General Public
008:         * License as published by the Free Software Foundation; either
009:         * version 2.1 of the License, or any later version.
010:         *
011:         * This library is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         * Lesser General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU Lesser General Public
017:         * License along with this library; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
019:         * USA
020:         *
021:         * --------------------------------------------------------------------------
022:         * $Id: A_ClientView.java 7106 2005-07-26 15:11:53Z durieuxp $
023:         * --------------------------------------------------------------------------
024:         */
025:
026:        package org.objectweb.jonas.jtests.clients.session;
027:
028:        import java.io.ByteArrayInputStream;
029:        import java.io.ByteArrayOutputStream;
030:        import java.io.ObjectInputStream;
031:        import java.io.ObjectOutputStream;
032:        import java.rmi.NoSuchObjectException;
033:        import java.rmi.RemoteException;
034:
035:        import javax.ejb.EJBException;
036:        import javax.ejb.EJBObject;
037:        import javax.ejb.RemoveException;
038:        import javax.ejb.EJBMetaData;
039:        import javax.ejb.Handle;
040:        import javax.ejb.HomeHandle;
041:        import javax.rmi.PortableRemoteObject;
042:
043:        import org.objectweb.jonas.jtests.beans.local.Target;
044:        import org.objectweb.jonas.jtests.beans.local.TargetSLHome;
045:        import org.objectweb.jonas.jtests.util.JTestCase;
046:
047:        /**
048:         * This Class defines Test cases that can be run either SF or SL bean.
049:         * These tests are related to the "Client View of a Session Bean"
050:         * A session bean that supports both Local & Remote interface is used
051:         * (TargetSL oe TargetSF in beans/local)
052:         * But here are testcases that can be run via a non remote suite.
053:         *
054:         * @see  EJB2.0 specification Chapter 6.
055:         * @author Ph Coq, Ph Durieux
056:         */
057:
058:        public abstract class A_ClientView extends JTestCase {
059:
060:            public A_ClientView(String name) {
061:                super (name);
062:            }
063:
064:            /**
065:             * @return TargetSLHome, that can be either SF or SL bean.
066:             */
067:            public abstract TargetSLHome getHome() throws Exception;
068:
069:            /**
070:             * Lookup a Home Object
071:             *
072:             * This test verify that we can look up a Home Object
073:             * via the root context
074:             */
075:
076:            public void testHomeLookup() throws Exception {
077:                TargetSLHome h = null;
078:                h = getHome();
079:                assertTrue(h != null);
080:            }
081:
082:            /**
083:             * This test verify we can create and remove a session bean
084:             */
085:            public void testCreateRemove() throws Exception {
086:                Target tr = getHome().create();
087:                tr.remove();
088:            }
089:
090:            /**
091:             * This test verify we can create and remove a session bean
092:             */
093:            public void testLongCreateRemove() throws Exception {
094:                for (int i = 0; i < 500; i++) {
095:                    Target tr = getHome().create();
096:                    tr.remove();
097:                }
098:            }
099:
100:            /**
101:             * This test verify we can create, access to the bean via
102:             * its remote interface and remove it
103:             * It verifies we cannot access to the bean after remove
104:             */
105:            public void testBusinessMethod1() throws Exception {
106:                Target tr = getHome().create();
107:                assertEquals(10, tr.getTen());
108:                tr.remove();
109:                try {
110:                    tr.method2("Bye");
111:                    fail("NoSuchObjectException must be raised");
112:                    //        } catch (NoSuchObjectException e) {
113:                } catch (NoSuchObjectException e) {
114:                }
115:            }
116:
117:            /**
118:             * Same test than testBusinessMethod1 but two calls to businessmethod
119:             */
120:            public void testBusinessMethod2() throws Exception {
121:                Target tr = getHome().create();
122:                assertEquals(10, tr.getTen());
123:                assertEquals(10, tr.getTen());
124:                tr.remove();
125:            }
126:
127:            /**
128:             * test 3 Remote Business Methods
129:             */
130:            public void testBusinessMethod3() throws Exception {
131:                Target tr = getHome().create();
132:                assertEquals(10, tr.getTen());
133:                tr.method2("Hello");
134:                assertEquals(10, tr.getTen());
135:                tr.remove();
136:            }
137:
138:            /**
139:             * test EJBObject.isIdentical on the same bean
140:             */
141:            public void testIsIdenticalOnSameBean() throws Exception {
142:                Target tr = getHome().create();
143:                assertTrue(tr.isIdentical(tr));
144:                tr.remove();
145:            }
146:
147:            /**
148:             * test EJBObject.getPrimary Key
149:             * This test verify that a Remote Exception must be catched
150:             */
151:            public void testGetPrimaryKey() throws Exception {
152:                Target tr = getHome().create();
153:                try {
154:                    tr.getPrimaryKey();
155:                    fail("getPrimaryKey should raise RemoteException on a session bean");
156:                } catch (RemoteException e) {
157:                } finally {
158:                    tr.remove();
159:                }
160:            }
161:
162:            /**
163:             * test EJBHome.getEJBMetaData().getPrimaryKeyClass()
164:             * This test verify that a EJBException must be catched
165:             */
166:            public void testGetPrimaryKeyClass() throws Exception {
167:                try {
168:                    getHome().getEJBMetaData().getPrimaryKeyClass();
169:                    fail("getEJBMetaData().getPrimaryKeyClass should raise EJBException on a session bean home");
170:                } catch (EJBException e) {
171:                }
172:            }
173:
174:            /**
175:             * test that EJBHome.remove(pk) should raise RemoteException (API) or
176:             * RemoveException (spec EJB 2.0 6.3.2)
177:             */
178:            public void testRemoveByPK() throws Exception {
179:                Object pk = null;
180:                try {
181:                    getHome().remove(pk);
182:                    fail("getPrimaryKey should raise Exception on a session bean");
183:                } catch (RemoteException e) {
184:                } catch (RemoveException e) {
185:                }
186:            }
187:
188:            /**
189:             * test that EJBHome.getEJBMetaData()
190:             * test we can obtain an handle for a session bean
191:             */
192:            public void testGetEJBMetaData() throws Exception {
193:                EJBMetaData hh = getHome().getEJBMetaData();
194:            }
195:
196:            /**
197:             * test that EJBHome.getHomeHandle()
198:             * test we can obtain a handle for a session bean's home interface
199:             */
200:            public void testGetHomeHandle() throws Exception {
201:                HomeHandle hh = getHome().getHomeHandle();
202:            }
203:
204:            /**
205:             * test serialize/deserialize handle.
206:             * @throws Exception
207:             */
208:            public void testSerializeHandle() throws Exception {
209:                TargetSLHome tgh = getHome();
210:                Target tr = tgh.create();
211:                Handle h = tr.getHandle();
212:                ObjectInputStream is = null;
213:                ObjectOutputStream os = null;
214:                ByteArrayOutputStream baos = new ByteArrayOutputStream();
215:                os = new ObjectOutputStream(baos);
216:                os.writeObject(h);
217:                byte[] b = baos.toByteArray();
218:                ByteArrayInputStream bais = new ByteArrayInputStream(b);
219:                is = new ObjectInputStream(bais);
220:                Handle deserializedHandle = (Handle) is.readObject();
221:                EJBObject ejbObject = deserializedHandle.getEJBObject();
222:                Target beanRef2 = (Target) PortableRemoteObject.narrow(
223:                        ejbObject, Target.class);
224:            }
225:
226:            /**
227:             * test that EJBHome.removeHandle()
228:             * test we can remove a session via its  handle
229:             * it verifies the bean cannot be accessed after remove and
230:             * java.rmi.NoSuchObjectException is raised
231:             */
232:            public void testRemoveHandle() throws Exception {
233:                TargetSLHome tgh = getHome();
234:                Target tr = tgh.create();
235:                Handle h = tr.getHandle();
236:                tgh.remove(h);
237:                try {
238:                    tr.method2("Bye");
239:                    fail("Cannot remove a session bean via its handle");
240:                } catch (NoSuchObjectException e) {
241:
242:                }
243:            }
244:
245:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.