Source Code Cross Referenced for TaskTest.java in  » Wiki-Engine » JSPWiki » com » ecyrd » jspwiki » workflow » 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 » Wiki Engine » JSPWiki » com.ecyrd.jspwiki.workflow 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.ecyrd.jspwiki.workflow;
002:
003:        import java.util.Collection;
004:        import java.util.List;
005:
006:        import junit.framework.TestCase;
007:
008:        import com.ecyrd.jspwiki.WikiException;
009:        import com.ecyrd.jspwiki.auth.WikiPrincipal;
010:
011:        public class TaskTest extends TestCase {
012:
013:            Workflow m_workflow;
014:            Task m_task;
015:
016:            /** Sample Task that completes normally. */
017:            public static class NormalTask extends Task {
018:                public NormalTask(Workflow workflow) {
019:                    super (workflow, "task.normal");
020:                }
021:
022:                public Outcome execute() throws WikiException {
023:                    return Outcome.STEP_COMPLETE;
024:                }
025:
026:            }
027:
028:            /** Sample Task that encounters an error during processing. */
029:            public static class ErrorTask extends Task {
030:                public ErrorTask(Workflow workflow) {
031:                    super (workflow, "task.error");
032:                }
033:
034:                public Outcome execute() throws WikiException {
035:                    addError("Found an error.");
036:                    addError("Found a second one!");
037:                    return Outcome.STEP_ABORT;
038:                }
039:
040:            }
041:
042:            protected void setUp() throws Exception {
043:                super .setUp();
044:                m_workflow = new Workflow("workflow.key", new WikiPrincipal(
045:                        "Owner1"));
046:                m_task = new NormalTask(m_workflow);
047:            }
048:
049:            public void testGetActor() {
050:                assertNotSame(new WikiPrincipal("Actor1"), m_task.getActor());
051:                assertEquals(SystemPrincipal.SYSTEM_USER, m_task.getActor());
052:            }
053:
054:            public void testSuccessors() {
055:                // If task finishes normally, branch to a decision (d1)
056:                Step d1 = new SimpleDecision(m_workflow, "decision1.key",
057:                        new WikiPrincipal("Actor1"));
058:                m_task.addSuccessor(Outcome.STEP_COMPLETE, d1);
059:
060:                // If the task aborts, branch to an alternate decision (d2)
061:                Step d2 = new SimpleDecision(m_workflow, "decision2.key",
062:                        new WikiPrincipal("Actor2"));
063:                m_task.addSuccessor(Outcome.STEP_ABORT, d2);
064:
065:                assertEquals(d1, m_task.getSuccessor(Outcome.STEP_COMPLETE));
066:                assertEquals(d2, m_task.getSuccessor(Outcome.STEP_ABORT));
067:
068:                // The other Outcomes should return null when looked up
069:                assertNull(m_task.getSuccessor(Outcome.DECISION_APPROVE));
070:                assertNull(m_task.getSuccessor(Outcome.DECISION_DENY));
071:                assertNull(m_task.getSuccessor(Outcome.DECISION_HOLD));
072:                assertNull(m_task.getSuccessor(Outcome.DECISION_REASSIGN));
073:                assertNull(m_task.getSuccessor(Outcome.STEP_CONTINUE));
074:            }
075:
076:            public void testErrors() {
077:                m_task.addError("Error deciding something.");
078:                m_task.addError("Error deciding something else.");
079:
080:                List errors = m_task.getErrors();
081:                assertEquals(2, errors.size());
082:                assertEquals("Error deciding something.", errors.get(0));
083:                assertEquals("Error deciding something else.", errors.get(1));
084:            }
085:
086:            public void testAvailableOutcomes() {
087:                Collection outcomes = m_task.getAvailableOutcomes();
088:                assertFalse(outcomes.contains(Outcome.DECISION_APPROVE));
089:                assertFalse(outcomes.contains(Outcome.DECISION_DENY));
090:                assertFalse(outcomes.contains(Outcome.DECISION_HOLD));
091:                assertFalse(outcomes.contains(Outcome.DECISION_REASSIGN));
092:                assertTrue(outcomes.contains(Outcome.STEP_ABORT));
093:                assertTrue(outcomes.contains(Outcome.STEP_COMPLETE));
094:            }
095:
096:            public void testGetEndTime() throws WikiException {
097:                assertEquals(Workflow.TIME_NOT_SET, m_task.getEndTime());
098:                m_task.start();
099:                m_task.setOutcome(m_task.execute());
100:                assertTrue((Workflow.TIME_NOT_SET != m_task.getEndTime()));
101:            }
102:
103:            public void testGetMessageKey() {
104:                assertEquals("task.normal", m_task.getMessageKey());
105:            }
106:
107:            public void testGetOutcome() throws WikiException {
108:                assertEquals(Outcome.STEP_CONTINUE, m_task.getOutcome());
109:                m_task.start();
110:                m_task.setOutcome(m_task.execute());
111:                assertEquals(Outcome.STEP_COMPLETE, m_task.getOutcome());
112:
113:                // Test the "error task"
114:                m_task = new ErrorTask(m_workflow);
115:                assertEquals(Outcome.STEP_CONTINUE, m_task.getOutcome());
116:                m_task.start();
117:                m_task.setOutcome(m_task.execute());
118:                assertEquals(Outcome.STEP_ABORT, m_task.getOutcome());
119:            }
120:
121:            public void testGetStartTime() throws WikiException {
122:                assertEquals(Workflow.TIME_NOT_SET, m_task.getStartTime());
123:                m_task.start();
124:                m_task.execute();
125:                assertTrue((Workflow.TIME_NOT_SET != m_task.getStartTime()));
126:            }
127:
128:            public void testGetWorkflow() {
129:                assertEquals(m_workflow, m_task.getWorkflow());
130:            }
131:
132:            public void testIsCompleted() throws WikiException {
133:                assertFalse(m_task.isCompleted());
134:                m_task.start();
135:                m_task.setOutcome(m_task.execute());
136:                assertTrue(m_task.isCompleted());
137:            }
138:
139:            public void testIsStarted() throws WikiException {
140:                assertFalse(m_task.isStarted());
141:                m_task.start();
142:                assertTrue(m_task.isStarted());
143:            }
144:
145:            public void testStartTwice() throws WikiException {
146:                m_task.start();
147:                try {
148:                    m_task.start();
149:                } catch (IllegalStateException e) {
150:                    // Swallow
151:                    return;
152:                }
153:                // We should never get here
154:                fail("Decision allowed itself to be started twice!");
155:            }
156:
157:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.