org.camunda.bpm.engine.impl.ProcessEngineImpl Java Examples

The following examples show how to use org.camunda.bpm.engine.impl.ProcessEngineImpl. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DatabaseHistoryPropertyAutoTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void usesDefaultValueAuditWhenNoValueIsConfigured() {
  final ProcessEngineConfigurationImpl config = config("true", ProcessEngineConfiguration.HISTORY_AUTO);
  ProcessEngineImpl processEngine = buildEngine(config);

  final Integer level = config.getCommandExecutorSchemaOperations().execute(new Command<Integer>() {
    @Override
    public Integer execute(CommandContext commandContext) {
      return HistoryLevelSetupCommand.databaseHistoryLevel(commandContext);
    }
  });

  assertThat(level, equalTo(HistoryLevel.HISTORY_LEVEL_AUDIT.getId()));

  assertThat(processEngine.getProcessEngineConfiguration().getHistoryLevel(), equalTo(HistoryLevel.HISTORY_LEVEL_AUDIT));
}
 
Example #2
Source File: TestHelper.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
  }
}
 
Example #3
Source File: UpgradedDBDropper.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
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();
  }
 
Example #4
Source File: EmbeddedProcessApplicationTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void testDeployAppWithCustomEngine() {

    TestApplicationWithCustomEngine processApplication = new TestApplicationWithCustomEngine();
    processApplication.deploy();

    ProcessEngine processEngine = BpmPlatform.getProcessEngineService().getProcessEngine("embeddedEngine");
    assertNotNull(processEngine);
    assertEquals("embeddedEngine", processEngine.getName());

    ProcessEngineConfiguration configuration = ((ProcessEngineImpl) processEngine).getProcessEngineConfiguration();

    // assert engine properties specified
    assertTrue(configuration.isJobExecutorDeploymentAware());
    assertTrue(configuration.isJobExecutorPreferTimerJobs());
    assertTrue(configuration.isJobExecutorAcquireByDueDate());
    assertEquals(5, configuration.getJdbcMaxActiveConnections());

    processApplication.undeploy();

  }
 
Example #5
Source File: AbstractFoxPlatformIntegrationTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Before
public void setupBeforeTest() {
  processEngineService = BpmPlatform.getProcessEngineService();
  processEngine = processEngineService.getDefaultProcessEngine();
  processEngineConfiguration = ((ProcessEngineImpl)processEngine).getProcessEngineConfiguration();
  processEngineConfiguration.getJobExecutor().shutdown(); // make sure the job executor is down
  formService = processEngine.getFormService();
  historyService = processEngine.getHistoryService();
  identityService = processEngine.getIdentityService();
  managementService = processEngine.getManagementService();
  repositoryService = processEngine.getRepositoryService();
  runtimeService = processEngine.getRuntimeService();
  taskService = processEngine.getTaskService();
  caseService = processEngine.getCaseService();
  decisionService = processEngine.getDecisionService();
}
 
Example #6
Source File: SequentialJobAcquisitionRunnable.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void executeJobs(JobAcquisitionContext context, ProcessEngineImpl currentProcessEngine, AcquiredJobs acquiredJobs) {
  // submit those jobs that were acquired in previous cycles but could not be scheduled for execution
  List<List<String>> additionalJobs = context.getAdditionalJobsByEngine().get(currentProcessEngine.getName());
  if (additionalJobs != null) {
    for (List<String> jobBatch : additionalJobs) {
      LOG.executeJobs(currentProcessEngine.getName(), jobBatch);

      jobExecutor.executeJobs(jobBatch, currentProcessEngine);
    }
  }

  // submit those jobs that were acquired in the current cycle
  for (List<String> jobIds : acquiredJobs.getJobIdBatches()) {
    LOG.executeJobs(currentProcessEngine.getName(), jobIds);

    jobExecutor.executeJobs(jobIds, currentProcessEngine);
  }
}
 
Example #7
Source File: JobAcquisitionBackoffTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
  jobExecutor1 = (ControllableJobExecutor)
      ((ProcessEngineConfigurationImpl) engineRule.getProcessEngine().getProcessEngineConfiguration())
        .getJobExecutor();
  jobExecutor1.setMaxJobsPerAcquisition(DEFAULT_NUM_JOBS_TO_ACQUIRE);
  jobExecutor1.setBackoffTimeInMillis(BASE_BACKOFF_TIME);
  jobExecutor1.setMaxBackoff(MAX_BACKOFF_TIME);
  jobExecutor1.setBackoffDecreaseThreshold(BACKOFF_DECREASE_THRESHOLD);
  acquisitionThread1 = jobExecutor1.getAcquisitionThreadControl();

  jobExecutor2 = new ControllableJobExecutor((ProcessEngineImpl) engineRule.getProcessEngine());
  jobExecutor2.setMaxJobsPerAcquisition(DEFAULT_NUM_JOBS_TO_ACQUIRE);
  jobExecutor2.setBackoffTimeInMillis(BASE_BACKOFF_TIME);
  jobExecutor2.setMaxBackoff(MAX_BACKOFF_TIME);
  jobExecutor2.setBackoffDecreaseThreshold(BACKOFF_DECREASE_THRESHOLD);
  acquisitionThread2 = jobExecutor2.getAcquisitionThreadControl();
}
 
Example #8
Source File: FetchAndLockHandlerImpl.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Override
public void shutdown() {
  try {
    ProcessEngineImpl.EXT_TASK_CONDITIONS.removeConsumer(condition);
  }
  finally {
    isRunning = false;
    condition.signal();
  }

  try {
    handlerThread.join();
  } catch (InterruptedException e) {
    LOG.log(Level.WARNING, "Shutting down the handler thread failed: {0}", e);
  }
}
 
Example #9
Source File: ElasticSearchClientProvider.java    From camunda-bpm-elasticsearch with Apache License 2.0 6 votes vote down vote up
protected static void createClient(ProcessEngine processEngine) {
  List<ProcessEnginePlugin> processEnginePlugins = ((ProcessEngineImpl) processEngine).getProcessEngineConfiguration()
    .getProcessEnginePlugins();

  // check whether process enigne has elastic search plugin configured
  for (ProcessEnginePlugin processEnginePlugin : processEnginePlugins) {
    if (processEnginePlugin instanceof ElasticSearchHistoryPlugin) {
      ElasticSearchHistoryPlugin historyPlugin = (ElasticSearchHistoryPlugin) processEnginePlugin;
      cachedClient = historyPlugin.getElasticSearchClient();
      break;
    }
  }

  if(cachedClient == null) {
    // create new client from classpath configuration
    ElasticSearchHistoryPluginConfiguration elasticSearchPluginConfiguration = ElasticSearchHistoryPluginConfiguration.readConfigurationFromClasspath();
    cachedClient = new ElasticSearchClient(elasticSearchPluginConfiguration);
  }
}
 
Example #10
Source File: AbstractElasticSearchTest.java    From camunda-bpm-elasticsearch with Apache License 2.0 6 votes vote down vote up
@Before
public void initialize() {
  ElasticSearchHistoryPluginConfiguration historyPluginConfiguration = ElasticSearchHistoryPluginConfiguration.readConfigurationFromClasspath();
  ElasticSearchHelper.checkIndex(client, historyPluginConfiguration.getIndex());
  ElasticSearchHelper.checkTypeAndMapping(client, historyPluginConfiguration.getIndex(), historyPluginConfiguration.getType());

  List<ProcessEnginePlugin> processEnginePlugins = ((ProcessEngineImpl) processEngineRule.getProcessEngine())
      .getProcessEngineConfiguration()
      .getProcessEnginePlugins();
  for (ProcessEnginePlugin processEnginePlugin : processEnginePlugins) {
    if (processEnginePlugin instanceof ElasticSearchHistoryPlugin) {
      ElasticSearchHistoryPlugin plugin = (ElasticSearchHistoryPlugin) processEnginePlugin;
      plugin.setElasticSearchClient(client);
    }
  }
}
 
Example #11
Source File: JobExecutorMetricsTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = "org/camunda/bpm/engine/test/api/mgmt/metrics/asyncServiceTaskProcess.bpmn20.xml")
@Test
public void testJobRejectedExecutionMetricReporting() {
  // replace job executor with one that rejects all jobs
  RejectingJobExecutor rejectingExecutor = new RejectingJobExecutor();
  processEngineConfiguration.setJobExecutor(rejectingExecutor);
  rejectingExecutor.registerProcessEngine((ProcessEngineImpl) processEngine);

  // given three jobs
  for (int i = 0; i < 3; i++) {
    runtimeService.startProcessInstanceByKey("asyncServiceTaskProcess");
  }

  // when executing the jobs
  testRule.waitForJobExecutorToProcessAllJobs(5000L);

  // then all of them were rejected by the job executor which is reflected by the metric
  long numRejectedJobs = managementService.createMetricsQuery().name(Metrics.JOB_EXECUTION_REJECTED).sum();

  assertEquals(3, numRejectedJobs);
}
 
Example #12
Source File: ThreadPoolJobExecutor.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void executeJobs(List<String> jobIds, ProcessEngineImpl processEngine) {
  try {
    threadPoolExecutor.execute(getExecuteJobsRunnable(jobIds, processEngine));

  } catch (RejectedExecutionException e) {

    logRejectedExecution(processEngine, jobIds.size());
    rejectedJobsHandler.jobsRejected(jobIds, processEngine, this);

  }
}
 
Example #13
Source File: JobExecutor.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void logAcquisitionAttempt(ProcessEngineImpl engine) {
  if (engine.getProcessEngineConfiguration().isMetricsEnabled()) {
    engine.getProcessEngineConfiguration()
      .getMetricsRegistry()
      .markOccurrence(Metrics.JOB_ACQUISITION_ATTEMPT);
  }
}
 
Example #14
Source File: SequentialJobAcquisitionRunnable.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected AcquiredJobs acquireJobs(
    JobAcquisitionContext context,
    JobAcquisitionStrategy acquisitionStrategy,
    ProcessEngineImpl currentProcessEngine) {
  CommandExecutor commandExecutor = currentProcessEngine.getProcessEngineConfiguration()
      .getCommandExecutorTxRequired();

  int numJobsToAcquire = acquisitionStrategy.getNumJobsToAcquire(currentProcessEngine.getName());

  AcquiredJobs acquiredJobs = null;

  if (numJobsToAcquire > 0) {
    jobExecutor.logAcquisitionAttempt(currentProcessEngine);
    acquiredJobs = commandExecutor.execute(jobExecutor.getAcquireJobsCmd(numJobsToAcquire));
  }
  else {
    acquiredJobs = new AcquiredJobs(numJobsToAcquire);
  }

  context.submitAcquiredJobs(currentProcessEngine.getName(), acquiredJobs);

  jobExecutor.logAcquiredJobs(currentProcessEngine, acquiredJobs.size());
  jobExecutor.logAcquisitionFailureJobs(currentProcessEngine, acquiredJobs.getNumberOfJobsFailedToLock());

  LOG.acquiredJobs(currentProcessEngine.getName(), acquiredJobs);

  return acquiredJobs;
}
 
Example #15
Source File: RuntimeContainerJobExecutor.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void executeJobs(List<String> jobIds, ProcessEngineImpl processEngine) {

    final RuntimeContainerDelegate runtimeContainerDelegate = getRuntimeContainerDelegate();
    final ExecutorService executorService = runtimeContainerDelegate.getExecutorService();

    Runnable executeJobsRunnable = getExecuteJobsRunnable(jobIds, processEngine);

    // delegate job execution to runtime container
    if(!executorService.schedule(executeJobsRunnable, false)) {

      logRejectedExecution(processEngine, jobIds.size());
      rejectedJobsHandler.jobsRejected(jobIds, processEngine, this);
    }
  }
 
Example #16
Source File: JobAcquisitionTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
  // two job executors with the default settings
  jobExecutor1 = (ControllableJobExecutor)
      ((ProcessEngineConfigurationImpl) engineRule.getProcessEngine().getProcessEngineConfiguration())
      .getJobExecutor();
  jobExecutor1.setMaxJobsPerAcquisition(DEFAULT_NUM_JOBS_TO_ACQUIRE);
  acquisitionThread1 = jobExecutor1.getAcquisitionThreadControl();

  jobExecutor2 = new ControllableJobExecutor((ProcessEngineImpl) engineRule.getProcessEngine());
  jobExecutor2.setMaxJobsPerAcquisition(DEFAULT_NUM_JOBS_TO_ACQUIRE);
  acquisitionThread2 = jobExecutor2.getAcquisitionThreadControl();
}
 
Example #17
Source File: ProcessEngineJobExecutorPerformanceTestCase.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
@Before
public void setup() {
  super.setup();
  ProcessEngineConfigurationImpl engineConfiguration = ((ProcessEngineImpl) engine).getProcessEngineConfiguration();
  jobExecutor = engineConfiguration.getJobExecutor();
  jobExecutor.start();
}
 
Example #18
Source File: DetermineHistoryLevelCmdTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void failWhenExistingHistoryLevelIsNotRegistered() {
  // init the db with custom level
  HistoryLevel customLevel = new HistoryLevel() {
    @Override
    public int getId() {
      return 99;
    }

    @Override
    public String getName() {
      return "custom";
    }

    @Override
    public boolean isHistoryEventProduced(HistoryEventType eventType, Object entity) {
      return false;
    }
  };
  ProcessEngineConfigurationImpl config = config("true", "custom");
  config.setCustomHistoryLevels(Arrays.asList(customLevel));
  processEngineImpl = (ProcessEngineImpl) config.buildProcessEngine();

  thrown.expect(ProcessEngineException.class);
  thrown.expectMessage("The configured history level with id='99' is not registered in this config.");

  config.getCommandExecutorSchemaOperations().execute(
      new DetermineHistoryLevelCmd(Collections.<HistoryLevel>emptyList()));
}
 
Example #19
Source File: DetermineHistoryLevelCmdTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void useDefaultLevelAudit() throws Exception {
  ProcessEngineConfigurationImpl config = config("true", ProcessEngineConfiguration.HISTORY_AUTO);

  // init the db with level=auto -> audit
  processEngineImpl = (ProcessEngineImpl) config.buildProcessEngine();
  // the history Level has been overwritten with audit
  assertThat(config.getHistoryLevel(), CoreMatchers.equalTo(HistoryLevel.HISTORY_LEVEL_AUDIT));

  // and this is written to the database
  HistoryLevel databaseLevel =
      config.getCommandExecutorSchemaOperations().execute(new DetermineHistoryLevelCmd(config.getHistoryLevels()));
  assertThat(databaseLevel, CoreMatchers.equalTo(HistoryLevel.HISTORY_LEVEL_AUDIT));
}
 
Example #20
Source File: TestHelper.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
/**
 * 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(
        purgeReport.getDatabasePurgeReport().isDbContainsLicenseKey() ? "Database contains license key but is considered clean." : "Database was clean.");
  }
  if (paRegistrationMessage != null) {
    message.append(paRegistrationMessage);
  }

  if (fail && message.length() > 0) {
    Assert.fail(message.toString());
  }

  return message.toString();
}
 
Example #21
Source File: ProcessEngineRule.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void initializeServices() {
  processEngineConfiguration = ((ProcessEngineImpl) processEngine).getProcessEngineConfiguration();
  repositoryService = processEngine.getRepositoryService();
  runtimeService = processEngine.getRuntimeService();
  taskService = processEngine.getTaskService();
  historyService = processEngine.getHistoryService();
  identityService = processEngine.getIdentityService();
  managementService = processEngine.getManagementService();
  formService = processEngine.getFormService();
  authorizationService = processEngine.getAuthorizationService();
  caseService = processEngine.getCaseService();
  filterService = processEngine.getFilterService();
  externalTaskService = processEngine.getExternalTaskService();
  decisionService = processEngine.getDecisionService();
}
 
Example #22
Source File: DetermineHistoryLevelCmdTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void readLevelFullfromDB() throws Exception {
  final ProcessEngineConfigurationImpl config = config("true", ProcessEngineConfiguration.HISTORY_FULL);

  // init the db with level=full
  processEngineImpl = (ProcessEngineImpl) config.buildProcessEngine();

  HistoryLevel historyLevel = config.getCommandExecutorSchemaOperations().execute(new DetermineHistoryLevelCmd(config.getHistoryLevels()));

  assertThat(historyLevel, CoreMatchers.equalTo(HistoryLevel.HISTORY_LEVEL_FULL));
}
 
Example #23
Source File: ExternalTaskConditionsTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@After
public void tearDown() {

  ProcessEngineImpl.EXT_TASK_CONDITIONS.removeConsumer(condition);

  if (deploymentId != null) {
    rule.getRepositoryService().deleteDeployment(deploymentId, true);
  }
}
 
Example #24
Source File: SpringJobExecutor.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void executeJobs(List<String> jobIds, ProcessEngineImpl processEngine) {
  try {
     taskExecutor.execute(getExecuteJobsRunnable(jobIds, processEngine));
   } catch (RejectedExecutionException e) {

     logRejectedExecution(processEngine, jobIds.size());
     rejectedJobsHandler.jobsRejected(jobIds, processEngine, this);
   }
}
 
Example #25
Source File: DatabaseHistoryPropertyTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
private static ProcessEngineImpl createProcessEngineImpl(String databaseSchemaUpdate, boolean executeSchemaOperations) {
  ProcessEngineImpl processEngine = 
      (ProcessEngineImpl) new CustomStandaloneInMemProcessEngineConfiguration()
             .setExecuteSchemaOperations(executeSchemaOperations)
             .setProcessEngineName("database-history-test-engine")
             .setDatabaseSchemaUpdate(databaseSchemaUpdate)
             .setHistory(ProcessEngineConfiguration.HISTORY_FULL)
             .setJdbcUrl("jdbc:h2:mem:DatabaseHistoryPropertyTest")
             .buildProcessEngine();
  
  return processEngine;
}
 
Example #26
Source File: DatabaseHistoryPropertyAutoTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void secondEngineCopiesHistoryLevelFromFirst() {
  // given
  buildEngine(config("true", ProcessEngineConfiguration.HISTORY_FULL));

  // when
  ProcessEngineImpl processEngineTwo = buildEngine(config("true", ProcessEngineConfiguration.HISTORY_AUTO));

  // then
  assertThat(processEngineTwo.getProcessEngineConfiguration().getHistory(), is(ProcessEngineConfiguration.HISTORY_AUTO));
  assertThat(processEngineTwo.getProcessEngineConfiguration().getHistoryLevel(), is(HistoryLevel.HISTORY_LEVEL_FULL));

}
 
Example #27
Source File: DatabaseHistoryPropertyAutoTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@After
public void after() {
  for (ProcessEngineImpl engine : processEngines) {
    // no need to drop schema when testing with h2
    engine.close();
  }

  processEngines.clear();
}
 
Example #28
Source File: ExternalTaskConditionsTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {

  MockitoAnnotations.initMocks(this);

  ProcessEngineImpl.EXT_TASK_CONDITIONS.addConsumer(condition);

  deploymentId = rule.getRepositoryService()
      .createDeployment()
      .addModelInstance("process.bpmn", testProcess)
      .deploy()
      .getId();
}
 
Example #29
Source File: BuiltInValidatorsTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void testDefaultFormFieldValidators() {

    // assert default validators are registered
    FormValidators formValidators = ((ProcessEngineImpl) processEngine).getProcessEngineConfiguration().getFormValidators();

    Map<String, Class<? extends FormFieldValidator>> validators = formValidators.getValidators();
    assertEquals(RequiredValidator.class, validators.get("required"));
    assertEquals(ReadOnlyValidator.class, validators.get("readonly"));
    assertEquals(MinValidator.class, validators.get("min"));
    assertEquals(MaxValidator.class, validators.get("max"));
    assertEquals(MaxLengthValidator.class, validators.get("maxlength"));
    assertEquals(MinLengthValidator.class, validators.get("minlength"));

  }
 
Example #30
Source File: ManagementServiceTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@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());
}