Java Code Examples for org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl#buildProcessEngine()

The following examples show how to use org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl#buildProcessEngine() . 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: KeycloakConfigureAdminUserIdAsUsernameTest.java    From camunda-bpm-identity-keycloak with Apache License 2.0 6 votes vote down vote up
public static Test suite() {
    return new TestSetup(new TestSuite(KeycloakConfigureAdminUserIdAsUsernameTest.class)) {

    	// @BeforeClass
        protected void setUp() throws Exception {
    		ProcessEngineConfigurationImpl config = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration
    				.createProcessEngineConfigurationFromResource("camunda.configureAdminUserIdAsUsername.cfg.xml");
    		configureKeycloakIdentityProviderPlugin(config);
    		PluggableProcessEngineTestCase.cachedProcessEngine = config.buildProcessEngine();
        }
        
        // @AfterClass
        protected void tearDown() throws Exception {
    		PluggableProcessEngineTestCase.cachedProcessEngine.close();
    		PluggableProcessEngineTestCase.cachedProcessEngine = null;
        }
    };
}
 
Example 2
Source File: DmnEngineConfigurationTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void setScriptEngineResolver() {
  // given a DMN engine configuration with script engine resolver
  DefaultDmnEngineConfiguration dmnEngineConfiguration = (DefaultDmnEngineConfiguration) DmnEngineConfiguration.createDefaultDmnEngineConfiguration();
  DmnScriptEngineResolver scriptEngineResolver = mock(DmnScriptEngineResolver.class);
  dmnEngineConfiguration.setScriptEngineResolver(scriptEngineResolver);

  ProcessEngineConfigurationImpl processEngineConfiguration = createProcessEngineConfiguration();
  processEngineConfiguration.setDmnEngineConfiguration(dmnEngineConfiguration);

  // when the engine is initialized
  engine = processEngineConfiguration.buildProcessEngine();

  // then the script engine resolver should be set on the DMN engine
  assertThat(getConfigurationOfDmnEngine().getScriptEngineResolver(), is(scriptEngineResolver));
}
 
Example 3
Source File: DmnEngineConfigurationTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void setCustomPostTableExecutionListener() {
  // given a DMN engine configuration with custom listener
  DefaultDmnEngineConfiguration dmnEngineConfiguration = (DefaultDmnEngineConfiguration) DmnEngineConfiguration.createDefaultDmnEngineConfiguration();
  DmnDecisionTableEvaluationListener customEvaluationListener = mock(DmnDecisionTableEvaluationListener.class);
  List<DmnDecisionTableEvaluationListener> customListeners = new ArrayList<DmnDecisionTableEvaluationListener>();
  customListeners.add(customEvaluationListener);
  dmnEngineConfiguration.setCustomPostDecisionTableEvaluationListeners(customListeners);

  ProcessEngineConfigurationImpl processEngineConfiguration = createProcessEngineConfiguration();
  processEngineConfiguration.setDmnEngineConfiguration(dmnEngineConfiguration);

  // when the engine is initialized
  engine = processEngineConfiguration.buildProcessEngine();

  // then the custom listener should be set on the DMN engine
  assertThat(getConfigurationOfDmnEngine().getCustomPostDecisionTableEvaluationListeners(), hasItem(customEvaluationListener));
}
 
Example 4
Source File: KeycloakUseKeycloakIdAsUserIdQueryTest.java    From camunda-bpm-identity-keycloak with Apache License 2.0 6 votes vote down vote up
public static Test suite() {
    return new TestSetup(new TestSuite(KeycloakUseKeycloakIdAsUserIdQueryTest.class)) {

    	// @BeforeClass
        protected void setUp() throws Exception {
    		ProcessEngineConfigurationImpl config = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration
    				.createProcessEngineConfigurationFromResource("camunda.useKeycloakIdAsCamundaUserId.cfg.xml");
    		configureKeycloakIdentityProviderPlugin(config);
    		PluggableProcessEngineTestCase.cachedProcessEngine = config.buildProcessEngine();
        }
        
        // @AfterClass
        protected void tearDown() throws Exception {
    		PluggableProcessEngineTestCase.cachedProcessEngine.close();
    		PluggableProcessEngineTestCase.cachedProcessEngine = null;
        }
    };
}
 
Example 5
Source File: HistoryCleanupOnEngineBootstrapTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldCreateHistoryCleanupJobLogs() {

  final ProcessEngineConfigurationImpl standaloneInMemProcessEngineConfiguration =
      (ProcessEngineConfigurationImpl)ProcessEngineConfiguration
          .createStandaloneInMemProcessEngineConfiguration();
  standaloneInMemProcessEngineConfiguration.setHistoryCleanupBatchWindowStartTime("23:00");
  standaloneInMemProcessEngineConfiguration.setHistoryCleanupBatchWindowEndTime("01:00");
  standaloneInMemProcessEngineConfiguration
      .setJdbcUrl("jdbc:h2:mem:camunda" + getClass().getSimpleName() + "testHistoryCleanupJobScheduled");

  ProcessEngine engine = standaloneInMemProcessEngineConfiguration.buildProcessEngine();
  try {
    List<HistoricJobLog> historicJobLogs = engine.getHistoryService()
                                                 .createHistoricJobLogQuery()
                                                 .jobDefinitionType(HistoryCleanupJobHandler.TYPE)
                                                 .list();
    for (HistoricJobLog historicJobLog : historicJobLogs) {
      assertNotNull(historicJobLog.getHostname());
    }
  } finally {
    closeProcessEngine(engine);
  }
}
 
Example 6
Source File: KeycloakConfigureAdminUserIdAndUseMailAsIdTest.java    From camunda-bpm-identity-keycloak with Apache License 2.0 6 votes vote down vote up
public static Test suite() {
    return new TestSetup(new TestSuite(KeycloakConfigureAdminUserIdAndUseMailAsIdTest.class)) {

    	// @BeforeClass
        protected void setUp() throws Exception {
    		ProcessEngineConfigurationImpl config = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration
    				.createProcessEngineConfigurationFromResource("camunda.configureAdminUserIdAndUseMailAsId.cfg.xml");
    		configureKeycloakIdentityProviderPlugin(config).setAdministratorUserId(USER_ID_CAMUNDA_ADMIN);
    		PluggableProcessEngineTestCase.cachedProcessEngine = config.buildProcessEngine();
        }
        
        // @AfterClass
        protected void tearDown() throws Exception {
    		PluggableProcessEngineTestCase.cachedProcessEngine.close();
    		PluggableProcessEngineTestCase.cachedProcessEngine = null;
        }
    };
}
 
Example 7
Source File: DmnEngineConfigurationTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void setDmnEngineConfigurationOverXmlConfiguration() {
  // given an embedded DMN engine configuration in XML process engine configuration
  // with default expression language
  ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration
      .createProcessEngineConfigurationFromResource(CONFIGURATION_XML);

  // checks that the configuration is set as on XML
  DefaultDmnEngineConfiguration dmnEngineConfiguration = processEngineConfiguration.getDmnEngineConfiguration();
  assertThat(dmnEngineConfiguration, is(notNullValue()));
  assertThat(dmnEngineConfiguration.getDefaultInputExpressionExpressionLanguage(), is("groovy"));

  // when the engine is initialized
  engine = processEngineConfiguration.buildProcessEngine();

  // then the default expression language should be set in the DMN engine
  assertThat(getConfigurationOfDmnEngine().getDefaultInputExpressionExpressionLanguage(), is("groovy"));
}
 
Example 8
Source File: CompetingHistoryCleanupAcquisitionTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void initializeProcessEngine() {
  processEngineConfiguration = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration
    .createProcessEngineConfigurationFromResource("camunda.cfg.xml");

  jobExecutor.setMaxJobsPerAcquisition(1);
  processEngineConfiguration.setJobExecutor(jobExecutor);
  processEngineConfiguration.setHistoryCleanupBatchWindowStartTime("12:00");

  processEngineConfiguration.setCustomPostCommandInterceptorsTxRequiresNew(Collections.<CommandInterceptor>singletonList(new CommandInterceptor() {
    @Override
    public <T> T execute(Command<T> command) {

      T executed = next.execute(command);
      if(syncBeforeFlush.get() != null && syncBeforeFlush.get()) {
        cleanupThread.sync();
      }

      return executed;
    }
  }));

  processEngine = processEngineConfiguration.buildProcessEngine();
}
 
Example 9
Source File: HostnameProviderTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() {
  configuration =
      (ProcessEngineConfigurationImpl) ProcessEngineConfiguration
          .createStandaloneInMemProcessEngineConfiguration();

  configuration
      .setJdbcUrl("jdbc:h2:mem:camunda" + getClass().getSimpleName() + "testHostnameProvider")
      .setProcessEngineName(ENGINE_NAME)
      .setHostname(hostname)
      .setHostnameProvider(hostnameProvider)
      .setMetricsReporterIdProvider(reporterProvider);

  engine = configuration.buildProcessEngine();
  configuration.getMetricsRegistry().markOccurrence("TEST", 1L);
  configuration.getDbMetricsReporter().reportNow();

  managementService = configuration.getManagementService();
}
 
Example 10
Source File: KeycloakConfigureAdminGroupAsPath.java    From camunda-bpm-identity-keycloak with Apache License 2.0 6 votes vote down vote up
public static Test suite() {
    return new TestSetup(new TestSuite(KeycloakConfigureAdminGroupAsPath.class)) {

    	// @BeforeClass
        protected void setUp() throws Exception {
    		ProcessEngineConfigurationImpl config = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration
    				.createProcessEngineConfigurationFromResource("camunda.configureAdminGroupAsPath.cfg.xml");
    		configureKeycloakIdentityProviderPlugin(config);
    		PluggableProcessEngineTestCase.cachedProcessEngine = config.buildProcessEngine();
        }
        
        // @AfterClass
        protected void tearDown() throws Exception {
    		PluggableProcessEngineTestCase.cachedProcessEngine.close();
    		PluggableProcessEngineTestCase.cachedProcessEngine = null;
        }
    };
}
 
Example 11
Source File: ConcurrentHistoryCleanupReconfigureTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void initializeProcessEngine() {
  processEngineConfiguration = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration
    .createProcessEngineConfigurationFromResource("camunda.cfg.xml");

  processEngineConfiguration.setHistoryCleanupBatchWindowStartTime("12:00");

  processEngine = processEngineConfiguration.buildProcessEngine();
}
 
Example 12
Source File: AbstractKeycloakIdentityProviderTest.java    From camunda-bpm-identity-keycloak with Apache License 2.0 5 votes vote down vote up
/**
 * Initializes the process engine using standard configuration camunda.cfg.xml, but
 * replaces the KeyCloakProvider's client secret with the actual test setup.
 * Furthermore it uses a new database for each test class.
 * @return the process engine
 */
private ProcessEngine getOrInitializeCachedProcessEngine() {
	if (cachedProcessEngine == null) {
		ProcessEngineConfigurationImpl config = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration
				.createProcessEngineConfigurationFromResource("camunda.cfg.xml");
		configureKeycloakIdentityProviderPlugin(config);
		config.setJdbcUrl(config.getJdbcUrl().replace("KeycloakIdentityServiceTest", getClass().getSimpleName()));
		cachedProcessEngine = config.buildProcessEngine();
	}
	return cachedProcessEngine;
}
 
Example 13
Source File: FallbackSerializerFactoryTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testFallbackSerializerDoesNotOverrideRegularSerializer() {
  // given
  // that the process engine is configured with a serializer for a certain format
  // and a fallback serializer factory for the same format
   ProcessEngineConfigurationImpl engineConfiguration = new StandaloneInMemProcessEngineConfiguration()
     .setJdbcUrl("jdbc:h2:mem:camunda-forceclose")
     .setProcessEngineName("engine-forceclose");

   engineConfiguration.setCustomPreVariableSerializers(Arrays.<TypedValueSerializer>asList(new ExampleConstantSerializer()));
   engineConfiguration.setFallbackSerializerFactory(new ExampleSerializerFactory());

   processEngine = engineConfiguration.buildProcessEngine();
   deployOneTaskProcess(processEngine);

   // when setting a variable that no regular serializer can handle
   ObjectValue objectValue = Variables.objectValue("foo").serializationDataFormat(ExampleSerializer.FORMAT).create();

   ProcessInstance pi = processEngine.getRuntimeService().startProcessInstanceByKey("oneTaskProcess",
       Variables.createVariables().putValueTyped("var", objectValue));

   ObjectValue fetchedValue = processEngine.getRuntimeService().getVariableTyped(pi.getId(), "var", true);

   // then the fallback serializer is used
   Assert.assertNotNull(fetchedValue);
   Assert.assertEquals(ExampleSerializer.FORMAT, fetchedValue.getSerializationDataFormat());
   Assert.assertEquals(ExampleConstantSerializer.DESERIALIZED_VALUE, fetchedValue.getValue());
}
 
Example 14
Source File: DatabaseTableSchemaTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void testPerformDatabaseSchemaOperationCreateTwice() throws Exception {

    // both process engines will be using this datasource.
    PooledDataSource pooledDataSource = new PooledDataSource(ReflectUtil.getClassLoader(), "org.h2.Driver",
        "jdbc:h2:mem:DatabaseTablePrefixTest;DB_CLOSE_DELAY=1000", "sa", "");

    Connection connection = pooledDataSource.getConnection();
    connection.createStatement().execute("drop schema if exists " + SCHEMA_NAME);
    connection.createStatement().execute("create schema " + SCHEMA_NAME);
    connection.close();

    ProcessEngineConfigurationImpl config1 = createCustomProcessEngineConfiguration().setProcessEngineName("DatabaseTablePrefixTest-engine1")
    // disable auto create/drop schema
        .setDataSource(pooledDataSource).setDatabaseSchemaUpdate("NO_CHECK");
    config1.setDatabaseTablePrefix(SCHEMA_NAME + ".");
    config1.setDatabaseSchema(SCHEMA_NAME);
    config1.setDbMetricsReporterActivate(false);
    ProcessEngine engine1 = config1.buildProcessEngine();

    // create the tables for the first time
    connection = pooledDataSource.getConnection();
    connection.createStatement().execute("set schema " + SCHEMA_NAME);
    engine1.getManagementService().databaseSchemaUpgrade(connection, "", SCHEMA_NAME);
    connection.close();
    // create the tables for the second time; here we shouldn't crash since the
    // session should tell us that the tables are already present and
    // databaseSchemaUpdate is set to noop
    connection = pooledDataSource.getConnection();
    connection.createStatement().execute("set schema " + SCHEMA_NAME);
    engine1.getManagementService().databaseSchemaUpgrade(connection, "", SCHEMA_NAME);
    engine1.close();
  }
 
Example 15
Source File: TestFixture.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
  ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration
    .createProcessEngineConfigurationFromResource("camunda.cfg.xml");
  ProcessEngine processEngine = processEngineConfiguration.buildProcessEngine();

  // register test scenarios
  ScenarioRunner runner = new ScenarioRunner(processEngine, ENGINE_VERSION);

  // example scenario setup
  // runner.setupScenarios(ExampleScenario.class);

  processEngine.close();
}
 
Example 16
Source File: JPAVariableTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void setUp() throws Exception {
  ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration
      .createProcessEngineConfigurationFromResource("org/camunda/bpm/engine/test/standalone/jpa/camunda.cfg.xml");

  processEngineConfiguration.setJavaSerializationFormatEnabled(true);

  cachedProcessEngine = processEngineConfiguration.buildProcessEngine();

  EntityManagerSessionFactory entityManagerSessionFactory = (EntityManagerSessionFactory) processEngineConfiguration
    .getSessionFactories()
    .get(EntityManagerSession.class);

  entityManagerFactory = entityManagerSessionFactory.getEntityManagerFactory();
}
 
Example 17
Source File: TestFixture.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
  ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration
    .createProcessEngineConfigurationFromResource("camunda.cfg.xml");
  ProcessEngine processEngine = processEngineConfiguration.buildProcessEngine();

  // register test scenarios
  ScenarioRunner runner = new ScenarioRunner(processEngine, ENGINE_VERSION);

  // compensation
  runner.setupScenarios(CreateProcessInstanceWithVariableScenario.class);

  processEngine.close();
}
 
Example 18
Source File: TestFixture.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
  ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration
    .createProcessEngineConfigurationFromResource("camunda.cfg.xml");
  ProcessEngine processEngine = processEngineConfiguration.buildProcessEngine();

  // register test scenarios
  ScenarioRunner runner = new ScenarioRunner(processEngine, ENGINE_VERSION);

  runner.setupScenarios(DeleteHistoricDecisionsBatchScenario.class);
  runner.setupScenarios(DeleteHistoricProcessInstancesBatchScenario.class);
  runner.setupScenarios(DeleteProcessInstancesBatchScenario.class);
  runner.setupScenarios(SetExternalTaskRetriesBatchScenario.class);
  runner.setupScenarios(SetJobRetriesBatchScenario.class);
  runner.setupScenarios(UpdateProcessInstanceSuspendStateBatchScenario.class);
  runner.setupScenarios(RestartProcessInstanceBatchScenario.class);
  runner.setupScenarios(TimerChangeProcessDefinitionScenario.class);
  runner.setupScenarios(TimerChangeJobDefinitionScenario.class);
  runner.setupScenarios(ModificationBatchScenario.class);
  runner.setupScenarios(ProcessInstanceModificationScenario.class);
  runner.setupScenarios(MigrationBatchScenario.class);
  runner.setupScenarios(TaskFilterScenario.class);
  runner.setupScenarios(TaskFilterVariablesScenario.class);
  runner.setupScenarios(TaskFilterPropertiesScenario.class);
  runner.setupScenarios(DeploymentDeployTimeScenario.class);
  runner.setupScenarios(JobTimestampsScenario.class);
  runner.setupScenarios(IncidentTimestampScenario.class);
  runner.setupScenarios(TaskCreateTimeScenario.class);
  runner.setupScenarios(ExternalTaskLockExpTimeScenario.class);
  runner.setupScenarios(EventSubscriptionCreateTimeScenario.class);
  runner.setupScenarios(MeterLogTimestampScenario.class);
  runner.setupScenarios(UserLockExpTimeScenario.class);
  runner.setupScenarios(CreateStandaloneTaskScenario.class);
  runner.setupScenarios(SetAssigneeProcessInstanceTaskScenario.class);
  runner.setupScenarios(CreateStandaloneTaskDeleteScenario.class);
  runner.setupScenarios(SuspendProcessDefinitionDeleteScenario.class);
  runner.setupScenarios(AuthorizationCheckProcessDefinitionScenario.class);
  runner.setupScenarios(NoAuthorizationCheckScenario.class);

  processEngine.close();
}
 
Example 19
Source File: ForceCloseMybatisConnectionPoolTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testForceCloseMybatisConnectionPoolFalse() {

  // given
  // that the process engine is configured with forceCloseMybatisConnectionPool = false
  ProcessEngineConfigurationImpl configurationImpl = new StandaloneInMemProcessEngineConfiguration()
   .setJdbcUrl("jdbc:h2:mem:camunda-forceclose")
   .setProcessEngineName("engine-forceclose")
   .setForceCloseMybatisConnectionPool(false);

  ProcessEngine processEngine = configurationImpl
   .buildProcessEngine();

  PooledDataSource pooledDataSource = (PooledDataSource) configurationImpl.getDataSource();
  PoolState state = pooledDataSource.getPoolState();
  int idleConnections = state.getIdleConnectionCount();


  // then
  // if the process engine is closed
  processEngine.close();

  // the idle connections are not closed
  Assert.assertEquals(state.getIdleConnectionCount(), idleConnections);

  pooledDataSource.forceCloseAll();

  Assert.assertTrue(state.getIdleConnectionCount() == 0);
}
 
Example 20
Source File: TestFixture.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
  ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration
    .createProcessEngineConfigurationFromResource("camunda.cfg.xml");
  ProcessEngine processEngine = processEngineConfiguration.buildProcessEngine();

  // register test scenarios
  ScenarioRunner runner = new ScenarioRunner(processEngine, ENGINE_VERSION);

  // cmmn sentries
  runner.setupScenarios(SentryScenario.class);

  // compensation
  runner.setupScenarios(SingleActivityCompensationScenario.class);
  runner.setupScenarios(NestedCompensationScenario.class);
  runner.setupScenarios(SingleActivityConcurrentCompensationScenario.class);
  runner.setupScenarios(ParallelMultiInstanceCompensationScenario.class);
  runner.setupScenarios(SequentialMultiInstanceCompensationScenario.class);
  runner.setupScenarios(NestedMultiInstanceCompensationScenario.class);
  runner.setupScenarios(InterruptingEventSubProcessCompensationScenario.class);
  runner.setupScenarios(NonInterruptingEventSubProcessCompensationScenario.class);
  runner.setupScenarios(InterruptingEventSubProcessNestedCompensationScenario.class);

  // job
  runner.setupScenarios(JobMigrationScenario.class);

  // boundary events
  runner.setupScenarios(NonInterruptingBoundaryEventScenario.class);

  processEngine.close();
}