Package org.activiti.engine

Examples of org.activiti.engine.ProcessEngine


import org.apache.commons.io.IOUtils;

public class GenDiagTest extends TestCase{
   
    public void testGenDiag() throws Exception{
        ProcessEngine eng = ProcessEngineConfiguration
                            .createStandaloneInMemProcessEngineConfiguration()
                            .buildProcessEngine();
       
        System.out.println("engine version: "+eng.VERSION);
       
        RepositoryService repoSvc = eng.getRepositoryService();
        RuntimeService rtSvc = eng.getRuntimeService();
       
        String wfn = "/diagrams/GenDiag.bpmn";
        String wffn = wfn+"20.xml"; // workaround for http://forums.activiti.org/en/viewtopic.php?f=8&t=3745&start=10
        DeploymentBuilder db = repoSvc
                               .createDeployment()
View Full Code Here


  }
 
  protected void deployProcess(BpmnModel bpmnModel)  {
    byte[] xml = new BpmnXMLConverter().convertToXML(bpmnModel);
    ProcessEngineConfiguration configuration = ProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration();
    ProcessEngine processEngine = configuration.buildProcessEngine();
    try {
      Deployment deployment = processEngine.getRepositoryService().createDeployment().name("test").addString("test.bpmn20.xml", new String(xml)).deploy();
      processEngine.getRepositoryService().deleteDeployment(deployment.getId());
    } finally {
      processEngine.close();
    }
  }
View Full Code Here

*/
public class MuleSendActivitiBehaviorTest extends FunctionalTestCase {

  @Deployment
  public void testSend() {
    ProcessEngine processEngine = muleContext.getRegistry().get("processEngine");
    TestHelper.annotationDeploymentSetUp(processEngine, getClass(), getName());

    RuntimeService runtimeService = muleContext.getRegistry().get("runtimeService");
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("muleProcess");
    assertFalse(processInstance.isEnded());
View Full Code Here

import org.activiti.engine.runtime.ProcessInstance;

public class ScriptScriptTest extends TestCase{
 
  public void testWfSleep() throws Exception{
    ProcessEngine eng = ProcessEngineConfiguration
              .createStandaloneInMemProcessEngineConfiguration()
              .buildProcessEngine();
   
    System.out.println("engine version: "+eng.VERSION);
   
    RepositoryService repoSvc = eng.getRepositoryService();
    RuntimeService rtSvc = eng.getRuntimeService();
   
    String wfn = "/diagrams/ScriptScript.bpmn";
    String wffn = wfn+"20.xml"; // workaround for http://forums.activiti.org/en/viewtopic.php?f=8&t=3745&start=10
        DeploymentBuilder db = repoSvc
                 .createDeployment()
                 .addInputStream(wffn,this.getClass().getResourceAsStream(wfn));
   
        Deployment d = db.deploy();
        ProcessDefinition pDef = repoSvc
                                 .createProcessDefinitionQuery()
                                 .deploymentId(d.getId())
                                 .singleResult();

        ProcessInstance proc = rtSvc.startProcessInstanceById(pDef.getId());
       
        String procId = proc.getId();
        System.out.println("procId="+procId);
       
        long timeout = System.currentTimeMillis()+15*1000;
        HistoryService hstSvc = eng.getHistoryService();
        while (true){
            if (System.currentTimeMillis() > timeout) throw new TimeoutException();
            HistoricProcessInstance hProcInst = hstSvc.createHistoricProcessInstanceQuery().processInstanceId(procId).singleResult();
            if (hProcInst.getEndTime() != null){
                System.out.println(wfn+" ended");
View Full Code Here

   
    if(loginInfo.getPassword() == null) {
      throw new ActivitiException("No password supplied");
    }
   
    ProcessEngine pe = ActivitiUtil.getProcessEngine();
    if (pe != null) {
      if (pe.getIdentityService().checkPassword(loginInfo.getUserId(), loginInfo.getPassword()) == false) {
        throw new ActivitiException("Username and password does not match.");
      }
      return new LoginResponse().setSuccess(true);
   
    } else {
View Full Code Here

import org.activiti.engine.runtime.ProcessInstance;

public class WfSleepTest extends TestCase{
 
  public void testWfSleep() throws Exception{
    ProcessEngine eng = ProcessEngineConfiguration
              .createStandaloneInMemProcessEngineConfiguration()
              .setJobExecutorActivate(true)
              .buildProcessEngine();
   
    System.out.println("engine version: "+eng.VERSION);
   
    RepositoryService repoSvc = eng.getRepositoryService();
    RuntimeService rtSvc = eng.getRuntimeService();
   
    String wfn = "/diagrams/WfSleep.bpmn";
    String wffn = wfn+"20.xml"; // workaround for http://forums.activiti.org/en/viewtopic.php?f=8&t=3745&start=10
        DeploymentBuilder db = repoSvc
                 .createDeployment()
                 .addInputStream(wffn,this.getClass().getResourceAsStream(wfn));
   
        Deployment d = db.deploy();
        ProcessDefinition pDef = repoSvc
                                 .createProcessDefinitionQuery()
                                 .deploymentId(d.getId())
                                 .singleResult();

        ProcessInstance proc = rtSvc.startProcessInstanceById(pDef.getId());
       
        String procId = proc.getId();
        System.out.println("procId="+procId);
       
        long timeout = System.currentTimeMillis()+15*1000;
        HistoryService hstSvc = eng.getHistoryService();
        while (true){
            if (System.currentTimeMillis() > timeout) throw new TimeoutException();
            HistoricProcessInstance hProcInst = hstSvc.createHistoricProcessInstanceQuery().processInstanceId(procId).singleResult();
            if (hProcInst.getEndTime() != null){
                System.out.println(wfn+" ended");
View Full Code Here

      ProxyDriver.setUrl(processEngineConfiguration.getJdbcUrl());
      processEngineConfiguration.setJdbcUrl("proxy");
      DriverManager.registerDriver(new ProxyDriver());

      log.fine("building the process engine...");
      ProcessEngine processEngine = processEngineConfiguration.buildProcessEngine();

     
      log.fine("### Running data generator "+ClassNameUtil.getClassNameWithoutPackage(CommonDataGenerator.class)+" in the old version");
      CommonDataGenerator commonDataGenerator = new CommonDataGenerator();
      commonDataGenerator.setProcessEngine(processEngine);
View Full Code Here

  private String filename = "/Users/henryyan/work/projects/activiti/activiti-study/src/test/resources/diagrams/TimeBoundaryEvent.bpmn";

  public void startProcessWithJob() throws Exception {
    ProcessEngineConfiguration createStandaloneInMemProcessEngineConfiguration = StandaloneInMemProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration();
    createStandaloneInMemProcessEngineConfiguration.setJobExecutorActivate(true);
    ProcessEngine processEngine = createStandaloneInMemProcessEngineConfiguration.buildProcessEngine();
    RepositoryService repositoryService = processEngine.getRepositoryService();
    repositoryService.createDeployment().addInputStream("TimeBoundaryEvent.bpmn20.xml",
        new FileInputStream(filename)).deploy();
    RuntimeService runtimeService = processEngine.getRuntimeService();
    Map<String, Object> variableMap = new HashMap<String, Object>();
   
    Calendar ca = Calendar.getInstance();
    ca.add(Calendar.SECOND, 1);
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    SimpleDateFormat sdft = new SimpleDateFormat("HH:mm:ss");
    variableMap.put("datetime", sdf.format(ca.getTime()) + "T" + sdft.format(ca.getTime()));
   
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("TimeBoundaryEvent", variableMap);
    assertNotNull(processInstance.getId());
    System.out.println("id " + processInstance.getId() + " "
        + processInstance.getProcessDefinitionId());
   
    TaskService taskService = processEngine.getTaskService();
    Task task = taskService.createTaskQuery().singleResult();
    assertNotNull(task);
   
    taskService.complete(task.getId());
    Thread.sleep(2000);
View Full Code Here

    // Creating the DB schema (without building a process engine)
    ProcessEngineConfigurationImpl processEngineConfiguration = new StandaloneInMemProcessEngineConfiguration();
    processEngineConfiguration.setProcessEngineName("reboot-test-schema");
    processEngineConfiguration.setJdbcUrl("jdbc:h2:mem:activiti-reboot-test;DB_CLOSE_DELAY=1000");
    ProcessEngine schemaProcessEngine = processEngineConfiguration.buildProcessEngine();
   
    // Create process engine and deploy test process
     ProcessEngine processEngine = new StandaloneProcessEngineConfiguration()
       .setProcessEngineName("reboot-test")
       .setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_FALSE)
       .setJdbcUrl("jdbc:h2:mem:activiti-reboot-test;DB_CLOSE_DELAY=1000")
       .setJobExecutorActivate(false)
       .buildProcessEngine();
    
     processEngine.getRepositoryService()
       .createDeployment()
       .addClasspathResource("org/activiti/engine/test/cache/originalProcess.bpmn20.xml")
       .deploy();
 
     // verify existance of process definiton
     List<ProcessDefinition> processDefinitions = processEngine
       .getRepositoryService()
       .createProcessDefinitionQuery()
       .list();
    
     assertEquals(1, processDefinitions.size());
    
     // Start a new Process instance
     ProcessInstance processInstance = processEngine.getRuntimeService().startProcessInstanceById(processDefinitions.get(0).getId());
     String processInstanceId = processInstance.getId();
     assertNotNull(processInstance);
       
     // Close the process engine
     processEngine.close();
     assertNotNull(processEngine.getRuntimeService());
    
     // Reboot the process engine
     processEngine = new StandaloneProcessEngineConfiguration()
       .setProcessEngineName("reboot-test")
       .setDatabaseSchemaUpdate(org.activiti.engine.ProcessEngineConfiguration.DB_SCHEMA_UPDATE_FALSE)
       .setJdbcUrl("jdbc:h2:mem:activiti-reboot-test;DB_CLOSE_DELAY=1000")
       .setJobExecutorActivate(false)
       .buildProcessEngine();
    
     // Check if the existing process instance is still alive
     processInstance = processEngine
       .getRuntimeService()
       .createProcessInstanceQuery()
       .processInstanceId(processInstanceId)
       .singleResult();
    
     assertNotNull(processInstance);
    
     // Complete the task.  That will end the process instance
     TaskService taskService = processEngine.getTaskService();
     Task task = taskService
       .createTaskQuery()
       .list()
       .get(0);
     taskService.complete(task.getId());
    
     // Check if the process instance has really ended.  This means that the process definition has
     // re-loaded into the process definition cache
     processInstance = processEngine
       .getRuntimeService()
       .createProcessInstanceQuery()
       .processInstanceId(processInstanceId)
       .singleResult();

     assertNull(processInstance);
    
     // Extra check to see if a new process instance can be started as well
     processInstance = processEngine.getRuntimeService().startProcessInstanceById(processDefinitions.get(0).getId());
     assertNotNull(processInstance);

     // close the process engine
     processEngine.close();
     
     // Cleanup schema
     schemaProcessEngine.close();
   }
View Full Code Here

 
 
  public void testDeployRevisedProcessAfterDeleteOnOtherProcessEngine() {
   
    // Setup both process engines
    ProcessEngine processEngine1 = new StandaloneProcessEngineConfiguration()
      .setProcessEngineName("reboot-test-schema")
      .setDatabaseSchemaUpdate(org.activiti.engine.ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE)
      .setJdbcUrl("jdbc:h2:mem:activiti-process-cache-test;DB_CLOSE_DELAY=1000")
      .setJobExecutorActivate(false)
      .buildProcessEngine();
    RepositoryService repositoryService1 = processEngine1.getRepositoryService();
   
    ProcessEngine processEngine2 = new StandaloneProcessEngineConfiguration()
      .setProcessEngineName("reboot-test")
      .setDatabaseSchemaUpdate(org.activiti.engine.ProcessEngineConfiguration.DB_SCHEMA_UPDATE_FALSE)
      .setJdbcUrl("jdbc:h2:mem:activiti-process-cache-test;DB_CLOSE_DELAY=1000")
      .setJobExecutorActivate(false)
      .buildProcessEngine();
    RepositoryService repositoryService2 = processEngine2.getRepositoryService();
    RuntimeService runtimeService2 = processEngine2.getRuntimeService();
    TaskService taskService2 = processEngine2.getTaskService();
   
    // Deploy first version of process: start->originalTask->end on first process engine
    String deploymentId = repositoryService1.createDeployment()
      .addClasspathResource("org/activiti/engine/test/cache/originalProcess.bpmn20.xml")
      .deploy()
      .getId();
   
    // Start process instance on second engine
    String processDefinitionId = repositoryService2.createProcessDefinitionQuery().singleResult().getId();
    runtimeService2.startProcessInstanceById(processDefinitionId);
    Task task = taskService2.createTaskQuery().singleResult();
    assertEquals("original task", task.getName());
   
    // Delete the deployment on second process engine
    repositoryService2.deleteDeployment(deploymentId, true);
    assertEquals(0, repositoryService2.createDeploymentQuery().count());
    assertEquals(0, runtimeService2.createProcessInstanceQuery().count());
   
    // deploy a revised version of the process: start->revisedTask->end on first process engine
    //
    // Before the bugfix, this would set the cache on the first process engine,
    // but the second process engine still has the original process definition in his cache.
    // Since there is a deployment delete in between, the new generated process definition id is the same
    // as in the original deployment, making the second process engine using the old cached process definition.
    deploymentId = repositoryService1.createDeployment()
      .addClasspathResource("org/activiti/engine/test/cache/revisedProcess.bpmn20.xml")
      .deploy()
      .getId();
   
    // Start process instance on second process engine -> must use revised process definition
    processDefinitionId = repositoryService2.createProcessDefinitionQuery().singleResult().getId();
    runtimeService2.startProcessInstanceByKey("oneTaskProcess");
    task = taskService2.createTaskQuery().singleResult();
    assertEquals("revised task", task.getName());
   
    // cleanup
    repositoryService1.deleteDeployment(deploymentId, true);
    processEngine1.close();
    processEngine2.close();
  }
View Full Code Here

TOP

Related Classes of org.activiti.engine.ProcessEngine

Copyright © 2018 www.massapicom. 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.