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


001:        /*
002:         * Danet GmbH
003:         * Beratung und Software-Entwicklung
004:         * Geschäftstelle AN
005:         *
006:         * $Id: Proc.java,v 1.3.2.1 2007/11/02 22:11:45 mlipp Exp $
007:         *
008:         * $Log: Proc.java,v $
009:         * Revision 1.3.2.1  2007/11/02 22:11:45  mlipp
010:         * Merged bug fixes from HEAD.
011:         *
012:         * Revision 1.4  2007/09/21 06:19:35  mlipp
013:         * Fixed problem with NamingException during process deletion.
014:         *
015:         * Revision 1.3  2007/05/03 21:58:24  mlipp
016:         * Internal refactoring for making better use of local EJBs.
017:         *
018:         * Revision 1.2  2007/03/27 21:59:42  mlipp
019:         * Fixed lots of checkstyle warnings.
020:         *
021:         * Revision 1.1.1.1  2003/06/30 20:06:59  drmlipp
022:         * Initial import
023:         *
024:         * Revision 1.43  2003/04/26 16:12:36  lipp
025:         * Moved some classes to reduce package dependencies.
026:         *
027:         * Revision 1.42  2003/03/31 16:50:28  huaiyang
028:         * Logging using common-logging.
029:         *
030:         * Revision 1.41  2002/12/09 10:53:00  lipp
031:         * Updated to abort() modifications.
032:         *
033:         * Revision 1.40  2002/11/26 11:23:29  lipp
034:         * Modified RemoteException comment.
035:         *
036:         * Revision 1.39  2002/11/19 15:14:52  lipp
037:         * New transition manager.
038:         *
039:         * Revision 1.38  2002/11/11 12:20:44  lipp
040:         * Some fixes.
041:         *
042:         * Revision 1.37  2002/11/04 08:40:25  barzik
043:         * adapted to several modifications in the workflow component
044:         *
045:         * Revision 1.36  2002/10/21 11:54:23  lipp
046:         * Better suspend state handling.
047:         *
048:         * Revision 1.35  2002/10/18 13:46:02  lipp
049:         * Getting on with adaptions...
050:         *
051:         * Revision 1.34  2002/10/09 15:17:51  lipp
052:         * Improved start mode handling.
053:         *
054:         * Revision 1.33  2002/10/09 14:27:33  lipp
055:         * Intermediate, compilable state.
056:         *
057:         * Revision 1.32  2002/09/11 14:17:22  lipp
058:         * Execptions using msgs now.
059:         *
060:         * Revision 1.31  2002/08/30 13:37:05  lipp
061:         * Using Workflow engine facade now.
062:         *
063:         * Revision 1.30  2002/08/30 09:06:40  lipp
064:         * Renamed internal state to typed state and use polymorphism for type
065:         * names where possible.
066:         *
067:         * Revision 1.29  2002/08/28 12:58:03  lipp
068:         * Fixed unittests.
069:         *
070:         * Revision 1.28  2002/08/28 12:47:20  lipp
071:         * Starting new process generation.
072:         *
073:         * Revision 1.27  2002/08/22 15:19:34  lipp
074:         * Redesign of EJB persistence.
075:         *
076:         * Revision 1.26  2002/08/21 22:06:48  lipp
077:         * Finished transition to ProcessMgrStub.
078:         *
079:         * Revision 1.25  2002/08/02 09:28:53  huaiyang
080:         * Use JDOM.
081:         *
082:         * Revision 1.24  2002/06/27 10:47:35  lipp
083:         * Adapted to change in return type.
084:         *
085:         * Revision 1.23  2002/05/27 14:55:29  lipp
086:         * Adapted to API changes.
087:         *
088:         * Revision 1.22  2002/02/04 22:43:12  lipp
089:         * Adapted tests to changed.
090:         *
091:         * Revision 1.21  2002/02/04 15:18:55  lipp
092:         * Made ActivityFinderAndKey visible in EJB Remote interface.
093:         *
094:         * Revision 1.20  2002/02/03 21:41:41  lipp
095:         * Cleaned up unittests.
096:         *
097:         * Revision 1.19  2002/01/23 15:42:04  lipp
098:         * Adapted to interface changes.
099:         *
100:         * Revision 1.18  2001/12/18 22:16:53  lipp
101:         * Restructured DOM generation, implemented "assignments" method from ras.
102:         *
103:         * Revision 1.17  2001/12/15 12:47:07  lipp
104:         * Getting an ActivityFinder implemented.
105:         *
106:         * Revision 1.16  2001/12/13 22:11:48  lipp
107:         * Simplified temporary implementation of a requester.
108:         *
109:         * Revision 1.15  2001/12/13 21:00:05  lipp
110:         * Simplified temporary implementation of a requester.
111:         *
112:         * Revision 1.14  2001/12/11 09:54:45  lipp
113:         * Introduced security for workflow.
114:         *
115:         * Revision 1.13  2001/11/07 11:39:00  montag
116:         * changed to internal ejb references
117:         *
118:         * Revision 1.12  2001/10/25 17:15:51  lipp
119:         * Renamed getTransitionsRefs() to getNextActivities() (more appropriate
120:         * name) and added TransitionRefs to DOM representatiosn.
121:         *
122:         * Revision 1.11  2001/10/25 14:36:43  montag
123:         * Obsolete test case removed.
124:         *
125:         * Revision 1.10  2001/10/23 14:07:15  lipp
126:         * Adapted to interface changes.
127:         *
128:         * Revision 1.9  2001/10/09 07:43:51  montag
129:         * BaseElement reactivated
130:         *
131:         * Revision 1.8  2001/10/08 10:58:24  lipp
132:         * Adapted to interface/implementation separation in domain.
133:         *
134:         * Revision 1.7  2001/10/04 08:01:54  montag
135:         * unittests adopt for new transitionmanager
136:         *
137:         * Revision 1.6  2001/09/25 12:12:03  montag
138:         * unittests corrected
139:         *
140:         * Revision 1.5  2001/09/24 13:43:11  montag
141:         * WfProcessPK, WfActivityPK and ContributorPK removed.
142:         *
143:         * Revision 1.4  2001/09/24 12:30:52  montag
144:         * ProcessAttributes removed.
145:         *
146:         * Revision 1.3  2001/09/11 12:30:05  montag
147:         * clean up refresh/dispose due to new db scheme
148:         *
149:         * Revision 1.2  2001/09/10 06:37:19  montag
150:         * notify process not in setInternalState()
151:         *
152:         * Revision 1.1  2001/08/29 10:59:11  lipp
153:         * Tests split in groups.
154:         *
155:         */
156:        package domain;
157:
158:        import java.util.Collection;
159:        import java.util.Iterator;
160:        import java.util.Vector;
161:
162:        import java.rmi.RemoteException;
163:
164:        import de.danet.an.workflow.api.Activity.StartFinishMode;
165:        import de.danet.an.workflow.localapi.ActivityLocal;
166:        import de.danet.an.workflow.localapi.ProcessLocal;
167:        import de.danet.an.workflow.localcoreapi.WfActivityLocal;
168:        import de.danet.an.workflow.omgcore.AlreadySuspendedException;
169:        import de.danet.an.workflow.omgcore.InvalidStateException;
170:        import de.danet.an.workflow.omgcore.TransitionNotAllowedException;
171:        import de.danet.an.workflow.omgcore.WfExecutionObject.State;
172:
173:        import junit.framework.*;
174:
175:        /**
176:         * Zusammenstellung aller domain Tests für (Abstract)Process.
177:         * @author <a href="mailto:lipp@danet.de"></a>
178:         * @version 1.0
179:         */
180:        public class Proc extends TestCase {
181:
182:            private static final org.apache.commons.logging.Log logger = org.apache.commons.logging.LogFactory
183:                    .getLog(Proc.class);
184:
185:            /**
186:             * Konstruktor zum Erzeugen eines TestCase
187:             * @param name a <code>String</code> value
188:             */
189:            public Proc(String name) {
190:                super (name);
191:            }
192:
193:            /**
194:             * Stellt diese TestSuite zusammen.
195:             * @return a <code>Test</code> value
196:             */
197:            public static Test suite() {
198:                TestSuite suite = new TestSuite();
199:                suite.addTest(new Proc("processTest"));
200:                suite.addTest(new Proc("processTest2"));
201:                suite.addTest(new Proc("processTest3"));
202:                suite.addTest(new Proc("processTest4"));
203:                suite.addTest(new Proc("activityTest"));
204:                suite.addTest(new Proc("abortProcess"));
205:                return suite;
206:            }
207:
208:            /**
209:             * Test for Process
210:             * @exception Exception if an error occurs
211:             */
212:            public void processTest() throws Exception {
213:                TestProcess p = getProcess();
214:                assertTrue(p != null);
215:            }
216:
217:            /**
218:             * Test for Activity
219:             * @exception Exception if an error occurs
220:             */
221:            public void activityTest() throws Exception {
222:                TestActivity a = getActivity(null);
223:                assertTrue(a != null);
224:            }
225:
226:            /**
227:             * Test for Process with activity
228:             * @exception Exception if an error occurs
229:             */
230:            public void processTest2() throws Exception {
231:                TestProcess p = getProcess();
232:                assertTrue(p != null);
233:                TestActivity a = getActivity(p);
234:                assertTrue(a != null);
235:                Collection c = new Vector();
236:                c.add(a);
237:                p.setActivities(c);
238:
239:                Collection d = p.stepsLocal();
240:                Iterator it = d.iterator();
241:                while (it.hasNext()) {
242:                    WfActivityLocal wfa = (WfActivityLocal) it.next();
243:                    assertTrue(wfa != null);
244:                }
245:                boolean allClosed = p.allActivitiesClosed();
246:                assertTrue(!allClosed);
247:                p.start();
248:                allClosed = p.allActivitiesClosed();
249:                assertTrue(allClosed);
250:
251:            }
252:
253:            /**
254:             * Test for Process with activities
255:             * @exception Exception if an error occurs
256:             */
257:            public void processTest3() throws Exception {
258:                TestProcess p = getProcess();
259:                assertTrue(p != null);
260:                TestActivity a1 = getActivity(p);
261:                assertTrue(a1 != null);
262:                TestActivity a2 = getActivity(p);
263:                assertTrue(a2 != null);
264:                p.addActivity(a1);
265:                p.addActivity(a2);
266:                p.addTransition("t1", "t1", 0, a1, a2);
267:
268:                Collection d = p.stepsLocal();
269:                Iterator it = d.iterator();
270:                while (it.hasNext()) {
271:                    de.danet.an.workflow.localcoreapi.WfActivityLocal wfa = (de.danet.an.workflow.localcoreapi.WfActivityLocal) it
272:                            .next();
273:                    assertTrue(wfa != null);
274:                }
275:                assertTrue(p.activitiesInState("open").size() == 2);
276:                assertTrue(p.activitiesInState("open.not_running").size() == 2);
277:                assertTrue(p.activitiesInState("open.not_running.not_started")
278:                        .size() == 2);
279:                assertTrue(p.activitiesInState("closed").size() == 0);
280:                boolean allClosed = p.allActivitiesClosed();
281:                assertTrue(!allClosed);
282:                p.start();
283:                allClosed = p.allActivitiesClosed();
284:                assertTrue(allClosed);
285:                assertTrue(p.activitiesInState("open").size() == 0);
286:                assertTrue(p.activitiesInState("closed").size() == 2);
287:            }
288:
289:            /**
290:             * Test for Process with activities and transitions
291:             * @exception Exception if an error occurs
292:             */
293:            public void processTest4() throws Exception {
294:                TestProcess p = getProcess();
295:                assertTrue(p != null);
296:                TestActivity a1 = getActivity(p);
297:                assertTrue(a1 != null);
298:                TestActivity a2 = getActivity(p);
299:                assertTrue(a2 != null);
300:                Collection ca = new Vector();
301:                ca.add(a1);
302:                ca.add(a2);
303:                p.setActivities(ca);
304:            }
305:
306:            /**
307:             * Test for aborting a Process and his activities
308:             * @exception Exception if an error occurs
309:             */
310:            public void abortProcess() throws Exception {
311:                TestProcess p = getProcess();
312:                assertTrue(p != null);
313:                TestActivity a1 = getActivity(p);
314:                assertTrue(a1 != null);
315:                a1.setStartMode(StartFinishMode.MANUAL);
316:                TestActivity a2 = getActivity(p);
317:                assertTrue(a2 != null);
318:                a2.setStartMode(StartFinishMode.MANUAL);
319:                Collection c = new Vector();
320:                p.addActivity(a1);
321:                p.addActivity(a2);
322:                p.addTransition("t1", "t1", 0, a1, a2);
323:                p.start();
324:                assertTrue(a1.state().startsWith("open.not_running.suspended"));
325:                assertTrue(a2.state()
326:                        .startsWith("open.not_running.not_started"));
327:                p.changeState("open.not_running.suspended");
328:                assertTrue(p.state().startsWith("open.not_running.suspended"));
329:                boolean gotIt = false;
330:                try {
331:                    p.suspend();
332:                } catch (AlreadySuspendedException e) {
333:                    gotIt = true;
334:                }
335:                assertTrue(gotIt);
336:                p.resume();
337:                assertTrue(p.state().startsWith("open.running"));
338:                p.suspend();
339:                assertTrue(p.state().startsWith("open.not_running.suspended"));
340:                assertTrue(a1 + " is " + a1.state()
341:                        + " should be open.not_running.suspended", a1.state()
342:                        .startsWith("open.not_running.suspended"));
343:                assertTrue(a2 + " is " + a2.state()
344:                        + " should be open.not_running.not_started", a2.state()
345:                        .startsWith("open.not_running.not_started"));
346:                p.abort();
347:                assertTrue(p + " is " + p.state()
348:                        + ", should be closed.aborted", p.state().equals(
349:                        "closed.aborted"));
350:                assertTrue(a1 + " is " + a1.state()
351:                        + ", should be closed.aborted", a1.state().equals(
352:                        "closed.aborted"));
353:                assertTrue(a2 + " is " + a2.state()
354:                        + ", should be open.not_running.not_started", a2
355:                        .state().startsWith("open.not_running.not_started"));
356:            }
357:
358:            //////////////////////////////////////////////////////////
359:
360:            private TestProcess getProcess() {
361:                return new TestProcess();
362:            }
363:
364:            /**
365:             * Describe class <code>TestProcess</code> here.
366:             *
367:             */
368:            public class TestProcess extends VolatileProcess {
369:                /**
370:                 * Creates a new <code>TestProcess</code> instance.
371:                 *
372:                 */
373:                public TestProcess() {
374:                    super ("p1");
375:                }
376:
377:                /**
378:                 * Checks if all activities of the process are closed.
379:                 * @return <code>true</code>, if all activities of the process
380:                 * are closed; <code>false</code> else.
381:                 * @throws RemoteException if a system-level error occurs.
382:                 */
383:                public boolean allActivitiesClosed() throws RemoteException {
384:                    for (Iterator it = stepsLocal().iterator(); it.hasNext();) {
385:                        ActivityLocal act = (ActivityLocal) it.next();
386:                        if (!act.typedState().isSameOrSubState(State.CLOSED)) {
387:                            return false;
388:                        }
389:                    }
390:                    return true;
391:                }
392:            }
393:
394:            private TestActivity getActivity(TestProcess p) {
395:                return new TestActivity(p);
396:            }
397:
398:            private static int actkeyGen = 1;
399:
400:            /**
401:             * Describe class <code>TestActivity</code> here.
402:             *
403:             */
404:            public class TestActivity extends VolatileActivity {
405:
406:                /**
407:                 * Creates a new <code>TestActivity</code> instance.
408:                 *
409:                 * @param p a <code>Process</code> value
410:                 */
411:                public TestActivity(TestProcess p) {
412:                    super (p, "a" + Integer.toString(actkeyGen++));
413:                }
414:
415:                /**
416:                 * Describe <code>pubSetState</code> method here.
417:                 *
418:                 * @param s a <code>State</code> value
419:                 * @exception InvalidStateException if an error occurs
420:                 */
421:                public void pubSetState(State s) throws InvalidStateException,
422:                        TransitionNotAllowedException {
423:                    changeState(s);
424:                }
425:
426:            }
427:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.