use of org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl in project camunda-bpm-platform by camunda.
the class AuthorizationTestRule method finished.
protected void finished(Description description) {
super.finished(description);
ProcessEngineConfigurationImpl engineConfiguration = (ProcessEngineConfigurationImpl) engineRule.getProcessEngine().getProcessEngineConfiguration();
engineConfiguration.getCommandInterceptorsTxRequired().get(0).setNext(interceptor.getNext());
interceptor.setNext(null);
}
use of org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl in project camunda-bpm-platform by camunda.
the class DatabaseTableSchemaTest method testPerformDatabaseSchemaOperationCreateTwice.
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").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();
}
use of org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl in project camunda-bpm-platform by camunda.
the class DatabaseTableSchemaTest method testTablePresentWithSchemaAndPrefix.
public void testTablePresentWithSchemaAndPrefix() throws SQLException {
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.createStatement().execute("create table " + SCHEMA_NAME + "." + PREFIX_NAME + "SOME_TABLE(id varchar(64));");
connection.close();
ProcessEngineConfigurationImpl config1 = createCustomProcessEngineConfiguration().setProcessEngineName("DatabaseTablePrefixTest-engine1").setDataSource(pooledDataSource).setDatabaseSchemaUpdate("NO_CHECK");
config1.setDatabaseTablePrefix(SCHEMA_NAME + "." + PREFIX_NAME);
config1.setDatabaseSchema(SCHEMA_NAME);
config1.setDbMetricsReporterActivate(false);
ProcessEngine engine = config1.buildProcessEngine();
CommandExecutor commandExecutor = config1.getCommandExecutorTxRequired();
commandExecutor.execute(new Command<Void>() {
public Void execute(CommandContext commandContext) {
DbSqlSession sqlSession = commandContext.getSession(DbSqlSession.class);
assertTrue(sqlSession.isTablePresent("SOME_TABLE"));
return null;
}
});
engine.close();
}
use of org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl 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());
}
use of org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl 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());
}
Aggregations