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