Search in sources :

Example 1 with StandaloneInMemProcessEngineConfiguration

use of org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration in project camunda-bpm-platform by camunda.

the class ForceCloseMybatisConnectionPoolTest method testForceCloseMybatisConnectionPoolFalse.

@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);
}
Also used : PoolState(org.apache.ibatis.datasource.pooled.PoolState) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) StandaloneInMemProcessEngineConfiguration(org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration) ProcessEngine(org.camunda.bpm.engine.ProcessEngine) PooledDataSource(org.apache.ibatis.datasource.pooled.PooledDataSource) Test(org.junit.Test)

Example 2 with StandaloneInMemProcessEngineConfiguration

use of org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration in project camunda-bpm-platform by camunda.

the class DatabaseTableSchemaTest method testCreateConfigurationWithMismatchtingSchemaAndPrefix.

public void testCreateConfigurationWithMismatchtingSchemaAndPrefix() {
    try {
        StandaloneInMemProcessEngineConfiguration configuration = new StandaloneInMemProcessEngineConfiguration();
        configuration.setDatabaseSchema("foo");
        configuration.setDatabaseTablePrefix("bar");
        configuration.buildProcessEngine();
        fail("Should throw exception");
    } catch (ProcessEngineException e) {
        // as expected
        assertTrue(e.getMessage().contains("When setting a schema the prefix has to be schema + '.'"));
    }
}
Also used : StandaloneInMemProcessEngineConfiguration(org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 3 with StandaloneInMemProcessEngineConfiguration

use of org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration in project camunda-bpm-platform by camunda.

the class FallbackSerializerFactoryTest method testFallbackSerializerDoesNotOverrideRegularSerializer.

@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());
}
Also used : ObjectValue(org.camunda.bpm.engine.variable.value.ObjectValue) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) StandaloneInMemProcessEngineConfiguration(org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration) Test(org.junit.Test)

Example 4 with StandaloneInMemProcessEngineConfiguration

use of org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration in project camunda-bpm-platform by camunda.

the class FallbackSerializerFactoryTest method testFallbackSerializer.

@Test
public void testFallbackSerializer() {
    // given
    // that the process engine is configured with a fallback serializer factory
    ProcessEngineConfigurationImpl engineConfiguration = new StandaloneInMemProcessEngineConfiguration().setJdbcUrl("jdbc:h2:mem:camunda-forceclose").setProcessEngineName("engine-forceclose");
    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("foo", fetchedValue.getValue());
}
Also used : ObjectValue(org.camunda.bpm.engine.variable.value.ObjectValue) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) StandaloneInMemProcessEngineConfiguration(org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration) Test(org.junit.Test)

Example 5 with StandaloneInMemProcessEngineConfiguration

use of org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration in project camunda-bpm-platform by camunda.

the class HistoryLevelTest method createConfig.

protected ProcessEngineConfigurationImpl createConfig() {
    StandaloneInMemProcessEngineConfiguration configuration = new StandaloneInMemProcessEngineConfiguration();
    configuration.setProcessEngineName("process-engine-HistoryTest");
    configuration.setDbMetricsReporterActivate(false);
    configuration.setJdbcUrl("jdbc:h2:mem:HistoryTest");
    return configuration;
}
Also used : StandaloneInMemProcessEngineConfiguration(org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration)

Aggregations

StandaloneInMemProcessEngineConfiguration (org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration)16 Test (org.junit.Test)8 ProcessEngine (org.camunda.bpm.engine.ProcessEngine)6 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)6 StandaloneProcessEngineConfiguration (org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration)4 Calendar (java.util.Calendar)3 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)3 PoolState (org.apache.ibatis.datasource.pooled.PoolState)2 PooledDataSource (org.apache.ibatis.datasource.pooled.PooledDataSource)2 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)2 ObjectValue (org.camunda.bpm.engine.variable.value.ObjectValue)2 TaskService (org.camunda.bpm.engine.TaskService)1 ProcessEngineImpl (org.camunda.bpm.engine.impl.ProcessEngineImpl)1 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)1 Task (org.camunda.bpm.engine.task.Task)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1