Package process

Source Code of process.Types

/*
* This file is part of the WfMOpen project.
* Copyright (C) 2001-2004 Danet GmbH (www.danet.de), GS-AN.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*
* $Id: Types.java 1607 2006-09-29 12:32:13Z drmlipp $
*
* $Log$
* Revision 1.1.1.2  2004/08/18 15:18:47  drmlipp
* Update to 1.2
*
* Revision 1.2  2004/01/27 11:45:33  lipp
* Preserve newlines when reading process definitions.
*
* Revision 1.1  2004/01/19 12:30:59  lipp
* SchemaType now supported properly.
*
*/
package process;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;

import java.util.Collection;

import javax.security.auth.login.LoginException;

import de.danet.an.util.junit.EJBClientTest;

import de.danet.an.workflow.omgcore.ProcessDataInfo;
import de.danet.an.workflow.omgcore.WfProcess;
import de.danet.an.workflow.omgcore.WfRequester;

import de.danet.an.workflow.api.ExternalReference;
import de.danet.an.workflow.api.FactoryConfigurationError;
import de.danet.an.workflow.api.ProcessDefinitionDirectory;
import de.danet.an.workflow.api.ProcessDirectory;
import de.danet.an.workflow.api.ProcessMgr;
import de.danet.an.workflow.api.SAXEventBuffer;
import de.danet.an.workflow.api.WorkflowService;
import de.danet.an.workflow.api.WorkflowServiceFactory;

import common.UTLoginContext;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

/**
* Test the life cycle of different processes.
*/
public class Types extends TestCase {
    private static UTLoginContext plc = null;
    static {
  try {
      plc = new UTLoginContext();
      plc.login();
  } catch (LoginException e) {
      throw new IllegalStateException (e.getMessage ());
  }
    }

    /**
     * A process directory reference.
     */
    private ProcessDirectory pdd = null;

    /**
     * Constructor of this TestCase
     */
    public Types(String name) {
  super (name);
    }

    /**
     * Stellt diese TestSuite zusammen.
     */
    public static Test suite() {
        TestSuite suite = new TestSuite();
     suite.addTest(new Types("importProcessDefinitions"));
     suite.addTest(new Types("typeInformation"));
        return new EJBClientTest (plc, suite);
    }

    private WorkflowService workflowService = null;

    /**
     * Initialisierung.
     */
    protected void setUp() throws Exception {
  try {
      WorkflowServiceFactory wfsf
    = WorkflowServiceFactory.newInstance ();
      workflowService = wfsf.newWorkflowService();
  } catch (FactoryConfigurationError e) {
      throw new IllegalStateException (e.getMessage());
  }
    }

    protected void tearDown() throws Exception {
  workflowService.release (workflowService);
  workflowService = null;
    }

    /**
     * Import the process definitions from a XPDL file
     * unsing the ProcessDefinitionDirectory bean.
     */
    public void importProcessDefinitions() throws Exception {
  // Create process definition directory bean
  ProcessDefinitionDirectory pdd
      = workflowService.processDefinitionDirectory();

  InputStream is = getClass().getResourceAsStream("/process/types.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");
  }
  pdd.importProcessDefinitions(sb.toString());
  Collection processDefinitions = pdd.processDefinitions();
  assertTrue (processDefinitions.size() > 0);
 
    }

    private WfProcess createProcess
  (String pkgId, String prcId, WfRequester req)
        throws Exception {
  ProcessDefinitionDirectory procDir = null;
  try {
      procDir = workflowService.processDefinitionDirectory();
      ProcessMgr pmgr = procDir.processMgr(pkgId, prcId);
      return pmgr.createProcess (req);
  } finally {
      workflowService.release (procDir);
  }
    }
 
    /**
     * Test types.
     */
    public void typeInformation() throws Exception {
  ProcessDefinitionDirectory procDir = null;
  try {
      procDir = workflowService.processDefinitionDirectory();
      ProcessMgr pmgr = procDir.processMgr("typestest", "typestest1");
      ProcessDataInfo pdi = pmgr.contextSignature();
      assertTrue (pdi.get("XMLField") instanceof SAXEventBuffer);
      assertTrue (pdi.get("XMLField2") instanceof ExternalReference);
      assertTrue (((ExternalReference)pdi.get("XMLField2"))
      .location().toString()
      .equals ("http://somwhere.unknown"));
      assertTrue (pdi.get("XMLField3").equals(org.w3c.dom.Element.class));
  } finally {
      workflowService.release (procDir);
  }
    }

}
TOP

Related Classes of process.Types

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.