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: ProcHandling.java,v 1.3 2007/03/27 21:59:42 mlipp Exp $
021: *
022: * $Log: ProcHandling.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:13 drmlipp
027: * Consistently using WfMOpen as projct name now.
028: *
029: * Revision 1.1.1.2 2004/08/18 15:18:46 drmlipp
030: * Update to 1.2
031: *
032: * Revision 1.5 2004/01/27 11:45:33 lipp
033: * Preserve newlines when reading process definitions.
034: *
035: * Revision 1.4 2003/10/22 15:26:54 lipp
036: * Added create and start test.
037: *
038: * Revision 1.3 2003/10/22 11:00:58 lipp
039: * Extended.
040: *
041: * Revision 1.2 2003/10/21 21:00:45 lipp
042: * Moved EJBClientTest to new junit sub-package.
043: *
044: * Revision 1.1 2003/10/20 21:04:34 lipp
045: * Getting started.
046: *
047: */
048: package load;
049:
050: import java.io.BufferedReader;
051: import java.io.InputStream;
052: import java.io.InputStreamReader;
053:
054: import javax.security.auth.login.LoginException;
055:
056: import de.danet.an.util.junit.EJBClientTest;
057:
058: import de.danet.an.workflow.omgcore.WfProcess;
059: import de.danet.an.workflow.omgcore.WfRequester;
060:
061: import de.danet.an.workflow.api.DefaultRequester;
062: import de.danet.an.workflow.api.ProcessDefinitionDirectory;
063: import de.danet.an.workflow.api.ProcessMgr;
064: import de.danet.an.workflow.api.WorkflowService;
065: import de.danet.an.workflow.api.WorkflowServiceFactory;
066:
067: import common.UTLoginContext;
068: import junit.framework.Test;
069: import junit.framework.TestCase;
070: import junit.framework.TestSuite;
071:
072: /**
073: * This class provides ...
074: *
075: * @author <a href="mailto:mnl@mnl.de">Michael N. Lipp</a>
076: * @version $Revision: 1.3 $
077: */
078:
079: public class ProcHandling extends TestCase {
080:
081: private static UTLoginContext plc = null;
082: static {
083: try {
084: plc = new UTLoginContext();
085: plc.login();
086: } catch (LoginException e) {
087: throw new IllegalStateException(e.getMessage());
088: }
089: }
090:
091: private static ProcessDefinitionDirectory pdd = null;
092: private static ProcessMgr mgr1To5par = null;
093: private static ProcessMgr mgr1To10par = null;
094: private static ProcessMgr mgr1To20par = null;
095: private static WfRequester defReq = null;
096:
097: /**
098: * Constructor of this TestCase
099: */
100: public ProcHandling(String name) {
101: super (name);
102: }
103:
104: /**
105: * Make this test suite.
106: */
107: public static Test suite() {
108: TestSuite suite = new TestSuite();
109: suite.addTest(new ProcHandling("importProcessDefinitions"));
110: suite.addTest(new ProcHandling("createProcess6Acts"));
111: suite.addTest(new ProcHandling("createProcess11Acts"));
112: suite.addTest(new ProcHandling("createProcess21Acts"));
113: return new EJBClientTest(plc, suite);
114: }
115:
116: /**
117: * Import the process definitions from a XPDL file
118: * unsing the ProcessDefinitionDirectory bean.
119: */
120: public void importProcessDefinitions() throws Exception {
121: WorkflowServiceFactory wsf = WorkflowServiceFactory
122: .newInstance();
123: WorkflowService ws = wsf.newWorkflowService();
124: pdd = ws.processDefinitionDirectory();
125: InputStream is = getClass().getResourceAsStream(
126: "/load/processes.xml");
127: assertTrue(is != null);
128: BufferedReader br = new BufferedReader(new InputStreamReader(
129: is, "ISO-8859-1"));
130: StringBuffer sb = new StringBuffer();
131: String st;
132: while ((st = br.readLine()) != null) {
133: sb.append(st + "\n");
134: }
135: pdd.importProcessDefinitions(sb.toString());
136: mgr1To5par = pdd.processMgr("loadUnitTests", "1plus5actsPar");
137: mgr1To10par = pdd.processMgr("loadUnitTests", "1plus10actsPar");
138: mgr1To20par = pdd.processMgr("loadUnitTests", "1plus20actsPar");
139: defReq = new DefaultRequester(ws);
140: }
141:
142: public void createProcess6Acts() throws Exception {
143: WfProcess p = mgr1To5par.createProcess(defReq);
144: }
145:
146: public void createProcess11Acts() throws Exception {
147: WfProcess p = mgr1To10par.createProcess(defReq);
148: }
149:
150: public void createProcess21Acts() throws Exception {
151: WfProcess p = mgr1To20par.createProcess(defReq);
152: }
153:
154: public void createStart11Acts() throws Exception {
155: WfProcess p = mgr1To10par.createProcess(defReq);
156: p.start();
157: }
158:
159: }
|