use of org.drools.compiler.kie.builder.impl.InternalKieModule in project jbpm by kiegroup.
the class KjarRuntimeEnvironmentTest method setup.
@Before
public void setup() {
TestUtil.cleanupSingletonSessionId();
KieServices ks = KieServices.Factory.get();
ReleaseId releaseId = ks.newReleaseId(GROUP_ID, ARTIFACT_ID, VERSION);
List<String> processes = new ArrayList<String>();
processes.add("BPMN2-ScriptTask.bpmn2");
processes.add("BPMN2-UserTask.bpmn2");
processes.add("BPMN2-CustomTask.bpmn2");
InternalKieModule kJar1 = createKieJar(ks, releaseId, processes);
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.installArtifact(releaseId, kJar1, pom);
Properties properties = new Properties();
properties.setProperty("mary", "HR");
properties.setProperty("john", "HR");
userGroupCallback = new JBossUserGroupCallbackImpl(properties);
pds = TestUtil.setupPoolingDataSource();
}
use of org.drools.compiler.kie.builder.impl.InternalKieModule in project jbpm by kiegroup.
the class AbstractDeploymentDescriptorTest method createKieJar.
protected InternalKieModule createKieJar(KieServices ks, ReleaseId releaseId, Map<String, String> resources, ReleaseId... dependencies) {
KieFileSystem kfs = createKieFileSystemWithKProject(ks);
kfs.writePomXML(getPom(releaseId, dependencies));
for (Map.Entry<String, String> entry : resources.entrySet()) {
kfs.write(entry.getKey(), ResourceFactory.newByteArrayResource(entry.getValue().getBytes()));
}
KieBuilder kieBuilder = ks.newKieBuilder(kfs);
if (!kieBuilder.buildAll().getResults().getMessages().isEmpty()) {
for (Message message : kieBuilder.buildAll().getResults().getMessages()) {
logger.error("Error Message: ({}) {}", message.getPath(), message.getText());
}
throw new RuntimeException("There are errors builing the package, please check your knowledge assets!");
}
return (InternalKieModule) kieBuilder.getKieModule();
}
use of org.drools.compiler.kie.builder.impl.InternalKieModule in project jbpm by kiegroup.
the class DeploymentDescriptorManagerTest method testDeploymentDescriptorFromKieContainer.
@Test
public void testDeploymentDescriptorFromKieContainer() {
DeploymentDescriptorManager manager = new DeploymentDescriptorManager("org.jbpm.domain");
KieServices ks = KieServices.Factory.get();
ReleaseId releaseId = ks.newReleaseId(GROUP_ID, ARTIFACT_ID, VERSION);
DeploymentDescriptor descriptor = new DeploymentDescriptorImpl("org.jbpm.domain");
descriptor.getBuilder().runtimeStrategy(RuntimeStrategy.PER_PROCESS_INSTANCE);
Map<String, String> resources = new HashMap<String, String>();
resources.put("src/main/resources/simple.drl", SIMPLE_DRL);
resources.put("src/main/resources/META-INF/kie-deployment-descriptor.xml", descriptor.toXml());
InternalKieModule kJar1 = createKieJar(ks, releaseId, resources);
installKjar(releaseId, kJar1);
KieContainer kieContainer = ks.newKieContainer(releaseId);
assertNotNull(kieContainer);
List<DeploymentDescriptor> descriptorHierarchy = manager.getDeploymentDescriptorHierarchy(kieContainer);
assertNotNull(descriptorHierarchy);
assertEquals(2, descriptorHierarchy.size());
descriptor = descriptorHierarchy.get(0);
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.PER_PROCESS_INSTANCE, 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());
descriptor = descriptorHierarchy.get(1);
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());
}
use of org.drools.compiler.kie.builder.impl.InternalKieModule in project jbpm by kiegroup.
the class DeploymentDescriptorManagerTest method testDeploymentDescriptorFromKieContainerNoDescInKjar.
@Test
public void testDeploymentDescriptorFromKieContainerNoDescInKjar() {
DeploymentDescriptorManager manager = new DeploymentDescriptorManager("org.jbpm.domain");
KieServices ks = KieServices.Factory.get();
ReleaseId releaseId = ks.newReleaseId(GROUP_ID, ARTIFACT_ID, VERSION);
Map<String, String> resources = new HashMap<String, String>();
resources.put("src/main/resources/simple.drl", SIMPLE_DRL);
InternalKieModule kJar1 = createKieJar(ks, releaseId, resources);
installKjar(releaseId, kJar1);
KieContainer kieContainer = ks.newKieContainer(releaseId);
assertNotNull(kieContainer);
List<DeploymentDescriptor> descriptorHierarchy = manager.getDeploymentDescriptorHierarchy(kieContainer);
assertNotNull(descriptorHierarchy);
assertEquals(1, descriptorHierarchy.size());
DeploymentDescriptor descriptor = descriptorHierarchy.get(0);
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());
}
use of org.drools.compiler.kie.builder.impl.InternalKieModule in project jbpm by kiegroup.
the class MvelResolverDeploymentDescriptorManagerTest method testDeploymentDescriptorFromKieContainer.
@Test
public void testDeploymentDescriptorFromKieContainer() throws IOException {
Map<String, String> resources = new HashMap<String, String>();
KieServices ks = KieServices.Factory.get();
ReleaseId releaseId = ks.newReleaseId(GROUP_ID, ARTIFACT_ID, VERSION);
String kmoduleString = IOUtils.toString(this.getClass().getResourceAsStream("/kmodule-custom-wih.xml"), "UTF-8");
resources.put("src/main/resources/META-INF/kmodule.xml", kmoduleString);
String processString = IOUtils.toString(this.getClass().getResourceAsStream("/BPMN2-CustomTask.bpmn2"), "UTF-8");
resources.put("src/main/resources/BPMN2-CustomTask.bpmn2", processString);
InternalKieModule kJar1 = createKieJar(ks, releaseId, resources);
installKjar(releaseId, kJar1);
Properties properties = new Properties();
UserGroupCallback userGroupCallback = new JBossUserGroupCallbackImpl(properties);
RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder(releaseId).userGroupCallback(userGroupCallback).get();
manager = RuntimeManagerFactory.Factory.get().newPerProcessInstanceRuntimeManager(environment);
manager.getRuntimeEngine(ProcessInstanceIdContext.get()).getKieSession().startProcess("customtask");
}
Aggregations