Source Code Cross Referenced for A_bank.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas » stests » bank » 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.stests.bank 
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_bank.java 4125 2004-01-30 14:22:00Z durieuxp $
023:         * --------------------------------------------------------------------------
024:         */
025:
026:        package org.objectweb.jonas.stests.bank;
027:
028:        import javax.rmi.PortableRemoteObject;
029:        import org.objectweb.jonas.stests.util.JTestCase;
030:
031:        public abstract class A_bank extends JTestCase {
032:
033:            protected static final int OP_READ = 1;
034:            protected static final int OP_MOVE = 2;
035:            protected static final int OP_CREATE = 3;
036:            protected static final int OP_REMOVE = 4;
037:            protected static final int OP_ONEMOVE = 5;
038:            protected static final int OP_READTX = 6;
039:            protected static final int OP_ONEMOVETX = 7;
040:            protected static final int OP_MOVETO = 8;
041:
042:            static final int initialValue = 1000;
043:            static final int accountNb = 20;
044:
045:            protected static ManagerHome home = null;
046:            protected static Manager manager = null;
047:            public static boolean threadfail;
048:
049:            public A_bank(String name) {
050:                super (name);
051:            }
052:
053:            public abstract String getManagerHomeName();
054:
055:            public abstract boolean getPrefetch();
056:
057:            protected void setUp() throws Exception {
058:                super .setUp();
059:                if (home == null) {
060:                    useBeans("bank");
061:                    home = (ManagerHome) PortableRemoteObject.narrow(ictx
062:                            .lookup(getManagerHomeName()), ManagerHome.class);
063:                }
064:                if (manager == null) {
065:                    manager = home.create(initialValue, getPrefetch());
066:                }
067:                // Initializes the test by creating accounts
068:                manager.createAll(accountNb);
069:                threadfail = false;
070:            }
071:
072:            protected void tearDown() throws Exception {
073:                super .tearDown();
074:                if (threadfail && manager != null) {
075:                    manager.reinitAll();
076:                    manager.remove();
077:                    manager = null;
078:                }
079:            }
080:
081:            public void ope(int action, int accmin, int accmax, int loops,
082:                    int threads) throws Exception {
083:                ope(action, accmin, accmax, loops, threads, 10, true);
084:            }
085:
086:            public void ope(int action, int accmin, int accmax, int loops,
087:                    int threads, int amount) throws Exception {
088:                ope(action, accmin, accmax, loops, threads, amount, true);
089:            }
090:
091:            /**
092:             * generic operation.
093:             * @param accmin min range for account nb
094:             * @param accmax max range for account nb
095:             * @param loops nb of loop in each thread
096:             * @param threads nb of threads running the same operations
097:             */
098:            public void ope(int action, int accmin, int accmax, int loops,
099:                    int threads, int amount, boolean verify) throws Exception {
100:
101:                // Set transaction timeout in the server (global value!)
102:                stopTxAt(20);
103:
104:                // Create and start all threads
105:                A_thread[] t_thr = new A_thread[threads];
106:                for (int i = 0; i < threads; i++) {
107:                    t_thr[i] = new A_thread(getManagerHomeName(), i, ictx,
108:                            action, accmin, accmax, loops, amount,
109:                            getPrefetch());
110:                    t_thr[i].start();
111:                }
112:
113:                // Wait end of all threads
114:                for (int p = 0; p < threads; p++) {
115:                    t_thr[p].join();
116:                }
117:
118:                // Check if all threads run ok
119:                if (threadfail) {
120:                    fail("Error in a thread");
121:                }
122:                if (verify && !manager.checkAll()) {
123:                    threadfail = true; // to reinit the database
124:                    fail("Bad global state");
125:                }
126:            }
127:
128:            public void testBasicRead() throws Exception {
129:                ope(OP_READ, 0, 9, 1, 1, 10, false);
130:            }
131:
132:            public void testPrefetch() throws Exception {
133:                ope(OP_READ, 0, 9, 50, 8);
134:            }
135:
136:            public void testDeadlock() throws Exception {
137:                ope(OP_MOVETO, 3, 5, 1, 2, 20);
138:            }
139:
140:            public void testSameAccount() throws Exception {
141:                ope(OP_MOVETO, 2, 2, 10, 1, 10);
142:            }
143:
144:            public void testMultiSameAccount() throws Exception {
145:                ope(OP_MOVETO, 6, 6, 1, 10, 10);
146:            }
147:
148:            public void testBasicReadTx() throws Exception {
149:                ope(OP_READTX, 0, 9, 1, 1, 10, false);
150:            }
151:
152:            public void testLongRead() throws Exception {
153:                ope(OP_READ, 0, 9, 100, 1);
154:            }
155:
156:            public void testLongReadTx() throws Exception {
157:                ope(OP_READTX, 0, 9, 100, 1);
158:            }
159:
160:            public void testMultiRead() throws Exception {
161:                ope(OP_READ, 0, 9, 1, 10);
162:            }
163:
164:            public void testMultiReadTx() throws Exception {
165:                ope(OP_READTX, 0, 9, 1, 10);
166:            }
167:
168:            public void testMultiShortReadTx() throws Exception {
169:                ope(OP_READTX, 0, 9, 10, 10);
170:            }
171:
172:            public void testMultiOneMove() throws Exception {
173:                ope(OP_ONEMOVE, 0, 5, 1, 20);
174:            }
175:
176:            public void testTh3OneMoveTx() throws Exception {
177:                ope(OP_ONEMOVETX, 0, 5, 100, 3);
178:            }
179:
180:            public void testTh5OneMoveTx() throws Exception {
181:                ope(OP_ONEMOVETX, 0, 5, 100, 5);
182:            }
183:
184:            public void testTh7OneMoveTx() throws Exception {
185:                ope(OP_ONEMOVETX, 0, 5, 100, 7);
186:            }
187:
188:            public void testMultiOneMoveTx() throws Exception {
189:                ope(OP_ONEMOVETX, 0, 5, 1, 20);
190:            }
191:
192:            /**
193:             * This test is also used for perf measures
194:             * => DO NOT CHANGE ARG VALUES
195:             */
196:            public void testMultiLongRead() throws Exception {
197:                ope(OP_READ, 0, 9, 200, 12);
198:            }
199:
200:            /**
201:             * This test is also used for perf measures
202:             * => DO NOT CHANGE ARG VALUES
203:             */
204:            public void testMultiLongReadTx() throws Exception {
205:                ope(OP_READTX, 0, 19, 200, 12, 1);
206:            }
207:
208:            /**
209:             * This test is also used for perf measures
210:             * => DO NOT CHANGE ARG VALUES
211:             */
212:            public void testMultiLongOneMove() throws Exception {
213:                ope(OP_ONEMOVE, 0, 19, 200, 12, 1);
214:            }
215:
216:            /**
217:             * This test is also used for perf measures
218:             * => DO NOT CHANGE ARG VALUES
219:             */
220:            public void testMultiLongOneMoveTx() throws Exception {
221:                ope(OP_ONEMOVETX, 0, 19, 200, 12, 1);
222:            }
223:
224:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.