/*
* Danet GmbH
* Beratung und Software-Entwicklung
* Gesch�ftstelle AN
*
* $Id: ProcDef.java 2326 2007-03-27 21:59:44Z mlipp $
*
* $Log$
* Revision 1.2 2007/02/27 14:34:22 drmlipp
* Some refactoring to reduce cyclic dependencies.
*
* Revision 1.1.1.2 2004/08/18 15:18:46 drmlipp
* Update to 1.2
*
* Revision 1.10 2004/01/27 11:45:33 lipp
* Preserve newlines when reading process definitions.
*
* Revision 1.9 2003/06/05 09:00:32 schlue
* Changed package name Bootstrap init unittests.
*
* Revision 1.8 2003/05/06 13:21:31 lipp
* Resolved cyclic dependency.
*
* Revision 1.7 2003/04/25 20:05:32 lipp
* Retrieving participants from SAX now.
*
* Revision 1.6 2003/04/24 20:51:21 lipp
* Fixed some warnings.
*
* Revision 1.5 2003/04/24 15:08:42 lipp
* Reading ApplicationDefinitiosn from SAX now.
*
* Revision 1.4 2003/04/23 14:28:12 lipp
* Improved modelling of header data.
*
* Revision 1.3 2003/04/22 16:38:12 lipp
* Retrieving resultSiganture from SAX.
*
* Revision 1.2 2003/04/22 14:35:35 lipp
* Updated.
*
* Revision 1.1 2003/04/21 21:28:55 lipp
* Added test.
*
*/
package domain;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Date;
import de.danet.an.workflow.api.FormalParameter;
import de.danet.an.workflow.api.Participant;
import de.danet.an.workflow.api.ProcessDefinition;
import de.danet.an.workflow.api.SAXEventBuffer;
import de.danet.an.workflow.api.Participant.ParticipantType;
import de.danet.an.workflow.domain.ApplicationDefinition;
import de.danet.an.workflow.domain.DefaultProcessDefinition;
import junit.framework.*;
/**
* Zusammenstellung aller domain Tests f�r (Abstract)Process.
* @author <a href="mailto:lipp@danet.de"></a>
* @version 1.0
*/
public class ProcDef extends TestCase {
private static final org.apache.commons.logging.Log logger
= org.apache.commons.logging.LogFactory.getLog(ProcDef.class);
/**
* Konstruktor zum Erzeugen eines TestCase
* @param name a <code>String</code> value
*/
public ProcDef(String name) {
super (name);
}
/**
* Stellt diese TestSuite zusammen.
* @return a <code>Test</code> value
*/
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(new ProcDef("read"));
return suite;
}
/**
* Test for ProcessDefinition
* @exception Exception if an error occurs
*/
public void read() throws Exception {
InputStream is = getClass().getResourceAsStream("/domain/testProc.xml");
assertTrue (is != null);
BufferedReader br = new BufferedReader
(new InputStreamReader(is, "ISO-8859-1"));
StringBuffer sb = new StringBuffer();
String st;
while ((st = br.readLine()) != null) {
sb.append(st + "\n");
}
ProcessDefinition pd = new DefaultProcessDefinition (sb.toString());
assertTrue (pd.packageId().equals ("unittests"));
assertTrue (pd.packageName().equals ("Initial workflow processes"));
assertTrue (pd.processId().equals ("account_neu"));
assertTrue (pd.processName().equals ("Account anlegen"));
assertTrue (pd.processHeader().packageHeader().xpdlVersion().equals ("0.09"));
assertTrue (pd.processHeader().packageHeader().vendor().equals ("Danet GmbH, GS AN"));
assertTrue (pd.processHeader().packageHeader().created().equals ("Sat Aug 24 15:12:01 CEST 2002"));
assertTrue (pd.processHeader().created().equals ("01.09.2001"));
assertTrue (pd.processHeader().description().equals ("Anlegen eines Accounts"));
assertTrue (pd.processHeader().priority().equals ("1"));
assertTrue (pd.contextSignature()
.get ("packageString") == String.class);
assertTrue (pd.contextSignature()
.get ("packageFloat") == Double.class);
assertTrue (pd.contextSignature()
.get ("packageInteger") == Long.class);
assertTrue (pd.contextSignature()
.get ("packageDateTime") == Date.class);
assertTrue (pd.contextSignature()
.get ("packageBoolean") == Boolean.class);
assertTrue (pd.contextSignature()
.get ("packageXML") == org.w3c.dom.Element.class);
assertTrue ((pd.contextSignature()
.get ("packageXMLDefined")).getClass().toString(),
(pd.contextSignature()
.get ("packageXMLDefined")) instanceof SAXEventBuffer);
assertTrue (pd.contextSignature()
.get ("processString") == String.class);
assertTrue (pd.resultSignature() .get ("formalParam1") == null);
assertTrue (pd.resultSignature()
.get ("formalParam2") == String.class);
assertTrue (pd.resultSignature()
.get ("formalParam3") == String.class);
ApplicationDefinition appl
= (ApplicationDefinition)pd.applicationById("WebForm");
assertTrue (appl != null);
assertTrue (appl.description(), appl.description().equals
("Bearbeitung einer Aktivit�t �ber ein Web-Formular "));
appl = (ApplicationDefinition)pd.applicationById("WebFormPlus");
assertTrue (appl != null);
FormalParameter[] fps = appl.formalParameters();
assertTrue (fps.length == 2);
Participant p = pd.participantById("currentUser");
assertTrue (p != null);
assertTrue (p.getName().equals("Current User"));
assertTrue (p.getParticipantType() == ParticipantType.HUMAN);
}
}