001: /*
002: * Danet GmbH
003: * Beratung und Software-Entwicklung
004: * Geschäftstelle AN
005: *
006: * $Id: ProcDef.java,v 1.3 2007/03/27 21:59:42 mlipp Exp $
007: *
008: * $Log: ProcDef.java,v $
009: * Revision 1.3 2007/03/27 21:59:42 mlipp
010: * Fixed lots of checkstyle warnings.
011: *
012: * Revision 1.2 2007/02/27 14:34:22 drmlipp
013: * Some refactoring to reduce cyclic dependencies.
014: *
015: * Revision 1.1.1.2 2004/08/18 15:18:46 drmlipp
016: * Update to 1.2
017: *
018: * Revision 1.10 2004/01/27 11:45:33 lipp
019: * Preserve newlines when reading process definitions.
020: *
021: * Revision 1.9 2003/06/05 09:00:32 schlue
022: * Changed package name Bootstrap init unittests.
023: *
024: * Revision 1.8 2003/05/06 13:21:31 lipp
025: * Resolved cyclic dependency.
026: *
027: * Revision 1.7 2003/04/25 20:05:32 lipp
028: * Retrieving participants from SAX now.
029: *
030: * Revision 1.6 2003/04/24 20:51:21 lipp
031: * Fixed some warnings.
032: *
033: * Revision 1.5 2003/04/24 15:08:42 lipp
034: * Reading ApplicationDefinitiosn from SAX now.
035: *
036: * Revision 1.4 2003/04/23 14:28:12 lipp
037: * Improved modelling of header data.
038: *
039: * Revision 1.3 2003/04/22 16:38:12 lipp
040: * Retrieving resultSiganture from SAX.
041: *
042: * Revision 1.2 2003/04/22 14:35:35 lipp
043: * Updated.
044: *
045: * Revision 1.1 2003/04/21 21:28:55 lipp
046: * Added test.
047: *
048: */
049: package domain;
050:
051: import java.io.BufferedReader;
052: import java.io.InputStream;
053: import java.io.InputStreamReader;
054:
055: import java.util.Date;
056:
057: import de.danet.an.workflow.api.FormalParameter;
058: import de.danet.an.workflow.api.Participant;
059: import de.danet.an.workflow.api.ProcessDefinition;
060: import de.danet.an.workflow.api.SAXEventBuffer;
061: import de.danet.an.workflow.api.Participant.ParticipantType;
062:
063: import de.danet.an.workflow.domain.ApplicationDefinition;
064: import de.danet.an.workflow.domain.DefaultProcessDefinition;
065:
066: import junit.framework.*;
067:
068: /**
069: * Zusammenstellung aller domain Tests für (Abstract)Process.
070: * @author <a href="mailto:lipp@danet.de"></a>
071: * @version 1.0
072: */
073: public class ProcDef extends TestCase {
074:
075: private static final org.apache.commons.logging.Log logger = org.apache.commons.logging.LogFactory
076: .getLog(ProcDef.class);
077:
078: /**
079: * Konstruktor zum Erzeugen eines TestCase
080: * @param name a <code>String</code> value
081: */
082: public ProcDef(String name) {
083: super (name);
084: }
085:
086: /**
087: * Stellt diese TestSuite zusammen.
088: * @return a <code>Test</code> value
089: */
090: public static Test suite() {
091: TestSuite suite = new TestSuite();
092: suite.addTest(new ProcDef("read"));
093: return suite;
094: }
095:
096: /**
097: * Test for ProcessDefinition
098: * @exception Exception if an error occurs
099: */
100: public void read() throws Exception {
101: InputStream is = getClass().getResourceAsStream(
102: "/domain/testProc.xml");
103: assertTrue(is != null);
104: BufferedReader br = new BufferedReader(new InputStreamReader(
105: is, "ISO-8859-1"));
106: StringBuffer sb = new StringBuffer();
107: String st;
108: while ((st = br.readLine()) != null) {
109: sb.append(st + "\n");
110: }
111: ProcessDefinition pd = new DefaultProcessDefinition(sb
112: .toString());
113: assertTrue(pd.packageId().equals("unittests"));
114: assertTrue(pd.packageName()
115: .equals("Initial workflow processes"));
116: assertTrue(pd.processId().equals("account_neu"));
117: assertTrue(pd.processName().equals("Account anlegen"));
118: assertTrue(pd.processHeader().packageHeader().xpdlVersion()
119: .equals("0.09"));
120: assertTrue(pd.processHeader().packageHeader().vendor().equals(
121: "Danet GmbH, GS AN"));
122: assertTrue(pd.processHeader().packageHeader().created().equals(
123: "Sat Aug 24 15:12:01 CEST 2002"));
124: assertTrue(pd.processHeader().created().equals("01.09.2001"));
125: assertTrue(pd.processHeader().description().equals(
126: "Anlegen eines Accounts"));
127: assertTrue(pd.processHeader().priority().equals("1"));
128:
129: assertTrue(pd.contextSignature().get("packageString") == String.class);
130: assertTrue(pd.contextSignature().get("packageFloat") == Double.class);
131: assertTrue(pd.contextSignature().get("packageInteger") == Long.class);
132: assertTrue(pd.contextSignature().get("packageDateTime") == Date.class);
133: assertTrue(pd.contextSignature().get("packageBoolean") == Boolean.class);
134: assertTrue(pd.contextSignature().get("packageXML") == org.w3c.dom.Element.class);
135: assertTrue((pd.contextSignature().get("packageXMLDefined"))
136: .getClass().toString(), (pd.contextSignature()
137: .get("packageXMLDefined")) instanceof SAXEventBuffer);
138: assertTrue(pd.contextSignature().get("processString") == String.class);
139:
140: assertTrue(pd.resultSignature().get("formalParam1") == null);
141: assertTrue(pd.resultSignature().get("formalParam2") == String.class);
142: assertTrue(pd.resultSignature().get("formalParam3") == String.class);
143:
144: ApplicationDefinition appl = (ApplicationDefinition) pd
145: .applicationById("WebForm");
146: assertTrue(appl != null);
147: assertTrue(
148: appl.description(),
149: appl
150: .description()
151: .equals(
152: "Bearbeitung einer Aktivität über ein Web-Formular "));
153: appl = (ApplicationDefinition) pd
154: .applicationById("WebFormPlus");
155: assertTrue(appl != null);
156: FormalParameter[] fps = appl.formalParameters();
157: assertTrue(fps.length == 2);
158: Participant p = pd.participantById("currentUser");
159: assertTrue(p != null);
160: assertTrue(p.getName().equals("Current User"));
161: assertTrue(p.getParticipantType() == ParticipantType.HUMAN);
162: }
163:
164: }
|