Source Code Cross Referenced for TypicalProcessTests.java in  » Workflow-Engines » wfmopen-2.1.1 » load » 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 » Workflow Engines » wfmopen 2.1.1 » load 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * This file is part of the WfMOpen project.
003:         * Copyright (C) 2001-2003 Danet GmbH (www.danet.de), GS-AN.
004:         * All rights reserved.
005:         *
006:         * This program is free software; you can redistribute it and/or modify
007:         * it under the terms of the GNU General Public License as published by
008:         * the Free Software Foundation; either version 2 of the License, or
009:         * (at your option) any later version.
010:         *
011:         * This program 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
014:         * GNU General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU General Public License
017:         * along with this program; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
019:         *
020:         * $Id: TypicalProcessTests.java,v 1.3 2007/03/27 21:59:43 mlipp Exp $
021:         */
022:        package load;
023:
024:        import java.util.HashMap;
025:        import java.util.Map;
026:
027:        import javax.security.auth.login.LoginException;
028:
029:        import de.danet.an.util.junit.EJBClientTest;
030:        import de.danet.an.util.junit.NamedTestGroup;
031:
032:        import com.clarkware.junitperf.ConstantTimer;
033:        import com.clarkware.junitperf.LoadTest;
034:        import common.STProjectLoginContext;
035:        import junit.framework.Test;
036:        import junit.framework.TestSuite;
037:
038:        import org.apache.log4j.Logger;
039:
040:        import load.TypicalProcessManager.InitialProcessDataAdapter;
041:
042:        /**
043:         * This class generates base load for the workflow engine. 
044:         * Additionally a test suite for load test szenario with a running base load 
045:         * can be built.
046:         *
047:         * @author <a href="weidauer@danet.de">Christian Weidauer</a>
048:         * @version $Revision: 1.3 $
049:         */
050:
051:        public class TypicalProcessTests {
052:
053:            // base load parameters
054:            private static final int BASELOAD_PROCESS_NUMBER = 500;
055:            private static final int PROCESS_AVERAGE_DURATION = 60 * 60; // in s
056:            private static final int WAIT_TIME = (int) (0.1 * PROCESS_AVERAGE_DURATION); // in s
057:
058:            // test load parameters
059:            private static final int USERS = 30;
060:            private static final int ITERATIONS = 1;
061:            private static final int PROCESSSTARTS_PER_SECOND = 2;
062:
063:            // dependend test load parameters 
064:            private static final int DELAYTIME = (int) (1000 / PROCESSSTARTS_PER_SECOND); // in ms
065:
066:            // logger
067:            private static final Logger logger = Logger
068:                    .getLogger(TypicalProcessTests.class);
069:
070:            private static STProjectLoginContext plc = null;
071:            static {
072:                try {
073:                    plc = new STProjectLoginContext();
074:                    plc.login();
075:                } catch (LoginException e) {
076:                    throw new IllegalStateException(e.getMessage());
077:                }
078:            }
079:
080:            /**
081:             * Make this test suite.
082:             * @return the test suite
083:             */
084:            public static Test suite() throws Exception {
085:                clearWorkflowEngine();
086:                generateBaseLoad(BASELOAD_PROCESS_NUMBER,
087:                        PROCESS_AVERAGE_DURATION);
088:                System.out.println("waits for " + WAIT_TIME + " sec");
089:                pause(WAIT_TIME * 1000);
090:                System.out.println("starts test preparation");
091:
092:                //TypicalProcess tp1 = new TypicalProcess(PROCESS_AVERAGE_DURATION);
093:                TypicalProcess tp2a = new TypicalProcess(TypicalProcess.PATH1,
094:                        PROCESS_AVERAGE_DURATION / 4,
095:                        PROCESS_AVERAGE_DURATION / 4, 2);
096:                /*
097:                  TypicalProcess tp2b 
098:                    = new TypicalProcess(TypicalProcess.PATH2, 
099:                			 PROCESS_AVERAGE_DURATION / 3, 0, 3);
100:                TypicalProcess tp3 = new TypicalProcess(PROCESS_AVERAGE_DURATION / 8, 
101:                					PROCESS_AVERAGE_DURATION / 6, 
102:                					6);
103:                 */
104:
105:                TestSuite rootSuite = new TestSuite();
106:
107:                Map tg = new HashMap();
108:                TestSuite suite = new TestSuite();
109:                tg.put("title",
110:                        "Create typical processes along different pathes and start them."
111:                                + " Baseload: " + BASELOAD_PROCESS_NUMBER
112:                                + " processes,"
113:                                + " process starts per second: "
114:                                + PROCESSSTARTS_PER_SECOND + ".");
115:                //addTest(suite, "Create and Start Process along Path1", 
116:                //	tp1.createInitStartTest());
117:                addTest(suite, "Create and Start Process along Path2a", tp2a
118:                        .createInitStartTest());
119:                /*	addTest(suite, "Create and Start Process along Path2b", 
120:                	tp2b.createInitStartTest());
121:                addTest(suite, "Create and Start Process along Path3", 
122:                	tp3.createInitStartTest());
123:                 */
124:                rootSuite.addTest(new NamedTestGroup(suite, "TestGroup", tg));
125:                System.out.println("finished test preparation");
126:                return new EJBClientTest(plc, rootSuite);
127:            }
128:
129:            public static void generateBaseLoad(int processNumber,
130:                    int processAverageDuration) throws Exception {
131:                System.out.println("generates base load of "
132:                        + BASELOAD_PROCESS_NUMBER
133:                        + " processes of an average life time of "
134:                        + processAverageDuration + " sec");
135:                long startTime = System.currentTimeMillis();
136:                // 10% processes with 5 active activities
137:                generatePath1Processes((int) (processNumber * 0.1 * 0.5),
138:                        (int) (0.1 * processAverageDuration),
139:                        (int) (1.9 * processAverageDuration));
140:                generatePath2Processes((int) (processNumber * 0.1 * 0.5),
141:                        TypicalProcess.PATH1,
142:                        (int) (0.2 * processAverageDuration / 2),
143:                        (int) (0.8 * processAverageDuration / 2),
144:                        (int) (0.5 * processAverageDuration / 2), 2);
145:
146:                // 40% processes with 8-10 active activities
147:                generatePath3Processes((int) (processNumber * 0.4 * 0.3),
148:                        (int) (0.6 * processAverageDuration / 1),
149:                        (int) (1.4 * processAverageDuration / 1),
150:                        (int) (processAverageDuration / 5), 1);
151:
152:                generatePath2Processes((int) (processNumber * 0.4 * 0.3),
153:                        TypicalProcess.PATH1,
154:                        (int) (0.2 * processAverageDuration / 2),
155:                        (int) (0.8 * processAverageDuration / 2),
156:                        (int) (0.5 * processAverageDuration / 2), 2);
157:
158:                generatePath2Processes((int) (processNumber * 0.4 * 0.4),
159:                        TypicalProcess.PATH2,
160:                        (int) (0.2 * processAverageDuration / 2),
161:                        (int) (1.8 * processAverageDuration / 2), (int) 0, 2);
162:
163:                // 40% processes with 21-22 active activities
164:                generatePath3Processes((int) (processNumber * 0.4 * 0.3),
165:                        (int) (0.6 * processAverageDuration / 3),
166:                        (int) (1.4 * processAverageDuration / 3),
167:                        (int) (processAverageDuration / 5), 3);
168:
169:                generatePath2Processes((int) (processNumber * 0.4 * 0.3),
170:                        TypicalProcess.PATH1,
171:                        (int) (0.2 * processAverageDuration / 5),
172:                        (int) (0.8 * processAverageDuration / 5),
173:                        (int) (0.5 * processAverageDuration / 5), 5);
174:
175:                generatePath2Processes((int) (processNumber * 0.4 * 0.4),
176:                        TypicalProcess.PATH2,
177:                        (int) (0.2 * processAverageDuration / 4),
178:                        (int) (1.8 * processAverageDuration / 4), (int) 0, 4);
179:
180:                // 10% processes with 29-31 active activities
181:                generatePath3Processes((int) (processNumber * 0.1 * 0.4),
182:                        (int) (0.6 * processAverageDuration / 4),
183:                        (int) (1.4 * processAverageDuration / 4),
184:                        (int) (processAverageDuration / 10), 4);
185:                generatePath2Processes((int) (processNumber * 0.1 * 0.3),
186:                        TypicalProcess.PATH1,
187:                        (int) (0.2 * processAverageDuration / 7),
188:                        (int) (0.8 * processAverageDuration / 7),
189:                        (int) (0.5 * processAverageDuration / 7), 7);
190:                generatePath2Processes((int) (processNumber * 0.1 * 0.3),
191:                        TypicalProcess.PATH2,
192:                        (int) (0.2 * processAverageDuration / 6),
193:                        (int) (1.8 * processAverageDuration / 6), (int) 0, 6);
194:                long duration = System.currentTimeMillis() - startTime;
195:                System.out.println("... took " + duration / 1000 + " sec");
196:            }
197:
198:            private static void pause(int milliSeconds) throws Exception {
199:                Thread.currentThread().sleep(milliSeconds / 4);
200:                System.out.println("... waited " + milliSeconds / 4000
201:                        + " sec.");
202:                Thread.currentThread().sleep(milliSeconds / 4);
203:                System.out.println("... waited " + milliSeconds / 2000
204:                        + " sec.");
205:                Thread.currentThread().sleep(milliSeconds / 4);
206:                System.out.println("... waited " + milliSeconds / 1333
207:                        + " sec.");
208:                Thread.currentThread().sleep(milliSeconds / 4);
209:            }
210:
211:            private static void generatePath1Processes(int number, int duration)
212:                    throws Exception {
213:                TypicalProcessManager.STARTER.generate(new TypicalProcess(
214:                        duration), number);
215:            }
216:
217:            private static void generatePath1Processes(int number,
218:                    int durationFrom, int durationTo) throws Exception {
219:                InitialProcessDataAdapter adapter = TypicalProcessManager.STARTER
220:                        .createAdapter("BE1_3_Duration", durationFrom,
221:                                durationTo);
222:                TypicalProcessManager.STARTER.generate(new TypicalProcess(0),
223:                        number, adapter);
224:            }
225:
226:            private static void generatePath2Processes(int number,
227:                    String decision2, int durationBE2_1, int durationBE2_3_1,
228:                    int initialLoopCounter) throws Exception {
229:                TypicalProcessManager.STARTER.generate(new TypicalProcess(
230:                        decision2, durationBE2_1, durationBE2_3_1,
231:                        initialLoopCounter), number);
232:            }
233:
234:            private static void generatePath2Processes(int number,
235:                    String decision2, int durationBE2_1_From,
236:                    int durationBE2_1_To, int durationBE2_3_1,
237:                    int initialLoopCounter) throws Exception {
238:                InitialProcessDataAdapter adapter = TypicalProcessManager.STARTER
239:                        .createAdapter("BE2_1_Duration", durationBE2_1_From,
240:                                durationBE2_1_To);
241:                TypicalProcessManager.STARTER.generate(new TypicalProcess(
242:                        decision2, 0, durationBE2_3_1, initialLoopCounter),
243:                        number, adapter);
244:            }
245:
246:            private static void generatePath3Processes(int number,
247:                    int durationBE3_2_1, int durationBE3_2_2,
248:                    int initialLoopCounter) throws Exception {
249:                TypicalProcessManager.STARTER.generate(new TypicalProcess(
250:                        durationBE3_2_1, durationBE3_2_2, initialLoopCounter),
251:                        number);
252:            }
253:
254:            private static void generatePath3Processes(int number,
255:                    int durationBE3_2_1_From, int durationBE3_2_1_To,
256:                    int durationBE3_2_2, int initialLoopCounter)
257:                    throws Exception {
258:                InitialProcessDataAdapter adapter = TypicalProcessManager.STARTER
259:                        .createAdapter("BE3_2_1_Duration",
260:                                durationBE3_2_1_From, durationBE3_2_1_To);
261:                TypicalProcessManager.STARTER.generate(new TypicalProcess(0,
262:                        durationBE3_2_2, initialLoopCounter), number, adapter);
263:            }
264:
265:            private static void clearWorkflowEngine() throws Exception {
266:                System.out.println("clears workflow engine");
267:                GenericTest.closeAllCloseableProcesses();
268:                GenericTest.waitForNoRunningProcesses();
269:                GenericTest.removeAllProcesses();
270:            }
271:
272:            private static void addTest(TestSuite parentSuite, String title,
273:                    Test testCase) {
274:                TestSuite suite = new TestSuite();
275:                Map sas = new HashMap();
276:                sas.put("users", new Integer(USERS));
277:                suite.addTest(new NamedTestGroup(new LoadTest(testCase, USERS,
278:                        ITERATIONS, new ConstantTimer(DELAYTIME)), "Samples",
279:                        sas));
280:
281:                Map tt = new HashMap();
282:                tt.put("title", title);
283:                parentSuite.addTest(new NamedTestGroup(suite, "Test", tt));
284:            }
285:
286:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.