Package org.camunda.bpm.engine

Examples of org.camunda.bpm.engine.ProcessEngine


    cachedDefaultProcessEngine = null;
    cachedEngines = new HashMap<String, ProcessEngine>();
  }

  private ProcessEngine mockProcessEngine(String engineName) {
    ProcessEngine engine = mock(ProcessEngine.class);
    when(engine.getName()).thenReturn(engineName);
    mockServices(engine);
    mockProcessEngineConfiguration(engine);
    return engine;
  }
View Full Code Here


    if (name.equals("default")) {
      return getDefaultProcessEngine();
    }

    if (cachedEngines.get(name) == null) {
      ProcessEngine mock = mockProcessEngine(name);
      cachedEngines.put(name, mock);
    }

    return cachedEngines.get(name);
  }
View Full Code Here

    transactionsExternallyManaged = true;
  }

  @Override
  public ProcessEngine buildProcessEngine() {
    ProcessEngine processEngine = super.buildProcessEngine();
    autoDeployResources(processEngine);
    return processEngine;
  }
View Full Code Here

         || (beansOfType.isEmpty())
       ) {
      throw new ProcessEngineException("no "+ProcessEngine.class.getName()+" defined in the application context "+resource.toString());
    }
   
    ProcessEngine processEngine = beansOfType.values().iterator().next();

    log.fine("==== SPRING PROCESS ENGINE CREATED ==================================================================");
    return processEngine;
  }
View Full Code Here

 
  public void testMyBatisConnectionPoolProperlyConfigured() {
    ProcessEngineConfigurationImpl config = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration
      .createProcessEngineConfigurationFromResource("org/camunda/bpm/engine/test/db/connection-pool.camunda.cfg.xml");
   
    ProcessEngine engine = config.buildProcessEngine();
   
    // Expected values
    int maxActive = 25;
    int maxIdle = 10;
    int maxCheckoutTime = 30000;
    int maxWaitTime = 25000;
   
    assertEquals(maxActive, config.getJdbcMaxActiveConnections());
    assertEquals(maxIdle, config.getJdbcMaxIdleConnections());
    assertEquals(maxCheckoutTime, config.getJdbcMaxCheckoutTime());
    assertEquals(maxWaitTime, config.getJdbcMaxWaitTime());
   
    // Verify that these properties are correctly set in the MyBatis datasource
    DataSource datasource = config.getDbSqlSessionFactory().getSqlSessionFactory().getConfiguration().getEnvironment().getDataSource();
    assertTrue(datasource instanceof PooledDataSource);
   
    PooledDataSource pooledDataSource = (PooledDataSource) datasource;
    assertEquals(maxActive, pooledDataSource.getPoolMaximumActiveConnections());
    assertEquals(maxIdle, pooledDataSource.getPoolMaximumIdleConnections());
    assertEquals(maxCheckoutTime, pooledDataSource.getPoolMaximumCheckoutTime());
    assertEquals(maxWaitTime, pooledDataSource.getPoolTimeToWait());
   
    engine.close();
  }
View Full Code Here

   * @throws IOException
   */
  public void testProcessDiagramCreation() throws IOException {
    ProcessEngineConfigurationImpl config = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("camunda.cfg.xml");
    config.setCreateDiagramOnDeploy(true);
    ProcessEngine engine = config.buildProcessEngine();
    String deploymentId = engine.getRepositoryService().createDeployment()
      .addClasspathResource("org/camunda/bpm/engine/test/bpmn/deployment/BpmnDeploymentTest.testProcessDiagramCreation.bpmn20.xml")
      .deploy().getId();

    ProcessDefinition definition = engine.getRepositoryService().createProcessDefinitionQuery().singleResult();
    String expectedDiagramName = "org/camunda/bpm/engine/test/bpmn/deployment/BpmnDeploymentTest.testProcessDiagramCreation.processDiagramProcess.png";
    assertEquals(expectedDiagramName, definition.getDiagramResourceName());

    InputStream diagramStream = engine.getRepositoryService().getProcessDiagram(definition.getId());
    assertNotNull(diagramStream);
    diagramStream.close();

    // clean db
    engine.getRepositoryService().deleteDeployment(deploymentId);
  }
View Full Code Here

    ProcessEngineConfigurationImpl config1 = createCustomProcessEngineConfiguration()
            .setProcessEngineName("DatabaseTablePrefixTest-engine1")
            .setDataSource(pooledDataSource)
            .setDatabaseSchemaUpdate("NO_CHECK"); // disable auto create/drop schema
    config1.setDatabaseTablePrefix("SCHEMA1.");
    ProcessEngine engine1 = config1.buildProcessEngine();
   
    ProcessEngineConfigurationImpl config2 = createCustomProcessEngineConfiguration()
            .setProcessEngineName("DatabaseTablePrefixTest-engine2")
            .setDataSource(pooledDataSource)
            .setDatabaseSchemaUpdate("NO_CHECK"); // disable auto create/drop schema       
    config2.setDatabaseTablePrefix("SCHEMA2.");
    ProcessEngine engine2 = config2.buildProcessEngine();
   
    // create the tables in SCHEMA1
    connection = pooledDataSource.getConnection();
    connection.createStatement().execute("set schema SCHEMA1");   
    engine1.getManagementService().databaseSchemaUpgrade(connection, "", "SCHEMA1");
    connection.close();

    // create the tables in SCHEMA2
    connection = pooledDataSource.getConnection();
    connection.createStatement().execute("set schema SCHEMA2");   
    engine2.getManagementService().databaseSchemaUpgrade(connection, "", "SCHEMA2");
    connection.close();

    // if I deploy a process to one engine, it is not visible to the other
    // engine:
    try {
      engine1.getRepositoryService()
        .createDeployment()
        .addClasspathResource("org/camunda/bpm/engine/test/db/oneJobProcess.bpmn20.xml")
        .deploy();

      assertEquals(1, engine1.getRepositoryService().createDeploymentQuery().count());
      assertEquals(0, engine2.getRepositoryService().createDeploymentQuery().count());

    } finally {
      engine1.close();
      engine2.close();
    }
  }
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/camunda/bpm/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.camunda.bpm.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.camunda.bpm.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.camunda.bpm.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/camunda/bpm/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/camunda/bpm/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

*
*/
public class DB71Dropper {

  public static void main(String[] args) {
    ProcessEngine engine = ProcessEngineConfiguration
        .createProcessEngineConfigurationFromResource("process-engine-config71.xml").buildProcessEngine();
   
    DB71Dropper fixture = new DB71Dropper();
    fixture.cleanDatabase(engine);
  }
View Full Code Here

TOP

Related Classes of org.camunda.bpm.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.