Source Code Cross Referenced for TestRelation1_N.java in  » Database-ORM » Speedo_1.4.5 » org » objectweb » speedo » stress » 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 » Database ORM » Speedo_1.4.5 » org.objectweb.speedo.stress 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Copyright (C) 2001-2004 France Telecom R&D
003:         *
004:         * This library is free software; you can redistribute it and/or
005:         * modify it under the terms of the GNU Lesser General Public
006:         * License as published by the Free Software Foundation; either
007:         * version 2 of the License, or (at your option) any later version.
008:         *
009:         * This library is distributed in the hope that it will be useful,
010:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
011:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
012:         * Lesser General Public License for more details.
013:         *
014:         * You should have received a copy of the GNU Lesser General Public
015:         * License along with this library; if not, write to the Free Software
016:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
017:         */package org.objectweb.speedo.stress;
018:
019:        import org.objectweb.speedo.pobjects.relations.A;
020:        import org.objectweb.speedo.pobjects.relations.B;
021:
022:        import javax.jdo.JDOFatalException;
023:        import javax.jdo.PersistenceManager;
024:
025:        /**
026:         * Stress the relation one-many implementation by Speedo.
027:         *
028:         * @author M. Guillemin
029:         */
030:        public class TestRelation1_N extends StressHelper {
031:
032:            public TestRelation1_N(String s) {
033:                super (s);
034:            }
035:
036:            protected String[] getClassNamesToInit() {
037:                return new String[] {
038:                        org.objectweb.speedo.pobjects.relations.A.class
039:                                .getName(),
040:                        org.objectweb.speedo.pobjects.relations.B.class
041:                                .getName() };
042:            }
043:
044:            protected String getLoggerName() {
045:                return STRESS_LOG_NAME + ".TestRelation1_1";
046:            }
047:
048:            protected void perform(StressHelper.Task task, int threadId,
049:                    int txId, Object ctx, StressHelper.PerformResult res) {
050:                PersistenceManager pm = getPM(task, threadId, txId);
051:                try {
052:                    res.beginTest();
053:                    int oid = txId * 4;
054:                    beginTx(pm, task, threadId, txId);
055:
056:                    // Execute first transaction (makePersistent)
057:                    A a1 = new A("a" + oid);
058:                    A a2 = new A("a" + oid + 1);
059:
060:                    B b1 = new B("b" + oid);
061:                    B b2 = new B("b" + oid + 1);
062:                    B b3 = new B("b" + oid + 2);
063:                    B b4 = new B("b" + oid + 3);
064:
065:                    pm.makePersistent(a1);
066:                    pm.makePersistent(a2);
067:                    pm.makePersistent(b1);
068:                    pm.makePersistent(b2);
069:                    pm.makePersistent(b3);
070:                    pm.makePersistent(b4);
071:                    Object oida1 = pm.getObjectId(a1);
072:                    Object oida2 = pm.getObjectId(a2);
073:                    Object oidb1 = pm.getObjectId(b1);
074:                    Object oidb2 = pm.getObjectId(b2);
075:                    Object oidb3 = pm.getObjectId(b3);
076:                    Object oidb4 = pm.getObjectId(b4);
077:
078:                    // validate (make speedoproxy)
079:                    commitTx(pm, task, threadId, txId);
080:
081:                    a1.getNbs().add(b1);
082:                    assertTrue(b1.getNa() == a1);
083:                    a1.getNbs().add(b2);
084:                    assertTrue(b2.getNa() == a1);
085:
086:                    a2.getNbs().add(b3);
087:                    assertTrue(b3.getNa() == a2);
088:                    a2.getNbs().add(b4);
089:                    assertTrue(b4.getNa() == a2);
090:
091:                    a1.getNbs().add(b3);
092:                    assertTrue(b3.getNa() == a1);
093:                    assertTrue(!a2.getNbs().contains(b3));
094:
095:                    a1.getNbs().remove(b1);
096:                    assertTrue(b1.getNa() == null);
097:
098:                    b3.setNa(a2);
099:                    assertTrue(!a1.getNbs().contains(b3));
100:                    assertTrue(a2.getNbs().contains(b3));
101:
102:                    a1.setNbs(a2.getNbs());
103:
104:                    // reload objects before testing effects of the above assignement
105:                    pm.close();
106:                    pm = pmf.getPersistenceManager();
107:
108:                    assertTrue(!a1.getNbs().contains(b1));
109:                    assertTrue(!a1.getNbs().contains(b2));
110:                    assertTrue(a1.getNbs().contains(b3));
111:                    assertTrue(a1.getNbs().contains(b4));
112:                    assertTrue(a1.getNbs().size() == 2);
113:
114:                    assertTrue(!a2.getNbs().contains(b1));
115:                    assertTrue(!a2.getNbs().contains(b2));
116:                    assertTrue(!a2.getNbs().contains(b3));
117:                    assertTrue(!a2.getNbs().contains(b4));
118:
119:                    assertTrue(b1.getNa() == null);
120:                    assertTrue(b2.getNa() == null);
121:                    assertTrue(b3.getNa() == a1);
122:                    assertTrue(b4.getNa() == a1);
123:
124:                    // Delete persistent (speedoproxy)
125:                    beginTx(pm, task, threadId, txId);
126:                    pm.deletePersistent(pm.getObjectById(oidb3, false));
127:                    assertTrue(
128:                            "reverse reference of b3.na (a1.nbs) must not contain b3",
129:                            !a1.getNbs().contains(b3));
130:                    commitTx(pm, task, threadId, txId);
131:                    pm.close();
132:
133:                    pm = pmf.getPersistenceManager();
134:                    assertTrue(
135:                            "reverse reference of b3.na (a1.nbs) must not contain b3",
136:                            !a1.getNbs().contains(b3));
137:
138:                    beginTx(pm, task, threadId, txId);
139:                    pm.deletePersistent(pm.getObjectById(oida1, false));
140:                    pm.deletePersistent(pm.getObjectById(oida2, false));
141:                    pm.deletePersistent(pm.getObjectById(oidb1, false));
142:                    pm.deletePersistent(pm.getObjectById(oidb2, false));
143:                    pm.deletePersistent(pm.getObjectById(oidb4, false));
144:                    commitTx(pm, task, threadId, txId);
145:
146:                    res.endTest();
147:                } catch (JDOFatalException e) {
148:                    rollbackOnException(pm, e, res, task, threadId, txId);
149:                } catch (Throwable e) {
150:                    stopOnError(pm, e, res, task, threadId, txId);
151:                } finally {
152:                    closePM(pm, threadId, txId, task, res);
153:                }
154:            }
155:
156:            /**
157:             * Tests the read of a lot of persistent objects, with interactive setting
158:             * of test parameteres (see file userconf/project.properties).
159:             */
160:            public void testRelation1_N() {
161:                if (interactive) {
162:                    perform(Integer.getInteger(THREAD, 1).intValue(), Integer
163:                            .getInteger(TX, 1).intValue(), Integer.getInteger(
164:                            TIMEOUT, 1).intValue(), null);
165:                }
166:            }
167:
168:            /**
169:             * Tests 100 transactions where each of them stress 1_N linked persistents objects using 1 thread.
170:             */
171:            public void testRelation1_NTh1Tx100() {
172:                if (!interactive) {
173:                    perform(1, 100, 1000000, null);
174:                }
175:            }
176:
177:            /**
178:             * Tests 1000 transactions where each of them stress 1_N linked persistents objects using 1 thread.
179:             */
180:            public void testRelation1_NTh1Tx1000() {
181:                if (!interactive) {
182:                    perform(1, 1000, 1000000, null);
183:                }
184:            }
185:
186:            /**
187:             * Tests 10000 transactions where each of them stress 1_N linked persistents objects using 1 thread.
188:             */
189:            public void testRelation1_NTh1Tx10000() {
190:                if (!interactive) {
191:                    perform(1, 10000, 1000000, null);
192:                }
193:            }
194:
195:            /**
196:             * Tests 100 transactions where each of them stress 1_N linked persistents objects using 2 thread.
197:             */
198:            public void testRelation1_NTh2Tx100() {
199:                if (!interactive) {
200:                    perform(2, 100, 1000000, null);
201:                }
202:            }
203:
204:            /**
205:             * Tests 1000 transactions where each of them stress 1_N linked persistents objects using 2 thread.
206:             */
207:            public void testRelation1_NTh2Tx1000() {
208:                if (!interactive) {
209:                    perform(2, 1000, 1000000, null);
210:                }
211:            }
212:
213:            /**
214:             * Tests 10000 transactions where each of them stress 1_N linked persistents objects using 2 thread.
215:             */
216:            public void testRelation1_NTh2Tx10000() {
217:                if (!interactive) {
218:                    perform(2, 10000, 1000000, null);
219:                }
220:            }
221:
222:            /**
223:             * Tests 100 transactions where each of them stress 1_N linked persistents objects using 10 thread.
224:             */
225:            public void testRelation1_NTh10Tx100() {
226:                if (!interactive) {
227:                    perform(10, 100, 1000000, null);
228:                }
229:            }
230:
231:            /**
232:             * Tests 1000 transactions where each of them stress 1_N linked persistents objects using 10 thread.
233:             */
234:            public void testRelation1_NTh10Tx1000() {
235:                if (!interactive) {
236:                    perform(10, 1000, 1000000, null);
237:                }
238:            }
239:
240:            /**
241:             * Tests 10000 transactions where each of them stress 1_N linked persistents objects using 10 thread.
242:             */
243:            public void testRelation1_NTh10Tx10000() {
244:                if (!interactive) {
245:                    perform(10, 10000, 1000000, null);
246:                }
247:            }
248:
249:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.