The method createProcessEngineConfigurationFromResourceDefault() will also look for the activiti.cfg.xml file, and now we only need to call the buildProcessEngine() API.

In this case, the default bean name it looks for is processEngineConfiguration. If we want to change the config file name or the bean name, we can use other available methods for creating the ProcessEngineConfiguration.

Let's have a look at a few examples.

First, we'll change the configuration file name and ask the API to use our custom file:

Of course, now that the configuration is expecting different names, we need to change the filename (and the bean name) to match – before running the test.

Other available options to create the engine are createProcessEngineConfigurationFromInputStream(InputStream inputStream),createProcessEngineConfigurationFromInputStream(InputStream inputStream, String beanName).

If we don't want to use XML config, we can also set things up using Java config only.

We're going to work with four different classes; each of these represents a different environment:

org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration – the ProcessEngine is used in a standalone way, backed by the DB

org.activiti.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration – by default, an H2 in-memory database is used. The DB is created and dropped when the engine starts and shuts down – hence, this configuration style can be used for testing

org.activiti.spring.SpringProcessEngineConfiguration – to be used in Spring environment