Java Code Examples for org.flowable.engine.ProcessEngineConfiguration#buildProcessEngine()

The following examples show how to use org.flowable.engine.ProcessEngineConfiguration#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: RecordRuntimeActivitiesTest.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Test
public void mandatoryRecordRuntimeActivities() {
    ProcessEngineConfiguration processEngineConfiguration = new StandaloneInMemProcessEngineConfiguration()
        .setJdbcUrl("jdbc:h2:mem:RecordRuntimeActivitiesTest");
    ProcessEngine processEngine = processEngineConfiguration.buildProcessEngine();

    Deployment deployment = processEngine.getRepositoryService().createDeployment()
        .addClasspathResource("org/flowable/engine/test/api/oneTaskProcess.bpmn20.xml")
        .deploy();

    try {
        processEngine.getRuntimeService().startProcessInstanceByKey("oneTaskProcess");

        assertTrue(processEngine.getRuntimeService().createActivityInstanceQuery().count() > 0L);
    } finally {
        processEngine.getRepositoryService().deleteDeployment(deployment.getId(), true);
        processEngine.close();
    }

}
 
Example 2
Source File: EngineEventsTest.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Test
public void testEngineEventsTest() {
    ProcessEngineConfiguration processEngineConfiguration = StandaloneProcessEngineConfiguration
            .createProcessEngineConfigurationFromResource("org/flowable/standalone/event/flowable-eventlistener.cfg.xml");
    ProcessEngine processEngine = processEngineConfiguration.buildProcessEngine();

    // Fetch the listener to check received events
    TestFlowableEventListener listener = (TestFlowableEventListener) processEngineConfiguration.getBeans().get("eventListener");
    assertThat(listener).isNotNull();

    // Check create-event
    assertThat(listener.getEventsReceived().get(0).getType()).isEqualTo(FlowableEngineEventType.ENGINE_CREATED);
    listener.clearEventsReceived();

    // Check close-event
    processEngine.close();
    assertThat(listener.getEventsReceived().get(listener.getEventsReceived().size() - 1).getType()).isEqualTo(FlowableEngineEventType.ENGINE_CLOSED);
}
 
Example 3
Source File: JobExecutorJMXClientTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Test
public void testJobExecutorJMXClient() throws Exception {
    String hostName = Utils.getHostName();
    JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://" + hostName + ":10111/jndi/rmi://" + hostName + ":1099/jmxrmi/flowable");

    ProcessEngineConfiguration processEngineConfig = ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("flowable.cfg.xml");
    processEngineConfig.buildProcessEngine();

    // wait for jmx server to come up
    Thread.sleep(500);
    JMXConnector jmxc = JMXConnectorFactory.connect(url, null);

    MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();
    ObjectName jobExecutorBeanName = new ObjectName("org.flowable.jmx.Mbeans:type=JobExecutor");

    processEngineConfig.getAsyncExecutor().shutdown();

    // first check that job executor is not activated and correctly reported
    // as being inactive
    assertFalse(processEngineConfig.isAsyncExecutorActivate());
    assertFalse((Boolean) mbsc.getAttribute(jobExecutorBeanName, "JobExecutorActivated"));
    // now activate it remotely
    mbsc.invoke(jobExecutorBeanName, "setJobExecutorActivate", new Boolean[] { true }, new String[] { Boolean.class.getName() });

    // check if it has the effect and correctly reported
    // assertTrue(processEngineConfig.getJobExecutor().isActive());
    assertTrue((Boolean) mbsc.getAttribute(jobExecutorBeanName, "JobExecutorActivated"));

    // again disable and check it
    mbsc.invoke(jobExecutorBeanName, "setJobExecutorActivate", new Boolean[] { false }, new String[] { Boolean.class.getName() });

    // check if it has the effect and correctly reported
    assertFalse(processEngineConfig.isAsyncExecutorActivate());
    assertFalse((Boolean) mbsc.getAttribute(jobExecutorBeanName, "JobExecutorActivated"));
}
 
Example 4
Source File: ProcessEngineInitializationTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
public void testNoTables() {
    try {
        ProcessEngineConfiguration processEngineConfiguration = (ProcessEngineConfiguration) ProcessEngineConfiguration
                .createProcessEngineConfigurationFromResource("org/activiti/standalone/initialization/notables.flowable.cfg.xml")
                .setEventRegistryConfigurator(new CustomEventRegistryEngineConfigurator());
        processEngineConfiguration.buildProcessEngine();
        fail("expected exception");
    } catch (Exception e) {
        // OK
    }
}
 
Example 5
Source File: ResourceFlowableExtension.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
protected ProcessEngine initializeProcessEngine() {
    ProcessEngineConfiguration config = ProcessEngineConfiguration.createProcessEngineConfigurationFromResource(configurationResource);
    if (processEngineName != null) {
        logger.info("Initializing process engine with name '{}'", processEngineName);
        config.setEngineName(processEngineName);
    }
    configurationConsumer.accept(config);
    ProcessEngine processEngine = config.buildProcessEngine();
    ProcessEngines.setInitialized(true);
    return processEngine;
}
 
Example 6
Source File: SpringJmsConfig.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Bean
public ProcessEngine processEngine(ProcessEngineConfiguration processEngineConfiguration) {
    return processEngineConfiguration.buildProcessEngine();
}