Source Code Cross Referenced for TurbineAntelopeWorkflowSubProcessTest.java in  » ERP-CRM-Financial » antelope » com » anite » antelope » zebra » helper » 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 » ERP CRM Financial » antelope » com.anite.antelope.zebra.helper 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2004 Anite - Central Government Division
003:         *    http://www.anite.com/publicsector
004:         *
005:         * Licensed under the Apache License, Version 2.0 (the "License");
006:         * you may not use this file except in compliance with the License.
007:         * You may obtain a copy of the License at
008:         *
009:         *    http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:
018:        package com.anite.antelope.zebra.helper;
019:
020:        import java.util.Iterator;
021:
022:        import junit.framework.TestCase;
023:        import net.sf.hibernate.HibernateException;
024:        import net.sf.hibernate.exception.NestableException;
025:
026:        import org.apache.avalon.framework.component.ComponentException;
027:        import org.apache.commons.logging.Log;
028:        import org.apache.commons.logging.LogFactory;
029:
030:        import com.anite.antelope.TurbineTestCase;
031:        import com.anite.antelope.zebra.om.AntelopeProcessInstance;
032:        import com.anite.antelope.zebra.om.AntelopePropertySetEntry;
033:        import com.anite.antelope.zebra.om.AntelopeTaskDefinition;
034:        import com.anite.antelope.zebra.om.AntelopeTaskInstance;
035:        import com.anite.antelope.zebra.om.AntelopeTaskInstanceHistory;
036:        import com.anite.meercat.PersistenceException;
037:        import com.anite.zebra.core.exceptions.TransitionException;
038:
039:        /**
040:         * Run a workflow from End to end
041:         * @author John Rae
042:         */
043:        public class TurbineAntelopeWorkflowSubProcessTest extends TestCase {
044:
045:            private static final String PUSHSUBFLOW = "PushSubflow";
046:            private static Log log = LogFactory
047:                    .getLog(TurbineAntelopeRunWorkflowTest.class);
048:
049:            private static final String RUBBISH = "Rubbish";
050:
051:            private static final String SPURIOUS = "Spurious";
052:
053:            private static final String CHILD_CHANGE_PROPERTIES = "Child Change Properties";
054:
055:            private static final String READ_PROPERTIES = "Child Read Properties";
056:
057:            private static final String INITIALISE_SOME_PROPERTY = "Initialise Some Property";
058:
059:            private static final String CHANGE_PROPERTIES = "Change Properties";
060:
061:            private static final String DO_SOMETHING_ELSE = "Do something else";
062:
063:            private static final String PARENT = "Parent";
064:
065:            private static final String WOBBLE_VALUE = "Wobble Value";
066:
067:            private static final String WOBBLE = "Wobble";
068:
069:            private static final String WIBBLE = "Wibble";
070:
071:            private static final String BOB = "Bob";
072:
073:            private ZebraHelper zebraHelper;
074:
075:            private AntelopeProcessInstance processInstance;
076:
077:            private Iterator taskInstanceIterator;
078:
079:            protected void setUp() throws Exception {
080:
081:                TurbineTestCase.initialiseTurbine();
082:
083:                zebraHelper = ZebraHelper.getInstance();
084:            }
085:
086:            /**
087:             * @throws TransitionException
088:             * @throws ComponentException
089:             * @throws PersistenceException
090:             * @throws HibernateException
091:             * @throws NestableException
092:             * @throws org.apache.commons.lang.exception.NestableException
093:             * 
094:             * This Test tests the Parent-Sub workflow. 
095:             * Wobble and Spurious are set, (Wibble is set with a default value), 
096:             * the flow goes into the subprocess where the values are checked
097:             * Spurious should not be visible here
098:             * Rubbish is created here but should not be visible outside
099:             * Wibble's value is checked and put into Bob
100:             * Wobble is checked and then has "edited" appended
101:             * the subprocess is left
102:             * at the end of the flow spurious is checked to make sure it isn't visible
103:             * Wobble is checked to see that it has been changed
104:             * Bob is checked to see that it contains Wibble's original value
105:             * Wibble is checked to be null
106:             * A value called "Gobbledigook" is checked to be null as it should be
107:             */
108:            public void testRunWorkflowSubProcess() throws TransitionException,
109:                    ComponentException, PersistenceException,
110:                    HibernateException, NestableException,
111:                    org.apache.commons.lang.exception.NestableException {
112:                log.debug("testing workflow Subprocess");
113:                //use parent
114:                //use sub within
115:                AntelopeTaskInstance task;
116:                AntelopePropertySetEntry antelopePropertySetEntry;
117:
118:                processInstance = zebraHelper.createProcessPaused(PARENT);
119:                assertNotNull(processInstance);
120:
121:                //get process instance
122:                zebraHelper.getEngine().startProcess(processInstance);
123:
124:                //check first screen 
125:                task = checkTaskDef(INITIALISE_SOME_PROPERTY);
126:                //set values
127:                processInstance.getPropertySet().put(SPURIOUS,
128:                        new AntelopePropertySetEntry(SPURIOUS));
129:                processInstance.getPropertySet().put(WOBBLE,
130:                        new AntelopePropertySetEntry(WOBBLE_VALUE));
131:                transitionTask(task);
132:
133:                //into subprocess
134:                task = checkTaskDef(READ_PROPERTIES,
135:                        (AntelopeProcessInstance) processInstance
136:                                .getRunningChildProcesses().get(0));
137:                transitionTask(task, (AntelopeProcessInstance) processInstance
138:                        .getRunningChildProcesses().get(0));
139:
140:                //next screen
141:                task = checkTaskDef(CHILD_CHANGE_PROPERTIES,
142:                        (AntelopeProcessInstance) processInstance
143:                                .getRunningChildProcesses().get(0));
144:                //check no Spurious value exists
145:                assertNull(((AntelopeProcessInstance) processInstance
146:                        .getRunningChildProcesses().get(0)).getPropertySet()
147:                        .get(SPURIOUS));
148:                //enter Rubbish value
149:                ((AntelopeProcessInstance) task.getProcessInstance())
150:                        .getPropertySet().put(RUBBISH,
151:                                new AntelopePropertySetEntry(RUBBISH));
152:                assertNotNull(((AntelopeProcessInstance) processInstance
153:                        .getRunningChildProcesses().get(0)).getPropertySet()
154:                        .get(RUBBISH));
155:                //get Wibble's value
156:                antelopePropertySetEntry = (AntelopePropertySetEntry) ((AntelopeProcessInstance) processInstance
157:                        .getRunningChildProcesses().get(0)).getPropertySet()
158:                        .get(WIBBLE);
159:                assertEquals(antelopePropertySetEntry.getValue(), "Moorhen");
160:                // and chuck it in Bob
161:                ((AntelopeProcessInstance) task.getProcessInstance())
162:                        .getPropertySet().put(BOB, antelopePropertySetEntry);
163:                //check Wobble while we're here
164:                antelopePropertySetEntry = (AntelopePropertySetEntry) ((AntelopeProcessInstance) processInstance
165:                        .getRunningChildProcesses().get(0)).getPropertySet()
166:                        .get(WOBBLE);
167:                assertEquals(antelopePropertySetEntry.getValue(), WOBBLE_VALUE);
168:                //then change it (adding edited to it's string value)
169:                AntelopePropertySetEntry newPropSetEntry = new AntelopePropertySetEntry(
170:                        antelopePropertySetEntry.getValue() + "edited");
171:                ((AntelopeProcessInstance) task.getProcessInstance())
172:                        .getPropertySet().put(WOBBLE, newPropSetEntry);
173:                transitionTask(task, (AntelopeProcessInstance) processInstance
174:                        .getRunningChildProcesses().get(0));
175:
176:                //out of subprocess
177:                task = checkTaskDef(DO_SOMETHING_ELSE);
178:                //check that values Bob, Wibble & Spurious  are here, and Rubbish is not
179:                assertEquals(((AntelopePropertySetEntry) processInstance
180:                        .getPropertySet().get(BOB)).getValue(), "Moorhen");
181:                assertEquals(((AntelopePropertySetEntry) processInstance
182:                        .getPropertySet().get(WOBBLE)).getValue(), WOBBLE_VALUE
183:                        + "edited");
184:                assertEquals(((AntelopePropertySetEntry) processInstance
185:                        .getPropertySet().get(SPURIOUS)).getValue(), SPURIOUS);
186:                assertNull(processInstance.getPropertySet().get(RUBBISH));
187:                //Check wibble is gone
188:                assertNull(processInstance.getPropertySet().get(WIBBLE));
189:
190:                //Gobbledigook never mentioned before here
191:                assertNull(processInstance.getPropertySet().get("Gobbledigook"));
192:                transitionTask(task);
193:
194:            }
195:
196:            /**
197:             * @throws TransitionException
198:             * @throws ComponentException
199:             * @throws PersistenceException
200:             * @throws HibernateException
201:             * @throws NestableException
202:             * @throws org.apache.commons.lang.exception.NestableException
203:             * 
204:             * This Test tests the PushSubflow workflow.
205:             * it tests the same things as the test for Parent except it has "push outputs" enabled
206:             * this means that some tests which failed on the Parent test will pass here
207:             *  
208:             * Wobble and Spurious are set, (Wibble is set with a default value), 
209:             * the flow goes into the subprocess where the values are checked
210:             * Spurious should not be visible here
211:             * Rubbish is created here but should not be visible outside
212:             * Wibble's value is checked and put into Bob
213:             * Wobble is checked and then has "edited" appended
214:             * the subprocess is left
215:             * at the end of the flow spurious is checked to make sure it isn't visible
216:             * Wobble is checked to see that it has been changed
217:             * Bob is checked to see that it contains Wibble's original value
218:             * Wibble is checked to be null
219:             * A value called "Gobbledigook" is checked to be null as it should be
220:             */
221:
222:            public void testRunWorkflowPushSubProcess()
223:                    throws TransitionException, ComponentException,
224:                    PersistenceException, HibernateException,
225:                    NestableException,
226:                    org.apache.commons.lang.exception.NestableException {
227:                log.debug("testing workflow Subprocess");
228:                //use parent
229:                //use sub within
230:                AntelopeTaskInstance task;
231:                AntelopePropertySetEntry antelopePropertySetEntry;
232:
233:                processInstance = zebraHelper.createProcessPaused(PUSHSUBFLOW);
234:                assertNotNull(processInstance);
235:
236:                //get process instance
237:                zebraHelper.getEngine().startProcess(processInstance);
238:
239:                //check first screen 
240:                task = checkTaskDef(INITIALISE_SOME_PROPERTY);
241:                //set values
242:                processInstance.getPropertySet().put(SPURIOUS,
243:                        new AntelopePropertySetEntry(SPURIOUS));
244:                processInstance.getPropertySet().put(WOBBLE,
245:                        new AntelopePropertySetEntry(WOBBLE_VALUE));
246:                transitionTask(task);
247:
248:                //into subprocess
249:                task = checkTaskDef(READ_PROPERTIES,
250:                        (AntelopeProcessInstance) processInstance
251:                                .getRunningChildProcesses().get(0));
252:                transitionTask(task, (AntelopeProcessInstance) processInstance
253:                        .getRunningChildProcesses().get(0));
254:
255:                //next screen
256:                task = checkTaskDef(CHILD_CHANGE_PROPERTIES,
257:                        (AntelopeProcessInstance) processInstance
258:                                .getRunningChildProcesses().get(0));
259:                //check no Spurious value exists
260:                assertNull(((AntelopeProcessInstance) processInstance
261:                        .getRunningChildProcesses().get(0)).getPropertySet()
262:                        .get(SPURIOUS));
263:                //enter Rubbish value
264:                ((AntelopeProcessInstance) task.getProcessInstance())
265:                        .getPropertySet().put(RUBBISH,
266:                                new AntelopePropertySetEntry(RUBBISH));
267:                assertNotNull(((AntelopeProcessInstance) processInstance
268:                        .getRunningChildProcesses().get(0)).getPropertySet()
269:                        .get(RUBBISH));
270:                //get Wibble's value
271:                antelopePropertySetEntry = (AntelopePropertySetEntry) ((AntelopeProcessInstance) processInstance
272:                        .getRunningChildProcesses().get(0)).getPropertySet()
273:                        .get(WIBBLE);
274:                assertEquals(antelopePropertySetEntry.getValue(), "Moorhen");
275:                // and chuck it in Bob
276:                ((AntelopeProcessInstance) task.getProcessInstance())
277:                        .getPropertySet().put(BOB, antelopePropertySetEntry);
278:                //check Wobble while we're here
279:                antelopePropertySetEntry = (AntelopePropertySetEntry) ((AntelopeProcessInstance) processInstance
280:                        .getRunningChildProcesses().get(0)).getPropertySet()
281:                        .get(WOBBLE);
282:                assertEquals(antelopePropertySetEntry.getValue(), WOBBLE_VALUE);
283:                //then change it (adding edited to it's string value)
284:                AntelopePropertySetEntry newPropSetEntry = new AntelopePropertySetEntry(
285:                        antelopePropertySetEntry.getValue() + "edited");
286:                ((AntelopeProcessInstance) task.getProcessInstance())
287:                        .getPropertySet().put(WOBBLE, newPropSetEntry);
288:                transitionTask(task, (AntelopeProcessInstance) processInstance
289:                        .getRunningChildProcesses().get(0));
290:
291:                //out of subprocess
292:                task = checkTaskDef(DO_SOMETHING_ELSE);
293:                //check that values Bob, Wibble & Spurious  are here, and Rubbish is not
294:                assertEquals(((AntelopePropertySetEntry) processInstance
295:                        .getPropertySet().get(BOB)).getValue(), "Moorhen");
296:                assertEquals(((AntelopePropertySetEntry) processInstance
297:                        .getPropertySet().get(WOBBLE)).getValue(), WOBBLE_VALUE
298:                        + "edited");
299:                assertEquals(((AntelopePropertySetEntry) processInstance
300:                        .getPropertySet().get(SPURIOUS)).getValue(), SPURIOUS);
301:
302:                //***********these are the only two lines that are different from the check on Parent********************
303:                //***********they show that the Rubbish value and Wibble are still available after the Subprocess********
304:                assertEquals(((AntelopePropertySetEntry) processInstance
305:                        .getPropertySet().get(RUBBISH)).getValue(), RUBBISH);
306:                assertEquals(((AntelopePropertySetEntry) processInstance
307:                        .getPropertySet().get(WIBBLE)).getValue(), "Moorhen");
308:
309:                //Gobbledigook never mentioned before here
310:                assertNull(processInstance.getPropertySet().get("Gobbledigook"));
311:                transitionTask(task);
312:
313:                //use pushSubflow
314:                //use sub
315:
316:            }
317:
318:            /**
319:             * @param task
320:             * @throws TransitionException
321:             * @throws ComponentException
322:             */
323:            private void transitionTask(AntelopeTaskInstance task,
324:                    AntelopeProcessInstance antelopeProcessInstance)
325:                    throws TransitionException, ComponentException {
326:                log.debug("transitioning task");
327:                //goto next task
328:                zebraHelper.getEngine().transitionTask(task);
329:                boolean found = false;
330:                for (Iterator iter = antelopeProcessInstance
331:                        .getHistoryInstances().iterator(); iter.hasNext();) {
332:                    AntelopeTaskInstanceHistory element = (AntelopeTaskInstanceHistory) iter
333:                            .next();
334:                    String elementName = ((AntelopeTaskDefinition) element
335:                            .getTaskDefinition()).getName();
336:                    String taskName = ((AntelopeTaskDefinition) task
337:                            .getTaskDefinition()).getName();
338:                    if (elementName.equals(taskName))
339:                        found = true;
340:                }
341:
342:                assertTrue(found);
343:
344:            }
345:
346:            private void transitionTask(AntelopeTaskInstance task)
347:                    throws TransitionException, ComponentException {
348:                transitionTask(task, processInstance);
349:            }
350:
351:            /**
352:             * @param taskName
353:             * @throws TransitionException
354:             * @throws ComponentException
355:             * 
356:             * tests Task Definitions
357:             */
358:            private AntelopeTaskInstance checkTaskDef(String taskName,
359:                    AntelopeProcessInstance antelopeProcessInstance)
360:                    throws TransitionException, ComponentException {
361:                log.debug("testing task");
362:                //get process
363:                //check correct process
364:                //advance flow
365:                assertEquals(antelopeProcessInstance.getTaskInstances().size(),
366:                        1);
367:                taskInstanceIterator = antelopeProcessInstance
368:                        .getTaskInstances().iterator();
369:                AntelopeTaskInstance task = (AntelopeTaskInstance) taskInstanceIterator
370:                        .next();
371:                assertNotNull(task);
372:                assertEquals(
373:                        ((AntelopeTaskDefinition) task.getTaskDefinition())
374:                                .getName(), taskName);
375:                return task;
376:                //zebraHelper.getEngine().transitionTask(task);//do this externally now
377:            }
378:
379:            private AntelopeTaskInstance checkTaskDef(String taskName)
380:                    throws TransitionException, ComponentException {
381:                return checkTaskDef(taskName, processInstance);
382:            }
383:
384:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.