Source Code Cross Referenced for TestCollection.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 java.util.ArrayList;
020:        import java.util.List;
021:
022:        import javax.jdo.JDOFatalException;
023:        import javax.jdo.PersistenceManager;
024:
025:        import junit.framework.Assert;
026:
027:        import org.objectweb.speedo.pobjects.collection.AllCollection;
028:        import org.objectweb.util.monolog.api.BasicLevel;
029:
030:        /**
031:         * Stress the collection access function of Speedo.
032:         *
033:         * @author S.Rodiere
034:         */
035:        public class TestCollection extends StressHelper {
036:            static private int nbBeginTest = 0;
037:
038:            public TestCollection(String s) {
039:                super (s);
040:            }
041:
042:            protected String[] getClassNamesToInit() {
043:                return new String[] { AllCollection.class.getName() };
044:            }
045:
046:            protected String getLoggerName() {
047:                return STRESS_LOG_NAME + ".TestCollection";
048:            }
049:
050:            protected void perform(Task task, int threadId, int txId,
051:                    Object ctx, PerformResult res) {
052:                synchronized (this ) {
053:                    nbBeginTest++;
054:                }
055:                long oids = (nbBeginTest * 6);
056:                PersistenceManager pm = getPM(task, threadId, txId);
057:                try {
058:                    res.beginTest();
059:                    // Execute first transaction on persistent Collections
060:                    beginTx(pm, task, threadId, txId);
061:                    long[] ls = new long[] { oids, oids + 1, oids + 2,
062:                            oids + 3, oids + 4, oids + 5 };
063:                    long[] reverse = new long[] { oids + 5, oids + 4, oids + 3,
064:                            oids + 2, oids + 1, oids };
065:                    AllCollection ac = new AllCollection("stressCollection"
066:                            + nbBeginTest);
067:                    ac.setLongs(ls);
068:                    ac.setRefs(new Object[] { ac });
069:                    pm.makePersistent(ac);
070:                    commitTx(pm, task, threadId, txId);
071:
072:                    // Reverse the data
073:                    ac.setLongs(reverse);
074:                    ac.setRefs(new Object[] { ac });
075:
076:                    // Verify result
077:                    List expectedLong = new ArrayList(reverse.length);
078:                    for (int i = 0; i < reverse.length; i++) {
079:                        expectedLong.add(new Long(reverse[i]));
080:                    }
081:
082:                    List expectedRef = new ArrayList(1);
083:                    expectedRef.add(ac);
084:
085:                    //Collection
086:                    Assert.assertNotNull("The collection of Long is null", ac
087:                            .getCol_Long());
088:                    assertSameCollection("The collection of Long",
089:                            expectedLong, ac.getCol_Long());
090:                    Assert.assertNotNull("The collection of reference is null",
091:                            ac.getCol_ref());
092:                    assertSameCollection("The collection of ref", expectedRef,
093:                            ac.getCol_ref());
094:
095:                    //HashSet
096:                    Assert.assertNotNull("The Hashset of Long is null", ac
097:                            .getHset_Long());
098:                    assertSameCollection("The Hashset of Long", expectedLong,
099:                            ac.getHset_Long());
100:                    Assert.assertNotNull("The Hashset of reference is null", ac
101:                            .getHset_ref());
102:                    assertSameCollection("The Hashset of ref", expectedRef, ac
103:                            .getHset_ref());
104:
105:                    //List
106:                    Assert.assertNotNull("The list of Long is null", ac
107:                            .getList_Long());
108:                    assertSameList("The list of Long", expectedLong, ac
109:                            .getList_Long());
110:                    Assert.assertNotNull("The list of reference is null", ac
111:                            .getList_ref());
112:                    assertSameList("The list of reference", expectedRef, ac
113:                            .getList_ref());
114:
115:                    //Set
116:                    Assert.assertNotNull("The set of Long is null", ac
117:                            .getSet_Long());
118:                    assertSameCollection("The set of Long", expectedLong, ac
119:                            .getSet_Long());
120:                    Assert.assertNotNull("The set of reference is null", ac
121:                            .getSet_ref());
122:                    assertSameCollection("The set of ref", expectedRef, ac
123:                            .getSet_ref());
124:
125:                    // Execute second transaction on persistent Collections
126:                    beginTx(pm, task, threadId, txId);
127:                    logger.log(BasicLevel.DEBUG, ac.getId()
128:                            + " is being deleted");
129:                    pm.deletePersistent(ac);
130:                    commitTx(pm, task, threadId, txId);
131:                    res.endTest();
132:
133:                } catch (JDOFatalException e) {
134:                    rollbackOnException(pm, e, res, task, threadId, txId);
135:                } catch (Throwable e) {
136:                    stopOnError(pm, e, res, task, threadId, txId);
137:                } finally {
138:                    closePM(pm, threadId, txId, task, res);
139:                }
140:            }
141:
142:            /**
143:             * Tests the read of a lot of persistent objects, with interactive setting
144:             * of test parameteres (see file userconf/project.properties).
145:             */
146:            public void testCollection() {
147:                if (interactive) {
148:                    perform(Integer.getInteger(THREAD, 1).intValue(), Integer
149:                            .getInteger(TX, 9).intValue(), Integer.getInteger(
150:                            TIMEOUT, 200000).intValue(), null);
151:                }
152:            }
153:
154:            /**
155:             * Tests 100 transactions which stress collections using 1 thread.
156:             */
157:            public void testCollectionTh1Tx100() {
158:                if (!interactive) {
159:                    logger.log(BasicLevel.INFO, "testCollectionTh1Tx100");
160:                    perform(1, 100, 1000000, null);
161:                }
162:            }
163:
164:            /**
165:             * Tests 1.000 transactions which stress collections using 1 thread.
166:             */
167:            public void testCollectionTh1Tx1000() {
168:
169:                if (!interactive) {
170:                    logger.log(BasicLevel.INFO, "testCollectionTh1Tx1000");
171:                    perform(1, 1000, 1000000, null);
172:                }
173:            }
174:
175:            /**
176:             * Tests 10.000 transactions which stress collections using 1 thread.
177:             */
178:            public void testCollectionTh1Tx10000() {
179:
180:                if (!interactive) {
181:                    logger.log(BasicLevel.INFO, "testCollectionTh1Tx10000");
182:                    perform(1, 10000, 1000000, null);
183:                }
184:            }
185:
186:            /**
187:             * Tests 100.000 transactions which stress collections using 1 thread.
188:             */
189:            public void _testCollectionTh1Tx100000() {
190:
191:                if (!interactive) {
192:                    logger.log(BasicLevel.INFO, "testCollectionTh1Tx100000");
193:                    perform(1, 100000, 1000000, null);
194:                }
195:            }
196:
197:            /**
198:             * Tests 100 transactions which stress collections using 2 thread.
199:             */
200:            public void testCollectionTh2Tx100() {
201:
202:                if (!interactive) {
203:                    logger.log(BasicLevel.INFO, "testCollectionTh2Tx100");
204:                    perform(2, 100, 1000000, null);
205:                }
206:            }
207:
208:            /**
209:             * Tests 1000 transactions which stress collections using 2 thread.
210:             */
211:            public void testCollectionTh2Tx1000() {
212:
213:                if (!interactive) {
214:                    logger.log(BasicLevel.INFO, "testCollectionTh2Tx1000");
215:                    perform(2, 1000, 1000000, null);
216:                }
217:            }
218:
219:            /**
220:             * Tests 10.000 transactions which stress collections using 2 thread.
221:             */
222:            public void testCollectionTh2Tx10000() {
223:
224:                if (!interactive) {
225:                    logger.log(BasicLevel.INFO, "testCollectionTh2Tx10000");
226:                    perform(2, 10000, 1000000, null);
227:                }
228:            }
229:
230:            /**
231:             * Tests 100.000 transactions which stress collections using 2 thread.
232:             */
233:            public void _testCollectionTh2Tx100000() {
234:
235:                if (!interactive) {
236:                    logger.log(BasicLevel.INFO, "testCollectionTh2Tx100000");
237:                    perform(2, 100000, 1000000, null);
238:                }
239:            }
240:
241:            /**
242:             * Tests 1000 transactions which stress collections using 10 thread.
243:             */
244:            public void testCollectionTh10Tx1000() {
245:
246:                if (!interactive) {
247:                    logger.log(BasicLevel.INFO, "testCollectionTh10Tx1000");
248:                    perform(10, 1000, 1000000, null);
249:                }
250:            }
251:
252:            /**
253:             * Tests 10.000 transactions which stress collections using 10 thread.
254:             */
255:            public void testCollectionTh10Tx10000() {
256:
257:                if (!interactive) {
258:                    logger.log(BasicLevel.INFO, "testCollectionTh10Tx10000");
259:                    perform(10, 10000, 1000000, null);
260:                }
261:            }
262:
263:            /**
264:             * Tests 100.000 transactions which stress collections using 10 thread.
265:             */
266:            public void _testCollectionTh10Tx100000() {
267:
268:                if (!interactive) {
269:                    logger.log(BasicLevel.INFO, "testCollectionTh10Tx100000");
270:                    perform(10, 100000, 1000000, null);
271:                }
272:            }
273:
274:            /**
275:             * Tests 100 transactions which stress collections using 100 thread.
276:             */
277:            public void testCollectionTh100Tx100() {
278:
279:                if (!interactive) {
280:                    logger.log(BasicLevel.INFO, "testCollectionTh100Tx100");
281:                    perform(100, 100, 1000000, null);
282:                }
283:            }
284:
285:            /**
286:             * Tests 1000 transactions which stress collections using 1000 thread.
287:             */
288:            public void testCollectionTh1000Tx1000() {
289:
290:                if (!interactive) {
291:                    logger.log(BasicLevel.INFO, "testCollectionTh1000Tx1000");
292:                    perform(1000, 1000, 1000000, null);
293:                }
294:            }
295:
296:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.