use of org.activiti.engine.ProcessEngine in project Activiti by Activiti.
the class AsyncExecutorTest method testAsyncFailingScript.
@Test
public void testAsyncFailingScript() {
ProcessEngine processEngine = null;
try {
// Deploy
processEngine = createProcessEngine(true);
processEngine.getProcessEngineConfiguration().getClock().reset();
deploy(processEngine, "AsyncExecutorTest.testAsyncFailingScript.bpmn20.xml");
// Start process instance. Wait for all jobs to be done.
processEngine.getRuntimeService().startProcessInstanceByKey("asyncScript");
// There is a back off mechanism for the retry, so need a bit of time
// But to be sure, we make the wait time small
processEngine.getProcessEngineConfiguration().setAsyncFailedJobWaitTime(1);
final ProcessEngine processEngineCopy = processEngine;
JobTestHelper.waitForJobExecutorOnCondition(processEngine.getProcessEngineConfiguration(), 10000L, 2000L, new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return processEngineCopy.getManagementService().createJobQuery().withRetriesLeft().count() == 0;
}
});
// Verify if all is as expected
Assert.assertEquals(0, processEngine.getTaskService().createTaskQuery().taskName("Task after script").count());
Assert.assertEquals(1, processEngine.getManagementService().createJobQuery().count());
Assert.assertEquals(0, processEngine.getManagementService().createJobQuery().withRetriesLeft().count());
Assert.assertEquals(1, processEngine.getManagementService().createJobQuery().noRetriesLeft().count());
Assert.assertEquals(1, processEngine.getManagementService().createJobQuery().withException().count());
Assert.assertEquals(3, getAsyncExecutorJobCount(processEngine));
} finally {
// Clean up
cleanup(processEngine);
}
}
use of org.activiti.engine.ProcessEngine in project Activiti by Activiti.
the class AsyncExecutorTest method testAsyncExecutorDisabledOnOneEngine.
@Test
public void testAsyncExecutorDisabledOnOneEngine() {
ProcessEngine firstProcessEngine = null;
ProcessEngine secondProcessEngine = null;
try {
// Deploy on one engine, where the async executor is disabled
firstProcessEngine = createProcessEngine(false);
Date now = setClockToCurrentTime(firstProcessEngine);
deploy(firstProcessEngine, "AsyncExecutorTest.testRegularAsyncExecution.bpmn20.xml");
// Start process instance on first engine
firstProcessEngine.getRuntimeService().startProcessInstanceByKey("asyncExecutor");
// Move clock 5 minutes and 1 second. Triggers the timer normally, but not now since async execution is disabled
// 301 = 5m01s
addSecondsToCurrentTime(firstProcessEngine, 301);
Assert.assertEquals(1, firstProcessEngine.getTaskService().createTaskQuery().taskName("The Task").count());
Assert.assertEquals(0, firstProcessEngine.getTaskService().createTaskQuery().taskName("Task after timer").count());
Assert.assertEquals(1, firstProcessEngine.getManagementService().createJobQuery().count());
// Create second engine, with async executor enabled. Same time as the first engine to start, then add 301 seconds
secondProcessEngine = createProcessEngine(true, now);
addSecondsToCurrentTime(secondProcessEngine, 361);
waitForAllJobsBeingExecuted(secondProcessEngine);
// Verify if all is as expected
Assert.assertEquals(0, firstProcessEngine.getTaskService().createTaskQuery().taskName("The Task").count());
Assert.assertEquals(1, firstProcessEngine.getTaskService().createTaskQuery().taskName("Task after timer").count());
Assert.assertEquals(0, firstProcessEngine.getManagementService().createJobQuery().count());
Assert.assertEquals(0, getAsyncExecutorJobCount(firstProcessEngine));
Assert.assertEquals(1, getAsyncExecutorJobCount(secondProcessEngine));
} finally {
// Clean up
cleanup(firstProcessEngine);
cleanup(secondProcessEngine);
}
}
use of org.activiti.engine.ProcessEngine in project Activiti by Activiti.
the class AsyncExecutorTest method testAsyncScriptExecution.
@Test
public void testAsyncScriptExecution() {
ProcessEngine processEngine = null;
try {
// Deploy
processEngine = createProcessEngine(true);
setClockToCurrentTime(processEngine);
deploy(processEngine, "AsyncExecutorTest.testAsyncScriptExecution.bpmn20.xml");
// Start process instance. Wait for all jobs to be done
processEngine.getRuntimeService().startProcessInstanceByKey("asyncScript");
waitForAllJobsBeingExecuted(processEngine);
// Verify if all is as expected
Assert.assertEquals(1, processEngine.getTaskService().createTaskQuery().taskName("Task after script").count());
Assert.assertEquals(0, processEngine.getManagementService().createJobQuery().count());
Assert.assertEquals(1, getAsyncExecutorJobCount(processEngine));
} finally {
// Clean up
cleanup(processEngine);
}
}
use of org.activiti.engine.ProcessEngine in project Activiti by Activiti.
the class ProcessEnginesTest method testProcessEngineInfo.
public void testProcessEngineInfo() {
List<ProcessEngineInfo> processEngineInfos = ProcessEngines.getProcessEngineInfos();
assertEquals(1, processEngineInfos.size());
ProcessEngineInfo processEngineInfo = processEngineInfos.get(0);
assertNull(processEngineInfo.getException());
assertNotNull(processEngineInfo.getName());
assertNotNull(processEngineInfo.getResourceUrl());
ProcessEngine processEngine = ProcessEngines.getProcessEngine(ProcessEngines.NAME_DEFAULT);
assertNotNull(processEngine);
}
use of org.activiti.engine.ProcessEngine in project Activiti by Activiti.
the class MuleHttpBasicAuthTest method httpWithBasicAuth.
@Test
public void httpWithBasicAuth() throws Exception {
Assert.assertTrue(muleContext.isStarted());
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
Deployment deployment = processEngine.getRepositoryService().createDeployment().addClasspathResource("org/activiti/mule/testHttpBasicAuth.bpmn20.xml").deploy();
RuntimeService runtimeService = processEngine.getRuntimeService();
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("muleProcess");
Assert.assertFalse(processInstance.isEnded());
Object result = runtimeService.getVariable(processInstance.getProcessInstanceId(), "theVariable");
Assert.assertEquals(10, result);
runtimeService.deleteProcessInstance(processInstance.getId(), "test");
processEngine.getHistoryService().deleteHistoricProcessInstance(processInstance.getId());
processEngine.getRepositoryService().deleteDeployment(deployment.getId());
assertAndEnsureCleanDb(processEngine);
ProcessEngines.destroy();
}
Aggregations