use of org.camunda.bpm.engine.impl.ProcessEngineImpl in project camunda-bpm-platform by camunda.
the class UpgradedDBDropper method cleanDatabase.
public void cleanDatabase(ProcessEngine engine) {
// delete all deployments
RepositoryService repositoryService = engine.getRepositoryService();
List<Deployment> deployments = repositoryService.createDeploymentQuery().list();
for (Deployment deployment : deployments) {
repositoryService.deleteDeployment(deployment.getId(), true);
}
// drop DB
((ProcessEngineImpl) engine).getProcessEngineConfiguration().getCommandExecutorTxRequired().execute(new Command<Void>() {
public Void execute(CommandContext commandContext) {
commandContext.getDbSqlSession().dbSchemaDrop();
return null;
}
});
engine.close();
}
use of org.camunda.bpm.engine.impl.ProcessEngineImpl in project camunda-bpm-platform by camunda.
the class ProcessEngineConfigurationImpl method buildProcessEngine.
// buildProcessEngine ///////////////////////////////////////////////////////
@Override
public ProcessEngine buildProcessEngine() {
init();
processEngine = new ProcessEngineImpl(this);
invokePostProcessEngineBuild(processEngine);
return processEngine;
}
use of org.camunda.bpm.engine.impl.ProcessEngineImpl in project camunda-bpm-platform by camunda.
the class TestHelper method assertAndEnsureCleanDbAndCache.
/**
* Ensures that the deployment cache and database is clean after a test. If not the cache
* and database will be cleared.
*
* @param processEngine the {@link ProcessEngine} to test
* @param fail if true the method will throw an {@link AssertionError} if the deployment cache or database is not clean
* @throws AssertionError if the deployment cache or database was not clean
*/
public static String assertAndEnsureCleanDbAndCache(ProcessEngine processEngine, boolean fail) {
ProcessEngineConfigurationImpl processEngineConfiguration = ((ProcessEngineImpl) processEngine).getProcessEngineConfiguration();
// clear user operation log in case some operations are
// executed with an authenticated user
clearUserOperationLog(processEngineConfiguration);
LOG.debug("verifying that db is clean after test");
PurgeReport purgeReport = ((ManagementServiceImpl) processEngine.getManagementService()).purge();
String paRegistrationMessage = assertAndEnsureNoProcessApplicationsRegistered(processEngine);
StringBuilder message = new StringBuilder();
CachePurgeReport cachePurgeReport = purgeReport.getCachePurgeReport();
if (!cachePurgeReport.isEmpty()) {
message.append("Deployment cache is not clean:\n").append(cachePurgeReport.getPurgeReportAsString());
} else {
LOG.debug("Deployment cache was clean.");
}
DatabasePurgeReport databasePurgeReport = purgeReport.getDatabasePurgeReport();
if (!databasePurgeReport.isEmpty()) {
message.append("Database is not clean:\n").append(databasePurgeReport.getPurgeReportAsString());
} else {
LOG.debug("Database was clean.");
}
if (paRegistrationMessage != null) {
message.append(paRegistrationMessage);
}
if (fail && message.length() > 0) {
Assert.fail(message.toString());
}
return message.toString();
}
use of org.camunda.bpm.engine.impl.ProcessEngineImpl in project camunda-bpm-platform by camunda.
the class TestHelper method assertAndEnsureCleanDeploymentCache.
/**
* Ensures that the deployment cache is empty after a test. If not the cache
* will be cleared.
*
* @param processEngine the {@link ProcessEngine} to test
* @param fail if true the method will throw an {@link AssertionError} if the deployment cache is not clean
* @return the deployment cache summary if fail is set to false or null if deployment cache was clean
* @throws AssertionError if the deployment cache was not clean and fail is set to true
*/
public static String assertAndEnsureCleanDeploymentCache(ProcessEngine processEngine, boolean fail) {
StringBuilder outputMessage = new StringBuilder();
ProcessEngineConfigurationImpl processEngineConfiguration = ((ProcessEngineImpl) processEngine).getProcessEngineConfiguration();
CachePurgeReport cachePurgeReport = processEngineConfiguration.getDeploymentCache().purgeCache();
outputMessage.append(cachePurgeReport.getPurgeReportAsString());
if (outputMessage.length() > 0) {
outputMessage.insert(0, "Deployment cache not clean:\n");
LOG.error(outputMessage.toString());
if (fail) {
Assert.fail(outputMessage.toString());
}
return outputMessage.toString();
} else {
LOG.debug("Deployment cache was clean");
return null;
}
}
use of org.camunda.bpm.engine.impl.ProcessEngineImpl in project camunda-bpm-platform by camunda.
the class ManagementServiceTest method testDeleteJobThatWasAlreadyAcquired.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/mgmt/timerOnTask.bpmn20.xml" })
public void testDeleteJobThatWasAlreadyAcquired() {
ClockUtil.setCurrentTime(new Date());
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("timerOnTask");
Job timerJob = managementService.createJobQuery().processInstanceId(processInstance.getId()).singleResult();
// We need to move time at least one hour to make the timer executable
ClockUtil.setCurrentTime(new Date(ClockUtil.getCurrentTime().getTime() + 7200000L));
// Acquire job by running the acquire command manually
ProcessEngineImpl processEngineImpl = (ProcessEngineImpl) processEngine;
JobExecutor jobExecutor = processEngineImpl.getProcessEngineConfiguration().getJobExecutor();
AcquireJobsCmd acquireJobsCmd = new AcquireJobsCmd(jobExecutor);
CommandExecutor commandExecutor = processEngineImpl.getProcessEngineConfiguration().getCommandExecutorTxRequired();
commandExecutor.execute(acquireJobsCmd);
// Try to delete the job. This should fail.
try {
managementService.deleteJob(timerJob.getId());
fail();
} catch (ProcessEngineException e) {
// Exception is expected
}
// Clean up
managementService.executeJob(timerJob.getId());
}
Aggregations