Package process

Source Code of process.ProcDir

/*
* Danet GmbH
* Beratung und Software-Entwicklung
* Gesch�ftstelle AN
*
* $Id: ProcDir.java 2900 2009-01-22 23:01:54Z mlipp $
*
* $Log$
* Revision 1.2  2006/10/07 20:41:34  mlipp
* Merged J2EE 1.4 adaptions from test branch.
*
* Revision 1.1.1.2  2003/12/19 13:01:48  drmlipp
* Updated to 1.1rc1
*
* Revision 1.11  2003/10/21 21:00:45  lipp
* Moved EJBClientTest to new junit sub-package.
*
* Revision 1.10  2003/10/08 11:52:55  huaiyang
* make test weblogic compatible.
*
* Revision 1.9  2003/04/26 16:46:55  lipp
* Made unittests and systemtests coexist in eclipse.
*
* Revision 1.8  2003/04/16 19:25:04  lipp
* Adapted to jdk 1.4
*
* Revision 1.7  2002/09/08 19:19:18  lipp
* Replaced process type with process manager.
*
* Revision 1.6  2002/08/30 13:37:05  lipp
* Using Workflow engine facade now.
*
* Revision 1.5  2002/08/26 20:23:14  lipp
* Lots of method renames.
*
* Revision 1.4  2002/08/21 22:06:48  lipp
* Finished transition to ProcessMgrStub.
*
* Revision 1.3  2002/06/27 10:48:07  lipp
* Obscure test disabled.
*
* Revision 1.2  2002/02/04 16:18:59  huaiyang
* Add the test method of getProcessMgr.
*
* Revision 1.1  2002/02/03 21:41:42  lipp
* Cleaned up unittests.
*
* Revision 1.9  2002/01/23 15:42:04  lipp
* Adapted to interface changes.
*
* Revision 1.8  2001/12/13 21:00:05  lipp
* Simplified temporary implementation of a requester.
*
* Revision 1.7  2001/12/11 09:54:45  lipp
* Introduced security for workflow.
*
* Revision 1.6  2001/11/07 11:39:00  montag
* changed to internal ejb references
*
* Revision 1.5  2001/09/25 12:12:03  montag
* unittests corrected
*
* Revision 1.4  2001/09/24 13:54:15  montag
* WfProcessPK, WfActivityPK and ContributorPK removed.
*
* Revision 1.3  2001/09/03 15:10:34  schlue
* Assertion for process list added
*
* Revision 1.2  2001/08/29 14:40:16  lipp
* New functions for listing processes
*
* Revision 1.1  2001/08/29 10:59:11  lipp
* Tests split in groups.
*
*/
package process;

import java.rmi.RemoteException;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;

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

import common.UTLoginContext;

import javax.security.auth.login.LoginException;

import de.danet.an.util.junit.EJBClientTest;
import de.danet.an.workflow.api.ProcessDirectory;
import de.danet.an.workflow.api.RangeAccess;
import de.danet.an.workflow.api.WorkflowServiceFactory;
import de.danet.an.workflow.api.query.AndOperation;
import de.danet.an.workflow.api.query.DescendingOrder;
import de.danet.an.workflow.api.query.FilterCriterion;
import de.danet.an.workflow.api.query.NotOperation;
import de.danet.an.workflow.api.query.PropertyEquality;
import de.danet.an.workflow.ejbs.core.WfProcess;

/**
* Zusammenstellung aller TimerObjectTests.
*/
public class ProcDir extends TestCase {
    private static UTLoginContext plc = null;
    static {
  try {
      plc = new UTLoginContext();
      plc.login();
  } catch (LoginException e) {
      throw new IllegalStateException (e.getMessage ());
  }
    }

    /**
     * Konstruktor zum Erzeugen eines TestCase
     */
    public ProcDir(String name) {
  super (name);
    }

    /**
     * Stellt diese TestSuite zusammen.
     */
    public static Test suite() {
        TestSuite suite = new TestSuite();
     suite.addTest(new ProcDir("listProcessTypes"));
     suite.addTest(new ProcDir("listProcesses"));
        suite.addTest(new ProcDir("listProcessesInRange"));
       suite.addTest(new ProcDir("listActivities"));
        return new EJBClientTest (plc, suite);
    }
 

    /**
     * Returns a list of all defined process types
     * from the ProcessDirectory bean.
     */
    public void listProcessTypes() throws Exception {
        ProcessDirectory pdir
            = WorkflowServiceFactory.newInstance()
            .newWorkflowService().processDirectory();
  Collection processTypes = pdir.processMgrNames ();
  assertTrue (processTypes.size() > 0);
    }

    /**
     * Returns a list of all defined process types
     * from the ProcessDirectory bean.
     */
    public void listProcesses() throws Exception {
        ProcessDirectory pdir
            = WorkflowServiceFactory.newInstance()
            .newWorkflowService().processDirectory();
  Collection pts = pdir.processMgrNames ();
  Collection procs = pdir.processes();
    }

    /**
     * Returns a list of all defined process types
     * from the ProcessDirectory bean.
     */
    public void listProcessesInRange() throws Exception {
        ProcessDirectory pdir
            = WorkflowServiceFactory.newInstance()
            .newWorkflowService().processDirectory();
        List refList = (List)pdir.processes();
        Collections.sort(refList, new Comparator () {
            public int compare (Object obj1, Object obj2) {
                try {
                    return Integer.parseInt(((WfProcess)obj2).key())
                            - Integer.parseInt(((WfProcess)obj1).key());
                } catch (RemoteException e) {
                    throw new IllegalArgumentException();
                }
            }
        });
        Iterator iter = refList.iterator();
        iter.next();
        WfProcess p = (WfProcess)iter.next();
        String o1 = p.key();
        iter.remove();
        iter.next();
        p = (WfProcess)iter.next();
        String o2 = p.key();
        iter.remove();
        FilterCriterion filter = new AndOperation
            (new NotOperation(new PropertyEquality("key", o1)),
             new NotOperation(new PropertyEquality("key", o2)));
        RangeAccess ra = pdir.processes(filter, new DescendingOrder("key"));
        List procs = ra.items(0, 10);
        Iterator i1 = refList.iterator();
        Iterator i2 = procs.iterator();
        for (int i = 0; i < 11; i++) {
            WfProcess p1 = (WfProcess)i1.next();
            WfProcess p2 = (WfProcess)i2.next();
            assertTrue (p1.key().equals(p2.key()));
        }
        procs = ra.items(11, 15);
        i2 = procs.iterator();
        for (int i = 0; i < 4; i++) {
            WfProcess p1 = (WfProcess)i1.next();
            WfProcess p2 = (WfProcess)i2.next();
            assertTrue (p1.key().equals(p2.key()));
        }
    }

    /**
     * Returns a list of all activities assigned to a given user
     * from the ProcessDirectory bean.
     */
    public void listActivities() throws Exception {
        ProcessDirectory pdir
            = WorkflowServiceFactory.newInstance()
            .newWorkflowService().processDirectory();
  // Collection c = pdir.getActivities();
  // assertTrue (c != null);
    }

}
TOP

Related Classes of process.ProcDir

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.