Source code: domain/ProcDef.java
1 /*
2 * Danet GmbH
3 * Beratung und Software-Entwicklung
4 * Geschäftstelle AN
5 *
6 * $Id: ProcDef.java,v 1.9 2003/06/05 09:00:32 schlue Exp $
7 *
8 * $Log: ProcDef.java,v $
9 * Revision 1.9 2003/06/05 09:00:32 schlue
10 * Changed package name Bootstrap init unittests.
11 *
12 * Revision 1.8 2003/05/06 13:21:31 lipp
13 * Resolved cyclic dependency.
14 *
15 * Revision 1.7 2003/04/25 20:05:32 lipp
16 * Retrieving participants from SAX now.
17 *
18 * Revision 1.6 2003/04/24 20:51:21 lipp
19 * Fixed some warnings.
20 *
21 * Revision 1.5 2003/04/24 15:08:42 lipp
22 * Reading ApplicationDefinitiosn from SAX now.
23 *
24 * Revision 1.4 2003/04/23 14:28:12 lipp
25 * Improved modelling of header data.
26 *
27 * Revision 1.3 2003/04/22 16:38:12 lipp
28 * Retrieving resultSiganture from SAX.
29 *
30 * Revision 1.2 2003/04/22 14:35:35 lipp
31 * Updated.
32 *
33 * Revision 1.1 2003/04/21 21:28:55 lipp
34 * Added test.
35 *
36 */
37 package domain;
38
39 import java.io.BufferedReader;
40 import java.io.InputStream;
41 import java.io.InputStreamReader;
42
43 import java.util.Date;
44
45 import de.danet.an.workflow.api.FormalParameter;
46 import de.danet.an.workflow.api.ProcessDefinition;
47 import de.danet.an.workflow.api.SAXEventBuffer;
48
49 import de.danet.an.workflow.domain.ApplicationDefinition;
50 import de.danet.an.workflow.domain.DefaultProcessDefinition;
51
52 import de.danet.an.workflow.spis.ras.Participant;
53 import de.danet.an.workflow.spis.ras.Participant.ParticipantType;
54
55 import junit.framework.*;
56
57 /**
58 * Zusammenstellung aller domain Tests für (Abstract)Process.
59 * @author <a href="mailto:lipp@danet.de"></a>
60 * @version 1.0
61 */
62 public class ProcDef extends TestCase {
63
64 private static final org.apache.commons.logging.Log logger
65 = org.apache.commons.logging.LogFactory.getLog(ProcDef.class);
66
67 /**
68 * Konstruktor zum Erzeugen eines TestCase
69 * @param name a <code>String</code> value
70 */
71 public ProcDef(String name) {
72 super (name);
73 }
74
75 /**
76 * Stellt diese TestSuite zusammen.
77 * @return a <code>Test</code> value
78 */
79 public static Test suite() {
80 TestSuite suite = new TestSuite();
81 suite.addTest(new ProcDef("read"));
82 return suite;
83 }
84
85 /**
86 * Test for ProcessDefinition
87 * @exception Exception if an error occurs
88 */
89 public void read() throws Exception {
90 InputStream is =
91 getClass().getResourceAsStream("/domain/testProc.xml");
92 assertTrue (is != null);
93 BufferedReader br = new BufferedReader
94 (new InputStreamReader(is, "ISO-8859-1"));
95 StringBuffer sb = new StringBuffer();
96 String st;
97 while ((st = br.readLine()) != null) {
98 sb.append(st);
99 }
100 ProcessDefinition pd = new DefaultProcessDefinition (sb.toString());
101 assertTrue (pd.packageId().equals ("unittests"));
102 assertTrue (pd.packageName().equals ("Initial workflow processes"));
103 assertTrue (pd.processId().equals ("account_neu"));
104 assertTrue (pd.processName().equals ("Account anlegen"));
105 assertTrue (pd.processHeader().packageHeader().xpdlVersion().equals ("0.09"));
106 assertTrue (pd.processHeader().packageHeader().vendor().equals ("Danet GmbH, GS AN"));
107 assertTrue (pd.processHeader().packageHeader().created().equals ("Sat Aug 24 15:12:01 CEST 2002"));
108 assertTrue (pd.processHeader().created().equals ("01.09.2001"));
109 assertTrue (pd.processHeader().description().equals ("Anlegen eines Accounts"));
110 assertTrue (pd.processHeader().priority().equals ("1"));
111
112 assertTrue (pd.contextSignature()
113 .get ("packageString") == String.class);
114 assertTrue (pd.contextSignature()
115 .get ("packageFloat") == Double.class);
116 assertTrue (pd.contextSignature()
117 .get ("packageInteger") == Long.class);
118 assertTrue (pd.contextSignature()
119 .get ("packageDateTime") == Date.class);
120 assertTrue (pd.contextSignature()
121 .get ("packageBoolean") == Boolean.class);
122 assertTrue (pd.contextSignature()
123 .get ("packageXML") == org.w3c.dom.Element.class);
124 assertTrue ((pd.contextSignature()
125 .get ("packageXMLDefined")).getClass().toString(),
126 (pd.contextSignature()
127 .get ("packageXMLDefined")) instanceof SAXEventBuffer);
128 assertTrue (pd.contextSignature()
129 .get ("processString") == String.class);
130
131 assertTrue (pd.resultSignature() .get ("formalParam1") == null);
132 assertTrue (pd.resultSignature()
133 .get ("formalParam2") == String.class);
134 assertTrue (pd.resultSignature()
135 .get ("formalParam3") == String.class);
136
137 ApplicationDefinition appl
138 = (ApplicationDefinition)pd.applicationById("WebForm");
139 assertTrue (appl != null);
140 assertTrue (appl.description(), appl.description().equals
141 ("Bearbeitung einer Aktivität über ein Web-Formular "));
142 appl = (ApplicationDefinition)pd.applicationById("WebFormPlus");
143 assertTrue (appl != null);
144 FormalParameter[] fps = appl.formalParameters();
145 assertTrue (fps.length == 2);
146 Participant p = pd.participantById("currentUser");
147 assertTrue (p != null);
148 assertTrue (p.getName().equals("Current User"));
149 assertTrue (p.getParticipantType() == ParticipantType.HUMAN);
150 }
151
152 }
153