Source Code Cross Referenced for ClusteredCreate.java in  » Workflow-Engines » wfmopen-2.1.1 » procdef » 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 » procdef 
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: ClusteredCreate.java,v 1.3 2007/03/27 21:59:42 mlipp Exp $
021:         *
022:         * $Log: ClusteredCreate.java,v $
023:         * Revision 1.3  2007/03/27 21:59:42  mlipp
024:         * Fixed lots of checkstyle warnings.
025:         *
026:         * Revision 1.2  2006/09/29 12:32:09  drmlipp
027:         * Consistently using WfMOpen as projct name now.
028:         *
029:         * Revision 1.1.1.1  2003/12/19 13:01:44  drmlipp
030:         * Updated to 1.1rc1
031:         *
032:         * Revision 1.1  2003/11/06 15:52:43  huaiyang
033:         * Initial.
034:         *
035:         * Revision 1.14  2003/10/27 15:32:05  huaiyang
036:         * use wrappedProcess/Activity.
037:         *
038:         * Revision 1.13  2003/10/21 21:00:45  lipp
039:         * Moved EJBClientTest to new junit sub-package.
040:         *
041:         * Revision 1.12  2003/10/08 12:39:40  huaiyang
042:         * make test weblogic compatible.
043:         *
044:         * Revision 1.11  2003/06/27 09:44:03  lipp
045:         * Fixed copyright/license information.
046:         *
047:         * Revision 1.10  2003/06/02 15:25:19  lipp
048:         * Activated IPR38 check.
049:         *
050:         * Revision 1.9  2003/05/31 18:29:59  lipp
051:         * Fixed test case.
052:         *
053:         * Revision 1.8  2003/05/22 11:39:57  lipp
054:         * Fixed test case.
055:         *
056:         * Revision 1.7  2003/05/14 12:02:26  schlue
057:         * Import of process descriptions changed due to modified import behaviour.
058:         *
059:         * Revision 1.6  2003/05/14 09:30:27  schlue
060:         * Package names for minimal and full changed due to modified import behaviour.
061:         *
062:         * Revision 1.5  2003/05/07 09:55:21  schlue
063:         * Redefinable header with version info added.
064:         *
065:         * Revision 1.4  2003/04/26 16:12:22  lipp
066:         * Moved some classes to reduce package dependencies.
067:         *
068:         * Revision 1.3  2003/04/16 14:06:26  schlue
069:         * Some renames.
070:         *
071:         * Revision 1.2  2003/04/15 14:17:22  schlue
072:         * Cleanup added.
073:         *
074:         * Revision 1.1  2003/04/15 12:57:25  schlue
075:         * Static tests of process and activity (definitions) moved to directory process.
076:         * More test cases for block activities added.
077:         *
078:         * Revision 1.3  2003/04/11 14:39:56  schlue
079:         * System tests for activitites added.
080:         *
081:         * Revision 1.2  2003/04/10 09:44:08  schlue
082:         * Test cases for process data added.
083:         *
084:         * Revision 1.1  2003/03/21 10:00:59  schlue
085:         * Initial version.
086:         *
087:         *
088:         *
089:         */
090:        package procdef;
091:
092:        import java.io.BufferedReader;
093:        import java.io.InputStream;
094:        import java.io.InputStreamReader;
095:
096:        import java.util.ArrayList;
097:        import java.util.Collection;
098:        import java.util.HashSet;
099:        import java.util.Iterator;
100:        import java.util.LinkedList;
101:        import java.util.List;
102:        import java.util.Set;
103:
104:        import java.rmi.RemoteException;
105:
106:        import de.danet.an.workflow.omgcore.InvalidPriorityException;
107:        import de.danet.an.workflow.omgcore.NotEnabledException;
108:        import de.danet.an.workflow.omgcore.WfExecutionObject;
109:        import de.danet.an.workflow.omgcore.WfProcess;
110:        import de.danet.an.workflow.omgcore.WfProcessMgr;
111:        import de.danet.an.workflow.omgcore.WfRequester;
112:
113:        import de.danet.an.util.junit.EJBClientTest;
114:        import de.danet.an.workflow.api.Activity;
115:        import de.danet.an.workflow.api.DefaultRequester;
116:        import de.danet.an.workflow.api.ImportException;
117:        import de.danet.an.workflow.api.InvalidKeyException;
118:        import de.danet.an.workflow.api.PrioritizedMessage;
119:        import de.danet.an.workflow.api.Process;
120:        import de.danet.an.workflow.api.ProcessDefinitionDirectory;
121:        import de.danet.an.workflow.api.ProcessDirectory;
122:        import de.danet.an.workflow.api.ProcessMgr;
123:        import de.danet.an.workflow.api.WorkflowService;
124:        import de.danet.an.workflow.api.WorkflowServiceFactory;
125:
126:        import junit.framework.Test;
127:        import junit.framework.TestSuite;
128:        import process.WfMOpenTestCase;
129:        import process.EventWatch;
130:        import common.WrappedProcess;
131:        import common.WrappedActivity;
132:        import common.WrappedProcessDefinitionDirectory;
133:        import common.Util;
134:
135:        /**
136:         * Test creation of processes.
137:         * After completion, all previously imported process descriptions
138:         * and created processes are cleared.
139:         * @author <a href="mailto:schlueter@danet.de">Holger Schlueter</a>
140:         * @version 1.0
141:         */
142:        public class ClusteredCreate extends WfMOpenTestCase {
143:            static final org.apache.commons.logging.Log logger = org.apache.commons.logging.LogFactory
144:                    .getLog(ClusteredCreate.class);
145:
146:            private static Collection createdProcs = new ArrayList();
147:
148:            /**
149:             * Access to process definition directory (singleton)
150:             */
151:            private WrappedProcessDefinitionDirectory defDir = null;
152:
153:            /**
154:             * Access to process directory (singleton)
155:             */
156:            private ProcessDirectory procDir = null;
157:
158:            /**
159:             * Access to default requester (singleton)
160:             */
161:            private WfRequester requester = null;
162:
163:            /**
164:             * Constructor of this TestCase
165:             * @param name a <code>String</code> value
166:             */
167:            public ClusteredCreate(String name) {
168:                super (name);
169:            }
170:
171:            /**
172:             * Construct this test suite.
173:             * @return a <code>Test</code> value
174:             */
175:            public static Test suite() {
176:                TestSuite suite = new TestSuite();
177:                suite.addTest(new ClusteredCreate("testEnabled"));
178:                suite.addTest(new ClusteredCreate("createMinimal"));
179:                suite.addTest(new ClusteredCreate("testProcAttributes"));
180:                suite.addTest(new ClusteredCreate("testActivities"));
181:                suite.addTest(new ClusteredCreate("testActivitiesBlock1"));
182:                suite.addTest(new ClusteredCreate("testActivitiesBlock2"));
183:                suite.addTest(new ClusteredCreate("removeProcesses"));
184:                suite.addTest(new ClusteredCreate("cleanup"));
185:                suite.addTest(new ClusteredCreate("testActivitiesBlock2"));
186:                suite.addTest(new ClusteredCreate("removeProcesses"));
187:                return new EJBClientTest(plc, suite);
188:            }
189:
190:            /**
191:             * Test enable flag on creation of a process.
192:             * @exception Exception if an error occurs
193:             */
194:            public void testEnabled() throws Exception {
195:                Util.logEntry("testEnabled");
196:                boolean gotException = false;
197:                // test default setting
198:                assertTrue(defDir.isEnabled("SystemTest_minimal", "minimal"));
199:                defDir.setEnabled("SystemTest_minimal", "minimal", false);
200:                ProcessMgr mgr = defDir.processMgr("SystemTest_minimal",
201:                        "minimal");
202:                int noprocs = mgr.processes().size();
203:                //WfProcess proc = null;
204:                WrappedProcess proc = null;
205:                Util.sleep(15000);
206:                // Make sure that default is "disabled"
207:                assertTrue(mgr.processMgrState() == WfProcessMgr.DISABLED);
208:                // Test that process creation is not possible
209:                try {
210:                    //proc = mgr.createProcess(requester);
211:                    proc = new WrappedProcess(mgr.createProcess(requester));
212:                } catch (NotEnabledException exc) {
213:                    gotException = true;
214:                }
215:                assertTrue(gotException);
216:                // Enable now and make sure that process can be created
217:                mgr.setProcessMgrState(WfProcessMgr.ENABLED);
218:                Util.sleep(15000);
219:                assertTrue(mgr.processes().size() == noprocs);
220:                proc = new WrappedProcess(mgr.createProcess(requester));
221:                createdProcs.add(proc);
222:                assertTrue(mgr.processes().size() == noprocs + 1);
223:                Util.logExit("testEnabled");
224:            }
225:
226:            /**
227:             * Test creation of a process with minimal process definition. 
228:             * @exception Exception if an error occurs
229:             */
230:            public void createMinimal() throws Exception {
231:                Util.logEntry("createMinimal");
232:                boolean gotException = false;
233:                // Try invald packageId
234:                try {
235:                    defDir.processMgr("Systemtest", "minimal");
236:                } catch (InvalidKeyException exc) {
237:                    gotException = true;
238:                }
239:                assertTrue(gotException);
240:                // Try invald processId
241:                gotException = false;
242:                try {
243:                    defDir.processMgr("SystemTest_minimal", "Minimal");
244:                } catch (InvalidKeyException exc) {
245:                    gotException = true;
246:                }
247:                assertTrue(gotException);
248:                // Try correct identifier
249:                ProcessMgr mgr = defDir.processMgr("SystemTest_minimal",
250:                        "minimal");
251:                Util.sleep(15000);
252:                int noprocs = mgr.processes().size();
253:                //WfProcess proc = mgr.createProcess(requester);
254:                WrappedProcess proc = new WrappedProcess(mgr
255:                        .createProcess(requester));
256:                assertTrue(mgr.processes().size() == noprocs + 1);
257:                createdProcs.add(proc);
258:                Util.logExit("createMinimal");
259:            }
260:
261:            /**
262:             * Test removal of all previously created processes.
263:             * @exception Exception if an error occurs
264:             */
265:            public void removeProcesses() throws Exception {
266:                Util.logEntry("removeProcesses");
267:                int noprocs = procDir.processes().size();
268:                Iterator procs = createdProcs.iterator();
269:                while (procs.hasNext()) {
270:                    //WfProcess proc = (Process)procs.next();
271:                    WrappedProcess proc = (WrappedProcess) procs.next();
272:                    Util.sleep(15000);
273:                    procDir.removeProcess(proc.getWfProcess());
274:                }
275:                assertTrue(procDir.processes().size() == noprocs
276:                        - createdProcs.size());
277:                createdProcs.clear();
278:                Util.logExit("removeProcesses");
279:            }
280:
281:            /**
282:             * Remove all imported process definitions.
283:             * @exception Exception if an error occurs
284:             */
285:            public void cleanup() throws Exception {
286:                Util.logEntry("cleanup");
287:                defDir.removeProcessDefinition("SystemTest_minimal", "minimal");
288:                boolean procdefRemoved = false;
289:                try {
290:                    defDir.processMgr("SystemTest_minimal", "minimal");
291:                } catch (InvalidKeyException exc) {
292:                    procdefRemoved = true;
293:                }
294:                assertTrue(procdefRemoved);
295:                Util.sleep(15000);
296:                defDir.removeProcessDefinition("SystemTest_full", "full");
297:                procdefRemoved = false;
298:                try {
299:                    defDir.processMgr("SystemTest_full", "full");
300:                } catch (InvalidKeyException exc) {
301:                    procdefRemoved = true;
302:                }
303:                assertTrue(procdefRemoved);
304:                Util.sleep(15000);
305:                defDir.removeProcessDefinition("SystemTest", "block_diamond");
306:                procdefRemoved = false;
307:                try {
308:                    defDir.processMgr("SystemTest", "block_diamond");
309:                } catch (InvalidKeyException exc) {
310:                    procdefRemoved = true;
311:                }
312:                assertTrue(procdefRemoved);
313:                defDir
314:                        .removeProcessDefinition("SystemTest",
315:                                "block_2_in_2_out");
316:                procdefRemoved = false;
317:                try {
318:                    defDir.processMgr("SystemTest", "block_2_in_2_out");
319:                } catch (InvalidKeyException exc) {
320:                    procdefRemoved = true;
321:                }
322:                assertTrue(procdefRemoved);
323:                Util.logExit("cleanup");
324:            }
325:
326:            /**
327:             * Test all accessible attributes of process manager and process
328:             * (except process data and process context information).
329:             * @exception Exception if an error occurs
330:             */
331:            public void testProcAttributes() throws Exception {
332:                Util.logEntry("testProcAttributes");
333:                ProcessMgr mgrMin = defDir.processMgr("SystemTest_minimal",
334:                        "minimal");
335:                ProcessMgr mgrFull = defDir.processMgr("SystemTest_full",
336:                        "full");
337:
338:                // Test attributes of process manager
339:                assertTrue(mgrMin.category() == null);
340:                assertTrue(mgrMin.description() == null);
341:                assertTrue(mgrMin.version() == null);
342:                assertTrue(mgrMin.name().equals("SystemTest_minimal/minimal"));
343:                assertTrue(mgrFull.category().equals("System Test (procdef)"));
344:                assertTrue(mgrFull.description().equals(
345:                        "Description for test of all accessible attributes"));
346:
347:                assertTrue(mgrFull.version().equals("beta 1"));
348:                assertTrue(mgrFull.name().equals("SystemTest_full/full"));
349:
350:                // 	WfProcess proc1 = mgrMin.createProcess(requester);
351:                // 	WfProcess proc2 = mgrFull.createProcess(requester);
352:                // 	WfProcess proc3 = mgrFull.createProcess(requester);
353:                Util.sleep(15000);
354:                WrappedProcess proc1 = new WrappedProcess(mgrMin
355:                        .createProcess(requester));
356:                WrappedProcess proc2 = new WrappedProcess(mgrFull
357:                        .createProcess(requester));
358:                WrappedProcess proc3 = new WrappedProcess(mgrFull
359:                        .createProcess(requester));
360:                // Test attributes of processes without existing process definition
361:                defDir.removeProcessDefinition("SystemTest_minimal", "minimal");
362:                defDir.removeProcessDefinition("SystemTest_full", "full");
363:                Util.sleep(15000);
364:                boolean procdefRemoved = false;
365:                try {
366:                    mgrMin = defDir.processMgr("SystemTest_minimal", "minimal");
367:                } catch (InvalidKeyException exc) {
368:                    procdefRemoved = true;
369:                }
370:                assertTrue(procdefRemoved);
371:                procdefRemoved = false;
372:                try {
373:                    mgrFull = defDir.processMgr("SystemTest_full", "full");
374:                } catch (InvalidKeyException exc) {
375:                    procdefRemoved = true;
376:                }
377:                assertTrue(procdefRemoved);
378:
379:                assertTrue(proc1.name() == null);
380:                proc1.setName("minimal Process");
381:                assertTrue(proc2.name().equals("PROCESS_COMPLETE_ATTRIBUTES"));
382:                assertTrue(proc3.name().equals("PROCESS_COMPLETE_ATTRIBUTES"));
383:                proc2.setName(null);
384:                assertTrue(proc1.name().equals("minimal Process"));
385:                assertTrue(proc2.name() == null);
386:                assertTrue(proc3.name().equals("PROCESS_COMPLETE_ATTRIBUTES"));
387:                assertTrue(!proc2.key().equals(proc3.key()));
388:                assertTrue(proc1.description() == null);
389:                assertTrue(proc2.description().equals(
390:                        "Description for test of all accessible attributes"));
391:                assertTrue(proc3.description().equals(
392:                        "Description for test of all accessible attributes"));
393:                proc3.setDescription("full");
394:                assertTrue(proc2.description().equals(
395:                        "Description for test of all accessible attributes"));
396:                assertTrue(proc3.description().equals("full"));
397:                assertTrue(proc1.priority() == 3); // default priority
398:                assertTrue(proc2.priority() == 5);
399:                boolean gotException = false;
400:                try {
401:                    proc1.setPriority(0);
402:                } catch (InvalidPriorityException exc) {
403:                    gotException = true;
404:                }
405:                assertTrue(gotException);
406:                proc1.setPriority(1);
407:                gotException = false;
408:                try {
409:                    proc2.setPriority(6);
410:                } catch (InvalidPriorityException exc) {
411:                    gotException = true;
412:                }
413:                assertTrue(gotException);
414:                proc2.setPriority(4);
415:                assertTrue(proc1.priority() == 1);
416:                assertTrue(proc2.priority() == 4);
417:
418:                /* Make sure that process attributes are no longer
419:                   accessible after removal of process */
420:                procDir.removeProcess(proc1.getWfProcess());
421:                procDir.removeProcess(proc2.getWfProcess());
422:                procDir.removeProcess(proc3.getWfProcess());
423:                boolean processNotAccessible = false;
424:                try {
425:                    int dummy = proc1.priority();
426:                } catch (RemoteException exc) {
427:                    processNotAccessible = true;
428:                }
429:                assertTrue(processNotAccessible);
430:                Util.logExit("testProcAttributes");
431:            }
432:
433:            /**
434:             * Test activitiy information for minimal and full description.
435:             * @exception Exception if an error occurs
436:             */
437:            public void testActivities() throws Exception {
438:                Util.logEntry("testActivities");
439:                ProcessMgr mgrMin = defDir.processMgr("SystemTest_minimal",
440:                        "minimal");
441:                ProcessMgr mgrFull = defDir.processMgr("SystemTest_full",
442:                        "full");
443:                // 	WfProcess proc1 = mgrMin.createProcess(requester);
444:                // 	WfProcess proc2 = mgrFull.createProcess(requester);
445:                // 	WfProcess proc3 = mgrFull.createProcess(requester);
446:                WrappedProcess proc1 = new WrappedProcess(mgrMin
447:                        .createProcess(requester));
448:                WrappedProcess proc2 = new WrappedProcess(mgrFull
449:                        .createProcess(requester));
450:                WrappedProcess proc3 = new WrappedProcess(mgrFull
451:                        .createProcess(requester));
452:
453:                // Test activity of process 1
454:                assertTrue(proc1.steps().size() == 1);
455:                WrappedActivity act = (WrappedActivity) proc1.steps().toArray()[0];
456:                Util.sleep(15000);
457:                assertTrue(act.assignments().size() == 0);
458:                assertTrue(act.name() == null);
459:                assertTrue(act.priority() == 3); // Default priority
460:                assertTrue(act.container().key().equals(proc1.key()));
461:                assertTrue(act.nextActivities().size() == 0);
462:
463:                // Test activities of processes 2 and 3
464:                assertTrue(proc2.steps().size() == 3);
465:                assertTrue(proc3.steps().size() == 3);
466:                Iterator it = proc2.steps().iterator();
467:                List acts = new LinkedList();
468:                while (it.hasNext()) {
469:                    act = (WrappedActivity) it.next();
470:                    acts.clear();
471:                    if (act.name().equals("ACT1")) {
472:                        Util.sleep(15000);
473:                        assertTrue(act.priority() == 1);
474:                        assertTrue(act.description().equals(
475:                                "Activity with dummy implementation"));
476:                        assertTrue(act.assignments().size() == 0);
477:                        assertTrue(act.container().equals(proc2));
478:                        assertTrue(act.nextActivities().size() == 1);
479:                        acts.add("SET1");
480:                        assertTrue(activitiesIncluded(act.nextActivities(),
481:                                acts));
482:                    } else if (act.name().equals("ACT2")) {
483:                        assertTrue(act.priority() == 2);
484:                        assertTrue(act.description() == null);
485:                        assertTrue(act.assignments().size() == 0);
486:                        assertTrue(act.nextActivities().size() == 1);
487:                        acts.add("SET1");
488:                        assertTrue(activitiesIncluded(act.nextActivities(),
489:                                acts));
490:                    } else if (act.name().equals("SET1")) {
491:                        assertTrue(act.priority() == 3); // default priority
492:                        assertTrue(act.description() == null);
493:                        assertTrue(act.assignments().size() == 0);
494:                        assertTrue(act.nextActivities().size() == 0);
495:                    } else {
496:                        assertTrue("Invalid activity " + act.name(), false);
497:                    }
498:                }
499:                it = proc3.steps().iterator();
500:                Set step3Keys = new HashSet();
501:                while (it.hasNext()) {
502:                    step3Keys.add(((WrappedActivity) it.next()).key());
503:                }
504:                it = proc3.activitiesInState("open.not_running.not_started")
505:                        .iterator();
506:                Set state3NSKeys = new HashSet();
507:                while (it.hasNext()) {
508:                    state3NSKeys.add(((WrappedActivity) it.next()).key());
509:                }
510:                it = proc3.activitiesInState("open.not_running.not_started")
511:                        .iterator();
512:                Set state3NRKeys = new HashSet();
513:                while (it.hasNext()) {
514:                    state3NRKeys.add(((WrappedActivity) it.next()).key());
515:                }
516:                it = proc2.activitiesInState("open.not_running").iterator();
517:                Set state2Keys = new HashSet();
518:                while (it.hasNext()) {
519:                    state2Keys.add(((WrappedActivity) it.next()).key());
520:                }
521:                // Make sure that all activities are in state 
522:                // "open.not_running.not_started" and differ between process
523:                // instances.
524:                assertTrue(step3Keys.equals(state3NSKeys));
525:                assertTrue(step3Keys.equals(state3NRKeys));
526:                assertTrue(!step3Keys.equals(state2Keys));
527:                assertTrue(proc3
528:                        .activitiesInState("open.not_running.suspended").size() == 0);
529:                assertTrue(proc3.steps().size() == proc3.activitiesInState(
530:                        "open").size());
531:                assertTrue(proc3.activitiesInState("closed").size() == 0);
532:
533:                assertTrue(proc1.workflowState() == WfExecutionObject.State.OPEN);
534:                assertTrue(proc2.workflowState() == WfExecutionObject.State.OPEN);
535:                assertTrue(proc3.workflowState() == WfExecutionObject.State.OPEN);
536:
537:                procDir.removeProcess(proc1.getWfProcess());
538:                procDir.removeProcess(proc2.getWfProcess());
539:                procDir.removeProcess(proc3.getWfProcess());
540:                Util.logExit("testActivities");
541:            }
542:
543:            /**
544:             * Test activitiy information for second block activity
545:             * @exception Exception if an error occurs
546:             */
547:            public void testActivitiesBlock1() throws Exception {
548:                Util.logEntry("testActivitiesBlock1");
549:                ProcessMgr mgr = defDir.processMgr("SystemTest",
550:                        "block_2_in_2_out");
551:                //WfProcess proc = mgr.createProcess(requester);
552:                WrappedProcess proc = new WrappedProcess(mgr
553:                        .createProcess(requester));
554:
555:                // Test activities of process
556:                assertTrue(proc.steps().size() == 9);
557:                Iterator it = proc.steps().iterator();
558:                List acts = new LinkedList();
559:                while (it.hasNext()) {
560:                    WrappedActivity act = (WrappedActivity) it.next();
561:                    acts.clear();
562:                    if (act.name().equals("ACT1")) {
563:                        Util.sleep(15000);
564:                        assertTrue(act.priority() == 1);
565:                        assertTrue(act.description().equals(
566:                                "Activity with dummy implementation"));
567:                        assertTrue(act.assignments().size() == 0);
568:                        assertTrue(act.container().key().equals(proc.key()));
569:                        assertTrue(act.nextActivities().size() == 2);
570:                        acts.add("B1");
571:                        acts.add("B2");
572:                        assertTrue(activitiesIncluded(act.nextActivities(),
573:                                acts));
574:                    } else if (act.name().equals("ACT2")) {
575:                        Util.sleep(15000);
576:                        assertTrue(act.priority() == 2);
577:                        assertTrue(act.description() == null);
578:                        assertTrue(act.assignments().size() == 0);
579:                        assertTrue(act.nextActivities().size() == 2);
580:                        acts.add("B1");
581:                        acts.add("B2");
582:                        assertTrue(activitiesIncluded(act.nextActivities(),
583:                                acts));
584:                    } else if (act.name().equals("ACT3")) {
585:                        assertTrue(act.priority() == 3);
586:                        assertTrue(act.description() == null);
587:                        assertTrue(act.assignments().size() == 0);
588:                        assertTrue(act.nextActivities().size() == 0);
589:                    } else if (act.name().equals("ACT4")) {
590:                        assertTrue(act.priority() == 4);
591:                        assertTrue(act.description() == null);
592:                        assertTrue(act.assignments().size() == 0);
593:                        assertTrue(act.nextActivities().size() == 0);
594:                    } else if (act.name().equals("B0")) {
595:                        assertTrue(act.priority() == 3); // default priority
596:                        assertTrue(act.description() == null);
597:                        assertTrue(act.assignments().size() == 0);
598:                        assertTrue(act.nextActivities().size() == 2);
599:                        acts.add("B3");
600:                        acts.add("B4");
601:                        assertTrue(activitiesIncluded(act.nextActivities(),
602:                                acts));
603:                    } else if (act.name().equals("B1")) {
604:                        assertTrue(act.priority() == 3); // default priority
605:                        assertTrue(act.description() == null);
606:                        assertTrue(act.assignments().size() == 0);
607:                        assertTrue(act.nextActivities().size() == 1);
608:                        acts.add("B0");
609:                        assertTrue(activitiesIncluded(act.nextActivities(),
610:                                acts));
611:                    } else if (act.name().equals("B2")) {
612:                        assertTrue(act.priority() == 3); // default priority
613:                        assertTrue(act.description() == null);
614:                        assertTrue(act.assignments().size() == 0);
615:                        assertTrue(act.nextActivities().size() == 1);
616:                        acts.add("B0");
617:                        assertTrue(activitiesIncluded(act.nextActivities(),
618:                                acts));
619:                    } else if (act.name().equals("B3")) {
620:                        assertTrue(act.priority() == 5);
621:                        assertTrue(act.description() == null);
622:                        assertTrue(act.assignments().size() == 0);
623:                        assertTrue(act.nextActivities().size() == 2);
624:                        acts.add("ACT3");
625:                        acts.add("ACT4");
626:                        assertTrue(activitiesIncluded(act.nextActivities(),
627:                                acts));
628:                    } else if (act.name().equals("B4")) {
629:                        assertTrue(act.priority() == 3); // default priority
630:                        assertTrue(act.description() == null);
631:                        assertTrue(act.assignments().size() == 0);
632:                        assertTrue(act.nextActivities().size() == 2);
633:                        acts.add("ACT3");
634:                        acts.add("ACT4");
635:                        assertTrue(activitiesIncluded(act.nextActivities(),
636:                                acts));
637:                    } else {
638:                        assertTrue("Invalid activity " + act.name(), false);
639:                    }
640:                }
641:                procDir.removeProcess(proc.getWfProcess());
642:                Util.logExit("testActivitiesBlock1");
643:            }
644:
645:            /**
646:             * Test activitiy information for second block activity
647:             * @exception Exception if an error occurs
648:             */
649:            public void testActivitiesBlock2() throws Exception {
650:                Util.logEntry("testActivitiesBlock2");
651:                ProcessMgr mgr = defDir.processMgr("SystemTest",
652:                        "block_diamond");
653:                //	WfProcess proc = mgr.createProcess(requester);
654:                WrappedProcess proc = new WrappedProcess(mgr
655:                        .createProcess(requester));
656:                // Test activities of process
657:                assertTrue(proc.steps().size() == 15);
658:                Iterator it = proc.steps().iterator();
659:                List acts = new LinkedList();
660:                while (it.hasNext()) {
661:                    WrappedActivity act = (WrappedActivity) it.next();
662:                    acts.clear();
663:                    if (act.name().equals("S1A1")) {
664:                        Util.sleep(15000);
665:                        assertTrue(act.nextActivities().size() == 2);
666:                        acts.add("S1A3");
667:                        acts.add("S1A4");
668:                        assertTrue(activitiesIncluded(act.nextActivities(),
669:                                acts));
670:                    } else if (act.name().equals("S1A2")) {
671:                        Util.sleep(15000);
672:                        assertTrue(act.nextActivities().size() == 2);
673:                        acts.add("S1A3");
674:                        acts.add("S1A4");
675:                        assertTrue(activitiesIncluded(act.nextActivities(),
676:                                acts));
677:                    } else if (act.name().equals("S1A3")) {
678:                        assertTrue(act.nextActivities().size() == 3);
679:                        acts.add("S2A1");
680:                        acts.add("S3A1");
681:                        acts.add("S3A2");
682:                        assertTrue(activitiesIncluded(act.nextActivities(),
683:                                acts));
684:                    } else if (act.name().equals("S1A4")) {
685:                        assertTrue(act.nextActivities().size() == 3);
686:                        acts.add("S2A1");
687:                        acts.add("S3A1");
688:                        acts.add("S3A2");
689:                        assertTrue(activitiesIncluded(act.nextActivities(),
690:                                acts));
691:                    } else if (act.name().equals("S2A1")) {
692:                        assertTrue(act.nextActivities().size() == 3);
693:                        acts.add("S2A2");
694:                        acts.add("S2A3");
695:                        acts.add("S2A4");
696:                        assertTrue(activitiesIncluded(act.nextActivities(),
697:                                acts));
698:                    } else if (act.name().equals("S2A2")) {
699:                        assertTrue(act.nextActivities().size() == 3);
700:                        acts.add("S4A1");
701:                        acts.add("S4A2");
702:                        acts.add("S4A3");
703:                        assertTrue(activitiesIncluded(act.nextActivities(),
704:                                acts));
705:                    } else if (act.name().equals("S2A3")) {
706:                        assertTrue(act.nextActivities().size() == 3);
707:                        acts.add("S4A1");
708:                        acts.add("S4A2");
709:                        acts.add("S4A3");
710:                        assertTrue(activitiesIncluded(act.nextActivities(),
711:                                acts));
712:                    } else if (act.name().equals("S2A4")) {
713:                        assertTrue(act.nextActivities().size() == 3);
714:                        acts.add("S4A1");
715:                        acts.add("S4A2");
716:                        acts.add("S4A3");
717:                        assertTrue(activitiesIncluded(act.nextActivities(),
718:                                acts));
719:                    } else if (act.name().equals("S3A1")) {
720:                        assertTrue(act.nextActivities().size() == 1);
721:                        acts.add("S3A3");
722:                        assertTrue(activitiesIncluded(act.nextActivities(),
723:                                acts));
724:                    } else if (act.name().equals("S3A2")) {
725:                        assertTrue(act.nextActivities().size() == 1);
726:                        acts.add("S3A3");
727:                        assertTrue(activitiesIncluded(act.nextActivities(),
728:                                acts));
729:                    } else if (act.name().equals("S3A3")) {
730:                        assertTrue(act.nextActivities().size() == 3);
731:                        acts.add("S4A1");
732:                        acts.add("S4A2");
733:                        acts.add("S4A3");
734:                        assertTrue(activitiesIncluded(act.nextActivities(),
735:                                acts));
736:                    } else if (act.name().equals("S4A1")) {
737:                        assertTrue(act.nextActivities().size() == 1);
738:                        acts.add("S4A4");
739:                        assertTrue(activitiesIncluded(act.nextActivities(),
740:                                acts));
741:                    } else if (act.name().equals("S4A2")) {
742:                        assertTrue(act.nextActivities().size() == 1);
743:                        acts.add("S4A4");
744:                        assertTrue(activitiesIncluded(act.nextActivities(),
745:                                acts));
746:                    } else if (act.name().equals("S4A3")) {
747:                        assertTrue(act.nextActivities().size() == 1);
748:                        acts.add("S4A4");
749:                        assertTrue(activitiesIncluded(act.nextActivities(),
750:                                acts));
751:                    } else if (act.name().equals("S4A4")) {
752:                        assertTrue(act.nextActivities().size() == 0);
753:                    } else {
754:                        assertTrue("Invalid activity " + act.name(), false);
755:                    }
756:                }
757:                procDir.removeProcess(proc.getWfProcess());
758:                Util.logExit("testActivitiesBlock2");
759:            }
760:
761:            /**
762:             * Initialisation.
763:             * The <code>setUp</code> method defines the way a state change is 
764:             * realized. Override this method to change this way.
765:             * @exception Exception if an error occurs
766:             */
767:            protected void setUp() throws Exception {
768:                super .setUp();
769:                WorkflowService wfs = WorkflowServiceFactory.newInstance()
770:                        .newWorkflowService();
771:                try {
772:                    defDir = new WrappedProcessDefinitionDirectory(wfs
773:                            .processDefinitionDirectory());
774:                } catch (RemoteException exc) {
775:                    System.err
776:                            .println("Process definition directory not accessible: "
777:                                    + exc.getMessage());
778:                    System.exit(-1);
779:                }
780:
781:                // Read process definitions
782:                importProcessDefinition("/procdef/full.xml");
783:                importProcessDefinition("/procdef/minimal.xml");
784:                importProcessDefinition("/procdef/blockActivities.xml");
785:                procDir = wfs.processDirectory();
786:                requester = new DefaultRequester(wfs);
787:            }
788:
789:            private static boolean activitiesIncluded(List activities,
790:                    List names) throws Exception {
791:                List acts = new LinkedList();
792:                Iterator it = activities.iterator();
793:                while (it.hasNext()) {
794:                    acts.add(((WrappedActivity) it.next()).name());
795:                }
796:                return acts.containsAll(names) && (acts.size() == names.size());
797:            }
798:
799:            private void importProcessDefinition(String name) throws Exception {
800:                StringBuffer processDefinition = new StringBuffer();
801:                InputStream is = getClass().getResourceAsStream(name);
802:                BufferedReader in = new BufferedReader(new InputStreamReader(
803:                        is, "ISO-8859-1"));
804:                String line = null;
805:                while ((line = in.readLine()) != null) {
806:                    processDefinition.append(line + "\n");
807:                }
808:                try {
809:                    defDir.importProcessDefinitions(processDefinition
810:                            .toString());
811:                } catch (ImportException exc) {
812:                    Iterator msg = exc.messages().iterator();
813:                    while (msg.hasNext()) {
814:                        System.out.println(((PrioritizedMessage) msg.next())
815:                                .message());
816:                    }
817:                }
818:            }
819:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.