Search in sources :

Example 11 with PersistableRunner

use of org.drools.persistence.PersistableRunner in project jbpm by kiegroup.

the class SingleSessionCommandServiceTest method testPersistenceTimer2.

@Test
public void testPersistenceTimer2() throws Exception {
    setUp();
    Properties properties = new Properties();
    properties.setProperty("drools.commandService", PersistableRunner.class.getName());
    properties.setProperty("drools.processInstanceManagerFactory", JPAProcessInstanceManagerFactory.class.getName());
    properties.setProperty("drools.workItemManagerFactory", JPAWorkItemManagerFactory.class.getName());
    properties.setProperty("drools.processSignalManagerFactory", JPASignalManagerFactory.class.getName());
    SessionConfiguration config = SessionConfiguration.newInstance(properties);
    config.setOption(TimerJobFactoryOption.get(TimerJobFactoryType.JPA.getId()));
    InternalKnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
    Collection<KiePackage> kpkgs = getProcessTimer2();
    kbase.addPackages(kpkgs);
    PersistableRunner service = new PersistableRunner(kbase, config, env);
    Long sessionId = service.getSessionId();
    StartProcessCommand startProcessCommand = new StartProcessCommand();
    startProcessCommand.setProcessId("org.drools.test.TestProcess");
    ProcessInstance processInstance = service.execute(startProcessCommand);
    logger.info("Started process instance {}", processInstance.getId());
    Thread.sleep(2000);
    service = new PersistableRunner(sessionId, kbase, config, env);
    GetProcessInstanceCommand getProcessInstanceCommand = new GetProcessInstanceCommand();
    getProcessInstanceCommand.setProcessInstanceId(processInstance.getId());
    processInstance = service.execute(getProcessInstanceCommand);
    assertNull(processInstance);
}
Also used : JPASignalManagerFactory(org.jbpm.persistence.processinstance.JPASignalManagerFactory) Properties(java.util.Properties) JPAWorkItemManagerFactory(org.drools.persistence.jpa.processinstance.JPAWorkItemManagerFactory) StartProcessCommand(org.drools.core.command.runtime.process.StartProcessCommand) PersistableRunner(org.drools.persistence.PersistableRunner) GetProcessInstanceCommand(org.drools.core.command.runtime.process.GetProcessInstanceCommand) KiePackage(org.kie.api.definition.KiePackage) JPAProcessInstanceManagerFactory(org.jbpm.persistence.processinstance.JPAProcessInstanceManagerFactory) RuleFlowProcessInstance(org.jbpm.ruleflow.instance.RuleFlowProcessInstance) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) SessionConfiguration(org.drools.core.SessionConfiguration) InternalKnowledgeBase(org.drools.core.impl.InternalKnowledgeBase) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest) Test(org.junit.Test)

Aggregations

PersistableRunner (org.drools.persistence.PersistableRunner)11 Test (org.junit.Test)8 AbstractBaseTest (org.jbpm.test.util.AbstractBaseTest)6 Properties (java.util.Properties)5 SessionConfiguration (org.drools.core.SessionConfiguration)5 GetProcessInstanceCommand (org.drools.core.command.runtime.process.GetProcessInstanceCommand)5 StartProcessCommand (org.drools.core.command.runtime.process.StartProcessCommand)5 InternalKnowledgeBase (org.drools.core.impl.InternalKnowledgeBase)5 JPAWorkItemManagerFactory (org.drools.persistence.jpa.processinstance.JPAWorkItemManagerFactory)5 JPAProcessInstanceManagerFactory (org.jbpm.persistence.processinstance.JPAProcessInstanceManagerFactory)5 JPASignalManagerFactory (org.jbpm.persistence.processinstance.JPASignalManagerFactory)5 RuleFlowProcessInstance (org.jbpm.ruleflow.instance.RuleFlowProcessInstance)5 KiePackage (org.kie.api.definition.KiePackage)5 KieSession (org.kie.api.runtime.KieSession)5 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)5 KieBase (org.kie.api.KieBase)4 ArrayList (java.util.ArrayList)3 UserTransaction (javax.transaction.UserTransaction)3 FireAllRulesInterceptor (org.drools.core.command.impl.FireAllRulesInterceptor)3 LoggingInterceptor (org.drools.core.command.impl.LoggingInterceptor)3