Search in sources :

Example 1 with StandaloneProcessEngineConfiguration

use of org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration in project camunda-bpm-platform by camunda.

the class PropertyHelperTest method testProcessEngineConfigurationProperties.

/**
 * Assert that String, int and boolean properties can be set.
 */
public void testProcessEngineConfigurationProperties() {
    ProcessEngineConfiguration engineConfiguration = new StandaloneProcessEngineConfiguration();
    Map<String, String> propertiesToSet = new HashMap<String, String>();
    propertiesToSet.put(JOB_EXECUTOR_DEPLOYMENT_AWARE_PROP, "true");
    propertiesToSet.put(JOB_EXECUTOR_PREFER_TIMER_JOBS, "true");
    propertiesToSet.put(JOB_EXECUTOR_ACQUIRE_BY_DUE_DATE, "true");
    propertiesToSet.put(MAIL_SERVER_PORT_PROP, "42");
    propertiesToSet.put(JDBC_URL_PROP, "someUrl");
    PropertyHelper.applyProperties(engineConfiguration, propertiesToSet);
    Assert.assertTrue(engineConfiguration.isJobExecutorDeploymentAware());
    Assert.assertTrue(engineConfiguration.isJobExecutorPreferTimerJobs());
    Assert.assertTrue(engineConfiguration.isJobExecutorAcquireByDueDate());
    Assert.assertEquals(42, engineConfiguration.getMailServerPort());
    Assert.assertEquals("someUrl", engineConfiguration.getJdbcUrl());
}
Also used : ProcessEngineConfiguration(org.camunda.bpm.engine.ProcessEngineConfiguration) StandaloneProcessEngineConfiguration(org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration) StandaloneProcessEngineConfiguration(org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration) HashMap(java.util.HashMap)

Example 2 with StandaloneProcessEngineConfiguration

use of org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration in project camunda-bpm-platform by camunda.

the class PropertyHelperTest method testNonExistingPropertyForProcessEngineConfiguration.

public void testNonExistingPropertyForProcessEngineConfiguration() {
    ProcessEngineConfiguration engineConfiguration = new StandaloneProcessEngineConfiguration();
    Map<String, String> propertiesToSet = new HashMap<String, String>();
    propertiesToSet.put("aNonExistingProperty", "someValue");
    try {
        PropertyHelper.applyProperties(engineConfiguration, propertiesToSet);
        Assert.fail();
    } catch (Exception e) {
    // happy path
    }
}
Also used : ProcessEngineConfiguration(org.camunda.bpm.engine.ProcessEngineConfiguration) StandaloneProcessEngineConfiguration(org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration) StandaloneProcessEngineConfiguration(org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration) HashMap(java.util.HashMap)

Example 3 with StandaloneProcessEngineConfiguration

use of org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration in project camunda-bpm-platform by camunda.

the class PropertyHelperTest method testConfigurationPropertiesWithMismatchingFieldAndSetter.

/**
 * Assures that property names are matched on the setter name according to java beans conventions
 * and not on the field name.
 */
public void testConfigurationPropertiesWithMismatchingFieldAndSetter() {
    ProcessEngineConfigurationImpl engineConfiguration = new StandaloneProcessEngineConfiguration();
    Map<String, String> propertiesToSet = new HashMap<String, String>();
    propertiesToSet.put(DB_IDENTITY_USED_PROP, "false");
    PropertyHelper.applyProperties(engineConfiguration, propertiesToSet);
    Assert.assertFalse(engineConfiguration.isDbIdentityUsed());
    propertiesToSet.put(DB_IDENTITY_USED_PROP, "true");
    PropertyHelper.applyProperties(engineConfiguration, propertiesToSet);
    Assert.assertTrue(engineConfiguration.isDbIdentityUsed());
}
Also used : StandaloneProcessEngineConfiguration(org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration) HashMap(java.util.HashMap) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)

Example 4 with StandaloneProcessEngineConfiguration

use of org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration in project camunda-bpm-platform by camunda.

the class RuntimeServiceTest method testStartProcessInstanceByIdAfterReboot.

// Test for a bug: when the process engine is rebooted the
// cache is cleaned and the deployed process definition is
// removed from the process cache. This led to problems because
// the id wasnt fetched from the DB after a redeploy.
@Test
public void testStartProcessInstanceByIdAfterReboot() {
    // In case this test is run in a test suite, previous engines might
    // have been initialized and cached.  First we close the
    // existing process engines to make sure that the db is clean
    // and that there are no existing process engines involved.
    ProcessEngines.destroy();
    // 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/api/oneTaskProcess.bpmn20.xml").deploy();
    // verify existence of process definition
    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();
}
Also used : Task(org.camunda.bpm.engine.task.Task) StandaloneProcessEngineConfiguration(org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration) TaskService(org.camunda.bpm.engine.TaskService) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) StandaloneInMemProcessEngineConfiguration(org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration) ProcessEngine(org.camunda.bpm.engine.ProcessEngine) Test(org.junit.Test)

Example 5 with StandaloneProcessEngineConfiguration

use of org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration in project camunda-bpm-platform by camunda.

the class RepositoryServiceTest method testDeployRevisedProcessAfterDeleteOnOtherProcessEngine.

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/api/repository/RepositoryServiceTest.testDeployRevisedProcessAfterDeleteOnOtherProcessEngine.v1.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/api/repository/RepositoryServiceTest.testDeployRevisedProcessAfterDeleteOnOtherProcessEngine.v2.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();
}
Also used : Task(org.camunda.bpm.engine.task.Task) StandaloneProcessEngineConfiguration(org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration) RuntimeService(org.camunda.bpm.engine.RuntimeService) TaskService(org.camunda.bpm.engine.TaskService) ProcessEngine(org.camunda.bpm.engine.ProcessEngine) RepositoryService(org.camunda.bpm.engine.RepositoryService)

Aggregations

StandaloneProcessEngineConfiguration (org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration)9 ProcessEngine (org.camunda.bpm.engine.ProcessEngine)5 StandaloneInMemProcessEngineConfiguration (org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration)4 Test (org.junit.Test)4 Calendar (java.util.Calendar)3 HashMap (java.util.HashMap)3 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)3 ProcessEngineConfiguration (org.camunda.bpm.engine.ProcessEngineConfiguration)2 TaskService (org.camunda.bpm.engine.TaskService)2 Task (org.camunda.bpm.engine.task.Task)2 RepositoryService (org.camunda.bpm.engine.RepositoryService)1 RuntimeService (org.camunda.bpm.engine.RuntimeService)1 ProcessEnginePlugin (org.camunda.bpm.engine.impl.cfg.ProcessEnginePlugin)1 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)1 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)1 PerfTestException (org.camunda.bpm.qa.performance.engine.framework.PerfTestException)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1