Source Code Cross Referenced for ProcData.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:         * This file is part of the WfMOpen project.
003:         * Copyright (C) 2001-2003 Danet GmbH (www.danet.de), GS-AN.
004:         * All rights reserved.
005:         *
006:         * This program is free software; you can redistribute it and/or modify
007:         * it under the terms of the GNU General Public License as published by
008:         * the Free Software Foundation; either version 2 of the License, or
009:         * (at your option) any later version.
010:         *
011:         * This program is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014:         * GNU General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU General Public License
017:         * along with this program; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
019:         * 
020:         * $Id: ProcData.java,v 1.2 2006/09/29 12:32:10 drmlipp Exp $
021:         *
022:         * $Log: ProcData.java,v $
023:         * Revision 1.2  2006/09/29 12:32:10  drmlipp
024:         * Consistently using WfMOpen as projct name now.
025:         *
026:         * Revision 1.1.1.3  2004/08/18 15:18:47  drmlipp
027:         * Update to 1.2
028:         *
029:         * Revision 1.20  2004/02/13 09:01:41  lipp
030:         * Method renamed.
031:         *
032:         * Revision 1.19  2004/02/09 15:15:29  lipp
033:         * Support for looking up processes by the value of a data item.
034:         *
035:         * Revision 1.18  2003/10/21 21:00:45  lipp
036:         * Moved EJBClientTest to new junit sub-package.
037:         *
038:         * Revision 1.17  2003/10/08 11:52:55  huaiyang
039:         * make test weblogic compatible.
040:         *
041:         * Revision 1.16  2003/06/27 09:44:13  lipp
042:         * Fixed copyright/license information.
043:         *
044:         * Revision 1.15  2003/05/14 08:30:07  lipp
045:         * Package import behaviour changed.
046:         *
047:         * Revision 1.14  2003/04/26 16:46:55  lipp
048:         * Made unittests and systemtests coexist in eclipse.
049:         *
050:         * Revision 1.13  2003/04/26 16:12:35  lipp
051:         * Moved some classes to reduce package dependencies.
052:         *
053:         * Revision 1.12  2003/04/16 19:25:04  lipp
054:         * Adapted to jdk 1.4
055:         *
056:         * Revision 1.11  2003/03/31 16:50:29  huaiyang
057:         * Logging using common-logging.
058:         *
059:         * Revision 1.10  2003/02/25 17:08:27  lipp
060:         * Reorganized requester implementation.
061:         *
062:         * Revision 1.9  2003/02/05 15:57:06  lipp
063:         * Replaced DummyRequester with DefaultRequester.
064:         *
065:         * Revision 1.8  2002/10/23 07:29:15  lipp
066:         * Adapted to state handling changes.
067:         *
068:         * Revision 1.7  2002/09/08 18:49:18  lipp
069:         * Proper use of packageId and processId.
070:         *
071:         * Revision 1.6  2002/08/30 13:37:05  lipp
072:         * Using Workflow engine facade now.
073:         *
074:         * Revision 1.5  2002/08/29 12:49:52  lipp
075:         * Fixed lookup.
076:         *
077:         * Revision 1.4  2002/08/21 22:06:48  lipp
078:         * Finished transition to ProcessMgrStub.
079:         *
080:         * Revision 1.3  2002/08/20 07:20:19  lipp
081:         * Extended test.
082:         *
083:         * Revision 1.2  2002/08/19 19:21:06  lipp
084:         * Fixed.
085:         *
086:         * Revision 1.1  2002/08/19 15:29:02  lipp
087:         * New test.
088:         *
089:         */
090:        package process;
091:
092:        import java.util.ArrayList;
093:        import java.util.Collection;
094:        import java.util.Iterator;
095:
096:        import javax.security.auth.login.LoginException;
097:
098:        import de.danet.an.util.junit.EJBClientTest;
099:
100:        import de.danet.an.workflow.omgcore.InvalidDataException;
101:        import de.danet.an.workflow.omgcore.ProcessData;
102:        import de.danet.an.workflow.omgcore.WfProcess;
103:        import de.danet.an.workflow.omgcore.WfRequester;
104:
105:        import de.danet.an.workflow.api.DefaultProcessData;
106:        import de.danet.an.workflow.api.DefaultRequester;
107:        import de.danet.an.workflow.api.FactoryConfigurationError;
108:        import de.danet.an.workflow.api.Process;
109:        import de.danet.an.workflow.api.ProcessDefinitionDirectory;
110:        import de.danet.an.workflow.api.ProcessDirectory;
111:        import de.danet.an.workflow.api.ProcessMgr;
112:        import de.danet.an.workflow.api.WorkflowService;
113:        import de.danet.an.workflow.api.WorkflowServiceFactory;
114:
115:        import common.UTLoginContext;
116:        import junit.framework.Test;
117:        import junit.framework.TestCase;
118:        import junit.framework.TestSuite;
119:
120:        /**
121:         * Test the life cycle of different processes.
122:         */
123:        public class ProcData extends TestCase {
124:            private static UTLoginContext plc = null;
125:            static {
126:                try {
127:                    plc = new UTLoginContext();
128:                    plc.login();
129:                } catch (LoginException e) {
130:                    throw new IllegalStateException(e.getMessage());
131:                }
132:            }
133:
134:            static final org.apache.commons.logging.Log logger = org.apache.commons.logging.LogFactory
135:                    .getLog(ProcData.class);
136:
137:            /**
138:             * Constructor of this TestCase
139:             */
140:            public ProcData(String name) {
141:                super (name);
142:            }
143:
144:            /**
145:             * Stellt diese TestSuite zusammen.
146:             */
147:            public static Test suite() {
148:                TestSuite suite = new TestSuite();
149:                suite.addTest(new ProcData("verifyInit"));
150:                suite.addTest(new ProcData("modifyData"));
151:                suite.addTest(new ProcData("lookupByData"));
152:                return new EJBClientTest(plc, suite);
153:            }
154:
155:            private static WorkflowService wfsCache = null;
156:
157:            private WorkflowService workflowService() {
158:                if (wfsCache == null) {
159:                    try {
160:                        WorkflowServiceFactory wfsf = WorkflowServiceFactory
161:                                .newInstance();
162:                        wfsCache = wfsf.newWorkflowService();
163:                    } catch (FactoryConfigurationError e) {
164:                        throw new IllegalStateException(e.getMessage());
165:                    }
166:                }
167:                return wfsCache;
168:            }
169:
170:            private WfProcess createProcess(String pkgId, String prcId,
171:                    WfRequester req) throws Exception {
172:                ProcessDefinitionDirectory procDir = null;
173:                try {
174:                    procDir = workflowService().processDefinitionDirectory();
175:                    ProcessMgr pmgr = procDir.processMgr(pkgId, prcId);
176:                    return pmgr.createProcess(req);
177:                } finally {
178:                    workflowService().release(procDir);
179:                }
180:            }
181:
182:            /**
183:             * Check initialized data.
184:             */
185:            public void verifyInit() throws Exception {
186:                Basic.importProcessDefinitions("/process/testXPDL.xml");
187:                WfRequester req = new DefaultRequester(workflowService());
188:                // create the process
189:                WfProcess process = createProcess("ut-process", "jut1", req);
190:                ProcessData procData = process.processContext();
191:                assertTrue(procData.containsKey("testValue"));
192:                assertTrue(procData.get("testValue").equals("42"));
193:            }
194:
195:            /**
196:             * Check change data.
197:             */
198:            public void modifyData() throws Exception {
199:                WfRequester req = new DefaultRequester(workflowService());
200:                // create the process
201:                WfProcess process = createProcess("ut-process", "jut1", req);
202:                ProcessData pd = new DefaultProcessData();
203:                pd.put("testValue", "modifiedValue");
204:                process.setProcessContext(pd);
205:                ProcessData procData = process.processContext();
206:                assertTrue(procData.get("testValue").equals("modifiedValue"));
207:                boolean caught = false;
208:                pd.clear();
209:                pd.put("Test key", "42");
210:                try {
211:                    process.setProcessContext(pd);
212:                } catch (InvalidDataException inv) {
213:                    caught = true;
214:                }
215:                assertTrue(caught);
216:            }
217:
218:            /**
219:             * Lookup by data.
220:             */
221:            public void lookupByData() throws Exception {
222:                WfRequester req = new DefaultRequester(workflowService());
223:
224:                // Remove all old processes
225:                ProcessDefinitionDirectory procDefDir = workflowService()
226:                        .processDefinitionDirectory();
227:                ProcessDirectory procDir = workflowService().processDirectory();
228:                ProcessMgr pmgr = procDefDir.processMgr("ut-process",
229:                        "dataItemLookup");
230:                Collection oldProcs = pmgr.processes();
231:                for (Iterator i = oldProcs.iterator(); i.hasNext();) {
232:                    procDir.removeProcess((Process) i.next());
233:                }
234:
235:                // Create some processes, first with null data item
236:                WfProcess null1 = pmgr.createProcess(req);
237:                WfProcess null2 = pmgr.createProcess(req);
238:                null2.start(); // start one to show it makes no difference
239:
240:                // Now with value item
241:                ProcessData pd = new DefaultProcessData();
242:                pd.put("testValue", "Find this");
243:                WfProcess procThis1 = pmgr.createProcess(req);
244:                procThis1.setProcessContext(pd);
245:                WfProcess procThis2 = pmgr.createProcess(req);
246:                procThis2.setProcessContext(pd);
247:                WfProcess procThis3 = pmgr.createProcess(req);
248:                procThis3.setProcessContext(pd);
249:
250:                pd.put("testValue", "Find that");
251:                WfProcess procThat1 = pmgr.createProcess(req);
252:                procThat1.setProcessContext(pd);
253:                WfProcess procThat2 = pmgr.createProcess(req);
254:                procThat2.setProcessContext(pd);
255:
256:                // very long value item
257:                String dummyText = "Streng dem definierten Wesen des Blindtextes "
258:                        + "folgend, fungiere ich als solcher und gebe mich unverbindlich "
259:                        + "inhaltsleer. In bedrückender Enge in vorgefertigte Masken "
260:                        + "gepresst friste ich ein freudloses Dasein auf dem schmalen "
261:                        + "Grat zwischen Nichtbeachtung und Bedeutungslosigkeit und habe "
262:                        + "doch eine Bitte: Handeln Sie Sinn stiftend für meine Existenz "
263:                        + "und lesen Sie mich.";
264:                pd.put("testValue", dummyText);
265:                WfProcess procLong = pmgr.createProcess(req);
266:                procLong.setProcessContext(pd);
267:
268:                // Do tests
269:                Collection c = pmgr.findByDataItem("testValue", null);
270:                assertTrue(c.size() == 2);
271:                c = toKeys(c);
272:                assertTrue(c.contains(null1.key()));
273:                assertTrue(c.contains(null2.key()));
274:
275:                c = pmgr.findByDataItem("testValue", "Find this");
276:                assertTrue(c.size() == 3);
277:                c = toKeys(c);
278:                assertTrue(c.contains(procThis1.key()));
279:                assertTrue(c.contains(procThis2.key()));
280:                assertTrue(c.contains(procThis3.key()));
281:
282:                c = pmgr.findByDataItem("testValue", "Find that");
283:                assertTrue(c.size() == 2);
284:                c = toKeys(c);
285:                assertTrue(c.contains(procThat1.key()));
286:                assertTrue(c.contains(procThat2.key()));
287:
288:                c = pmgr.findByDataItem("testValue", dummyText);
289:                assertTrue(c.size() == 1);
290:                c = toKeys(c);
291:                assertTrue(c.contains(procLong.key()));
292:
293:                // Cleanup
294:                oldProcs = pmgr.processes();
295:                for (Iterator i = oldProcs.iterator(); i.hasNext();) {
296:                    procDir.removeProcess((Process) i.next());
297:                }
298:            }
299:
300:            private Collection toKeys(Collection pc) throws Exception {
301:                Collection res = new ArrayList();
302:                for (Iterator i = pc.iterator(); i.hasNext();) {
303:                    res.add(((Process) i.next()).key());
304:                }
305:                return res;
306:            }
307:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.