Source Code Cross Referenced for Basic.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:         * Danet GmbH
003:         * Beratung und Software-Entwicklung
004:         * Geschäftstelle AN
005:         *
006:         * $Id: Basic.java,v 1.3 2006/10/13 13:58:32 drmlipp Exp $
007:         *
008:         * $Log: Basic.java,v $
009:         * Revision 1.3  2006/10/13 13:58:32  drmlipp
010:         * Adapted to new environment.
011:         *
012:         * Revision 1.2  2006/10/07 20:41:34  mlipp
013:         * Merged J2EE 1.4 adaptions from test branch.
014:         *
015:         * Revision 1.1.1.3  2004/08/18 15:18:46  drmlipp
016:         * Update to 1.2
017:         *
018:         * Revision 1.22  2004/01/27 11:45:33  lipp
019:         * Preserve newlines when reading process definitions.
020:         *
021:         * Revision 1.21  2003/10/21 21:00:45  lipp
022:         * Moved EJBClientTest to new junit sub-package.
023:         *
024:         * Revision 1.20  2003/10/07 15:55:57  lipp
025:         * Made tests weblogic compatible.
026:         *
027:         * Revision 1.19  2003/05/14 08:30:07  lipp
028:         * Package import behaviour changed.
029:         *
030:         * Revision 1.18  2003/05/09 10:40:16  huaiyang
031:         * test the reading of redefinable header in process.
032:         *
033:         * Revision 1.17  2003/04/26 16:46:55  lipp
034:         * Made unittests and systemtests coexist in eclipse.
035:         *
036:         * Revision 1.16  2003/04/23 14:28:12  lipp
037:         * Improved modelling of header data.
038:         *
039:         * Revision 1.15  2003/04/16 19:25:04  lipp
040:         * Adapted to jdk 1.4
041:         *
042:         * Revision 1.14  2003/04/08 12:31:23  lipp
043:         * Implemented version and category.
044:         *
045:         * Revision 1.13  2003/04/08 11:49:05  lipp
046:         * ResultSignature implemented.
047:         *
048:         * Revision 1.12  2002/11/06 12:15:18  huaiyang
049:         * Add the test of removeClosedProcess.
050:         *
051:         * Revision 1.11  2002/09/08 18:49:18  lipp
052:         * Proper use of packageId and processId.
053:         *
054:         * Revision 1.10  2002/09/04 20:38:44  lipp
055:         * Removed dubious use of id as process definition identifier.
056:         *
057:         * Revision 1.9  2002/09/02 12:26:51  huaiyang
058:         * Use initialProcesses instead of testXPDL.
059:         *
060:         * Revision 1.8  2002/08/30 13:37:05  lipp
061:         * Using Workflow engine facade now.
062:         *
063:         * Revision 1.7  2002/08/28 10:58:45  huaiyang
064:         * Remove the test of importNewProcessDefintions temporarily.
065:         *
066:         * Revision 1.6  2002/08/28 09:24:12  huaiyang
067:         * New method of importNewProcessDefinitions for new procDef spec.
068:         *
069:         * Revision 1.5  2002/08/26 20:23:14  lipp
070:         * Lots of method renames.
071:         *
072:         * Revision 1.4  2002/08/25 18:51:01  lipp
073:         * Extended test case.
074:         *
075:         * Revision 1.3  2002/08/22 08:47:29  lipp
076:         * Some minor optimizations.
077:         *
078:         * Revision 1.2  2002/02/06 20:45:24  lipp
079:         * Test for enabled.
080:         *
081:         * Revision 1.1  2002/02/03 21:41:42  lipp
082:         * Cleaned up unittests.
083:         *
084:         */
085:        package procdef;
086:
087:        import java.io.BufferedReader;
088:        import java.io.InputStream;
089:        import java.io.InputStreamReader;
090:
091:        import java.util.ArrayList;
092:        import java.util.Collection;
093:        import java.util.Iterator;
094:
095:        import javax.naming.InitialContext;
096:        import javax.security.auth.login.LoginException;
097:
098:        import de.danet.an.util.EJBUtil;
099:        import de.danet.an.util.junit.EJBClientTest;
100:
101:        import de.danet.an.workflow.omgcore.ProcessDataInfo;
102:
103:        import de.danet.an.workflow.api.ProcessDefinition;
104:        import de.danet.an.workflow.api.ProcessDefinitionDirectory;
105:        import de.danet.an.workflow.api.WorkflowServiceFactory;
106:
107:        import de.danet.an.workflow.ejbs.admin.ProcessDefinitionDirectoryHome;
108:
109:        import common.UTLoginContext;
110:        import junit.framework.Test;
111:        import junit.framework.TestCase;
112:        import junit.framework.TestSuite;
113:
114:        /**
115:         * Zusammenstellung der Basis-Testfälle für das Prozessdefinitionsverzeichnis.
116:         */
117:        public class Basic extends TestCase {
118:
119:            private static UTLoginContext plc = null;
120:            static {
121:                try {
122:                    plc = new UTLoginContext();
123:                    plc.login();
124:                } catch (LoginException e) {
125:                    throw new IllegalStateException(e.getMessage());
126:                }
127:            }
128:
129:            /**
130:             * Konstruktor zum Erzeugen eines TestCase
131:             */
132:            public Basic(String name) {
133:                super (name);
134:            }
135:
136:            /**
137:             * Stellt diese TestSuite zusammen.
138:             */
139:            public static Test suite() {
140:                TestSuite suite = new TestSuite();
141:                suite.addTest(new Basic("connect"));
142:                suite.addTest(new Basic("importProcessDefinitions"));
143:                suite.addTest(new Basic("listProcessDefinitions"));
144:                suite.addTest(new Basic("disableProcessDefinition"));
145:                suite.addTest(new Basic("removeProcessDefinition"));
146:                suite.addTest(new Basic("getProcessDefinition"));
147:                suite.addTest(new Basic("removeClosedProcess"));
148:                suite.addTest(new Basic("importProcessDefinitions"));
149:                suite.addTest(new Basic("getSignatures"));
150:                suite.addTest(new Basic("redefinableHeader"));
151:                return new EJBClientTest(plc, suite);
152:            }
153:
154:            /**
155:             * Simple test to check the jndi settings 
156:             */
157:            public void connect() throws Exception {
158:                InitialContext ic = new InitialContext();
159:                assertTrue(ic != null);
160:            }
161:
162:            /**
163:             * Import the process definitions from a XPDL file
164:             * unsing the ProcessDefinitionDirectory bean.
165:             */
166:            public void importProcessDefinitions() throws Exception {
167:                importProcessDefinitions("/procdef/initialProcesses.xml");
168:            }
169:
170:            /**
171:             * Returns a list of all defined process definitions
172:             * from the ProcessDefinitionDirectory bean.
173:             */
174:            public void listProcessDefinitions() throws Exception {
175:                ProcessDefinitionDirectory pdd = WorkflowServiceFactory
176:                        .newInstance().newWorkflowService()
177:                        .processDefinitionDirectory();
178:
179:                Collection processDefinitions = pdd.processDefinitions();
180:                assertTrue(processDefinitions.size() > 0);
181:                Collection ids = new ArrayList();
182:                Collection names = new ArrayList();
183:                for (Iterator pdi = processDefinitions.iterator(); pdi
184:                        .hasNext();) {
185:                    ProcessDefinition pd = (ProcessDefinition) pdi.next();
186:                    ids.add(pd.processId());
187:                    names.add(pd.processName());
188:                }
189:                assertTrue(ids.contains("jut1"));
190:                assertTrue(names.contains("JUnit Test Process 1"));
191:                assertTrue(ids.contains("jut2"));
192:                assertTrue(names.contains("JUnit Test Process 2"));
193:                assertTrue(ids.contains("jut3"));
194:                assertTrue(names.contains("JUnit Test Process 3"));
195:                assertTrue(ids.contains("jut4"));
196:                assertTrue(names.contains("JUnit Test Process 4"));
197:                assertTrue(ids.contains("jut5"));
198:                assertTrue(names.contains("JUnit Test Process 5"));
199:                assertTrue(ids.contains("jut6"));
200:                assertTrue(names.contains("JUnit Test Process 6"));
201:                assertTrue(ids.contains("jut7"));
202:                assertTrue(names.contains("JUnit Test Process 7"));
203:            }
204:
205:            /**
206:             * Disable/Enable ProcessDefinitionDirectory.
207:             */
208:            public void disableProcessDefinition() throws Exception {
209:                ProcessDefinitionDirectory pdd = WorkflowServiceFactory
210:                        .newInstance().newWorkflowService()
211:                        .processDefinitionDirectory();
212:
213:                Collection processDefinitions = pdd.processDefinitions();
214:                assertTrue(processDefinitions.size() > 0);
215:                ProcessDefinition pd = (ProcessDefinition) (processDefinitions
216:                        .iterator().next());
217:                assertTrue(pdd.isEnabled(pd.packageId(), pd.processId()));
218:                pdd.setEnabled(pd.packageId(), pd.processId(), false);
219:                assertTrue(!pdd.isEnabled(pd.packageId(), pd.processId()));
220:                pdd.setEnabled(pd.packageId(), pd.processId(), true);
221:                assertTrue(pdd.isEnabled(pd.packageId(), pd.processId()));
222:            }
223:
224:            /**
225:             * Removes a given process definition using the ProcessDirectory bean.
226:             */
227:            public void removeProcessDefinition() throws Exception {
228:                ProcessDefinitionDirectory pdd = WorkflowServiceFactory
229:                        .newInstance().newWorkflowService()
230:                        .processDefinitionDirectory();
231:
232:                ProcessDefinition pd = pdd.lookupProcessDefinition(
233:                        "ut-procdef", "jut1");
234:                assertTrue(pd != null);
235:                pdd.removeProcessDefinition("ut-procdef", "jut1");
236:                boolean gotEx = false;
237:                try {
238:                    pd = pdd.lookupProcessDefinition("ut-procdef", "jut1");
239:                } catch (Exception ex) {
240:                    gotEx = true;
241:                }
242:                assertTrue(gotEx);
243:            }
244:
245:            /**
246:             * Returns a process definition
247:             * from the ProcessDefinitionDirectory bean.
248:             */
249:            public ProcessDefinition getProcessDefinition() throws Exception {
250:                ProcessDefinitionDirectory pdd = WorkflowServiceFactory
251:                        .newInstance().newWorkflowService()
252:                        .processDefinitionDirectory();
253:
254:                ProcessDefinition pd = pdd.lookupProcessDefinition(
255:                        "ut-procdef", "jut2");
256:                assertTrue(pd != null);
257:                boolean gotEx = false;
258:                try {
259:                    pd = pdd.lookupProcessDefinition("ut-procdef",
260:                            "doesn't exist");
261:                } catch (Exception ex) {
262:                    gotEx = true;
263:                }
264:                assertTrue(gotEx);
265:                return pd;
266:            }
267:
268:            public void removeClosedProcess() throws Exception {
269:                ProcessDefinition procDef = getProcessDefinition();
270:                assertTrue(!procDef.removeClosedProcess());
271:            }
272:
273:            /**
274:             * Test the signatures
275:             */
276:            public void getSignatures() throws Exception {
277:                ProcessDefinitionDirectory pdd = WorkflowServiceFactory
278:                        .newInstance().newWorkflowService()
279:                        .processDefinitionDirectory();
280:
281:                ProcessDefinition pd = pdd.lookupProcessDefinition(
282:                        "ut-procdef", "called1");
283:                assertTrue(pd != null);
284:                assertTrue(pd.processHeader().created().equals("07.04.2003"));
285:                assertTrue(pd.processHeader().description().equals("Was tun"));
286:                ProcessDataInfo pdi = pd.resultSignature();
287:                assertTrue(pdi.keySet().size() == 1);
288:                assertTrue(pdi.containsKey("status"));
289:                assertTrue(pdi.get("status") == String.class);
290:            }
291:
292:            /**
293:             * Test if the refinableHeader in the package header and in the process
294:             * header can be parsed correctly.
295:             */
296:            public void redefinableHeader() throws Exception {
297:                importProcessDefinitions("/procdef/testRedefinableHeader.xml");
298:                ProcessDefinitionDirectory pdd = WorkflowServiceFactory
299:                        .newInstance().newWorkflowService()
300:                        .processDefinitionDirectory();
301:                ProcessDefinition pd = pdd.lookupProcessDefinition(
302:                        "ut-procdef", "testRedefinableHeader");
303:                assertTrue(pd.processHeader().author().equals("tester"));
304:                // Redefinable header of version in process overrides the version
305:                // defined in the package redefinable header.
306:                assertTrue(pd.processHeader().version().equals("1.2"));
307:                pdd.removeProcessDefinition("ut-procdef",
308:                        "testRedefinableHeader");
309:            }
310:
311:            public static void importProcessDefinitions(String filename)
312:                    throws Exception {
313:                ProcessDefinitionDirectory pdd = WorkflowServiceFactory
314:                        .newInstance().newWorkflowService()
315:                        .processDefinitionDirectory();
316:                InputStream is = Basic.class.getResourceAsStream(filename);
317:                assertTrue(is != null);
318:                BufferedReader br = new BufferedReader(new InputStreamReader(
319:                        is, "ISO-8859-1"));
320:                StringBuffer sb = new StringBuffer();
321:                String st;
322:                while ((st = br.readLine()) != null) {
323:                    sb.append(st + "\n");
324:                }
325:                pdd.importProcessDefinitions(sb.toString());
326:                Collection processDefinitions = pdd.processDefinitions();
327:                assertTrue(processDefinitions.size() > 0);
328:            }
329:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.