Search in sources :

Example 56 with DeploymentDescriptor

use of org.kie.internal.runtime.conf.DeploymentDescriptor in project jbpm by kiegroup.

the class RuntimeManagerWithDescriptorTest method testDeployWithDefaultDeploymentDescriptor.

@Test
public void testDeployWithDefaultDeploymentDescriptor() throws Exception {
    KieServices ks = KieServices.Factory.get();
    ReleaseId releaseId = ks.newReleaseId("org.jbpm.test.dd", "kjar-with-dd", "1.0.0");
    String processString = IOUtils.toString(this.getClass().getResourceAsStream("/BPMN2-ScriptTask.bpmn2"), "UTF-8");
    Map<String, String> resources = new HashMap<String, String>();
    resources.put("src/main/resources/BPMN2-ScriptTask.bpmn2", processString);
    InternalKieModule kJar1 = createKieJar(ks, releaseId, resources);
    installKjar(releaseId, kJar1);
    RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder(releaseId).userGroupCallback(userGroupCallback).get();
    manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);
    assertNotNull(manager);
    InternalRuntimeManager internalManager = (InternalRuntimeManager) manager;
    DeploymentDescriptor descriptor = internalManager.getDeploymentDescriptor();
    assertNotNull(descriptor);
    RegisterableItemsFactory factory = internalManager.getEnvironment().getRegisterableItemsFactory();
    assertNotNull(factory);
    assertTrue(factory instanceof InternalRegisterableItemsFactory);
    assertNotNull(((InternalRegisterableItemsFactory) factory).getRuntimeManager());
    String descriptorFromKjar = descriptor.toXml();
    DeploymentDescriptorManager ddManager = new DeploymentDescriptorManager();
    String defaultDescriptor = ddManager.getDefaultDescriptor().toXml();
    assertEquals(defaultDescriptor, descriptorFromKjar);
}
Also used : RuntimeEnvironment(org.kie.api.runtime.manager.RuntimeEnvironment) InternalRuntimeManager(org.kie.internal.runtime.manager.InternalRuntimeManager) HashMap(java.util.HashMap) DeploymentDescriptor(org.kie.internal.runtime.conf.DeploymentDescriptor) InternalRegisterableItemsFactory(org.kie.internal.runtime.manager.InternalRegisterableItemsFactory) InternalRegisterableItemsFactory(org.kie.internal.runtime.manager.InternalRegisterableItemsFactory) RegisterableItemsFactory(org.kie.api.runtime.manager.RegisterableItemsFactory) KieServices(org.kie.api.KieServices) ReleaseId(org.kie.api.builder.ReleaseId) InternalKieModule(org.drools.compiler.kie.builder.impl.InternalKieModule) Test(org.junit.Test)

Example 57 with DeploymentDescriptor

use of org.kie.internal.runtime.conf.DeploymentDescriptor in project jbpm by kiegroup.

the class RuntimeManagerWithDescriptorTest method testDeployWithCustomDeploymentDescriptor.

@Test
public void testDeployWithCustomDeploymentDescriptor() throws Exception {
    KieServices ks = KieServices.Factory.get();
    ReleaseId releaseId = ks.newReleaseId("org.jbpm.test.dd", "-kjar-with-dd", "1.0.0");
    DeploymentDescriptor customDescriptor = new DeploymentDescriptorImpl("org.jbpm.persistence.jpa");
    customDescriptor.getBuilder().runtimeStrategy(RuntimeStrategy.PER_REQUEST).addGlobal(new NamedObjectModel("service", "java.util.ArrayList"));
    String processString = IOUtils.toString(this.getClass().getResourceAsStream("/BPMN2-ScriptTask.bpmn2"), "UTF-8");
    Map<String, String> resources = new HashMap<String, String>();
    resources.put("src/main/resources/BPMN2-ScriptTask.bpmn2", processString);
    resources.put("src/main/resources/" + DeploymentDescriptor.META_INF_LOCATION, customDescriptor.toXml());
    String drl = "package org.jbpm; global java.util.List service; " + "	rule \"Start Hello1\"" + "	  when" + "	  then" + "	    System.out.println(\"Hello\");" + "	end";
    resources.put("src/main/resources/simple.drl", drl);
    InternalKieModule kJar1 = createKieJar(ks, releaseId, resources);
    installKjar(releaseId, kJar1);
    RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder(releaseId).userGroupCallback(userGroupCallback).get();
    manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);
    assertNotNull(manager);
    InternalRuntimeManager internalManager = (InternalRuntimeManager) manager;
    RegisterableItemsFactory factory = internalManager.getEnvironment().getRegisterableItemsFactory();
    assertNotNull(factory);
    assertTrue(factory instanceof InternalRegisterableItemsFactory);
    assertNotNull(((InternalRegisterableItemsFactory) factory).getRuntimeManager());
    DeploymentDescriptor descriptor = internalManager.getDeploymentDescriptor();
    assertNotNull(descriptor);
    assertEquals("org.jbpm.persistence.jpa", descriptor.getPersistenceUnit());
    assertEquals("org.jbpm.persistence.jpa", descriptor.getAuditPersistenceUnit());
    assertEquals(AuditMode.JPA, descriptor.getAuditMode());
    assertEquals(PersistenceMode.JPA, descriptor.getPersistenceMode());
    assertEquals(RuntimeStrategy.PER_REQUEST, descriptor.getRuntimeStrategy());
    assertEquals(0, descriptor.getMarshallingStrategies().size());
    assertEquals(0, descriptor.getConfiguration().size());
    assertEquals(0, descriptor.getEnvironmentEntries().size());
    assertEquals(0, descriptor.getEventListeners().size());
    assertEquals(1, descriptor.getGlobals().size());
    assertEquals(0, descriptor.getTaskEventListeners().size());
    assertEquals(0, descriptor.getWorkItemHandlers().size());
    assertEquals(0, descriptor.getRequiredRoles().size());
    RuntimeEngine engine = manager.getRuntimeEngine(EmptyContext.get());
    assertNotNull(engine);
    Object service = engine.getKieSession().getGlobal("service");
    assertNotNull(service);
    assertTrue(service instanceof ArrayList);
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) RuntimeEnvironment(org.kie.api.runtime.manager.RuntimeEnvironment) InternalRuntimeManager(org.kie.internal.runtime.manager.InternalRuntimeManager) HashMap(java.util.HashMap) DeploymentDescriptor(org.kie.internal.runtime.conf.DeploymentDescriptor) ArrayList(java.util.ArrayList) InternalRegisterableItemsFactory(org.kie.internal.runtime.manager.InternalRegisterableItemsFactory) RegisterableItemsFactory(org.kie.api.runtime.manager.RegisterableItemsFactory) KieServices(org.kie.api.KieServices) ReleaseId(org.kie.api.builder.ReleaseId) NamedObjectModel(org.kie.internal.runtime.conf.NamedObjectModel) InternalRegisterableItemsFactory(org.kie.internal.runtime.manager.InternalRegisterableItemsFactory) InternalKieModule(org.drools.compiler.kie.builder.impl.InternalKieModule) Test(org.junit.Test)

Example 58 with DeploymentDescriptor

use of org.kie.internal.runtime.conf.DeploymentDescriptor in project jbpm by kiegroup.

the class DeploymentDescriptorManagerTest method testDefaultDeploymentDescriptorFromFile.

@Test
public void testDefaultDeploymentDescriptorFromFile() {
    System.setProperty("org.kie.deployment.desc.location", "file:src/test/resources/deployment/deployment-descriptor-defaults-and-ms.xml");
    DeploymentDescriptorManager manager = new DeploymentDescriptorManager("org.jbpm.domain");
    DeploymentDescriptor descriptor = manager.getDefaultDescriptor();
    assertNotNull(descriptor);
    assertEquals("org.jbpm.domain", descriptor.getPersistenceUnit());
    assertEquals("org.jbpm.domain", descriptor.getAuditPersistenceUnit());
    assertEquals(AuditMode.JPA, descriptor.getAuditMode());
    assertEquals(PersistenceMode.JPA, descriptor.getPersistenceMode());
    assertEquals(RuntimeStrategy.SINGLETON, descriptor.getRuntimeStrategy());
    assertEquals(1, descriptor.getMarshallingStrategies().size());
    assertEquals(0, descriptor.getConfiguration().size());
    assertEquals(0, descriptor.getEnvironmentEntries().size());
    assertEquals(0, descriptor.getEventListeners().size());
    assertEquals(0, descriptor.getGlobals().size());
    assertEquals(0, descriptor.getTaskEventListeners().size());
    assertEquals(0, descriptor.getWorkItemHandlers().size());
}
Also used : DeploymentDescriptor(org.kie.internal.runtime.conf.DeploymentDescriptor) Test(org.junit.Test)

Example 59 with DeploymentDescriptor

use of org.kie.internal.runtime.conf.DeploymentDescriptor in project jbpm by kiegroup.

the class DeploymentDescriptorManagerTest method testDefaultDeploymentDescriptorFromClasspath.

@Test
public void testDefaultDeploymentDescriptorFromClasspath() {
    System.setProperty("org.kie.deployment.desc.location", "classpath:/deployment/deployment-descriptor-defaults-and-ms.xml");
    DeploymentDescriptorManager manager = new DeploymentDescriptorManager("org.jbpm.domain");
    DeploymentDescriptor descriptor = manager.getDefaultDescriptor();
    assertNotNull(descriptor);
    assertEquals("org.jbpm.domain", descriptor.getPersistenceUnit());
    assertEquals("org.jbpm.domain", descriptor.getAuditPersistenceUnit());
    assertEquals(AuditMode.JPA, descriptor.getAuditMode());
    assertEquals(PersistenceMode.JPA, descriptor.getPersistenceMode());
    assertEquals(RuntimeStrategy.SINGLETON, descriptor.getRuntimeStrategy());
    assertEquals(1, descriptor.getMarshallingStrategies().size());
    assertEquals(0, descriptor.getConfiguration().size());
    assertEquals(0, descriptor.getEnvironmentEntries().size());
    assertEquals(0, descriptor.getEventListeners().size());
    assertEquals(0, descriptor.getGlobals().size());
    assertEquals(0, descriptor.getTaskEventListeners().size());
    assertEquals(0, descriptor.getWorkItemHandlers().size());
}
Also used : DeploymentDescriptor(org.kie.internal.runtime.conf.DeploymentDescriptor) Test(org.junit.Test)

Example 60 with DeploymentDescriptor

use of org.kie.internal.runtime.conf.DeploymentDescriptor in project jbpm by kiegroup.

the class DeploymentDescriptorManagerTest method testDefaultDeploymentDescriptor.

@Test
public void testDefaultDeploymentDescriptor() {
    DeploymentDescriptorManager manager = new DeploymentDescriptorManager("org.jbpm.domain");
    DeploymentDescriptor descriptor = manager.getDefaultDescriptor();
    assertNotNull(descriptor);
    assertEquals("org.jbpm.domain", descriptor.getPersistenceUnit());
    assertEquals("org.jbpm.domain", descriptor.getAuditPersistenceUnit());
    assertEquals(AuditMode.JPA, descriptor.getAuditMode());
    assertEquals(PersistenceMode.JPA, descriptor.getPersistenceMode());
    assertEquals(RuntimeStrategy.SINGLETON, descriptor.getRuntimeStrategy());
    assertEquals(0, descriptor.getMarshallingStrategies().size());
    assertEquals(0, descriptor.getConfiguration().size());
    assertEquals(0, descriptor.getEnvironmentEntries().size());
    assertEquals(0, descriptor.getEventListeners().size());
    assertEquals(0, descriptor.getGlobals().size());
    assertEquals(0, descriptor.getTaskEventListeners().size());
    assertEquals(0, descriptor.getWorkItemHandlers().size());
}
Also used : DeploymentDescriptor(org.kie.internal.runtime.conf.DeploymentDescriptor) Test(org.junit.Test)

Aggregations

DeploymentDescriptor (org.kie.internal.runtime.conf.DeploymentDescriptor)78 Test (org.junit.Test)39 NamedObjectModel (org.kie.internal.runtime.conf.NamedObjectModel)30 HashMap (java.util.HashMap)27 DeploymentDescriptorImpl (org.jbpm.runtime.manager.impl.deploy.DeploymentDescriptorImpl)26 InternalKieModule (org.drools.compiler.kie.builder.impl.InternalKieModule)23 ObjectModel (org.kie.internal.runtime.conf.ObjectModel)23 KieServices (org.kie.api.KieServices)22 KModuleDeploymentUnit (org.jbpm.kie.services.impl.KModuleDeploymentUnit)21 ReleaseId (org.kie.api.builder.ReleaseId)21 ArrayList (java.util.ArrayList)18 File (java.io.File)13 KieMavenRepository (org.kie.scanner.KieMavenRepository)12 FileOutputStream (java.io.FileOutputStream)11 KieMavenRepository.getKieMavenRepository (org.kie.scanner.KieMavenRepository.getKieMavenRepository)11 DeployedUnit (org.jbpm.services.api.model.DeployedUnit)10 ByteArrayInputStream (java.io.ByteArrayInputStream)9 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)9 InternalRuntimeManager (org.kie.internal.runtime.manager.InternalRuntimeManager)8 DeploymentDescriptorManager (org.jbpm.runtime.manager.impl.deploy.DeploymentDescriptorManager)6