Source Code Cross Referenced for DispatcherTest.java in  » Workflow-Engines » bexee » bexee » core » 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 » bexee » bexee.core 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: DispatcherTest.java,v 1.2 2004/12/02 13:58:01 fornp1 Exp $
003:         *
004:         * Copyright (c) 2004 Patric Fornasier, Pawel Kowalski
005:         * Berne University of Applied Sciences
006:         * School of Engineering and Information Technology
007:         * All rights reserved.
008:         */
009:        package bexee.core;
010:
011:        import junit.framework.TestCase;
012:        import bexee.model.process.BPELProcess;
013:        import bexee.model.process.impl.BPELProcessImpl;
014:
015:        /**
016:         * @version $Revision: 1.2 $, $Date: 2004/12/02 13:58:01 $
017:         * @author Patric Fornasier
018:         * @author Pawel Kowalski
019:         */
020:        public class DispatcherTest extends TestCase {
021:
022:            private static final String SYNC_RESULT = "RESULT";
023:
024:            /**
025:             * Test if synchronous dispatching works.
026:             */
027:            public void testDispatchSynchronous() throws Exception {
028:
029:                // create process context
030:                ProcessContext ctx = new ProcessContext();
031:
032:                // create synchronous BPEL process
033:                BPELProcess process = new BPELProcessImpl();
034:                process.setSynchronous(true);
035:
036:                // create mock dispatcher with process context BPEL process
037:                MockDispatcher dispatcher = new MockDispatcher(ctx, process);
038:
039:                // get result
040:                Object result = dispatcher.dispatch();
041:
042:                // check
043:                assertEquals(SYNC_RESULT, result);
044:            }
045:
046:            /**
047:             * Test if asynchronous dispatching works.
048:             */
049:            public void testDispatchAsynchronous() throws Exception {
050:
051:                // create process context
052:                ProcessContext ctx = new ProcessContext();
053:
054:                // create asynchronous BPEL process
055:                BPELProcess process = new BPELProcessImpl();
056:                process.setSynchronous(false);
057:
058:                // create mock dispatcher with process context BPEL process
059:                MockDispatcher dispatcher = new MockDispatcher(ctx, process);
060:
061:                // get result
062:                Object result = dispatcher.dispatch();
063:
064:                // check
065:                assertEquals(Dispatcher.ASYNC_RESULT, result);
066:            }
067:
068:            /**
069:             * Test if <code>Dispatcher</code> throws an exception if no
070:             * <code>BPELProcess</code> was found.
071:             */
072:            public void testDispatchNoBPELProcess() {
073:
074:                // set for clarity
075:                MockDispatcher dispatcher = new MockDispatcher(null, null);
076:
077:                try {
078:                    dispatcher.dispatch();
079:                    fail("Dispatcher should throw an exception if BPELProcess is null");
080:                } catch (DispatcherException e) {
081:                    // nothing to do here
082:                }
083:            }
084:
085:            /**
086:             * Test if <code>Dispatcher</code> throws an exception if no
087:             * <code>ProcessContext</code> was found.
088:             */
089:            public void testDispatchNoProcessContext() {
090:
091:                // set for clarity
092:                MockDispatcher dispatcher = new MockDispatcher(null, null);
093:
094:                try {
095:                    dispatcher.dispatch();
096:                    fail("Dispatcher should throw an exception if ProcessContext is null");
097:                } catch (DispatcherException e) {
098:                    // nothing to do here
099:                }
100:            }
101:
102:            /**
103:             * 
104:             * @version $Revision: 1.2 $, $Date: 2004/12/02 13:58:01 $
105:             * @author Patric Fornasier
106:             * @author Pawel Kowalski
107:             */
108:            private class MockDispatcher extends Dispatcher {
109:
110:                private ProcessContext ctx;
111:
112:                private BPELProcess process;
113:
114:                /**
115:                 * Create a new <code>MockDispatcher</code> object
116:                 * @param ctx the <code>ProcessContext</code>
117:                 * @param process the <code>BPELProcess</code>
118:                 */
119:                public MockDispatcher(ProcessContext ctx, BPELProcess process) {
120:                    super (null);
121:                    instance = new ProcessInstance(process, ctx);
122:                }
123:
124:                /**
125:                 * Do nothing
126:                 */
127:                protected BPELProcess getBPELProcess(BexeeMessage message) {
128:                    return null;
129:                }
130:
131:                /**
132:                 * Do nothing
133:                 */
134:                protected ProcessContext getProcessContext(BexeeMessage message) {
135:                    return null;
136:                }
137:
138:                /**
139:                 * Simulate the synchronous call to the <code>ProcessController</code>
140:                 */
141:                public void run() {
142:
143:                    ProcessContext ctx = instance.getContext();
144:                    BPELProcess process = instance.getProcess();
145:
146:                    if (process.isSynchronous()) {
147:                        ctx.setResult(SYNC_RESULT);
148:                    }
149:                }
150:
151:            }
152:
153:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.