Search in sources :

Example 81 with RuntimeEnvironment

use of org.kie.api.runtime.manager.RuntimeEnvironment in project jbpm by kiegroup.

the class SecurityManagerTest method testNoSecurityManager.

@Test
public void testNoSecurityManager() {
    RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newEmptyBuilder().userGroupCallback(userGroupCallback).addAsset(ResourceFactory.newClassPathResource("BPMN2-ScriptTask.bpmn2"), ResourceType.BPMN2).get();
    manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);
    assertNotNull(manager);
    RuntimeEngine runtime = manager.getRuntimeEngine(EmptyContext.get());
    assertNotNull(runtime);
    manager.disposeRuntimeEngine(runtime);
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) RuntimeEnvironment(org.kie.api.runtime.manager.RuntimeEnvironment) Test(org.junit.Test) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest)

Example 82 with RuntimeEnvironment

use of org.kie.api.runtime.manager.RuntimeEnvironment in project jbpm by kiegroup.

the class SecurityManagerTest method testDenyAllSecurityManager.

@Test(expected = SecurityException.class)
public void testDenyAllSecurityManager() {
    RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newEmptyBuilder().userGroupCallback(userGroupCallback).addAsset(ResourceFactory.newClassPathResource("BPMN2-ScriptTask.bpmn2"), ResourceType.BPMN2).get();
    manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);
    assertNotNull(manager);
    ((InternalRuntimeManager) manager).setSecurityManager(new SecurityManager() {

        @Override
        public void checkPermission() throws SecurityException {
            throw new SecurityException("Deny all on purpose");
        }
    });
    manager.getRuntimeEngine(EmptyContext.get());
}
Also used : RuntimeEnvironment(org.kie.api.runtime.manager.RuntimeEnvironment) InternalRuntimeManager(org.kie.internal.runtime.manager.InternalRuntimeManager) SecurityManager(org.kie.internal.runtime.manager.SecurityManager) Test(org.junit.Test) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest)

Example 83 with RuntimeEnvironment

use of org.kie.api.runtime.manager.RuntimeEnvironment in project jbpm by kiegroup.

the class SecurityManagerTest method testCustomSecurityManager.

@Test(expected = SecurityException.class)
public void testCustomSecurityManager() {
    RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newEmptyBuilder().userGroupCallback(userGroupCallback).addAsset(ResourceFactory.newClassPathResource("BPMN2-ScriptTask.bpmn2"), ResourceType.BPMN2).get();
    manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);
    assertNotNull(manager);
    final User user = new User("john");
    ((InternalRuntimeManager) manager).setSecurityManager(new SecurityManager() {

        @Override
        public void checkPermission() throws SecurityException {
            if ("mary".equals(user.getName())) {
                throw new SecurityException("Mary is not allowed to use runtime manager");
            }
        }
    });
    RuntimeEngine runtime = manager.getRuntimeEngine(EmptyContext.get());
    assertNotNull(runtime);
    manager.disposeRuntimeEngine(runtime);
    user.setName("mary");
    manager.getRuntimeEngine(EmptyContext.get());
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) RuntimeEnvironment(org.kie.api.runtime.manager.RuntimeEnvironment) InternalRuntimeManager(org.kie.internal.runtime.manager.InternalRuntimeManager) SecurityManager(org.kie.internal.runtime.manager.SecurityManager) Test(org.junit.Test) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest)

Example 84 with RuntimeEnvironment

use of org.kie.api.runtime.manager.RuntimeEnvironment in project jbpm by kiegroup.

the class ExecutionErrorHandlingRuntimeManagerTest method createRuntimeManager.

private void createRuntimeManager() {
    RuntimeEnvironment environment = createEnvironment();
    if ("singleton".equals(strategy)) {
        manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment, "first");
    } else if ("processinstance".equals(strategy)) {
        manager = RuntimeManagerFactory.Factory.get().newPerProcessInstanceRuntimeManager(environment, "first");
    } else if ("request".equals(strategy)) {
        manager = RuntimeManagerFactory.Factory.get().newPerRequestRuntimeManager(environment, "first");
    } else if ("case".equals(strategy)) {
        manager = RuntimeManagerFactory.Factory.get().newPerCaseRuntimeManager(environment, "first");
    }
    assertNotNull(manager);
}
Also used : RuntimeEnvironment(org.kie.api.runtime.manager.RuntimeEnvironment)

Example 85 with RuntimeEnvironment

use of org.kie.api.runtime.manager.RuntimeEnvironment in project jbpm by kiegroup.

the class InMemorySessionFactoryLeakTest method createRuntimeManager.

private void createRuntimeManager() {
    RuntimeEnvironment environment = createEnvironment();
    if ("singleton".equals(strategy)) {
        manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment, "first");
    } else if ("processinstance".equals(strategy)) {
        manager = RuntimeManagerFactory.Factory.get().newPerProcessInstanceRuntimeManager(environment, "first");
    } else if ("request".equals(strategy)) {
        manager = RuntimeManagerFactory.Factory.get().newPerRequestRuntimeManager(environment, "first");
    } else if ("case".equals(strategy)) {
        manager = RuntimeManagerFactory.Factory.get().newPerCaseRuntimeManager(environment, "first");
    }
    assertNotNull(manager);
}
Also used : RuntimeEnvironment(org.kie.api.runtime.manager.RuntimeEnvironment)

Aggregations

RuntimeEnvironment (org.kie.api.runtime.manager.RuntimeEnvironment)177 Test (org.junit.Test)163 RuntimeEngine (org.kie.api.runtime.manager.RuntimeEngine)148 KieSession (org.kie.api.runtime.KieSession)127 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)107 AbstractBaseTest (org.jbpm.test.util.AbstractBaseTest)101 NodeLeftCountDownProcessEventListener (org.jbpm.test.listener.NodeLeftCountDownProcessEventListener)51 AbstractExecutorBaseTest (org.jbpm.test.util.AbstractExecutorBaseTest)49 ProcessEventListener (org.kie.api.event.process.ProcessEventListener)48 HashMap (java.util.HashMap)47 DefaultRegisterableItemsFactory (org.jbpm.runtime.manager.impl.DefaultRegisterableItemsFactory)42 WorkItemHandler (org.kie.api.runtime.process.WorkItemHandler)38 ArrayList (java.util.ArrayList)21 TaskSummary (org.kie.api.task.model.TaskSummary)21 NodeTriggeredCountDownProcessEventListener (org.jbpm.test.listener.NodeTriggeredCountDownProcessEventListener)20 AuditService (org.kie.api.runtime.manager.audit.AuditService)20 CountDownAsyncJobListener (org.jbpm.executor.test.CountDownAsyncJobListener)19 SystemOutWorkItemHandler (org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler)19 DefaultProcessEventListener (org.kie.api.event.process.DefaultProcessEventListener)19 InternalRuntimeManager (org.kie.internal.runtime.manager.InternalRuntimeManager)17