Search in sources :

Example 1 with StandaloneInMemProcessEngineConfiguration

use of org.activiti.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration in project Activiti by Activiti.

the class AsyncExecutorTest method createProcessEngine.

private ProcessEngine createProcessEngine(boolean enableAsyncExecutor, Date time) {
    ProcessEngineConfigurationImpl processEngineConfiguration = new StandaloneInMemProcessEngineConfiguration();
    processEngineConfiguration.setJdbcUrl("jdbc:h2:mem:activiti-AsyncExecutorTest;DB_CLOSE_DELAY=1000");
    processEngineConfiguration.setDatabaseSchemaUpdate("true");
    if (enableAsyncExecutor) {
        processEngineConfiguration.setAsyncExecutorActivate(true);
        CountingAsyncExecutor countingAsyncExecutor = new CountingAsyncExecutor();
        // To avoid waiting too long when a retry happens
        countingAsyncExecutor.setDefaultAsyncJobAcquireWaitTimeInMillis(50);
        countingAsyncExecutor.setDefaultTimerJobAcquireWaitTimeInMillis(50);
        processEngineConfiguration.setAsyncExecutor(countingAsyncExecutor);
    }
    ProcessEngine processEngine = processEngineConfiguration.buildProcessEngine();
    if (time != null) {
        processEngine.getProcessEngineConfiguration().getClock().setCurrentTime(time);
    }
    return processEngine;
}
Also used : ProcessEngineConfigurationImpl(org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl) StandaloneInMemProcessEngineConfiguration(org.activiti.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration) ProcessEngine(org.activiti.engine.ProcessEngine)

Example 2 with StandaloneInMemProcessEngineConfiguration

use of org.activiti.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration in project Activiti by Activiti.

the class ProcessDefinitionInfoCacheTest 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 wasn't fetched from the DB after a redeploy.
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-info-test-schema");
    processEngineConfiguration.setJdbcUrl("jdbc:h2:mem:activiti-reboot-info-test;DB_CLOSE_DELAY=1000");
    ProcessEngine schemaProcessEngine = processEngineConfiguration.buildProcessEngine();
    // Create process engine and deploy test process
    ProcessEngine processEngine = new StandaloneProcessEngineConfiguration().setProcessEngineName("reboot-info-test").setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_FALSE).setJdbcUrl("jdbc:h2:mem:activiti-reboot-info-test;DB_CLOSE_DELAY=1000").setJobExecutorActivate(false).setEnableProcessDefinitionInfoCache(true).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());
    String processDefinitionId = processDefinitions.get(0).getId();
    ObjectNode infoNode = processEngine.getDynamicBpmnService().getProcessDefinitionInfo(processDefinitionId);
    assertNotNull(infoNode);
    infoNode = processEngineConfiguration.getObjectMapper().createObjectNode();
    infoNode.put("test", "test");
    processEngine.getDynamicBpmnService().saveProcessDefinitionInfo(processDefinitionId, infoNode);
    infoNode = processEngine.getDynamicBpmnService().getProcessDefinitionInfo(processDefinitionId);
    assertNotNull(infoNode);
    assertEquals("test", infoNode.get("test").asText());
    // Start a new Process instance
    ProcessInstance processInstance = processEngine.getRuntimeService().startProcessInstanceById(processDefinitionId);
    String processInstanceId = processInstance.getId();
    assertNotNull(processInstance);
    // Close the process engine
    processEngine.close();
    assertNotNull(processEngine.getRuntimeService());
    // Reboot the process engine
    processEngine = new StandaloneProcessEngineConfiguration().setProcessEngineName("reboot-info-test").setDatabaseSchemaUpdate(org.activiti.engine.ProcessEngineConfiguration.DB_SCHEMA_UPDATE_FALSE).setJdbcUrl("jdbc:h2:mem:activiti-reboot-info-test;DB_CLOSE_DELAY=1000").setJobExecutorActivate(false).setEnableProcessDefinitionInfoCache(true).buildProcessEngine();
    infoNode = processEngine.getDynamicBpmnService().getProcessDefinitionInfo(processDefinitionId);
    assertNotNull(infoNode);
    assertEquals("test", infoNode.get("test").asText());
    // 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.activiti.engine.task.Task) StandaloneProcessEngineConfiguration(org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) TaskService(org.activiti.engine.TaskService) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) ProcessEngineConfigurationImpl(org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl) StandaloneInMemProcessEngineConfiguration(org.activiti.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration) ProcessEngine(org.activiti.engine.ProcessEngine)

Example 3 with StandaloneInMemProcessEngineConfiguration

use of org.activiti.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration in project Activiti by Activiti.

the class DisabledSchemaValidationTest method setup.

@Before
public void setup() {
    this.processEngine = new StandaloneInMemProcessEngineConfiguration().setJdbcUrl("jdbc:h2:mem:activiti-process-validation;DB_CLOSE_DELAY=1000").buildProcessEngine();
    this.repositoryService = processEngine.getRepositoryService();
}
Also used : StandaloneInMemProcessEngineConfiguration(org.activiti.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration) Before(org.junit.Before)

Example 4 with StandaloneInMemProcessEngineConfiguration

use of org.activiti.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration in project Activiti by Activiti.

the class SecureScriptingBaseTest method initProcessEngine.

@Before
public void initProcessEngine() {
    SecureJavascriptConfigurator configurator = new SecureJavascriptConfigurator().setWhiteListedClasses(new HashSet<String>(Arrays.asList("java.util.ArrayList", "org.activiti.test.scripting.secure.MyBean"))).setMaxStackDepth(10).setMaxScriptExecutionTime(3000L).setMaxMemoryUsed(3145728L);
    Map<Object, Object> beans = new HashMap<Object, Object>();
    beans.put("myBean", new MyBean());
    this.processEngine = new StandaloneInMemProcessEngineConfiguration().addConfigurator(configurator).setBeans(beans).setDatabaseSchemaUpdate("create-drop").setEnableProcessDefinitionInfoCache(true).buildProcessEngine();
    this.runtimeService = processEngine.getRuntimeService();
    this.repositoryService = processEngine.getRepositoryService();
    this.taskService = processEngine.getTaskService();
    this.historyService = processEngine.getHistoryService();
    this.dynamicBpmnService = processEngine.getDynamicBpmnService();
}
Also used : HashMap(java.util.HashMap) SecureJavascriptConfigurator(org.activiti.scripting.secure.SecureJavascriptConfigurator) StandaloneInMemProcessEngineConfiguration(org.activiti.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration) HashSet(java.util.HashSet) Before(org.junit.Before)

Example 5 with StandaloneInMemProcessEngineConfiguration

use of org.activiti.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration in project Activiti by Activiti.

the class RetryInterceptorTest method setupProcessEngine.

@Before
public void setupProcessEngine() {
    ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) new StandaloneInMemProcessEngineConfiguration();
    processEngineConfiguration.setJdbcUrl("jdbc:h2:mem:retryInterceptorTest");
    List<CommandInterceptor> interceptors = new ArrayList<CommandInterceptor>();
    retryInterceptor = new RetryInterceptor();
    interceptors.add(retryInterceptor);
    processEngineConfiguration.setCustomPreCommandInterceptors(interceptors);
    processEngine = processEngineConfiguration.buildProcessEngine();
}
Also used : ArrayList(java.util.ArrayList) CommandInterceptor(org.activiti.engine.impl.interceptor.CommandInterceptor) ProcessEngineConfigurationImpl(org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl) StandaloneInMemProcessEngineConfiguration(org.activiti.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration) RetryInterceptor(org.activiti.engine.impl.interceptor.RetryInterceptor) Before(org.junit.Before)

Aggregations

StandaloneInMemProcessEngineConfiguration (org.activiti.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration)6 ProcessEngineConfigurationImpl (org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl)4 ProcessEngine (org.activiti.engine.ProcessEngine)3 Before (org.junit.Before)3 TaskService (org.activiti.engine.TaskService)2 StandaloneProcessEngineConfiguration (org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration)2 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)2 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)2 Task (org.activiti.engine.task.Task)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 CommandInterceptor (org.activiti.engine.impl.interceptor.CommandInterceptor)1 RetryInterceptor (org.activiti.engine.impl.interceptor.RetryInterceptor)1 SecureJavascriptConfigurator (org.activiti.scripting.secure.SecureJavascriptConfigurator)1