use of org.kie.internal.runtime.conf.DeploymentDescriptor in project jbpm by kiegroup.
the class DeploymentDescriptorTest method testEmptyDeploymentDescriptor.
@Test
public void testEmptyDeploymentDescriptor() {
DeploymentDescriptorImpl descriptor = new DeploymentDescriptorImpl("org.jbpm.domain");
descriptor.getBuilder().addMarshalingStrategy(new ObjectModel("org.jbpm.testCustomStrategy", new Object[] { new ObjectModel("java.lang.String", new Object[] { "param1" }), "param2" })).addRequiredRole("experts");
assertFalse(descriptor.isEmpty());
InputStream input = this.getClass().getResourceAsStream("/deployment/empty-descriptor.xml");
DeploymentDescriptor fromXml = DeploymentDescriptorIO.fromXml(input);
assertNotNull(fromXml);
assertTrue(((DeploymentDescriptorImpl) fromXml).isEmpty());
assertNull(fromXml.getPersistenceUnit());
assertNull(fromXml.getAuditPersistenceUnit());
assertEquals(AuditMode.JPA, fromXml.getAuditMode());
assertEquals(PersistenceMode.JPA, fromXml.getPersistenceMode());
assertEquals(RuntimeStrategy.SINGLETON, fromXml.getRuntimeStrategy());
assertEquals(0, fromXml.getMarshallingStrategies().size());
assertEquals(0, fromXml.getConfiguration().size());
assertEquals(0, fromXml.getEnvironmentEntries().size());
assertEquals(0, fromXml.getEventListeners().size());
assertEquals(0, fromXml.getGlobals().size());
assertEquals(0, fromXml.getTaskEventListeners().size());
assertEquals(0, fromXml.getWorkItemHandlers().size());
assertEquals(0, fromXml.getRequiredRoles().size());
}
use of org.kie.internal.runtime.conf.DeploymentDescriptor in project jbpm by kiegroup.
the class RuntimeManagerWithDescriptorTest method testDeployWithFullCustomDeploymentDescriptor.
@Test
public void testDeployWithFullCustomDeploymentDescriptor() throws Exception {
Map<String, String> resources = new HashMap<String, String>();
String scriptString = IOUtils.toString(this.getClass().getResourceAsStream("/BPMN2-ScriptTask.bpmn2"), "UTF-8");
resources.put("src/main/resources/BPMN2-ScriptTask.bpmn2", scriptString);
String manualString = IOUtils.toString(this.getClass().getResourceAsStream("/BPMN2-ManualTask.bpmn2"), "UTF-8");
resources.put("src/main/resources/BPMN2-ManualTask.bpmn2", manualString);
String userString = IOUtils.toString(this.getClass().getResourceAsStream("/BPMN2-UserTask.bpmn2"), "UTF-8");
resources.put("src/main/resources/BPMN2-UserTask.bpmn2", userString);
String callString = IOUtils.toString(this.getClass().getResourceAsStream("/BPMN2-CallActivity.bpmn2"), "UTF-8");
resources.put("src/main/resources/BPMN2-CallActivity.bpmn2", callString);
String subProcessString = IOUtils.toString(this.getClass().getResourceAsStream("/BPMN2-CallActivitySubProcess.bpmn2"), "UTF-8");
resources.put("src/main/resources/BPMN2-CallActivitySubProcess.bpmn2", subProcessString);
DeploymentDescriptor customDescriptor = new DeploymentDescriptorImpl("org.jbpm.persistence.jpa");
customDescriptor.getBuilder().runtimeStrategy(RuntimeStrategy.PER_PROCESS_INSTANCE).addMarshalingStrategy(new ObjectModel("org.jbpm.runtime.manager.impl.deploy" + ".RuntimeManagerWithDescriptorTest$TestMarshallingStrategy")).addConfiguration(new NamedObjectModel("drools.processSignalManagerFactory", "java.lang.String", new Object[] { DefaultSignalManagerFactory.class.getName() })).addEnvironmentEntry(new NamedObjectModel("jbpm.business.calendar", "org.jbpm.runtime.manager.impl.deploy.RuntimeManagerWithDescriptorTest$TestBusinessCalendar")).addEventListener(new ObjectModel("org.jbpm.runtime.manager.impl.deploy" + ".RuntimeManagerWithDescriptorTest$TestProcessEventListener")).addGlobal(new NamedObjectModel("service", "java.util.ArrayList")).addTaskEventListener(new ObjectModel("org.jbpm.runtime.manager.impl.deploy" + ".RuntimeManagerWithDescriptorTest$TestTaskEventListener")).addWorkItemHandler(new NamedObjectModel("Manual Task", "org.jbpm.runtime.manager.impl.deploy" + ".RuntimeManagerWithDescriptorTest$TestWorkItemHandler"));
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);
KieServices ks = KieServices.Factory.get();
ReleaseId releaseId = ks.newReleaseId("org.jbpm.test.dd", "-kjar-with-dd", "1.0.0");
InternalKieModule kJar1 = createKieJar(ks, releaseId, resources);
installKjar(releaseId, kJar1);
RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder(releaseId).userGroupCallback(userGroupCallback).get();
manager = RuntimeManagerFactory.Factory.get().newPerProcessInstanceRuntimeManager(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_PROCESS_INSTANCE, descriptor.getRuntimeStrategy());
assertEquals(1, descriptor.getMarshallingStrategies().size());
// assertEquals(1, descriptor.getConfiguration().size());
assertEquals(1, descriptor.getEnvironmentEntries().size());
assertEquals(1, descriptor.getEventListeners().size());
assertEquals(1, descriptor.getGlobals().size());
assertEquals(1, descriptor.getTaskEventListeners().size());
assertEquals(1, descriptor.getWorkItemHandlers().size());
assertEquals(0, descriptor.getRequiredRoles().size());
RuntimeEngine engine = manager.getRuntimeEngine(ProcessInstanceIdContext.get());
assertNotNull(engine);
KieSession kieSession = engine.getKieSession();
// configuration
assertEquals(((SessionConfiguration) kieSession.getSessionConfiguration()).getSignalManagerFactory(), DefaultSignalManagerFactory.class.getName());
BusinessCalendar bc = (BusinessCalendar) kieSession.getEnvironment().get("jbpm.business.calendar");
assertNotNull(bc);
assertTrue(bc instanceof TestBusinessCalendar);
// globals
Object service = kieSession.getGlobal("service");
assertNotNull(service);
assertTrue(service instanceof ArrayList);
// work item handler
ProcessInstance processInstance = kieSession.startProcess("ManualTask");
long processInstanceId = processInstance.getId();
assertNotNull(kieSession.getProcessInstance(processInstanceId));
kieSession.getWorkItemManager().completeWorkItem(TestWorkItemHandler.getWorkItem().getId(), null);
assertNull(kieSession.getProcessInstance(processInstanceId));
manager.disposeRuntimeEngine(engine);
engine = manager.getRuntimeEngine(ProcessInstanceIdContext.get());
kieSession = engine.getKieSession();
// process event listener
assertArrayEquals(new String[] { "beforeProcessStarted", "afterProcessStarted", "beforeProcessCompleted", "afterProcessCompleted" }, processEvents.toArray());
processEvents.clear();
manager.disposeRuntimeEngine(engine);
engine = manager.getRuntimeEngine(ProcessInstanceIdContext.get());
kieSession = engine.getKieSession();
// task event listener
processInstance = kieSession.startProcess("UserTask");
processInstanceId = processInstance.getId();
assertNotNull(kieSession.getProcessInstance(processInstanceId));
manager.disposeRuntimeEngine(engine);
engine = manager.getRuntimeEngine(ProcessInstanceIdContext.get(processInstanceId));
TaskService taskService = engine.getTaskService();
List<TaskSummary> tasks = taskService.getTasksAssignedAsPotentialOwner("john", "en-UK");
long taskId = tasks.get(0).getId();
taskService.start(taskId, "john");
taskService.complete(taskId, "john", null);
assertArrayEquals(new String[] { "beforeTaskAddedEvent", "afterTaskAddedEvent", "beforeTaskStartedEvent", "afterTaskStartedEvent", "beforeTaskCompletedEvent", "afterTaskCompletedEvent" }, taskEvents.toArray());
manager.disposeRuntimeEngine(engine);
engine = manager.getRuntimeEngine(ProcessInstanceIdContext.get());
kieSession = engine.getKieSession();
// marshalling strategy
Map<String, Object> params = new HashMap<String, Object>();
params.put("x", "marshal");
processInstance = kieSession.startProcess("ParentProcess", params);
processInstanceId = processInstance.getId();
ProcessInstance pi = kieSession.getProcessInstance(processInstanceId);
assertNotNull(pi);
String varX = (String) ((WorkflowProcessInstance) pi).getVariable("x");
assertEquals(TestMarshallingStrategy.ALWAYS_RESPOND_WITH, varX);
manager.disposeRuntimeEngine(engine);
}
use of org.kie.internal.runtime.conf.DeploymentDescriptor in project jbpm by kiegroup.
the class TaskVariablesQueryServiceTest method prepare.
@Before
public void prepare() {
configureServices();
KieServices ks = KieServices.Factory.get();
ReleaseId releaseId = ks.newReleaseId(GROUP_ID, ARTIFACT_ID, VERSION);
File kjar = new File("src/test/resources/kjar-task-vars/task-vars-1.0.jar");
File pom = new File("src/test/resources/kjar-task-vars/pom.xml");
KieMavenRepository repository = getKieMavenRepository();
repository.installArtifact(releaseId, kjar, pom);
ReleaseId releaseIdSales = ks.newReleaseId("org.jbpm.test", "product-sale", "1.0");
File kjarSales = new File("src/test/resources/kjar-sales/product-sale-1.0.jar");
File pomSales = new File("src/test/resources/kjar-sales/pom.xml");
repository.installArtifact(releaseIdSales, kjarSales, pomSales);
assertNotNull(deploymentService);
KModuleDeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
deploymentService.deploy(deploymentUnit);
KModuleDeploymentUnit deploymentUnitSales = new KModuleDeploymentUnit(SALES_GROUP_ID, SALES_ARTIFACT_ID, SALES_VERSION);
DeploymentDescriptor customDescriptor = new DeploymentDescriptorImpl("org.jbpm.domain");
customDescriptor.getBuilder().addMarshalingStrategy(new ObjectModel("mvel", "new org.drools.persistence.jpa.marshaller.JPAPlaceholderResolverStrategy(\"org.jbpm.test:product-sale:1.0\", classLoader)"));
// disable below line to avoid jpa marshaling of ProductSale variable
deploymentUnitSales.setDeploymentDescriptor(customDescriptor);
deploymentService.deploy(deploymentUnitSales);
deploymentUnitSalesId = deploymentUnitSales.getIdentifier();
DeployedUnit deployed = deploymentService.getDeployedUnit(deploymentUnit.getIdentifier());
assertNotNull(deployed);
assertNotNull(deployed.getDeploymentUnit());
assertNotNull(runtimeDataService);
Collection<ProcessDefinition> processes = runtimeDataService.getProcesses(new QueryContext());
assertNotNull(processes);
assertEquals(2, processes.size());
deploymentUnitId = deploymentUnit.getIdentifier();
}
use of org.kie.internal.runtime.conf.DeploymentDescriptor in project jbpm by kiegroup.
the class UserTaskInstanceWithPotOwnerTest method prepare.
@Before
public void prepare() {
System.setProperty("org.jbpm.ht.callback", "custom");
System.setProperty("org.jbpm.ht.custom.callback", "org.jbpm.kie.services.test.objects.TestUserGroupCallbackImpl");
this.dataSourceJNDIname = getDataSourceJNDI();
configureServices();
logger.debug("Preparing kjar");
KieServices ks = KieServices.Factory.get();
ReleaseId releaseId = ks.newReleaseId(GROUP_ID, ARTIFACT_ID, VERSION);
List<String> processes = new ArrayList<String>();
processes.add("repo/processes/general/EmptyHumanTask.bpmn");
processes.add("repo/processes/general/humanTask.bpmn");
processes.add("repo/processes/general/BPMN2-UserTask.bpmn2");
processes.add("repo/processes/general/SimpleHTProcess.bpmn2");
processes.add("repo/processes/general/AdHocSubProcess.bpmn2");
processes.add("repo/processes/general/ExcludedOwner.bpmn2");
DeploymentDescriptor customDescriptor = new DeploymentDescriptorImpl("org.jbpm.domain");
customDescriptor.getBuilder().addRequiredRole("view:managers");
Map<String, String> resources = new HashMap<String, String>();
resources.put("src/main/resources/" + DeploymentDescriptor.META_INF_LOCATION, customDescriptor.toXml());
InternalKieModule kJar1 = createKieJar(ks, releaseId, processes, resources);
File pom = new File("target/kmodule", "pom.xml");
pom.getParentFile().mkdir();
try {
FileOutputStream fs = new FileOutputStream(pom);
fs.write(getPom(releaseId).getBytes());
fs.close();
} catch (Exception e) {
}
KieMavenRepository repository = getKieMavenRepository();
repository.deployArtifact(releaseId, kJar1, pom);
assertNotNull(deploymentService);
deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
deploymentService.deploy(deploymentUnit);
units.add(deploymentUnit);
prepareJPAModule(ks, repository);
assertNotNull(processService);
}
use of org.kie.internal.runtime.conf.DeploymentDescriptor in project jbpm by kiegroup.
the class QueryServiceImplTest method prepare.
@Before
public void prepare() {
System.setProperty("org.jbpm.ht.callback", "custom");
System.setProperty("org.jbpm.ht.custom.callback", "org.jbpm.kie.services.test.objects.TestUserGroupCallbackImpl");
this.dataSourceJNDIname = getDataSourceJNDI();
configureServices();
logger.debug("Preparing kjar");
KieServices ks = KieServices.Factory.get();
ReleaseId releaseId = ks.newReleaseId(GROUP_ID, ARTIFACT_ID, VERSION);
List<String> processes = new ArrayList<String>();
processes.add("repo/processes/general/EmptyHumanTask.bpmn");
processes.add("repo/processes/general/humanTask.bpmn");
processes.add("repo/processes/general/BPMN2-UserTask.bpmn2");
processes.add("repo/processes/general/SimpleHTProcess.bpmn2");
processes.add("repo/processes/general/AdHocSubProcess.bpmn2");
processes.add("repo/processes/general/ExcludedOwner.bpmn2");
DeploymentDescriptor customDescriptor = new DeploymentDescriptorImpl("org.jbpm.domain");
customDescriptor.getBuilder().addRequiredRole("view:managers");
Map<String, String> resources = new HashMap<String, String>();
resources.put("src/main/resources/" + DeploymentDescriptor.META_INF_LOCATION, customDescriptor.toXml());
InternalKieModule kJar1 = createKieJar(ks, releaseId, processes, resources);
File pom = new File("target/kmodule", "pom.xml");
pom.getParentFile().mkdir();
try {
FileOutputStream fs = new FileOutputStream(pom);
fs.write(getPom(releaseId).getBytes());
fs.close();
} catch (Exception e) {
}
KieMavenRepository repository = getKieMavenRepository();
repository.deployArtifact(releaseId, kJar1, pom);
assertNotNull(deploymentService);
deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
deploymentService.deploy(deploymentUnit);
units.add(deploymentUnit);
prepareJPAModule(ks, repository);
assertNotNull(processService);
}
Aggregations