Source Code Cross Referenced for F_RcycleEC2.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas » jtests » clients » entity » 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.entity 
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:         * $Id: F_RcycleEC2.java 7533 2005-10-19 15:55:05Z durieuxp $
022:         * --------------------------------------------------------------------------
023:         */
024:
025:        package org.objectweb.jonas.jtests.clients.entity;
026:
027:        import java.util.Collection;
028:        import java.util.Iterator;
029:
030:        import javax.naming.NamingException;
031:        import javax.rmi.PortableRemoteObject;
032:
033:        import junit.framework.Test;
034:        import junit.framework.TestSuite;
035:
036:        import org.objectweb.jonas.jtests.beans.relation.rcycle.PersonRemote;
037:        import org.objectweb.jonas.jtests.beans.relation.rcycle.PersonHomeRemote;
038:        import org.objectweb.jonas.jtests.util.JTestCase;
039:
040:        /**
041:         * This is a test suite on CMP 2 : legacy, cycle in relations, relations between
042:         * the same bean.
043:         * @author Helene Joanin
044:         */
045:        public class F_RcycleEC2 extends JTestCase {
046:
047:            private static final int ID_L_ERIC = 1;
048:
049:            private static final int ID_JL_HELENE = 2;
050:
051:            private static final int ID_L_GUILHEM = 3;
052:
053:            private static final int ID_L_MALVA = 4;
054:
055:            private static PersonHomeRemote personhome = null;
056:
057:            public F_RcycleEC2(String name) {
058:                super (name);
059:            }
060:
061:            protected boolean isInit = false;
062:
063:            protected void setUp() {
064:                super .setUp();
065:                if (!isInit) {
066:                    useBeans("rcycle", true);
067:                    try {
068:                        personhome = (PersonHomeRemote) PortableRemoteObject
069:                                .narrow(ictx.lookup("RcyclePersonHome"),
070:                                        PersonHomeRemote.class);
071:                    } catch (NamingException e) {
072:                        fail("Cannot get bean home: " + e.getMessage());
073:                    }
074:                    isInit = true;
075:                }
076:            }
077:
078:            /**
079:             * Test the findAll method.
080:             * @throws Exception
081:             */
082:            public void testFindAll() throws Exception {
083:                Collection cp = personhome.findAll();
084:                assertEquals("Number of Persons: ", 4, cp.size());
085:            }
086:
087:            /**
088:             * (Bug #300533) Test the findQuery1 method.
089:             * @throws Exception
090:             */
091:            public void testFindQuery1() throws Exception {
092:                Collection cp = personhome.findQuery1();
093:                assertEquals("Number of Persons: ", 0, cp.size());
094:            }
095:
096:            /**
097:             * Test the findQuery2 method.
098:             * @throws Exception
099:             */
100:            public void testFindQuery2() throws Exception {
101:                Collection cp = personhome.findQuery2();
102:                assertEquals("Number of Persons: ", 0, cp.size());
103:            }
104:
105:            /**
106:             * (Bug #300526) Test the findSpouse3 method.
107:             * @throws Exception
108:             */
109:            public void testFindSpouse3() throws Exception {
110:                PersonRemote p = personhome.findSpouse3();
111:                assertNull("Laurent Guilhem spouse: ", p);
112:            }
113:
114:            /**
115:             * Test the spouse relation.
116:             * @throws Exception
117:             */
118:            public void testSpouseRelation() throws Exception {
119:                PersonRemote ph = personhome.findByPrimaryKey(new Integer(
120:                        ID_L_ERIC));
121:                Integer iw = ph.retrieveSpouse();
122:                assertEquals("Wife of Laurent Eric: ", ID_JL_HELENE, iw
123:                        .intValue());
124:                PersonRemote pw = personhome.findByPrimaryKey(iw);
125:                Integer ih = pw.retrieveSpouse();
126:                assertEquals("Husband of Joanin-Laurent Helene: ", ID_L_ERIC,
127:                        ih.intValue());
128:                PersonRemote pc = personhome.findByPrimaryKey(new Integer(
129:                        ID_L_GUILHEM));
130:                Integer in = pc.retrieveSpouse();
131:                assertNull("Laurent Guilhem spouse: ", in);
132:            }
133:
134:            /**
135:             * Test the guardian/is-guardian-of relation.
136:             * @throws Exception
137:             */
138:            public void testGuardianRelation() throws Exception {
139:                Integer iLEric = new Integer(ID_L_ERIC);
140:                PersonRemote ph = personhome.findByPrimaryKey(iLEric);
141:                Collection c = ph.retrieveGuardianOf();
142:                assertEquals("Laurent Eric guardian of: ", 2, c.size());
143:                for (Iterator i = c.iterator(); i.hasNext();) {
144:                    Integer ip = (Integer) i.next();
145:                    PersonRemote p = personhome.findByPrimaryKey(ip);
146:                    assertEquals("Guardian of " + p.getName() + ": ", iLEric, p
147:                            .retrieveGuardian());
148:                }
149:            }
150:
151:            /**
152:             * Test the parents/children relation.
153:             * @throws Exception
154:             */
155:            public void testParentsChildrenRelation() throws Exception {
156:                Integer iLEric = new Integer(ID_L_ERIC);
157:                PersonRemote ph = personhome.findByPrimaryKey(iLEric);
158:                Collection cc = ph.retrieveChildren();
159:                assertEquals("Laurent Eric father of: ", 2, cc.size());
160:                for (Iterator i = cc.iterator(); i.hasNext();) {
161:                    Integer ip = (Integer) i.next();
162:                    PersonRemote p = personhome.findByPrimaryKey(ip);
163:                    Collection cp = p.retrieveParents();
164:                    assertTrue("Father of " + p.getName() + ": ", cp
165:                            .contains(iLEric));
166:                }
167:            }
168:
169:            /**
170:             * Test if a cmr null is 'null'
171:             * @throws Exception
172:             */
173:            public void testCmrNull() throws Exception {
174:                PersonRemote ph = personhome.findByPrimaryKey(new Integer(
175:                        ID_L_ERIC));
176:                assertTrue("CMR null is NOT null", ph.testCmrNull());
177:            }
178:
179:            /**
180:             * Verify the spy trace to check less database access are done
181:             * @throws Exception
182:             */
183:            public void testPrefetch() throws Exception {
184:                //sleep(15000);
185:                try {
186:                    utx.begin();
187:                    Integer iLEric = new Integer(ID_L_ERIC);
188:                    PersonRemote ph = personhome.findByPrimaryKey(iLEric);
189:                    // If there is CMR prefetching, this may imply less database access
190:                    Collection cc = ph.retrieveChildrenNames();
191:                    assertEquals("Laurent Eric father of: ", 2, cc.size());
192:                } finally {
193:                    utx.commit();
194:                }
195:            }
196:
197:            protected boolean initStateOK() throws Exception {
198:                return true;
199:            }
200:
201:            public static Test suite() {
202:                return new TestSuite(F_RcycleEC2.class);
203:            }
204:
205:            public static void main(String args[]) {
206:                String testtorun = null;
207:                // Get args
208:                for (int argn = 0; argn < args.length; argn++) {
209:                    String sarg = args[argn];
210:                    if (sarg.equals("-n")) {
211:                        testtorun = args[++argn];
212:                    }
213:                }
214:                if (testtorun == null) {
215:                    junit.textui.TestRunner.run(suite());
216:                } else {
217:                    junit.textui.TestRunner.run(new F_RcycleEC2(testtorun));
218:                }
219:            }
220:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.