Source Code Cross Referenced for Req.java in  » Workflow-Engines » wfmopen-2.1.1 » process » 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 » process 
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: Req.java,v 1.2 2007/03/27 21:59:42 mlipp Exp $
007:         *
008:         * $Log: Req.java,v $
009:         * Revision 1.2  2007/03/27 21:59:42  mlipp
010:         * Fixed lots of checkstyle warnings.
011:         *
012:         * Revision 1.1.1.3  2004/08/18 15:18:47  drmlipp
013:         * Update to 1.2
014:         *
015:         * Revision 1.9  2004/01/27 11:45:33  lipp
016:         * Preserve newlines when reading process definitions.
017:         *
018:         * Revision 1.8  2003/10/21 21:00:45  lipp
019:         * Moved EJBClientTest to new junit sub-package.
020:         *
021:         * Revision 1.7  2003/10/08 11:52:55  huaiyang
022:         * make test weblogic compatible.
023:         *
024:         * Revision 1.6  2003/04/26 16:46:55  lipp
025:         * Made unittests and systemtests coexist in eclipse.
026:         *
027:         * Revision 1.5  2003/04/26 16:12:35  lipp
028:         * Moved some classes to reduce package dependencies.
029:         *
030:         * Revision 1.4  2003/04/16 19:25:04  lipp
031:         * Adapted to jdk 1.4
032:         *
033:         * Revision 1.3  2003/02/25 17:08:27  lipp
034:         * Reorganized requester implementation.
035:         *
036:         * Revision 1.2  2003/02/07 15:56:19  lipp
037:         * Implemented Requester notifications.
038:         *
039:         * Revision 1.1  2003/02/06 12:47:47  lipp
040:         * Implemented Requester (no event handling yet).
041:         *
042:         */
043:        package process;
044:
045:        import java.io.BufferedReader;
046:        import java.io.InputStream;
047:        import java.io.InputStreamReader;
048:
049:        import java.util.ArrayList;
050:        import java.util.Collection;
051:        import java.util.HashMap;
052:        import java.util.Iterator;
053:        import java.util.List;
054:        import java.util.Map;
055:
056:        import java.rmi.RemoteException;
057:        import javax.security.auth.login.LoginException;
058:
059:        import de.danet.an.util.EJBUtil;
060:        import de.danet.an.util.junit.EJBClientTest;
061:        import de.danet.an.workflow.omgcore.InvalidPerformerException;
062:        import de.danet.an.workflow.omgcore.WfAuditEvent;
063:        import de.danet.an.workflow.omgcore.WfAuditHandler;
064:        import de.danet.an.workflow.omgcore.WfProcess;
065:        import de.danet.an.workflow.omgcore.WfProcessMgr;
066:        import de.danet.an.workflow.omgcore.WfRequester;
067:
068:        import de.danet.an.workflow.api.DefaultRequester;
069:        import de.danet.an.workflow.api.FactoryConfigurationError;
070:        import de.danet.an.workflow.api.Process;
071:        import de.danet.an.workflow.api.ProcessDefinitionDirectory;
072:        import de.danet.an.workflow.api.WorkflowService;
073:        import de.danet.an.workflow.api.WorkflowServiceFactory;
074:
075:        import common.UTLoginContext;
076:        import junit.framework.*;
077:
078:        /**
079:         * Zusammenstellung aller TimerObjectTests.
080:         */
081:        public class Req extends TestCase {
082:            private static UTLoginContext plc = null;
083:            static {
084:                try {
085:                    plc = new UTLoginContext();
086:                    plc.login();
087:                } catch (LoginException e) {
088:                    throw new IllegalStateException(e.getMessage());
089:                }
090:            }
091:
092:            /**
093:             * Konstruktor zum Erzeugen eines TestCase
094:             */
095:            public Req(String name) {
096:                super (name);
097:            }
098:
099:            /**
100:             * Stellt diese TestSuite zusammen.
101:             */
102:            public static Test suite() {
103:                TestSuite suite = new TestSuite();
104:                suite.addTest(new Req("importProcessDefinitions"));
105:                suite.addTest(new Req("testAssoc"));
106:                return new EJBClientTest(plc, suite);
107:            }
108:
109:            private static WorkflowService wfsCache = null;
110:
111:            private WorkflowService workflowService() {
112:                if (wfsCache == null) {
113:                    try {
114:                        WorkflowServiceFactory wfsf = WorkflowServiceFactory
115:                                .newInstance();
116:                        wfsCache = wfsf.newWorkflowService();
117:                    } catch (FactoryConfigurationError e) {
118:                        throw new IllegalStateException(e.getMessage());
119:                    }
120:                }
121:                return wfsCache;
122:            }
123:
124:            class EventLogger implements  WfAuditHandler {
125:
126:                public List evts = new ArrayList();
127:                public Map evtsByProc = new HashMap();
128:
129:                /**
130:                 * Describe <code>receiveEvent</code> method here.
131:                 *
132:                 * @param wfAuditEvent a <code>WfAuditEvent</code> value
133:                 * @exception InvalidPerformerException if an error occurs
134:                 * @exception RemoteException if an error occurs
135:                 */
136:                public void receiveEvent(WfAuditEvent wfAuditEvent)
137:                        throws InvalidPerformerException, RemoteException {
138:                    evts.add(wfAuditEvent);
139:                    String proc = wfAuditEvent.processKey();
140:                    if (!evtsByProc.containsKey(proc)) {
141:                        evtsByProc.put(proc, new ArrayList());
142:                    }
143:                    ((List) evtsByProc.get(proc)).add(wfAuditEvent);
144:                }
145:            }
146:
147:            /**
148:             * Import the process definitions from a XPDL file
149:             * unsing the ProcessDefinitionDirectory bean.
150:             */
151:            public void importProcessDefinitions() throws Exception {
152:                ProcessDefinitionDirectory pdd = workflowService()
153:                        .processDefinitionDirectory();
154:                InputStream is = getClass().getResourceAsStream(
155:                        "/process/testXPDL.xml");
156:                assertTrue(is != null);
157:                BufferedReader br = new BufferedReader(new InputStreamReader(
158:                        is, "ISO-8859-1"));
159:                StringBuffer sb = new StringBuffer();
160:                String st;
161:                while ((st = br.readLine()) != null) {
162:                    sb.append(st + "\n");
163:                }
164:                pdd.importProcessDefinitions(sb.toString());
165:                Collection processDefinitions = pdd.processDefinitions();
166:                assertTrue(processDefinitions.size() > 0);
167:            }
168:
169:            private WfProcess createProcess(String pkgId, String prcId,
170:                    WfRequester req) throws Exception {
171:                ProcessDefinitionDirectory pdd = workflowService()
172:                        .processDefinitionDirectory();
173:                WfProcessMgr pmgr = pdd.processMgr(pkgId, prcId);
174:                return pmgr.createProcess(req);
175:            }
176:
177:            /**
178:             * Test association of process and requester.
179:             */
180:            public void testAssoc() throws Exception {
181:                EventLogger evtlog1 = new EventLogger();
182:                WfRequester cont1 = new DefaultRequester(workflowService(),
183:                        evtlog1);
184:                Process proc1a = (Process) createProcess("ut-process", "jut1",
185:                        cont1);
186:                assertTrue(proc1a.requester().equals(cont1));
187:                Process proc1b = (Process) createProcess("ut-process", "jut1",
188:                        cont1);
189:                assertTrue(proc1b.requester().equals(cont1));
190:                EventLogger evtlog2 = new EventLogger();
191:                WfRequester cont2 = new DefaultRequester(workflowService(),
192:                        evtlog2);
193:                assertTrue(!cont2.equals(cont1));
194:                Process proc2 = (Process) createProcess("ut-process", "jut1",
195:                        cont2);
196:                assertTrue(proc2.requester().equals(cont2));
197:                Collection c1 = cont1.performers();
198:                assertTrue(c1.size() == 2);
199:                boolean foundA = false;
200:                boolean foundB = false;
201:                for (Iterator i = c1.iterator(); i.hasNext();) {
202:                    Process p = (Process) i.next();
203:                    if (p.key().equals(proc1a.key())) {
204:                        foundA = true;
205:                    }
206:                    if (p.key().equals(proc1b.key())) {
207:                        foundB = true;
208:                    }
209:                }
210:                assertTrue(foundA && foundB);
211:                Thread.sleep(2000);
212:                assertTrue("Have " + evtlog1.evts.size() + " events for "
213:                        + proc1a + " and " + proc1b, evtlog1.evts.size() == 4);
214:                assertTrue("Have events for "
215:                        + evtlog1.evtsByProc.keySet().size() + " processes",
216:                        evtlog1.evtsByProc.keySet().size() == 2);
217:                assertTrue("Have " + evtlog2.evts.size() + " events for "
218:                        + proc2, evtlog2.evts.size() == 2);
219:                assertTrue("Have events for "
220:                        + evtlog2.evtsByProc.keySet().size() + " processes",
221:                        evtlog2.evtsByProc.keySet().size() == 1);
222:            }
223:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.