Search in sources :

Example 6 with ProcessEngineImpl

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();
}
Also used : CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) Deployment(org.camunda.bpm.engine.repository.Deployment) ProcessEngineImpl(org.camunda.bpm.engine.impl.ProcessEngineImpl) RepositoryService(org.camunda.bpm.engine.RepositoryService)

Example 7 with ProcessEngineImpl

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;
}
Also used : ProcessEngineImpl(org.camunda.bpm.engine.impl.ProcessEngineImpl)

Example 8 with ProcessEngineImpl

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();
}
Also used : ManagementServiceImpl(org.camunda.bpm.engine.impl.ManagementServiceImpl) DatabasePurgeReport(org.camunda.bpm.engine.impl.management.DatabasePurgeReport) CachePurgeReport(org.camunda.bpm.engine.impl.persistence.deploy.cache.CachePurgeReport) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) ProcessEngineImpl(org.camunda.bpm.engine.impl.ProcessEngineImpl) PurgeReport(org.camunda.bpm.engine.impl.management.PurgeReport) CachePurgeReport(org.camunda.bpm.engine.impl.persistence.deploy.cache.CachePurgeReport) DatabasePurgeReport(org.camunda.bpm.engine.impl.management.DatabasePurgeReport)

Example 9 with ProcessEngineImpl

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;
    }
}
Also used : CachePurgeReport(org.camunda.bpm.engine.impl.persistence.deploy.cache.CachePurgeReport) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) ProcessEngineImpl(org.camunda.bpm.engine.impl.ProcessEngineImpl)

Example 10 with ProcessEngineImpl

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());
}
Also used : AcquireJobsCmd(org.camunda.bpm.engine.impl.cmd.AcquireJobsCmd) JobExecutor(org.camunda.bpm.engine.impl.jobexecutor.JobExecutor) CommandExecutor(org.camunda.bpm.engine.impl.interceptor.CommandExecutor) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Job(org.camunda.bpm.engine.runtime.Job) Date(java.util.Date) ProcessEngineImpl(org.camunda.bpm.engine.impl.ProcessEngineImpl) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

ProcessEngineImpl (org.camunda.bpm.engine.impl.ProcessEngineImpl)17 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)7 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)5 CommandExecutor (org.camunda.bpm.engine.impl.interceptor.CommandExecutor)3 Charset (java.nio.charset.Charset)2 CachePurgeReport (org.camunda.bpm.engine.impl.persistence.deploy.cache.CachePurgeReport)2 Test (org.junit.Test)2 Date (java.util.Date)1 ProcessEngine (org.camunda.bpm.engine.ProcessEngine)1 ProcessEngineConfiguration (org.camunda.bpm.engine.ProcessEngineConfiguration)1 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)1 RepositoryService (org.camunda.bpm.engine.RepositoryService)1 ManagementServiceImpl (org.camunda.bpm.engine.impl.ManagementServiceImpl)1 StandaloneInMemProcessEngineConfiguration (org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration)1 AcquireJobsCmd (org.camunda.bpm.engine.impl.cmd.AcquireJobsCmd)1 PersistenceSession (org.camunda.bpm.engine.impl.db.PersistenceSession)1 JobExecutor (org.camunda.bpm.engine.impl.jobexecutor.JobExecutor)1 DatabasePurgeReport (org.camunda.bpm.engine.impl.management.DatabasePurgeReport)1 PurgeReport (org.camunda.bpm.engine.impl.management.PurgeReport)1 Deployment (org.camunda.bpm.engine.repository.Deployment)1