• Home
  • LLMs
  • Docker
  • Kubernetes
  • Java
  • Maven
  • About
MtiTekFlow | About jBPM
  1. References
  2. Using jBPM plugins in Eclipse
  3. jBPM unit testing
  4. jBPM DDL scripts

  1. References
    The documentation of jBPM can be found in:
    jBPM Documentation 7.28.0.Final
    jBPM JavaDocs 7.28.0.Final
  2. Using jBPM plugins in Eclipse
    You can install the jBPM plugins in Eclipse using the folowing URL: http://downloads.jboss.org/jbpm/release/latestFinal/updatesite/

    Among the available plugins, you will use the Eclipse editor for creating BPMN2 processes.

    process editor

    Also you may be interested to create a jBPM project using the assistant plugin that can create an empty project, a sample project, or even download existing projects from jBPM online repository.
  3. jBPM unit testing
    You can add the jBPM-test module to your maven project:

    <dependency>
        <groupId>org.jbpm</groupId>
        <artifactId>jbpm-test</artifactId>
        <version>7.28.0.Final</version>
        <scope>test</scope>
    </dependency>

    Here's a sample unit test code, generated by the jBPM plugin:

    public class ProcessTest extends JbpmJUnitBaseTestCase {
        @Test
        public void test() {
            final RuntimeManager runtimeManager = createRuntimeManager("sample.bpmn");
            final RuntimeEngine runtimeEngine = getRuntimeEngine(null);
            final KieSession kieSession = runtimeEngine.getKieSession();
    
            final ProcessInstance processInstance = kieSession.startProcess("com.sample.bpmn.hello");
    
            assertProcessInstanceCompleted(processInstance.getId(), kieSession);
            assertNodeTriggered(processInstance.getId(), "Hello");
    
            runtimeManager.disposeRuntimeEngine(runtimeEngine);
            runtimeManager.close();
        }
    }

    You can look at the jbpm-test source code (jbpm-test-7.28.0.Final-sources) where you will find some sample codes that will help you understand how jBPM works.
    The main class you may be interested to look at is: org.jbpm.test.JbpmJUnitBaseTestCase

    For example if you are interested to see an example of how to create an instance of the org.kie.api.runtime.manager.RuntimeEnvironmentBuilder:

    RuntimeEnvironmentBuilder builder = RuntimeEnvironmentBuilder.Factory.get().newEmptyBuilder()
        .addConfiguration("drools.processSignalManagerFactory", DefaultSignalManagerFactory.class.getName())
        .addConfiguration("drools.processInstanceManagerFactory", DefaultProcessInstanceManagerFactory.class.getName())
        .registerableItemsFactory(new SimpleRegisterableItemsFactory() {
            @Override
            public Map<String, WorkItemHandler> getWorkItemHandlers(RuntimeEngine runtime) {
                Map<String, WorkItemHandler> handlers = new HashMap<String, WorkItemHandler>();
                handlers.putAll(super.getWorkItemHandlers(runtime));
                handlers.putAll(customHandlers);
                return handlers;
            }
    
            @Override
            public List<ProcessEventListener> getProcessEventListeners(RuntimeEngine runtime) {
                List<ProcessEventListener> listeners = super.getProcessEventListeners(runtime);
                listeners.addAll(customProcessListeners);
                return listeners;
            }
    
            @Override
            public List<AgendaEventListener> getAgendaEventListeners(RuntimeEngine runtime) {
                List<AgendaEventListener> listeners = super.getAgendaEventListeners(runtime);
                listeners.addAll(customAgendaListeners);
                return listeners;
            }
    
            @Override
            public List<TaskLifeCycleEventListener> getTaskListeners() {
                List<TaskLifeCycleEventListener> listeners = super.getTaskListeners();
                listeners.addAll(customTaskListeners);
                return listeners;
            }
        });

    If you are interested to see an example of how to create an instance of the org.kie.api.runtime.manager.RuntimeManager:

    protected RuntimeManager createRuntimeManager(Strategy strategy, Map<String, ResourceType> resources, RuntimeEnvironment environment, String identifier) {
        try {
            switch (strategy) {
            case SINGLETON:
                if (identifier == null) {
                    manager = managerFactory.newSingletonRuntimeManager(environment);
                } else {
                    manager = managerFactory.newSingletonRuntimeManager(environment, identifier);
                }
                break;
            case REQUEST:
                if (identifier == null) {
                    manager = managerFactory.newPerRequestRuntimeManager(environment);
                } else {
                    manager = managerFactory.newPerRequestRuntimeManager(environment, identifier);
                }
                break;
            case PROCESS_INSTANCE:
                if (identifier == null) {
                    manager = managerFactory.newPerProcessInstanceRuntimeManager(environment);
                } else {
                    manager = managerFactory.newPerProcessInstanceRuntimeManager(environment, identifier);
                }
                break;
            default:
                if (identifier == null) {
                    manager = managerFactory.newSingletonRuntimeManager(environment);
                } else {
                    manager = managerFactory.newSingletonRuntimeManager(environment, identifier);
                }
                break;
            }
    
            return manager;
        } catch (Exception e) {
            if (e instanceof BitronixSystemException || e instanceof ClosedChannelException) {
                TransactionManagerServices.getTransactionManager().shutdown();
            }
            throw new RuntimeException(e);
        }
    }

    You can also use the following methods to assert some conditions related to your unit testing:
    - void assertProcessInstanceState(long processInstanceId, Integer expectedState, String message)
    - void assertNodeActive(long processInstanceId, KieSession ksession, String... name)
    - void assertNodeTriggered(long processInstanceId, String... nodeNames)
    - ...
  4. jBPM DDL scripts
    You can download the jBPM DDL scripts from github:
    ► https://github.com/droolsjbpm/jbpm/tree/master/jbpm-installer/src/main/resources/db/ddl-scripts

    Here are the paths where you can find the jBPM DDL scripts for each supported database:

    • db2

    • derby

    • h2

    • hsqldb

    • mysql5

    • mysqlinnodb

    • oracle

    • postgresql

    • sqlserver

    • sqlserver2008

    • sybase
© 2025  mtitek