Source Code Cross Referenced for States.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: States.java,v 1.1.1.1 2003/06/30 20:06:59 drmlipp Exp $
007:         *
008:         * $Log: States.java,v $
009:         * Revision 1.1.1.1  2003/06/30 20:06:59  drmlipp
010:         * Initial import
011:         *
012:         * Revision 1.22  2003/06/05 17:26:58  lipp
013:         * Extended error message.
014:         *
015:         * Revision 1.21  2003/04/26 16:12:35  lipp
016:         * Moved some classes to reduce package dependencies.
017:         *
018:         * Revision 1.20  2002/11/11 12:20:44  lipp
019:         * Some fixes.
020:         *
021:         * Revision 1.19  2002/10/21 19:08:05  lipp
022:         * Continuing implementation of new state handling.
023:         *
024:         * Revision 1.18  2002/10/21 16:59:55  lipp
025:         * More fixes.
026:         *
027:         * Revision 1.17  2002/10/21 16:24:24  lipp
028:         * Added state compatibility test.
029:         *
030:         * Revision 1.16  2002/10/21 13:48:03  lipp
031:         * Continuing implementation of new state handling.
032:         *
033:         * Revision 1.15  2002/10/21 11:54:23  lipp
034:         * Better suspend state handling.
035:         *
036:         * Revision 1.14  2002/10/09 14:27:33  lipp
037:         * Intermediate, compilable state.
038:         *
039:         * Revision 1.13  2002/08/30 13:37:05  lipp
040:         * Using Workflow engine facade now.
041:         *
042:         * Revision 1.12  2002/08/22 15:19:34  lipp
043:         * Redesign of EJB persistence.
044:         *
045:         * Revision 1.11  2002/08/21 22:06:48  lipp
046:         * Finished transition to ProcessMgrStub.
047:         *
048:         * Revision 1.10  2002/08/02 09:28:53  huaiyang
049:         * Use JDOM.
050:         *
051:         * Revision 1.9  2002/02/04 22:43:12  lipp
052:         * Adapted tests to changed.
053:         *
054:         * Revision 1.8  2002/01/23 15:42:04  lipp
055:         * Adapted to interface changes.
056:         *
057:         * Revision 1.7  2001/12/13 21:00:05  lipp
058:         * Simplified temporary implementation of a requester.
059:         *
060:         * Revision 1.6  2001/10/08 10:58:24  lipp
061:         * Adapted to interface/implementation separation in domain.
062:         *
063:         * Revision 1.5  2001/09/26 13:52:46  montag
064:         * *** empty log message ***
065:         *
066:         * Revision 1.4  2001/09/25 12:12:03  montag
067:         * unittests corrected
068:         *
069:         * Revision 1.3  2001/09/24 13:54:15  montag
070:         * WfProcessPK, WfActivityPK and ContributorPK removed.
071:         *
072:         * Revision 1.2  2001/09/07 11:47:49  montag
073:         * new substates for open.not_running.suspended
074:         *
075:         * Revision 1.1  2001/08/29 10:59:11  lipp
076:         * Tests split in groups.
077:         *
078:         */
079:        package domain;
080:
081:        import de.danet.an.workflow.omgcore.NotRunningException;
082:        import de.danet.an.workflow.omgcore.TransitionNotAllowedException;
083:        import de.danet.an.workflow.omgcore.WfExecutionObject;
084:
085:        import de.danet.an.workflow.api.Activity.StartFinishMode;
086:
087:        import de.danet.an.workflow.domain.AbstractExecutionObject;
088:
089:        import junit.framework.Test;
090:        import junit.framework.TestCase;
091:        import junit.framework.TestSuite;
092:
093:        /**
094:         * Zusammenstellung aller TimerObjectTests.
095:         * @author <a href="mailto:lipp@danet.de"></a>
096:         * @version 1.0
097:         */
098:        public class States extends TestCase {
099:
100:            /**
101:             * Konstruktor zum Erzeugen eines TestCase
102:             * @param name a <code>String</code> value
103:             */
104:            public States(String name) {
105:                super (name);
106:            }
107:
108:            /**
109:             * Stellt diese TestSuite zusammen.
110:             * @return a <code>Test</code> value
111:             */
112:            public static Test suite() {
113:                TestSuite suite = new TestSuite();
114:                suite.addTest(new States("availableStates"));
115:                suite.addTest(new States("executionState"));
116:                suite.addTest(new States("availableModes"));
117:                return suite;
118:            }
119:
120:            /**
121:             * Check if state machine for 1for avaiable states of the 1. iteration.
122:             * @exception Exception if an error occurs
123:             */
124:            public void availableStates() throws Exception {
125:                WfExecutionObject.State[] states = new WfExecutionObject.State[11];
126:                states[0] = WfExecutionObject.State.fromString("open");
127:                assertTrue(states[0] != null);
128:                states[1] = WfExecutionObject.State.fromString("closed");
129:                assertTrue(states[1] != null);
130:                states[2] = WfExecutionObject.State.fromString("open.running");
131:                assertTrue(states[2] != null);
132:                states[3] = WfExecutionObject.State
133:                        .fromString("open.not_running");
134:                assertTrue(states[3] != null);
135:                states[4] = WfExecutionObject.State
136:                        .fromString("open.not_running.not_started");
137:                assertTrue(states[4] != null);
138:                states[5] = WfExecutionObject.State
139:                        .fromString("open.not_running.suspended");
140:                assertTrue(states[5] != null);
141:                states[6] = WfExecutionObject.State
142:                        .fromString("closed.completed");
143:                assertTrue(states[6] != null);
144:                states[7] = WfExecutionObject.State
145:                        .fromString("closed.aborted");
146:                assertTrue(states[7] != null);
147:                states[8] = WfExecutionObject.State
148:                        .fromString("closed.terminated");
149:                assertTrue(states[8] != null);
150:                WfExecutionObject.State s = AbstractExecutionObject.RunningState.RUNNING;
151:                s = AbstractExecutionObject.SuspendedState.SUSPENDED;
152:                states[9] = WfExecutionObject.State
153:                        .fromString("open.not_running.suspended.aborting");
154:                assertTrue(states[9] != null);
155:                states[10] = WfExecutionObject.State
156:                        .fromString("open.running.terminating");
157:                assertTrue(states[10] != null);
158:
159:                for (int i = 0; i < 11; i++) {
160:                    for (int j = 0; j < 11; j++) {
161:                        if (states[i].toString().equals(states[j].toString())
162:                                || (states[i].toString().startsWith(states[j]
163:                                        .toString()
164:                                        + "."))) {
165:                            assertTrue(states[i]
166:                                    + " should be same or have substate "
167:                                    + states[j], states[i]
168:                                    .isSameOrSubState(states[j]));
169:                        } else {
170:                            assertTrue(states[i]
171:                                    + " should not be same or have substate "
172:                                    + states[j], !states[i]
173:                                    .isSameOrSubState(states[j]));
174:                        }
175:                    }
176:                }
177:            }
178:
179:            /**
180:             * Check if state machine for 1. iteration works.
181:             * @exception Exception if an error occurs
182:             */
183:            public void executionState() throws Exception {
184:                VolatileProcess aeo = new VolatileProcess();
185:                VolatileActivity act = new VolatileActivity(aeo);
186:                aeo.addActivity(act);
187:                act.setStartMode(StartFinishMode.MANUAL);
188:                assertTrue(aeo.state().equals("open.not_running.not_started"));
189:                assertTrue(aeo.workflowState().equals(
190:                        WfExecutionObject.State.OPEN));
191:                assertTrue(aeo.whileOpen().equals(
192:                        WfExecutionObject.OpenState.NOT_RUNNING));
193:                assertTrue(aeo.whyNotRunning().equals(
194:                        WfExecutionObject.NotRunningState.NOT_STARTED));
195:                boolean exceptionCaught = false;
196:                try {
197:                    aeo.howClosed();
198:                } catch (IllegalStateException is) {
199:                    exceptionCaught = true;
200:                }
201:                assertTrue(exceptionCaught);
202:                // change to illegal state
203:                exceptionCaught = false;
204:                try {
205:                    aeo.changeState(WfExecutionObject.ClosedState.COMPLETED
206:                            .toString());
207:                } catch (TransitionNotAllowedException ie) {
208:                    exceptionCaught = true;
209:                }
210:                assertTrue(exceptionCaught);
211:                // change to illegal state
212:                exceptionCaught = false;
213:                try {
214:                    aeo.suspend();
215:                } catch (NotRunningException ce) {
216:                    exceptionCaught = true;
217:                }
218:                assertTrue(exceptionCaught);
219:
220:                // legal change
221:                aeo.changeState(WfExecutionObject.OpenState.RUNNING.toString());
222:                // change to illegal transition
223:                exceptionCaught = false;
224:                try {
225:                    aeo
226:                            .changeState(WfExecutionObject.NotRunningState.NOT_STARTED
227:                                    .toString());
228:                } catch (TransitionNotAllowedException te) {
229:                    exceptionCaught = true;
230:                }
231:                assertTrue(exceptionCaught);
232:                // finally abort
233:                aeo.suspend();
234:                aeo.abort();
235:                assertTrue(aeo.state().equals("closed.aborted"));
236:                assertTrue(aeo.workflowState().equals(
237:                        WfExecutionObject.State.CLOSED));
238:                exceptionCaught = false;
239:                try {
240:                    aeo.whileOpen();
241:                } catch (IllegalStateException is2) {
242:                    exceptionCaught = true;
243:                }
244:                assertTrue(exceptionCaught);
245:                exceptionCaught = false;
246:                try {
247:                    aeo.whyNotRunning();
248:                } catch (IllegalStateException is3) {
249:                    exceptionCaught = true;
250:                }
251:                assertTrue(exceptionCaught);
252:                assertTrue(aeo.howClosed().equals(
253:                        WfExecutionObject.ClosedState.ABORTED));
254:            }
255:
256:            /**
257:             * Check if state machine for 1for avaiable states of the 1. iteration.
258:             * @exception Exception if an error occurs
259:             */
260:            public void availableModes() throws Exception {
261:                StartFinishMode[] modes = new StartFinishMode[3];
262:                modes[0] = StartFinishMode.fromString("Manual");
263:                assertTrue(modes[0] == StartFinishMode.MANUAL);
264:                modes[1] = StartFinishMode.fromString("Automatic");
265:                assertTrue(modes[1] == StartFinishMode.AUTOMATIC);
266:            }
267:
268:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.