summaryrefslogtreecommitdiff
path: root/calamus-engine/src/test/java/io/trygvis/engine
diff options
context:
space:
mode:
Diffstat (limited to 'calamus-engine/src/test/java/io/trygvis/engine')
-rw-r--r--calamus-engine/src/test/java/io/trygvis/engine/MyTest.java90
1 files changed, 90 insertions, 0 deletions
diff --git a/calamus-engine/src/test/java/io/trygvis/engine/MyTest.java b/calamus-engine/src/test/java/io/trygvis/engine/MyTest.java
new file mode 100644
index 0000000..8c170ea
--- /dev/null
+++ b/calamus-engine/src/test/java/io/trygvis/engine/MyTest.java
@@ -0,0 +1,90 @@
+package io.trygvis.engine;
+
+import bitronix.tm.TransactionManagerServices;
+import bitronix.tm.resource.jdbc.PoolingDataSource;
+import org.jbpm.bpmn2.handler.ServiceTaskHandler;
+import org.jbpm.process.audit.AuditLoggerFactory;
+import org.junit.Before;
+import org.junit.Test;
+import org.kie.api.KieBase;
+import org.kie.api.definition.process.Process;
+import org.kie.api.runtime.Environment;
+import org.kie.api.runtime.EnvironmentName;
+import org.kie.api.runtime.KieSession;
+import org.kie.api.runtime.process.ProcessInstance;
+import org.kie.internal.KnowledgeBaseFactory;
+import org.kie.internal.io.ResourceFactory;
+import org.kie.internal.persistence.jpa.JPAKnowledgeService;
+import org.kie.internal.runtime.StatefulKnowledgeSession;
+import org.kie.internal.utils.KieHelper;
+
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+public class MyTest {
+
+ StatefulKnowledgeSession session;
+
+// @Before
+// public void setUp() throws Exception {
+// PoolingDataSource ds = new PoolingDataSource();
+// ds.setUniqueName("jdbc/jbpm-ds");
+// ds.setClassName(bitronix.tm.resource.jdbc.lrc.LrcXADataSource.class.getCanonicalName());
+// ds.setMaxPoolSize(3);
+// ds.setAllowLocalTransactions(true);
+// ds.getDriverProperties().put("user", "jbpm");
+// ds.getDriverProperties().put("password", "jbpm");
+// ds.getDriverProperties().put("url", "jdbc:postgresql://localhost/jbpm");
+// ds.getDriverProperties().put("driverClassName", org.postgresql.Driver.class.getCanonicalName());
+// ds.init();
+//
+// EntityManagerFactory emf = Persistence.createEntityManagerFactory("org.jbpm.persistence.jpa");
+// Environment env = KnowledgeBaseFactory.newEnvironment();
+// env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);
+// env.set(EnvironmentName.TRANSACTION_MANAGER, TransactionManagerServices.getTransactionManager());
+//
+// KieBase kieBase = new KieHelper()
+// .addResource(ResourceFactory.newClassPathResource("Deploy.bpmn2"))
+// .build();
+//
+// // create a new knowledge session that uses JPA to store the runtime state
+// session = JPAKnowledgeService.newStatefulKnowledgeSession(kieBase, null, env);
+// session.addEventListener(AuditLoggerFactory.newJPAInstance(env));
+//
+// session.getWorkItemManager().registerWorkItemHandler("Service Task", new ServiceTaskHandler());
+// session.getWorkItemManager().registerWorkItemHandler("Upgrade App", new UpgradeAppWorkItemHandler());
+// session.getWorkItemManager().registerWorkItemHandler("Restart App", new RestartAppWorkItemHandler());
+// }
+
+ @Test
+ public void testDeploy() {
+/*
+ ProcessInstance processInstance = session.startProcess("io.trygvis.bpm.Deploy");
+
+// assertProcessInstanceCompleted(processInstance.getId(), session);
+
+ System.out.println("processInstance = " + processInstance);
+ System.out.println("processInstance.getProcessId() = " + processInstance.getProcessId());
+ System.out.println("processInstance.getState() = " + processInstance.getState());
+
+ Process process = session.getKieBase().getProcess(processInstance.getProcessId());
+ System.out.println("process = " + process);
+ System.out.println("process.getType() = " + process.getType());
+*/
+ }
+
+ public static void assertProcessInstanceCompleted(long processInstanceId, KieSession ksession) {
+ assertNull(ksession.getProcessInstance(processInstanceId));
+ }
+
+ public static void assertProcessInstanceAborted(long processInstanceId, KieSession ksession) {
+ assertNull(ksession.getProcessInstance(processInstanceId));
+ }
+
+ public static void assertProcessInstanceActive(long processInstanceId, KieSession ksession) {
+ assertNotNull(ksession.getProcessInstance(processInstanceId));
+ }
+}