Source Code Cross Referenced for ClusteredProcData.java in  » Workflow-Engines » wfmopen-2.1.1 » procdef » 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 » procdef 
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: ClusteredProcData.java,v 1.3 2007/03/27 21:59:42 mlipp Exp $
021:         *
022:         * $Log: ClusteredProcData.java,v $
023:         * Revision 1.3  2007/03/27 21:59:42  mlipp
024:         * Fixed lots of checkstyle warnings.
025:         *
026:         * Revision 1.2  2006/09/29 12:32:09  drmlipp
027:         * Consistently using WfMOpen as projct name now.
028:         *
029:         * Revision 1.1.1.1  2003/12/19 13:01:44  drmlipp
030:         * Updated to 1.1rc1
031:         *
032:         * Revision 1.1  2003/11/06 15:52:43  huaiyang
033:         * Initial.
034:         *
035:         * Revision 1.11  2003/11/03 13:35:37  huaiyang
036:         * changed based on the supported of null and "" in oracle.
037:         *
038:         * Revision 1.10  2003/11/03 11:31:38  huaiyang
039:         * Fix another error with reading proc data from oracle.
040:         *
041:         * Revision 1.9  2003/11/03 10:03:08  montag
042:         * allow null or empty string for
043:         * packageStringData (due to oracle handling).
044:         *
045:         * Revision 1.8  2003/10/21 21:00:45  lipp
046:         * Moved EJBClientTest to new junit sub-package.
047:         *
048:         * Revision 1.7  2003/10/08 12:39:40  huaiyang
049:         * make test weblogic compatible.
050:         *
051:         * Revision 1.6  2003/06/27 09:44:03  lipp
052:         * Fixed copyright/license information.
053:         *
054:         * Revision 1.5  2003/05/14 09:30:27  schlue
055:         * Package names for minimal and full changed due to modified import behaviour.
056:         *
057:         * Revision 1.4  2003/05/07 09:54:43  schlue
058:         * PR30 fixed.
059:         *
060:         * Revision 1.3  2003/04/26 16:12:22  lipp
061:         * Moved some classes to reduce package dependencies.
062:         *
063:         * Revision 1.2  2003/04/15 14:17:22  schlue
064:         * Cleanup added.
065:         *
066:         * Revision 1.1  2003/04/15 12:57:25  schlue
067:         * Static tests of process and activity (definitions) moved to directory process.
068:         * More test cases for block activities added.
069:         *
070:         * Revision 1.2  2003/04/11 14:39:56  schlue
071:         * System tests for activitites added.
072:         *
073:         * Revision 1.1  2003/04/10 09:44:08  schlue
074:         * Test cases for process data added.
075:         *
076:         *
077:         *
078:         */
079:        package procdef;
080:
081:        import junit.framework.Test;
082:        import junit.framework.TestSuite;
083:
084:        import java.io.BufferedReader;
085:        import java.io.InputStream;
086:        import java.io.InputStreamReader;
087:        import java.rmi.RemoteException;
088:        import java.util.Iterator;
089:
090:        import de.danet.an.util.junit.EJBClientTest;
091:        import de.danet.an.workflow.api.ProcessDefinitionDirectory;
092:        import de.danet.an.workflow.api.ProcessDirectory;
093:        import de.danet.an.workflow.api.WorkflowServiceFactory;
094:        import de.danet.an.workflow.api.WorkflowService;
095:        import de.danet.an.workflow.api.ProcessMgr;
096:        import de.danet.an.workflow.api.DefaultRequester;
097:        import de.danet.an.workflow.api.PrioritizedMessage;
098:        import de.danet.an.workflow.api.ImportException;
099:        import de.danet.an.workflow.api.InvalidKeyException;
100:        import de.danet.an.workflow.omgcore.InvalidDataException;
101:        import de.danet.an.workflow.omgcore.WfActivity;
102:        import de.danet.an.workflow.omgcore.WfProcess;
103:        import de.danet.an.workflow.omgcore.WfRequester;
104:        import de.danet.an.workflow.omgcore.ProcessData;
105:        import de.danet.an.workflow.omgcore.ProcessDataInfo;
106:
107:        import common.Util;
108:
109:        import process.WfMOpenTestCase;
110:
111:        /**
112:         * Test dealing with process data (descriptions).
113:         * Every process description that's needed, is imported here.
114:         * @author <a href="mailto:schlueter@danet.de">Holger Schlueter</a>
115:         * @version 1.0
116:         */
117:        public class ClusteredProcData extends WfMOpenTestCase {
118:            static final org.apache.commons.logging.Log logger = org.apache.commons.logging.LogFactory
119:                    .getLog(ClusteredProcData.class);
120:            /**
121:             * Access to process definition directory (singleton)
122:             */
123:            private ProcessDefinitionDirectory defDir = null;
124:
125:            /**
126:             * Access to process directory (singleton)
127:             */
128:            private ProcessDirectory procDir = null;
129:
130:            /**
131:             * Access to default requester (singleton)
132:             */
133:            private WfRequester requester = null;
134:
135:            /**
136:             * Constructor of this TestCase
137:             * @param name a <code>String</code> value
138:             */
139:            public ClusteredProcData(String name) {
140:                super (name);
141:            }
142:
143:            /**
144:             * Construct this test suite.
145:             * @return a <code>Test</code> value
146:             */
147:            public static Test suite() {
148:                TestSuite suite = new TestSuite();
149:                suite.addTest(new ClusteredProcData("testInfo"));
150:                suite.addTest(new ClusteredProcData("testData"));
151:                suite.addTest(new ClusteredProcData("modifyData"));
152:                suite.addTest(new ClusteredProcData("cleanup"));
153:                return new EJBClientTest(plc, suite);
154:            }
155:
156:            /**
157:             * Test context signature of process description.
158:             * @exception Exception if an error occurs
159:             */
160:            public void testInfo() throws Exception {
161:                Util.logEntry("testInfo");
162:                ProcessMgr mgr = defDir.processMgr("SystemTest_full", "full");
163:                // Test context signature
164:                ProcessDataInfo ctxInfo = mgr.contextSignature();
165:                assertTrue(((Class) ctxInfo.get("packageBooleanData"))
166:                        .isAssignableFrom(Boolean.class));
167:                assertTrue(((Class) ctxInfo.get("testString"))
168:                        .isAssignableFrom(String.class));
169:                assertTrue(((Class) ctxInfo.get("packageIntegerData"))
170:                        .isAssignableFrom(Long.class));
171:                assertTrue(((Class) ctxInfo.get("packageIntegerData"))
172:                        .isAssignableFrom(Long.class));
173:                assertTrue(((Class) ctxInfo.get("packageStringData"))
174:                        .isAssignableFrom(String.class));
175:                //wait to shutdown the processing instance 
176:                Util.sleep(30000);
177:
178:                // Test result signature (all OUT or INOUT parameters)
179:                Iterator res = mgr.resultSignature().values().iterator();
180:                ProcessDataInfo resInfo = mgr.resultSignature();
181:                assertTrue(((Class) resInfo.get("PARAM-InOut-String"))
182:                        .isAssignableFrom(String.class));
183:                assertTrue(((Class) resInfo.get("PARAM-Out-Integer"))
184:                        .isAssignableFrom(Long.class));
185:
186:                mgr = defDir.processMgr("SystemTest_minimal", "minimal");
187:                //wait to shutdown the processing instance 
188:                Util.sleep(30000);
189:                assertTrue(mgr.contextSignature().isEmpty());
190:                assertTrue(mgr.resultSignature().isEmpty());
191:                Util.logExit("testInfo");
192:            }
193:
194:            /**
195:             * Test initial values of process data.
196:             * @exception Exception if an error occurs
197:             */
198:            public void testData() throws Exception {
199:                Util.logEntry("testData");
200:                ProcessMgr mgr = defDir.processMgr("SystemTest_full", "full");
201:                WfProcess proc = mgr.createProcess(requester);
202:                ProcessData data = proc.processContext();
203:                assertTrue(((Boolean) data.get("packageBooleanData"))
204:                        .booleanValue());
205:                assertTrue(((String) data.get("testString")).equals("WfMOpen"));
206:                assertTrue((((String) data.get("packageStringData")) == null));
207:                assertTrue(((Long) data.get("packageIntegerData")).intValue() == 3);
208:
209:                //wait to shutdown the processing instance 
210:                Util.sleep(30000);
211:                // Test access to context info via activity
212:                assertTrue(proc.steps().size() > 0);
213:                WfActivity act = (WfActivity) proc.steps().toArray()[0];
214:                data = act.processContext();
215:                assertTrue(((Boolean) data.get("packageBooleanData"))
216:                        .booleanValue());
217:                assertTrue(((String) data.get("testString")).equals("WfMOpen"));
218:                assertTrue((((String) data.get("packageStringData")) == null)
219:                        || (((String) data.get("packageStringData")).equals("")));
220:                assertTrue(((Long) data.get("packageIntegerData")).intValue() == 3);
221:
222:                procDir.removeProcess(proc);
223:
224:                mgr = defDir.processMgr("SystemTest_minimal", "minimal");
225:                //wait to shutdown the processing instance 
226:                Util.sleep(30000);
227:                proc = mgr.createProcess(requester);
228:                assertTrue(proc.processContext().isEmpty());
229:                procDir.removeProcess(proc);
230:                Util.logExit("testData");
231:            }
232:
233:            /**
234:             * Test modification of process data.
235:             * @exception Exception if an error occurs
236:             */
237:            public void modifyData() throws Exception {
238:                Util.logEntry("modifyData");
239:                ProcessMgr mgr = defDir.processMgr("SystemTest_full", "full");
240:                WfProcess proc = mgr.createProcess(requester);
241:                ProcessData data = proc.processContext();
242:
243:                assertTrue(((Boolean) data.get("packageBooleanData"))
244:                        .booleanValue());
245:                assertTrue(((String) data.get("testString")).equals("WfMOpen"));
246:                assertTrue((((String) data.get("packageStringData")) == null));
247:                assertTrue(((Long) data.get("packageIntegerData")).intValue() == 3);
248:                data.put("", null);
249:                //wait to shutdown the processing instance 
250:                Util.sleep(30000);
251:                // Illegal empty entry
252:                boolean invalidData = false;
253:                try {
254:                    proc.setProcessContext(data);
255:                } catch (InvalidDataException exc) {
256:                    invalidData = true;
257:                }
258:                assertTrue(invalidData);
259:                data.remove("");
260:                data.put("teststring", "illegal");
261:                data.put("packageIntegerData", "5");
262:                // Misspelled teststring and wrong data type for Integer
263:                invalidData = false;
264:                try {
265:                    proc.setProcessContext(data);
266:                } catch (InvalidDataException exc) {
267:                    invalidData = true;
268:                }
269:                data.remove("teststring");
270:                Iterator it = data.keySet().iterator();
271:                // Still wrong data type for Integer
272:                invalidData = false;
273:                try {
274:                    proc.setProcessContext(data);
275:                } catch (InvalidDataException exc) {
276:                    invalidData = true;
277:                }
278:                data.put("packageIntegerData", new Integer("5"));
279:
280:                proc.setProcessContext(data);
281:                ProcessDataInfo ctxInfo = mgr.contextSignature();
282:                // Fetch data to check modifications
283:                data = proc.processContext();
284:                assertTrue(((Long) data.get("packageIntegerData")).intValue() == 5);
285:
286:                procDir.removeProcess(proc);
287:
288:                mgr = defDir.processMgr("SystemTest_minimal", "minimal");
289:                //wait to shutdown the processing instance 
290:                Util.sleep(30000);
291:                proc = mgr.createProcess(requester);
292:                data = proc.processContext();
293:                assertTrue(data.isEmpty());
294:                proc.setProcessContext(data);
295:                data.put("", null);
296:                invalidData = false;
297:                try {
298:                    proc.setProcessContext(data);
299:                } catch (InvalidDataException exc) {
300:                    invalidData = true;
301:                }
302:                assertTrue(invalidData);
303:                data.remove("");
304:                proc.setProcessContext(data);
305:
306:                procDir.removeProcess(proc);
307:                Util.logExit("modifyData");
308:            }
309:
310:            /**
311:             * Remove all imported process definitions.
312:             * @exception Exception if an error occurs
313:             */
314:            public void cleanup() throws Exception {
315:                defDir.removeProcessDefinition("SystemTest_minimal", "minimal");
316:                boolean procdefRemoved = false;
317:                try {
318:                    defDir.processMgr("SystemTest_minimal", "minimal");
319:                } catch (InvalidKeyException exc) {
320:                    procdefRemoved = true;
321:                }
322:                assertTrue(procdefRemoved);
323:                defDir.removeProcessDefinition("SystemTest_full", "full");
324:                procdefRemoved = false;
325:                try {
326:                    defDir.processMgr("SystemTest_full", "full");
327:                } catch (InvalidKeyException exc) {
328:                    procdefRemoved = true;
329:                }
330:                assertTrue(procdefRemoved);
331:            }
332:
333:            /**
334:             * Initialisation.
335:             * The <code>setUp</code> method defines the way a state change is 
336:             * realized. Override this method to change this way.
337:             * @exception Exception if an error occurs
338:             */
339:            protected void setUp() throws Exception {
340:                super .setUp();
341:                WorkflowService wfs = WorkflowServiceFactory.newInstance()
342:                        .newWorkflowService();
343:                try {
344:                    defDir = wfs.processDefinitionDirectory();
345:                } catch (RemoteException exc) {
346:                    System.err
347:                            .println("Process definition directory not accessible: "
348:                                    + exc.getMessage());
349:                    System.exit(-1);
350:                }
351:                // Read process definitions
352:                importProcessDefinition("/procdef/full.xml");
353:                importProcessDefinition("/procdef/minimal.xml");
354:                procDir = wfs.processDirectory();
355:                requester = new DefaultRequester(wfs);
356:            }
357:
358:            private void importProcessDefinition(String name) throws Exception {
359:                StringBuffer processDefinition = new StringBuffer();
360:                InputStream is = getClass().getResourceAsStream(name);
361:                BufferedReader in = new BufferedReader(new InputStreamReader(
362:                        is, "ISO-8859-1"));
363:                String line = null;
364:                while ((line = in.readLine()) != null) {
365:                    processDefinition.append(line + "\n");
366:                }
367:                try {
368:                    defDir.importProcessDefinitions(processDefinition
369:                            .toString());
370:                } catch (ImportException exc) {
371:                    Iterator msg = exc.messages().iterator();
372:                    while (msg.hasNext()) {
373:                        System.out.println(((PrioritizedMessage) msg.next())
374:                                .message());
375:                    }
376:                }
377:            }
378:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.