[jbpm-commits] JBoss JBPM SVN: r3558 - in jbpm4/trunk/modules: test-db/src and 16 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Sat Dec 27 07:58:42 EST 2008
Author: tom.baeyens at jboss.com
Date: 2008-12-27 07:58:42 -0500 (Sat, 27 Dec 2008)
New Revision: 3558
Added:
jbpm4/trunk/modules/test-db/src/main/
jbpm4/trunk/modules/test-db/src/main/java/
jbpm4/trunk/modules/test-db/src/main/java/org/
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/activities/
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/activities/ExclusiveTest.java
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/activities/StateTest.java
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/cfg/
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/cfg/ConfigurationTest.java
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/ExecutionServiceTest.java
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/ManagementServiceTest.java
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/ProcessServiceTest.java
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/TaskServiceTest.java
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/variables/
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/variables/BasicVariablesTest.java
jbpm4/trunk/modules/test-db/src/main/resources/
jbpm4/trunk/modules/test-db/src/main/resources/hibernate.properties
jbpm4/trunk/modules/test-db/src/main/resources/jbpm.cfg.xml
jbpm4/trunk/modules/test-db/src/main/resources/logging.properties
Removed:
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/ExclusiveTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/StateTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/cfg/ConfigurationTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/ExecutionServiceTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/ManagementServiceTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/ProcessServiceTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/TaskServiceTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/variables/BasicVariablesTest.java
jbpm4/trunk/modules/test-db/src/test/resources/hibernate.properties
jbpm4/trunk/modules/test-db/src/test/resources/jbpm.cfg.xml
jbpm4/trunk/modules/test-db/src/test/resources/logging.properties
Modified:
jbpm4/trunk/modules/test-db/.classpath
jbpm4/trunk/modules/test-db/pom.xml
jbpm4/trunk/modules/test-pojo/pom.xml
Log:
fixed test-db api compile classpath: made it strict
Modified: jbpm4/trunk/modules/test-db/.classpath
===================================================================
--- jbpm4/trunk/modules/test-db/.classpath 2008-12-27 11:30:11 UTC (rev 3557)
+++ jbpm4/trunk/modules/test-db/.classpath 2008-12-27 12:58:42 UTC (rev 3558)
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
- <classpathentry kind="src" output="target/test-classes" path="src/test/resources"/>
+ <classpathentry kind="src" output="target/classes" path="src/main/java"/>
+ <classpathentry kind="src" output="target/classes" path="src/main/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
- <classpathentry kind="output" path="target/test-classes"/>
+ <classpathentry kind="output" path="target/classes"/>
</classpath>
Modified: jbpm4/trunk/modules/test-db/pom.xml
===================================================================
--- jbpm4/trunk/modules/test-db/pom.xml 2008-12-27 11:30:11 UTC (rev 3557)
+++ jbpm4/trunk/modules/test-db/pom.xml 2008-12-27 12:58:42 UTC (rev 3558)
@@ -43,15 +43,16 @@
<groupId>org.jbpm.jbpm4</groupId>
<artifactId>jbpm-jpdl</artifactId>
<version>${version}</version>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.jbpm.jbpm4</groupId>
<artifactId>jbpm-task</artifactId>
<version>${version}</version>
+ <scope>test</scope>
</dependency>
-
<!-- TODO remove PVM dependency for compilation (keep it for test)-->
<dependency>
<groupId>org.jbpm.jbpm4</groupId>
@@ -65,6 +66,14 @@
<!-- Plugins -->
<build>
<plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <testSourceDirectory>src/main/java</testSourceDirectory>
+ <classesDirectory>target/classes</classesDirectory>
+ <testClassesDirectory>target/classes</testClassesDirectory>
+ </configuration>
+ </plugin>
</plugins>
</build>
Copied: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/activities/ExclusiveTest.java (from rev 3557, jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/ExclusiveTest.java)
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/activities/ExclusiveTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/activities/ExclusiveTest.java 2008-12-27 12:58:42 UTC (rev 3558)
@@ -0,0 +1,96 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.activities;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jbpm.Execution;
+import org.jbpm.test.DbTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ExclusiveTest extends DbTestCase {
+
+ public void testExclusiveExpression() {
+ deployJpdlXmlString(
+ "<process name='Poolcar'>" +
+ " <start>" +
+ " <flow to='How far?' />" +
+ " </start>" +
+ " <exclusive name='How far?' expr='#{distance}'>" +
+ " <flow name='far' to='Big car' />" +
+ " <flow name='nearby' to='Small car' />" +
+ " </exclusive>" +
+ " <state name='Big car' />" +
+ " <state name='Small car' />" +
+ "</process>"
+ );
+
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("distance", "far");
+ Execution execution = executionService.startExecutionByKey("Poolcar", variables);
+ assertEquals("Big car", execution.getNodeName());
+
+ variables.put("distance", "nearby");
+ execution = executionService.startExecutionByKey("Poolcar", variables);
+ assertEquals("Small car", execution.getNodeName());
+ }
+
+ public void testExclusiveWithConditions() {
+ deployJpdlXmlString(
+ "<process name='Poolcar'>" +
+ " <start>" +
+ " <flow to='How far?' />" +
+ " </start>" +
+ " <exclusive name='How far?'>" +
+ " <flow to='Big car'>" +
+ " <condition expr='#{distance > 10}' />" +
+ " </flow>" +
+ " <flow to='Small car'>" +
+ " <condition expr='#{distance >= 3}' />" +
+ " </flow>" +
+ " <flow to='No car' />" +
+ " </exclusive>" +
+ " <state name='Big car' />" +
+ " <state name='Small car' />" +
+ " <state name='No car' />" +
+ "</process>"
+ );
+
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("distance", new Integer(69));
+ Execution execution = executionService.startExecutionByKey("Poolcar", variables);
+ assertEquals("Big car", execution.getNodeName());
+
+ variables.put("distance", new Integer(6));
+ execution = executionService.startExecutionByKey("Poolcar", variables);
+ assertEquals("Small car", execution.getNodeName());
+
+ variables.put("distance", new Integer(2));
+ execution = executionService.startExecutionByKey("Poolcar", variables);
+ assertEquals("No car", execution.getNodeName());
+ }
+
+}
Property changes on: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/activities/ExclusiveTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Copied: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/activities/StateTest.java (from rev 3557, jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/StateTest.java)
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/activities/StateTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/activities/StateTest.java 2008-12-27 12:58:42 UTC (rev 3558)
@@ -0,0 +1,153 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.activities;
+
+import org.jbpm.Execution;
+import org.jbpm.JbpmException;
+import org.jbpm.test.DbTestCase;
+
+/**
+ * @author Tom Baeyens
+ */
+public class StateTest extends DbTestCase {
+
+ public void testWaitStatesSequence() {
+ deployJpdlXmlString(
+ "<process name='ThreeStates'>" +
+ " <start name='a'>" +
+ " <flow to='b' />" +
+ " </start>" +
+ " <state name='b'>" +
+ " <flow to='c' />" +
+ " </state>" +
+ " <state name='c'>" +
+ " <flow to='d' />" +
+ " </state>" +
+ " <end name='d' />" +
+ "</process>"
+ );
+
+ Execution execution = executionService.startExecutionById("ThreeStates:1");
+ assertEquals("b", execution.getNodeName());
+
+ String executionId = execution.getId();
+ execution = executionService.signalExecutionById(executionId);
+ assertEquals("c", execution.getNodeName());
+
+ execution = executionService.signalExecutionById(executionId);
+ assertEquals("d", execution.getNodeName());
+ assertTrue(execution.isEnded());
+ }
+
+ public void testExternalDecision() {
+ deployJpdlXmlString(
+ "<process name='p'>" +
+ " <start>" +
+ " <flow to='ed' />" +
+ " </start>" +
+ " <state name='ed'>" +
+ " <flow name='left' to='b' />" +
+ " <flow name='middle' to='c' />" +
+ " <flow name='right' to='d' />" +
+ " </state>" +
+ " <state name='b' />" +
+ " <state name='c' />" +
+ " <state name='d' />" +
+ "</process>"
+ );
+
+ Execution execution = executionService.startExecutionByKey("p", "one");
+ assertEquals("ed", execution.getNodeName());
+ execution = executionService.signalExecutionById("p/one", "left");
+ assertEquals("b", execution.getNodeName());
+
+ executionService.startExecutionById("p:1", "two");
+ execution = executionService.signalExecutionById("p/two", "middle");
+ assertEquals("c", execution.getNodeName());
+
+ executionService.startExecutionById("p:1", "three");
+ execution = executionService.signalExecutionById("p/three", "right");
+ assertEquals("d", execution.getNodeName());
+ }
+
+ public void testDefaultSignalWithNamedTransitions() {
+ deployJpdlXmlString(
+ "<process name='p'>" +
+ " <start>" +
+ " <flow to='a' />" +
+ " </start>" +
+ " <state name='a'>" +
+ " <flow name='left' to='b' />" +
+ " <flow name='middle' to='c' />" +
+ " <flow name='right' to='d' />" +
+ " </state>" +
+ " <state name='b' />" +
+ " <state name='c' />" +
+ " <state name='d' />" +
+ "</process>"
+ );
+
+ executionService.startExecutionByKey("p", "one");
+ try {
+ executionService.signalExecutionById("p/one", "left");
+ } catch (JbpmException e) {
+ assertTextPresent("no matching transition or event for default signal in state(a)", e.getMessage());
+ }
+ }
+
+ public void testNamedSignalWithoutMatchingTransition() {
+ deployJpdlXmlString(
+ "<process name='p'>" +
+ " <start>" +
+ " <flow to='a' />" +
+ " </start>" +
+ " <state name='a'>" +
+ " <flow name='left' to='b' />" +
+ " <flow name='middle' to='c' />" +
+ " <flow name='right' to='d' />" +
+ " </state>" +
+ " <state name='b' />" +
+ " <state name='c' />" +
+ " <state name='d' />" +
+ "</process>"
+ );
+
+ executionService.startExecutionByKey("p", "one");
+ Execution execution = executionService.signalExecutionById("p/one", "up");
+ assertEquals("a", execution.getNodeName());
+ }
+
+ public void testDefaultSignalWithoutTransitions() {
+ deployJpdlXmlString(
+ "<process name='p'>" +
+ " <start>" +
+ " <flow to='a' />" +
+ " </start>" +
+ " <state name='a' />" +
+ "</process>"
+ );
+
+ executionService.startExecutionByKey("p", "one");
+ Execution execution = executionService.signalExecutionById("p/one");
+ assertEquals("a", execution.getNodeName());
+ }
+}
Copied: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/cfg/ConfigurationTest.java (from rev 3557, jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/cfg/ConfigurationTest.java)
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/cfg/ConfigurationTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/cfg/ConfigurationTest.java 2008-12-27 12:58:42 UTC (rev 3558)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.cfg;
+
+import org.jbpm.Configuration;
+import org.jbpm.ProcessEngine;
+import org.jbpm.test.JbpmTestCase;
+
+/**
+ * @author Tom Baeyens
+ */
+public class ConfigurationTest extends JbpmTestCase {
+
+ public void testDefaultConfiguration() {
+ ProcessEngine processEngine = new Configuration()
+ .buildProcessEngine();
+ assertNotNull(processEngine);
+ }
+
+ public void testMinimalConfiguration() {
+ ProcessEngine processEngine = new Configuration()
+ .setXmlString("<jbpm-configuration />")
+ .buildProcessEngine();
+ assertNotNull(processEngine);
+ }
+
+ public void testConfigurationServices() {
+ ProcessEngine processEngine = new Configuration()
+ .setXmlString(
+ "<jbpm-configuration>" +
+ " <process-engine>" +
+ " <process-service />" +
+ " <execution-service />" +
+ " <management-service />" +
+ " </process-engine>" +
+ "</jbpm-configuration>"
+ )
+ .buildProcessEngine();
+ assertNotNull(processEngine);
+ assertNotNull(processEngine.getProcessService());
+ assertNotNull(processEngine.getExecutionService());
+ assertNotNull(processEngine.getManagementService());
+ }
+}
Copied: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/ExecutionServiceTest.java (from rev 3557, jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/ExecutionServiceTest.java)
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/ExecutionServiceTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/ExecutionServiceTest.java 2008-12-27 12:58:42 UTC (rev 3558)
@@ -0,0 +1,517 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.svc;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.jbpm.Execution;
+import org.jbpm.test.DbTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ExecutionServiceTest extends DbTestCase {
+
+ // start new process instance ///////////////////////////////////////////////
+
+ public void testStartNewProcessInstance() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <flow to='a' />" +
+ " </start>" +
+ " <state name='a' />" +
+ "</process>"
+ );
+
+ Execution execution = executionService.startExecutionByKey("ICL");
+
+ assertNotNull(execution);
+ assertEquals("a", execution.getNodeName());
+ }
+
+ public void testAutoSwitchToNewVersion() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <flow to='a' />" +
+ " </start>" +
+ " <state name='a' />" +
+ "</process>"
+ );
+
+ Execution execution = executionService.startExecutionByKey("ICL");
+
+ assertNotNull(execution);
+ assertEquals("a", execution.getNodeName());
+
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <flow to='b' />" +
+ " </start>" +
+ " <state name='b' />" +
+ "</process>"
+ );
+
+ execution = executionService.startExecutionByKey("ICL");
+
+ assertNotNull(execution);
+ assertEquals("b", execution.getNodeName());
+ }
+
+ public void testStartNewProcessInstanceWithAKey() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <flow to='a' />" +
+ " </start>" +
+ " <state name='a' />" +
+ "</process>"
+ );
+
+ Execution execution = executionService.startExecutionByKey("ICL", "one");
+
+ assertNotNull(execution);
+ assertEquals("ICL/one", execution.getId());
+ }
+
+ public void testStartNewProcessInstanceWithVariables() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <flow to='a' />" +
+ " </start>" +
+ " <state name='a' />" +
+ "</process>"
+ );
+
+ Map<String,Object> variables = new HashMap<String,Object>();
+ variables.put("customer", "John Doe");
+ variables.put("type", "Accident");
+ variables.put("amount", new Float(763.74));
+
+ Execution execution = executionService.startExecutionByKey("ICL", variables);
+
+ String executionId = execution.getId();
+
+ assertNotNull(execution);
+
+ Map<String,Object> expectedVariables = new HashMap<String, Object>(variables);
+ Set<String> expectedVariableNames = new HashSet<String>(expectedVariables.keySet());
+ Set<String> variableNames = new HashSet<String>(executionService.getVariableNames(executionId));
+ assertEquals(expectedVariableNames, variableNames);
+
+ variables = executionService.getVariables(executionId, variableNames);
+ assertEquals(expectedVariables, variables);
+ }
+
+ // signal ///////////////////////////////////////////////////////////////////
+
+ public void testSignalExecutionByKey() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <flow to='a' />" +
+ " </start>" +
+ " <state name='a'>" +
+ " <flow to='b' />" +
+ " </state>" +
+ " <state name='b'>" +
+ " <flow to='c' />" +
+ " </state>" +
+ " <state name='c' />" +
+ "</process>"
+ );
+
+ Execution execution = executionService.startExecutionByKey("ICL", "82436");
+
+ assertEquals("a", execution.getNodeName());
+
+ execution = executionService.signalExecutionByKey("ICL", "82436");
+
+ assertEquals("b", execution.getNodeName());
+
+ execution = executionService.signalExecutionByKey("ICL", "82436");
+
+ assertEquals("c", execution.getNodeName());
+ }
+
+ public void testSignalExecutionById() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <flow to='a' />" +
+ " </start>" +
+ " <state name='a'>" +
+ " <flow to='b' />" +
+ " </state>" +
+ " <state name='b'>" +
+ " <flow to='c' />" +
+ " </state>" +
+ " <state name='c' />" +
+ "</process>"
+ );
+
+ Execution execution = executionService.startExecutionByKey("ICL", "82436");
+
+ assertEquals("a", execution.getNodeName());
+
+ execution = executionService.signalExecutionById("ICL/82436");
+
+ assertEquals("b", execution.getNodeName());
+
+ execution = executionService.signalExecutionById("ICL/82436");
+
+ assertEquals("c", execution.getNodeName());
+ }
+
+ public void testSignalExecutionWithVariables() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <flow to='a' />" +
+ " </start>" +
+ " <state name='a'>" +
+ " <flow to='b' />" +
+ " </state>" +
+ " <state name='b' />" +
+ "</process>"
+ );
+
+ Execution execution = executionService.startExecutionByKey("ICL", "82436");
+
+ Map<String,Object> variables = new HashMap<String,Object>();
+ variables.put("customer", "John Doe");
+ variables.put("type", "Accident");
+ variables.put("amount", new Float(763.74));
+
+ execution = executionService.signalExecutionById("ICL/82436", variables);
+
+ assertNotNull(execution);
+ String executionId = execution.getId();
+ assertEquals("b", execution.getNodeName());
+
+ Map<String,Object> expectedVariables = new HashMap<String, Object>(variables);
+ Set<String> expectedVariableNames = new HashSet<String>(expectedVariables.keySet());
+ Set<String> variableNames = new HashSet<String>(executionService.getVariableNames(executionId));
+ assertEquals(expectedVariableNames, variableNames);
+
+ variables = executionService.getVariables(executionId, variableNames);
+ assertEquals(expectedVariables, variables);
+ }
+
+
+ /*
+ public void testDefaultSignalWithoutTransitions() {
+ deployJpdlXmlString(
+ "<process name='p'>" +
+ " <start>" +
+ " <flow to='a' />" +
+ " </start>" +
+ " <state name='a' />" +
+ "</process>"
+ );
+
+ executionService.startExecutionByName("p", "one");
+ Execution execution = executionService.signalExecution("p/one");
+ assertEquals("a", execution.getNodeName());
+ }
+
+ public void testStartExecutionById()
+ {
+ ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
+
+ // deploy process with key 'NCLFU' and version 1
+ // then we know that the key for this process will be 'NCLFU:1'
+ ClientProcessDefinition processDefinition = ProcessFactory.build("nuclear fusion")
+ .version(1)
+ .key("NCLFU")
+ .node("initial").initial()
+ .behaviour(WaitState.class)
+ .done();
+
+ DeploymentImpl deploymentImpl = new DeploymentImpl(processDefinition);
+ processService.deploy(deploymentImpl);
+
+ ExecutionService executionService = getEnvironmentFactory().get(ExecutionService.class);
+
+ // start an execution for the process with the given id
+ Execution execution = executionService.startExecutionById("NCLFU:1");
+ assertNotNull(execution);
+
+ // checking the state
+ assertEquals("initial", execution.getNodeName());
+
+ // checking the generated id
+ assertNull(execution.getName());
+ assertNull(execution.getKey());
+ // if there is no user defined name or key specified in the execution,
+ // the default id generator will create a unique id like this: processDefinitionId/execution.dbid
+ assertEquals("NCLFU:1/", execution.getId().substring(0, 8));
+ // the last part of the execution key should be the dbid.
+ Long.parseLong(execution.getId().substring(8));
+ }
+
+ public void testStartExecutionByIdWithGivenExecutionKey()
+ {
+ ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
+
+ // deploy the same process with a given key and version
+ ClientProcessDefinition processDefinition = ProcessFactory.build("nuclear fusion").version(1).key("NCLFU").node("initial").initial()
+ .behaviour(WaitState.class).done();
+
+ DeploymentImpl deploymentImpl = new DeploymentImpl(processDefinition);
+ processService.deploy(deploymentImpl);
+
+ ExecutionService executionService = getEnvironmentFactory().get(ExecutionService.class);
+
+ Execution execution = executionService.startExecutionById("NCLFU:1", "TheFirstTime");
+ assertNotNull(execution);
+
+ // checking the state
+ assertEquals("initial", execution.getNodeName());
+
+ // checking the generated id
+ assertNull(execution.getName());
+ assertEquals("TheFirstTime", execution.getKey());
+ // if there is a user provided key in the execution, the default
+ // id generator will take that to create the id
+ assertEquals("NCLFU:1/TheFirstTime", execution.getId());
+ }
+
+ public void testStartExecutionByIdWithVariables()
+ {
+ ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
+
+ ClientProcessDefinition processDefinition = ProcessFactory.build("nuclear fusion").version(1).key("NCLFU").node("initial").initial()
+ .behaviour(WaitState.class).done();
+
+ processService.deploy(new DeploymentImpl(processDefinition));
+
+ // create the map with variables
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("a", new Integer(1));
+ variables.put("b", "text");
+
+ ExecutionService executionService = getEnvironmentFactory().get(ExecutionService.class);
+
+ // provide the variables in the start execution method
+ Execution execution = executionService.startExecutionById("NCLFU:1", variables);
+ String executionId = execution.getId();
+
+ assertEquals(new Integer(1), executionService.getVariable(executionId, "a"));
+ assertEquals("text", executionService.getVariable(executionId, "b"));
+ }
+
+ public void testStartExecutionInLatest()
+ {
+ // deploy following processes
+ // 'nuclear fusion' with id NFU:1
+ // 'ultimate seduction' with id USD:1
+ // 'ultimate seduction' with id USD:2
+ // 'nuclear fusion' with id NFU:2
+ // 'publish book' with id PBO:1
+ // 'nuclear fusion' with id NFU:3
+ deployMultipleVersionsOfProcesses();
+
+ ExecutionService executionService = getEnvironmentFactory().get(ExecutionService.class);
+
+ // start a nuclear fusion in the latest version of
+ // the process definition with name 'nuclear fusion'
+ Execution execution = executionService.startExecutionByKey("NFU");
+ assertNotNull(execution);
+
+ // in the generated id, we can see if the right process definition version was taken
+ assertTrue("the execution id shows that the execution is not started in the latest version of the process: " + execution.getId(),
+ execution.getId().startsWith("NFU:3/"));
+ }
+
+ public void testStartExecutionInLatestByNameWithVariables()
+ {
+ // deploy following processes
+ // 'nuclear fusion' with id NFU:1
+ // 'ultimate seduction' with id USD:1
+ // 'ultimate seduction' with id USD:2
+ // 'nuclear fusion' with id NFU:2
+ // 'publish book' with id PBO:1
+ // 'nuclear fusion' with id NFU:3
+ deployMultipleVersionsOfProcesses();
+
+ ExecutionService executionService = getEnvironmentFactory().get(ExecutionService.class);
+
+ // create variables that are fed into the process before it starts executing
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("a", new Integer(1));
+ variables.put("b", "text");
+
+ // feed the variables in
+ Execution execution = executionService.startExecutionByName("nuclear fusion", variables);
+ String executionId = execution.getId();
+
+ // verify that the variables are actually set
+ assertEquals(new Integer(1), executionService.getVariable(executionId, "a"));
+ assertEquals("text", executionService.getVariable(executionId, "b"));
+
+ // in the generated id, we can see if the right process definition version was taken
+ assertTrue("the execution id shows that the execution is not started in the latest version of the process: " + execution.getId(),
+ execution.getId().startsWith("NFU:3/"));
+ }
+
+ public void testStartExecutionByNameWithKey()
+ {
+ // deploy following processes
+ // 'nuclear fusion' with id NFU:1
+ // 'ultimate seduction' with id USD:1
+ // 'ultimate seduction' with id USD:2
+ // 'nuclear fusion' with id NFU:2
+ // 'publish book' with id PBO:1
+ // 'nuclear fusion' with id NFU:3
+ deployMultipleVersionsOfProcesses();
+
+ ExecutionService executionService = getEnvironmentFactory().get(ExecutionService.class);
+
+ Execution execution = executionService.startExecutionByName("nuclear fusion", "TheFirstTime");
+ assertNotNull(execution);
+ assertEquals("TheFirstTime", execution.getKey());
+ assertEquals("NFU:3/TheFirstTime", execution.getId());
+ }
+
+ public void testFindExecution()
+ {
+ // create an arbitrary execution
+ Execution execution = startExecution();
+ // take the id and see if the execution service can still find it back
+ execution = executionService.findExecution(execution.getId());
+ assertNotNull(execution);
+ }
+
+ public void testSetVariable()
+ {
+ Execution execution = startExecution();
+
+ String executionId = execution.getId();
+ // set variable a to value text
+ executionService.setVariable(executionId, "a", "text");
+ // check if we can read that value back
+ assertEquals("text", executionService.getVariable(executionId, "a"));
+
+ // overwrite the value of variable a with another text
+ executionService.setVariable(executionId, "a", "another text");
+ // see if we can read another text back from the variable
+ assertEquals("another text", executionService.getVariable(executionId, "a"));
+ }
+
+ public void testSetVariables()
+ {
+ Execution execution = startExecution();
+
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("a", new Integer(1));
+ variables.put("b", "text");
+
+ // set variables in bulk by providing a map
+ executionService.setVariables(execution.getId(), variables);
+
+ Map<String, Object> expected = new HashMap<String, Object>(variables);
+
+ Set<String> variableNames = new HashSet<String>();
+ variableNames.add("a");
+ variableNames.add("b");
+
+ // read the variables back and compare
+ assertEquals(expected, executionService.getVariables(execution.getId(), variableNames));
+
+ // now set variables b and c with a map
+ variables = new HashMap<String, Object>();
+ variables.put("b", new Integer(99));
+ variables.put("c", "another text");
+
+ // this should leave a untouched, overwrite b and create c
+ executionService.setVariables(execution.getId(), variables);
+
+ // update the expected map
+ expected.put("b", new Integer(99));
+ expected.put("c", "another text");
+
+ // add c to the variable names that should be collected
+ variableNames.add("c");
+
+ // read the variables back and compare
+ assertEquals(expected, executionService.getVariables(execution.getId(), variableNames));
+ }
+
+ // helper methods ///////////////////////////////////////////////////////////
+
+ /**
+ * deploys 3 versions of process with name 'nuclear fusion', 2 versions of the processes 'ultimate seduction' and
+ * 'publish book'
+ void deployMultipleVersionsOfProcesses()
+ {
+ ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
+
+ ProcessDefinition processDefinition = ProcessFactory.build("nuclear fusion").key("NFU").node("initial").initial().behaviour(
+ WaitState.class).done();
+ DeploymentImpl deploymentImpl = new DeploymentImpl(processDefinition);
+ processService.deploy(deploymentImpl);
+
+ processDefinition = ProcessFactory.build("ultimate seduction").key("USD").node("initial").initial().behaviour(WaitState.class).done();
+ deploymentImpl = new DeploymentImpl(processDefinition);
+ processService.deploy(deploymentImpl);
+
+ processDefinition = ProcessFactory.build("ultimate seduction").key("USD").node("initial").initial().behaviour(WaitState.class).done();
+ deploymentImpl = new DeploymentImpl(processDefinition);
+ processService.deploy(deploymentImpl);
+
+ processDefinition = ProcessFactory.build("nuclear fusion").key("NFU").node("initial").initial().behaviour(WaitState.class).done();
+ deploymentImpl = new DeploymentImpl(processDefinition);
+ processService.deploy(deploymentImpl);
+
+ processDefinition = ProcessFactory.build("publish book").key("PBO").node("initial").initial().behaviour(WaitState.class).done();
+ deploymentImpl = new DeploymentImpl(processDefinition);
+ processService.deploy(deploymentImpl);
+
+ processDefinition = ProcessFactory.build("nuclear fusion").key("NFU").node("initial").initial().behaviour(WaitState.class).done();
+ deploymentImpl = new DeploymentImpl(processDefinition);
+ processService.deploy(deploymentImpl);
+ }
+
+ Execution startExecution()
+ {
+ ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
+
+ ProcessDefinition processDefinition = ProcessFactory.build("nuclear fusion").node("initial").initial().behaviour(WaitState.class)
+ .done();
+ DeploymentImpl deploymentImpl = new DeploymentImpl(processDefinition);
+ processService.deploy(deploymentImpl);
+
+ ExecutionService executionService = getEnvironmentFactory().get(ExecutionService.class);
+
+ return executionService.startExecutionByName("nuclear fusion");
+ }
+
+ */
+}
Property changes on: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/ExecutionServiceTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Copied: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/ManagementServiceTest.java (from rev 3557, jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/ManagementServiceTest.java)
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/ManagementServiceTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/ManagementServiceTest.java 2008-12-27 12:58:42 UTC (rev 3558)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.svc;
+
+import org.jbpm.test.DbTestCase;
+
+/**
+ * @author Tom Baeyens
+ */
+public class ManagementServiceTest extends DbTestCase {
+
+ public void testGetJobs() {
+ assertEquals(0, managementService.getTimers(0, 10).size());
+ assertEquals(0, managementService.getMessages(0, 10).size());
+ }
+
+}
Copied: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/ProcessServiceTest.java (from rev 3557, jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/ProcessServiceTest.java)
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/ProcessServiceTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/ProcessServiceTest.java 2008-12-27 12:58:42 UTC (rev 3558)
@@ -0,0 +1,357 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.svc;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.Execution;
+import org.jbpm.JbpmException;
+import org.jbpm.ProcessDefinition;
+import org.jbpm.test.DbTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ProcessServiceTest extends DbTestCase {
+
+ public void testProcessWithNameOnly() {
+ ProcessDefinition processDefinition = deployJpdlXmlString(
+ "<process name='Insurance claim'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ assertNotNull(processDefinition);
+ assertEquals("Insurance claim", processDefinition.getName());
+ assertEquals("Insurance_claim", processDefinition.getKey());
+ assertEquals(1, processDefinition.getVersion());
+ assertEquals("Insurance_claim:1", processDefinition.getId());
+ }
+
+ public void testProcessWithNameAndKey() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ ProcessDefinition processDefinition = processService.findLatestProcessDefinitionByKey("ICL");
+
+ assertNotNull(processDefinition);
+ assertEquals("Insurance claim", processDefinition.getName());
+ assertEquals("ICL", processDefinition.getKey());
+ assertEquals(1, processDefinition.getVersion());
+ assertEquals("ICL:1", processDefinition.getId());
+ }
+
+ // interface methods ////////////////////////////////////////////////////////
+
+ public void testFindProcessDefinitionKeys() {
+ deployMultipleVersionsOfProcesses();
+
+ List<String> processKeys = processService.findProcessDefinitionKeys();
+
+ List<String> expected = new ArrayList<String>();
+ expected.add("nuclear_fusion");
+ expected.add("publish_book");
+ expected.add("ultimate_seduction");
+
+ assertEquals(expected, processKeys);
+ }
+
+
+ public void testFindProcessByKey() {
+ deployJpdlXmlString(
+ "<process name='Name with spaces'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ ProcessDefinition processDefinition = processService.findLatestProcessDefinitionByKey("Name_with_spaces");
+ assertNotNull(processDefinition);
+ assertEquals("Name with spaces", processDefinition.getName());
+ assertEquals("Name_with_spaces", processDefinition.getKey());
+ assertEquals(1, processDefinition.getVersion());
+ assertEquals("Name_with_spaces:1", processDefinition.getId());
+ }
+
+ public void testFindProcessDefinitions() {
+ deployMultipleVersionsOfProcesses();
+
+ List<ProcessDefinition> processDefinitions = processService.findProcessDefinitionsByKey("nuclear_fusion");
+ assertNotNull(processDefinitions);
+
+ assertEquals("expected 3 but was " + processDefinitions.size() + ": " + processDefinitions, 3, processDefinitions.size());
+ assertEquals("nuclear fusion", processDefinitions.get(0).getName());
+ assertEquals(3, processDefinitions.get(0).getVersion());
+
+ assertEquals("nuclear fusion", processDefinitions.get(1).getName());
+ assertEquals(2, processDefinitions.get(1).getVersion());
+
+ assertEquals("nuclear fusion", processDefinitions.get(2).getName());
+ assertEquals(1, processDefinitions.get(2).getVersion());
+ }
+
+ public void testFindLatestProcessDefinition() {
+ deployMultipleVersionsOfProcesses();
+
+ ProcessDefinition retrieved = processService.findLatestProcessDefinitionByKey("nuclear_fusion");
+ assertNotNull(retrieved);
+
+ assertEquals(3, retrieved.getVersion());
+ assertEquals("nuclear fusion", retrieved.getName());
+ assertEquals("nuclear_fusion", retrieved.getKey());
+ }
+
+ public void testFindProcessDefinitionById() {
+ deployJpdlXmlString(
+ "<process name='given' version='33'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ // load it
+ ProcessDefinition processDefinition = processService.findProcessDefinitionById("given:33");
+ assertNotNull(processDefinition);
+ assertEquals("given", processDefinition.getName());
+ assertEquals(33, processDefinition.getVersion());
+ }
+
+ public void testDeleteProcessDefinition() {
+ processService.createDeployment()
+ .addString("xmlstring.jpdl.xml",
+ "<process name='deleteme' version='33'>" +
+ " <start />" +
+ "</process>")
+ .deploy();
+
+ // load it
+ processService.deleteProcessDefinition("deleteme:33");
+
+ // check if the db is empty
+ assertEquals(0, processService.createProcessDefinitionQuery().list().size());
+ }
+
+ public void testDeleteProcessDefinitionAndInstances() {
+ processService.createDeployment()
+ .addString("xmlstring.jpdl.xml",
+ "<process name='deleteme' version='33'>" +
+ " <start>" +
+ " <flow to='w' />" +
+ " </start>" +
+ " <state name='w' />" +
+ "</process>")
+ .deploy();
+
+ executionService.startExecutionByKey("deleteme");
+ executionService.startExecutionByKey("deleteme");
+ executionService.startExecutionByKey("deleteme");
+ executionService.startExecutionByKey("deleteme");
+
+ // delete it all
+ processService.deleteProcessDefinitionAndInstances("deleteme:33");
+
+ // check if the db is empty
+ assertEquals(0, processService.createProcessDefinitionQuery().list().size());
+ assertEquals(0, executionService.createExecutionQuery().list().size());
+ }
+
+ public void testDeleteProcessDefinitionButNotInstances() {
+ deployJpdlXmlString(
+ "<process name='deleteme' version='33'>" +
+ " <start>" +
+ " <flow to='w' />" +
+ " </start>" +
+ " <state name='w' />" +
+ "</process>"
+ );
+
+ executionService.startExecutionByKey("deleteme");
+ executionService.startExecutionByKey("deleteme");
+ executionService.startExecutionByKey("deleteme");
+ executionService.startExecutionByKey("deleteme");
+
+ // delete it all
+ try {
+ processService.deleteProcessDefinition("deleteme:33");
+ fail("expected exception");
+ } catch (JbpmException e) {
+ assertTextPresent("still 4 process instances for process definition deleteme:33", e.getMessage());
+ }
+ }
+
+ // various other aspects ////////////////////////////////////////////////////
+
+ public void testAutomaticVersioning() {
+ deployJpdlXmlString(
+ "<process name='versionme'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ // look it up again
+ List<ProcessDefinition> processDefinitions = processService.findProcessDefinitionsByKey("versionme");
+ assertNotNull(processDefinitions);
+ // verify that there is only one
+ assertEquals(processDefinitions.toString(), 1, processDefinitions.size());
+ ProcessDefinition processDefinition = processDefinitions.get(0);
+ // and check that automatically assigned version starts with 1
+ assertEquals(1, processDefinition.getVersion());
+
+ deployJpdlXmlString(
+ "<process name='versionme'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ // look them up again
+ processDefinitions = processService.findProcessDefinitionsByKey("versionme");
+ // verify that there is only one
+ assertEquals(processDefinitions.toString(), 2, processDefinitions.size());
+ // and check that automatically assigned version starts with 1
+ assertEquals(2, processDefinitions.get(0).getVersion());
+ assertEquals(1, processDefinitions.get(1).getVersion());
+ }
+
+ public void testUserProvidedVersion() {
+ deployJpdlXmlString(
+ "<process name='takethis' version='234'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ // load it
+ List<ProcessDefinition> processDefinitions = processService.findProcessDefinitionsByKey("takethis");
+ assertNotNull(processDefinitions);
+ assertEquals(processDefinitions.toString(), 1, processDefinitions.size());
+ ProcessDefinition processDefinition = processDefinitions.get(0);
+ // verify that the user specified version was used
+ // (and not overwritten by an automatically assigned versioning)
+ assertEquals(234, processDefinition.getVersion());
+ }
+
+ public void testDuplicateUserProvidedVersion() {
+ deployJpdlXmlString(
+ "<process name='takethis' version='234'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ try {
+ deployJpdlXmlString(
+ "<process name='takethis' version='234'>" +
+ " <start />" +
+ "</process>"
+ );
+ fail("expected exception");
+ } catch (JbpmException e) {
+ assertTextPresent("process 'takethis:234' already exists", e.getMessage());
+ }
+ }
+
+ /**
+ * deploys 3 versions of process with name 'nuclear fusion', 2 versions of the processes 'ultimate seduction' and
+ * 'publish book'
+ */
+ void deployMultipleVersionsOfProcesses()
+ {
+ deployJpdlXmlString(
+ "<process name='nuclear fusion'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='ultimate seduction'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='ultimate seduction'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='ultimate seduction'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='ultimate seduction'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='publish book'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='nuclear fusion'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='nuclear fusion'>" +
+ " <start />" +
+ "</process>"
+ );
+ }
+
+ public void testMinimalProcess() {
+ deployJpdlXmlString(
+ "<process name='minimal'>" +
+ " <start>" +
+ " <flow to='end' />" +
+ " </start>" +
+ " <end name='end' />" +
+ "</process>"
+ );
+
+ Execution execution = executionService.startExecutionByKey("minimal");
+
+ assertEquals("end", execution.getNodeName());
+ assertTrue(execution.isEnded());
+ assertFalse(execution.isActive());
+ }
+
+ public void testMostMinimalProcess() {
+ deployJpdlXmlString(
+ "<process name='minimal'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ Execution execution = executionService.startExecutionByKey("minimal");
+
+ assertTrue(execution.isEnded());
+ assertFalse(execution.isActive());
+ }
+}
Copied: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/TaskServiceTest.java (from rev 3557, jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/TaskServiceTest.java)
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/TaskServiceTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/TaskServiceTest.java 2008-12-27 12:58:42 UTC (rev 3558)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.svc;
+
+import java.util.Date;
+
+import org.jbpm.task.Task;
+import org.jbpm.test.DbTestCase;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class TaskServiceTest extends DbTestCase {
+
+ public void testNewTask() {
+ Task task = taskService.newTask();
+ task = taskService.getTask(task.getId());
+ assertNull("expected null, but was " + task, task);
+ }
+
+ public void testGenerateTaskId() {
+ Task task = taskService.newTask();
+ String taskId = task.getId();
+ assertNull("expected null, but was " + taskId, taskId);
+ // save task to generate identifier
+ saveTask(task);
+ assertNotNull("expected non-null task id", task.getId());
+ }
+
+ public void testSaveTask() {
+ Task task = taskService.newTask();
+ saveTask(task);
+ String taskId = task.getId();
+ // task was made persistent
+ task = taskService.getTask(taskId);
+ assertNotNull("expected non-null task", task);
+ // make some change
+ Date dueDate = new Date();
+ task.setDueDate(dueDate);
+ taskService.saveTask(task);
+ // verify change is applied
+ task = taskService.getTask(taskId);
+ assertEquals(dueDate, task.getDueDate());
+ }
+
+ public void testDeleteTask() {
+ Task task = taskService.newTask();
+ taskService.saveTask(task);
+ String taskId = task.getId();
+
+ // task was made persistent
+ assertNotNull("expected non-null task", taskService.getTask(taskId));
+ // delete task and verify it does not exist
+ taskService.deleteTask(taskId);
+ task = taskService.getTask(taskId);
+ assertNull("expected null, but was " + task, task);
+ }
+}
Copied: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/variables/BasicVariablesTest.java (from rev 3557, jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/variables/BasicVariablesTest.java)
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/variables/BasicVariablesTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/variables/BasicVariablesTest.java 2008-12-27 12:58:42 UTC (rev 3558)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.variables;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.jbpm.test.DbTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class BasicVariablesTest extends DbTestCase {
+
+ public void testNoVariables() {
+ deployJpdlXmlString(
+ "<process name='var'>" +
+ " <start name='a'>" +
+ " <flow to='b' />" +
+ " </start>" +
+ " <state name='b'/>" +
+ "</process>"
+ );
+
+ executionService.startExecutionByKey("var", "one");
+ Set<String> variableNames = executionService.getVariableNames("var/one");
+ assertNotNull(variableNames);
+ assertEquals(0, variableNames.size());
+ }
+
+ public void testThreeVariables() {
+ deployJpdlXmlString(
+ "<process name='var'>" +
+ " <start name='a'>" +
+ " <flow to='b' />" +
+ " </start>" +
+ " <state name='b'/>" +
+ "</process>"
+ );
+
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("customer", "John Doe");
+ variables.put("type", "Accident");
+ variables.put("amount", new Float(763.74));
+
+ Set<String> expectedVariableNames = new HashSet<String>(variables.keySet());
+ Map<String, Object> expectedVariables = new HashMap<String, Object>(variables);
+
+ executionService.startExecutionByKey("var", variables, "one");
+
+ Set<String> variableNames = executionService.getVariableNames("var/one");
+ assertNotNull(variableNames);
+
+ assertEquals(expectedVariableNames, variableNames);
+
+ variables = executionService.getVariables("var/one", variableNames);
+
+ assertEquals(expectedVariables, variables);
+ }
+}
Property changes on: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/variables/BasicVariablesTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Copied: jbpm4/trunk/modules/test-db/src/main/resources/hibernate.properties (from rev 3557, jbpm4/trunk/modules/test-db/src/test/resources/hibernate.properties)
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/resources/hibernate.properties (rev 0)
+++ jbpm4/trunk/modules/test-db/src/main/resources/hibernate.properties 2008-12-27 12:58:42 UTC (rev 3558)
@@ -0,0 +1,11 @@
+hibernate.dialect org.hibernate.dialect.HSQLDialect
+hibernate.connection.driver_class org.hsqldb.jdbcDriver
+hibernate.connection.url jdbc:hsqldb:mem:.
+hibernate.connection.username sa
+hibernate.connection.password
+hibernate.hbm2ddl.auto create-drop
+hibernate.cache.use_second_level_cache true
+hibernate.cache.provider_class org.hibernate.cache.HashtableCacheProvider
+# hibernate.show_sql true
+# hibernate.format_sql true
+# hibernate.use_sql_comments true
Property changes on: jbpm4/trunk/modules/test-db/src/main/resources/hibernate.properties
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: jbpm4/trunk/modules/test-db/src/main/resources/jbpm.cfg.xml (from rev 3557, jbpm4/trunk/modules/test-db/src/test/resources/jbpm.cfg.xml)
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/resources/jbpm.cfg.xml (rev 0)
+++ jbpm4/trunk/modules/test-db/src/main/resources/jbpm.cfg.xml 2008-12-27 12:58:42 UTC (rev 3558)
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jbpm-configuration xmlns="http://jbpm.org/xsd/cfg">
+
+ <process-engine>
+
+ <deployer-manager>
+ <assign-file-type>
+ <file extension=".jpdl.xml" type="jpdl" />
+ </assign-file-type>
+ <parse-jpdl />
+ <check-process />
+ <check-problems />
+ <save />
+ </deployer-manager>
+
+ <process-service />
+ <execution-service />
+ <management-service />
+ <task-service />
+
+ <command-service>
+ <retry-interceptor />
+ <environment-interceptor />
+ <standard-transaction-interceptor />
+ </command-service>
+
+ <hibernate-configuration>
+ <properties resource="hibernate.properties" />
+ <mapping resource="jbpm.pvm.typedefs.hbm.xml" />
+ <mapping resource="jbpm.pvm.wire.hbm.xml" />
+ <mapping resource="jbpm.pvm.definition.hbm.xml" />
+ <mapping resource="jbpm.pvm.execution.hbm.xml" />
+ <mapping resource="jbpm.pvm.variable.hbm.xml" />
+ <mapping resource="jbpm.pvm.job.hbm.xml" />
+ <mapping resource="jbpm.jpdl.hbm.xml" />
+ <mapping resource="jbpm.task.hbm.xml" />
+ <cache-configuration resource="jbpm.pvm.cache.xml"
+ usage="nonstrict-read-write" />
+ </hibernate-configuration>
+
+ <hibernate-session-factory />
+
+ <script-manager default-expression-language="juel"
+ default-script-language="juel"
+ read-contexts="execution, environment, process-engine"
+ write-context="">
+ <script-language name="juel" factory="com.sun.script.juel.JuelScriptEngineFactory" />
+ </script-manager>
+
+ <job-executor auto-start="false" />
+ <job-test-helper />
+
+ <id-generator />
+ <variable-types resource="jbpm.pvm.types.xml" />
+
+ <business-calendar>
+ <monday hours="9:00-12:00 and 12:30-17:00"/>
+ <tuesday hours="9:00-12:00 and 12:30-17:00"/>
+ <wednesday hours="9:00-12:00 and 12:30-17:00"/>
+ <thursday hours="9:00-12:00 and 12:30-17:00"/>
+ <friday hours="9:00-12:00 and 12:30-17:00"/>
+ <holiday period="01/07/2008 - 31/08/2008"/>
+ </business-calendar>
+
+ </process-engine>
+
+ <environment>
+ <hibernate-session />
+ <transaction />
+ <pvm-db-session />
+ <job-db-session />
+ <task-db-session />
+ <message-session />
+ <timer-session />
+ </environment>
+
+</jbpm-configuration>
Property changes on: jbpm4/trunk/modules/test-db/src/main/resources/jbpm.cfg.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Copied: jbpm4/trunk/modules/test-db/src/main/resources/logging.properties (from rev 3557, jbpm4/trunk/modules/test-db/src/test/resources/logging.properties)
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/resources/logging.properties (rev 0)
+++ jbpm4/trunk/modules/test-db/src/main/resources/logging.properties 2008-12-27 12:58:42 UTC (rev 3558)
@@ -0,0 +1,28 @@
+handlers= java.util.logging.ConsoleHandler
+# to add the error triggered file handler
+# handlers= java.util.logging.ConsoleHandler org.jbpm.util.ErrorTriggeredFileHandler
+
+redirect.commons.logging = enabled
+
+java.util.logging.ConsoleHandler.level = FINEST
+java.util.logging.ConsoleHandler.formatter = org.jbpm.log.LogFormatter
+
+# org.jbpm.util.ErrorTriggeredFileHandler.size = 500
+# org.jbpm.util.ErrorTriggeredFileHandler.push = OFF
+# org.jbpm.util.ErrorTriggeredFileHandler.pattern = %h/jbpm%u.log
+
+# For example, set the com.xyz.foo logger to only log SEVERE messages:
+# com.xyz.foo.level = SEVERE
+
+org.jbpm.level=INFO
+# org.jbpm.pvm.internal.tx.level=FINE
+# org.jbpm.pvm.internal.wire.level=FINE
+# org.jbpm.pvm.internal.util.level=FINE
+
+org.hibernate.level=INFO
+org.hibernate.cfg.HbmBinder.level=SEVERE
+org.hibernate.cfg.SettingsFactory.level=SEVERE
+# org.hibernate.SQL.level=FINEST
+# org.hibernate.type.level=FINEST
+# org.hibernate.tool.hbm2ddl.SchemaExport.level=FINEST
+# org.hibernate.transaction.level=FINEST
Deleted: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/ExclusiveTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/ExclusiveTest.java 2008-12-27 11:30:11 UTC (rev 3557)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/ExclusiveTest.java 2008-12-27 12:58:42 UTC (rev 3558)
@@ -1,98 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.test.activities;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.jbpm.Execution;
-import org.jbpm.jpdl.ExclusiveHandler;
-import org.jbpm.model.OpenExecution;
-import org.jbpm.test.DbTestCase;
-
-
-/**
- * @author Tom Baeyens
- */
-public class ExclusiveTest extends DbTestCase {
-
- public void testExclusiveExpression() {
- deployJpdlXmlString(
- "<process name='Poolcar'>" +
- " <start>" +
- " <flow to='How far?' />" +
- " </start>" +
- " <exclusive name='How far?' expr='#{distance}'>" +
- " <flow name='far' to='Big car' />" +
- " <flow name='nearby' to='Small car' />" +
- " </exclusive>" +
- " <state name='Big car' />" +
- " <state name='Small car' />" +
- "</process>"
- );
-
- Map<String, Object> variables = new HashMap<String, Object>();
- variables.put("distance", "far");
- Execution execution = executionService.startExecutionByKey("Poolcar", variables);
- assertEquals("Big car", execution.getNodeName());
-
- variables.put("distance", "nearby");
- execution = executionService.startExecutionByKey("Poolcar", variables);
- assertEquals("Small car", execution.getNodeName());
- }
-
- public void testExclusiveWithConditions() {
- deployJpdlXmlString(
- "<process name='Poolcar'>" +
- " <start>" +
- " <flow to='How far?' />" +
- " </start>" +
- " <exclusive name='How far?'>" +
- " <flow to='Big car'>" +
- " <condition expr='#{distance > 10}' />" +
- " </flow>" +
- " <flow to='Small car'>" +
- " <condition expr='#{distance >= 3}' />" +
- " </flow>" +
- " <flow to='No car' />" +
- " </exclusive>" +
- " <state name='Big car' />" +
- " <state name='Small car' />" +
- " <state name='No car' />" +
- "</process>"
- );
-
- Map<String, Object> variables = new HashMap<String, Object>();
- variables.put("distance", new Integer(69));
- Execution execution = executionService.startExecutionByKey("Poolcar", variables);
- assertEquals("Big car", execution.getNodeName());
-
- variables.put("distance", new Integer(6));
- execution = executionService.startExecutionByKey("Poolcar", variables);
- assertEquals("Small car", execution.getNodeName());
-
- variables.put("distance", new Integer(2));
- execution = executionService.startExecutionByKey("Poolcar", variables);
- assertEquals("No car", execution.getNodeName());
- }
-
-}
Deleted: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/StateTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/StateTest.java 2008-12-27 11:30:11 UTC (rev 3557)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/StateTest.java 2008-12-27 12:58:42 UTC (rev 3558)
@@ -1,153 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.test.activities;
-
-import org.jbpm.Execution;
-import org.jbpm.JbpmException;
-import org.jbpm.test.DbTestCase;
-
-/**
- * @author Tom Baeyens
- */
-public class StateTest extends DbTestCase {
-
- public void testWaitStatesSequence() {
- deployJpdlXmlString(
- "<process name='ThreeStates'>" +
- " <start name='a'>" +
- " <flow to='b' />" +
- " </start>" +
- " <state name='b'>" +
- " <flow to='c' />" +
- " </state>" +
- " <state name='c'>" +
- " <flow to='d' />" +
- " </state>" +
- " <end name='d' />" +
- "</process>"
- );
-
- Execution execution = executionService.startExecutionById("ThreeStates:1");
- assertEquals("b", execution.getNodeName());
-
- String executionId = execution.getId();
- execution = executionService.signalExecutionById(executionId);
- assertEquals("c", execution.getNodeName());
-
- execution = executionService.signalExecutionById(executionId);
- assertEquals("d", execution.getNodeName());
- assertTrue(execution.isEnded());
- }
-
- public void testExternalDecision() {
- deployJpdlXmlString(
- "<process name='p'>" +
- " <start>" +
- " <flow to='ed' />" +
- " </start>" +
- " <state name='ed'>" +
- " <flow name='left' to='b' />" +
- " <flow name='middle' to='c' />" +
- " <flow name='right' to='d' />" +
- " </state>" +
- " <state name='b' />" +
- " <state name='c' />" +
- " <state name='d' />" +
- "</process>"
- );
-
- Execution execution = executionService.startExecutionByKey("p", "one");
- assertEquals("ed", execution.getNodeName());
- execution = executionService.signalExecutionById("p/one", "left");
- assertEquals("b", execution.getNodeName());
-
- executionService.startExecutionById("p:1", "two");
- execution = executionService.signalExecutionById("p/two", "middle");
- assertEquals("c", execution.getNodeName());
-
- executionService.startExecutionById("p:1", "three");
- execution = executionService.signalExecutionById("p/three", "right");
- assertEquals("d", execution.getNodeName());
- }
-
- public void testDefaultSignalWithNamedTransitions() {
- deployJpdlXmlString(
- "<process name='p'>" +
- " <start>" +
- " <flow to='a' />" +
- " </start>" +
- " <state name='a'>" +
- " <flow name='left' to='b' />" +
- " <flow name='middle' to='c' />" +
- " <flow name='right' to='d' />" +
- " </state>" +
- " <state name='b' />" +
- " <state name='c' />" +
- " <state name='d' />" +
- "</process>"
- );
-
- executionService.startExecutionByKey("p", "one");
- try {
- executionService.signalExecutionById("p/one", "left");
- } catch (JbpmException e) {
- assertTextPresent("no matching transition or event for default signal in state(a)", e.getMessage());
- }
- }
-
- public void testNamedSignalWithoutMatchingTransition() {
- deployJpdlXmlString(
- "<process name='p'>" +
- " <start>" +
- " <flow to='a' />" +
- " </start>" +
- " <state name='a'>" +
- " <flow name='left' to='b' />" +
- " <flow name='middle' to='c' />" +
- " <flow name='right' to='d' />" +
- " </state>" +
- " <state name='b' />" +
- " <state name='c' />" +
- " <state name='d' />" +
- "</process>"
- );
-
- executionService.startExecutionByKey("p", "one");
- Execution execution = executionService.signalExecutionById("p/one", "up");
- assertEquals("a", execution.getNodeName());
- }
-
- public void testDefaultSignalWithoutTransitions() {
- deployJpdlXmlString(
- "<process name='p'>" +
- " <start>" +
- " <flow to='a' />" +
- " </start>" +
- " <state name='a' />" +
- "</process>"
- );
-
- executionService.startExecutionByKey("p", "one");
- Execution execution = executionService.signalExecutionById("p/one");
- assertEquals("a", execution.getNodeName());
- }
-}
Deleted: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/cfg/ConfigurationTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/cfg/ConfigurationTest.java 2008-12-27 11:30:11 UTC (rev 3557)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/cfg/ConfigurationTest.java 2008-12-27 12:58:42 UTC (rev 3558)
@@ -1,63 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.test.cfg;
-
-import org.jbpm.Configuration;
-import org.jbpm.ProcessEngine;
-import org.jbpm.test.JbpmTestCase;
-
-/**
- * @author Tom Baeyens
- */
-public class ConfigurationTest extends JbpmTestCase {
-
- public void testDefaultConfiguration() {
- ProcessEngine processEngine = new Configuration()
- .buildProcessEngine();
- assertNotNull(processEngine);
- }
-
- public void testMinimalConfiguration() {
- ProcessEngine processEngine = new Configuration()
- .setXmlString("<jbpm-configuration />")
- .buildProcessEngine();
- assertNotNull(processEngine);
- }
-
- public void testConfigurationServices() {
- ProcessEngine processEngine = new Configuration()
- .setXmlString(
- "<jbpm-configuration>" +
- " <process-engine>" +
- " <process-service />" +
- " <execution-service />" +
- " <management-service />" +
- " </process-engine>" +
- "</jbpm-configuration>"
- )
- .buildProcessEngine();
- assertNotNull(processEngine);
- assertNotNull(processEngine.getProcessService());
- assertNotNull(processEngine.getExecutionService());
- assertNotNull(processEngine.getManagementService());
- }
-}
Deleted: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/ExecutionServiceTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/ExecutionServiceTest.java 2008-12-27 11:30:11 UTC (rev 3557)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/ExecutionServiceTest.java 2008-12-27 12:58:42 UTC (rev 3558)
@@ -1,517 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.test.svc;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.jbpm.Execution;
-import org.jbpm.test.DbTestCase;
-
-
-/**
- * @author Tom Baeyens
- */
-public class ExecutionServiceTest extends DbTestCase {
-
- // start new process instance ///////////////////////////////////////////////
-
- public void testStartNewProcessInstance() {
- deployJpdlXmlString(
- "<process name='Insurance claim' key='ICL'>" +
- " <start>" +
- " <flow to='a' />" +
- " </start>" +
- " <state name='a' />" +
- "</process>"
- );
-
- Execution execution = executionService.startExecutionByKey("ICL");
-
- assertNotNull(execution);
- assertEquals("a", execution.getNodeName());
- }
-
- public void testAutoSwitchToNewVersion() {
- deployJpdlXmlString(
- "<process name='Insurance claim' key='ICL'>" +
- " <start>" +
- " <flow to='a' />" +
- " </start>" +
- " <state name='a' />" +
- "</process>"
- );
-
- Execution execution = executionService.startExecutionByKey("ICL");
-
- assertNotNull(execution);
- assertEquals("a", execution.getNodeName());
-
- deployJpdlXmlString(
- "<process name='Insurance claim' key='ICL'>" +
- " <start>" +
- " <flow to='b' />" +
- " </start>" +
- " <state name='b' />" +
- "</process>"
- );
-
- execution = executionService.startExecutionByKey("ICL");
-
- assertNotNull(execution);
- assertEquals("b", execution.getNodeName());
- }
-
- public void testStartNewProcessInstanceWithAKey() {
- deployJpdlXmlString(
- "<process name='Insurance claim' key='ICL'>" +
- " <start>" +
- " <flow to='a' />" +
- " </start>" +
- " <state name='a' />" +
- "</process>"
- );
-
- Execution execution = executionService.startExecutionByKey("ICL", "one");
-
- assertNotNull(execution);
- assertEquals("ICL/one", execution.getId());
- }
-
- public void testStartNewProcessInstanceWithVariables() {
- deployJpdlXmlString(
- "<process name='Insurance claim' key='ICL'>" +
- " <start>" +
- " <flow to='a' />" +
- " </start>" +
- " <state name='a' />" +
- "</process>"
- );
-
- Map<String,Object> variables = new HashMap<String,Object>();
- variables.put("customer", "John Doe");
- variables.put("type", "Accident");
- variables.put("amount", new Float(763.74));
-
- Execution execution = executionService.startExecutionByKey("ICL", variables);
-
- String executionId = execution.getId();
-
- assertNotNull(execution);
-
- Map<String,Object> expectedVariables = new HashMap<String, Object>(variables);
- Set<String> expectedVariableNames = new HashSet<String>(expectedVariables.keySet());
- Set<String> variableNames = new HashSet<String>(executionService.getVariableNames(executionId));
- assertEquals(expectedVariableNames, variableNames);
-
- variables = executionService.getVariables(executionId, variableNames);
- assertEquals(expectedVariables, variables);
- }
-
- // signal ///////////////////////////////////////////////////////////////////
-
- public void testSignalExecutionByKey() {
- deployJpdlXmlString(
- "<process name='Insurance claim' key='ICL'>" +
- " <start>" +
- " <flow to='a' />" +
- " </start>" +
- " <state name='a'>" +
- " <flow to='b' />" +
- " </state>" +
- " <state name='b'>" +
- " <flow to='c' />" +
- " </state>" +
- " <state name='c' />" +
- "</process>"
- );
-
- Execution execution = executionService.startExecutionByKey("ICL", "82436");
-
- assertEquals("a", execution.getNodeName());
-
- execution = executionService.signalExecutionByKey("ICL", "82436");
-
- assertEquals("b", execution.getNodeName());
-
- execution = executionService.signalExecutionByKey("ICL", "82436");
-
- assertEquals("c", execution.getNodeName());
- }
-
- public void testSignalExecutionById() {
- deployJpdlXmlString(
- "<process name='Insurance claim' key='ICL'>" +
- " <start>" +
- " <flow to='a' />" +
- " </start>" +
- " <state name='a'>" +
- " <flow to='b' />" +
- " </state>" +
- " <state name='b'>" +
- " <flow to='c' />" +
- " </state>" +
- " <state name='c' />" +
- "</process>"
- );
-
- Execution execution = executionService.startExecutionByKey("ICL", "82436");
-
- assertEquals("a", execution.getNodeName());
-
- execution = executionService.signalExecutionById("ICL/82436");
-
- assertEquals("b", execution.getNodeName());
-
- execution = executionService.signalExecutionById("ICL/82436");
-
- assertEquals("c", execution.getNodeName());
- }
-
- public void testSignalExecutionWithVariables() {
- deployJpdlXmlString(
- "<process name='Insurance claim' key='ICL'>" +
- " <start>" +
- " <flow to='a' />" +
- " </start>" +
- " <state name='a'>" +
- " <flow to='b' />" +
- " </state>" +
- " <state name='b' />" +
- "</process>"
- );
-
- Execution execution = executionService.startExecutionByKey("ICL", "82436");
-
- Map<String,Object> variables = new HashMap<String,Object>();
- variables.put("customer", "John Doe");
- variables.put("type", "Accident");
- variables.put("amount", new Float(763.74));
-
- execution = executionService.signalExecutionById("ICL/82436", variables);
-
- assertNotNull(execution);
- String executionId = execution.getId();
- assertEquals("b", execution.getNodeName());
-
- Map<String,Object> expectedVariables = new HashMap<String, Object>(variables);
- Set<String> expectedVariableNames = new HashSet<String>(expectedVariables.keySet());
- Set<String> variableNames = new HashSet<String>(executionService.getVariableNames(executionId));
- assertEquals(expectedVariableNames, variableNames);
-
- variables = executionService.getVariables(executionId, variableNames);
- assertEquals(expectedVariables, variables);
- }
-
-
- /*
- public void testDefaultSignalWithoutTransitions() {
- deployJpdlXmlString(
- "<process name='p'>" +
- " <start>" +
- " <flow to='a' />" +
- " </start>" +
- " <state name='a' />" +
- "</process>"
- );
-
- executionService.startExecutionByName("p", "one");
- Execution execution = executionService.signalExecution("p/one");
- assertEquals("a", execution.getNodeName());
- }
-
- public void testStartExecutionById()
- {
- ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
-
- // deploy process with key 'NCLFU' and version 1
- // then we know that the key for this process will be 'NCLFU:1'
- ClientProcessDefinition processDefinition = ProcessFactory.build("nuclear fusion")
- .version(1)
- .key("NCLFU")
- .node("initial").initial()
- .behaviour(WaitState.class)
- .done();
-
- DeploymentImpl deploymentImpl = new DeploymentImpl(processDefinition);
- processService.deploy(deploymentImpl);
-
- ExecutionService executionService = getEnvironmentFactory().get(ExecutionService.class);
-
- // start an execution for the process with the given id
- Execution execution = executionService.startExecutionById("NCLFU:1");
- assertNotNull(execution);
-
- // checking the state
- assertEquals("initial", execution.getNodeName());
-
- // checking the generated id
- assertNull(execution.getName());
- assertNull(execution.getKey());
- // if there is no user defined name or key specified in the execution,
- // the default id generator will create a unique id like this: processDefinitionId/execution.dbid
- assertEquals("NCLFU:1/", execution.getId().substring(0, 8));
- // the last part of the execution key should be the dbid.
- Long.parseLong(execution.getId().substring(8));
- }
-
- public void testStartExecutionByIdWithGivenExecutionKey()
- {
- ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
-
- // deploy the same process with a given key and version
- ClientProcessDefinition processDefinition = ProcessFactory.build("nuclear fusion").version(1).key("NCLFU").node("initial").initial()
- .behaviour(WaitState.class).done();
-
- DeploymentImpl deploymentImpl = new DeploymentImpl(processDefinition);
- processService.deploy(deploymentImpl);
-
- ExecutionService executionService = getEnvironmentFactory().get(ExecutionService.class);
-
- Execution execution = executionService.startExecutionById("NCLFU:1", "TheFirstTime");
- assertNotNull(execution);
-
- // checking the state
- assertEquals("initial", execution.getNodeName());
-
- // checking the generated id
- assertNull(execution.getName());
- assertEquals("TheFirstTime", execution.getKey());
- // if there is a user provided key in the execution, the default
- // id generator will take that to create the id
- assertEquals("NCLFU:1/TheFirstTime", execution.getId());
- }
-
- public void testStartExecutionByIdWithVariables()
- {
- ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
-
- ClientProcessDefinition processDefinition = ProcessFactory.build("nuclear fusion").version(1).key("NCLFU").node("initial").initial()
- .behaviour(WaitState.class).done();
-
- processService.deploy(new DeploymentImpl(processDefinition));
-
- // create the map with variables
- Map<String, Object> variables = new HashMap<String, Object>();
- variables.put("a", new Integer(1));
- variables.put("b", "text");
-
- ExecutionService executionService = getEnvironmentFactory().get(ExecutionService.class);
-
- // provide the variables in the start execution method
- Execution execution = executionService.startExecutionById("NCLFU:1", variables);
- String executionId = execution.getId();
-
- assertEquals(new Integer(1), executionService.getVariable(executionId, "a"));
- assertEquals("text", executionService.getVariable(executionId, "b"));
- }
-
- public void testStartExecutionInLatest()
- {
- // deploy following processes
- // 'nuclear fusion' with id NFU:1
- // 'ultimate seduction' with id USD:1
- // 'ultimate seduction' with id USD:2
- // 'nuclear fusion' with id NFU:2
- // 'publish book' with id PBO:1
- // 'nuclear fusion' with id NFU:3
- deployMultipleVersionsOfProcesses();
-
- ExecutionService executionService = getEnvironmentFactory().get(ExecutionService.class);
-
- // start a nuclear fusion in the latest version of
- // the process definition with name 'nuclear fusion'
- Execution execution = executionService.startExecutionByKey("NFU");
- assertNotNull(execution);
-
- // in the generated id, we can see if the right process definition version was taken
- assertTrue("the execution id shows that the execution is not started in the latest version of the process: " + execution.getId(),
- execution.getId().startsWith("NFU:3/"));
- }
-
- public void testStartExecutionInLatestByNameWithVariables()
- {
- // deploy following processes
- // 'nuclear fusion' with id NFU:1
- // 'ultimate seduction' with id USD:1
- // 'ultimate seduction' with id USD:2
- // 'nuclear fusion' with id NFU:2
- // 'publish book' with id PBO:1
- // 'nuclear fusion' with id NFU:3
- deployMultipleVersionsOfProcesses();
-
- ExecutionService executionService = getEnvironmentFactory().get(ExecutionService.class);
-
- // create variables that are fed into the process before it starts executing
- Map<String, Object> variables = new HashMap<String, Object>();
- variables.put("a", new Integer(1));
- variables.put("b", "text");
-
- // feed the variables in
- Execution execution = executionService.startExecutionByName("nuclear fusion", variables);
- String executionId = execution.getId();
-
- // verify that the variables are actually set
- assertEquals(new Integer(1), executionService.getVariable(executionId, "a"));
- assertEquals("text", executionService.getVariable(executionId, "b"));
-
- // in the generated id, we can see if the right process definition version was taken
- assertTrue("the execution id shows that the execution is not started in the latest version of the process: " + execution.getId(),
- execution.getId().startsWith("NFU:3/"));
- }
-
- public void testStartExecutionByNameWithKey()
- {
- // deploy following processes
- // 'nuclear fusion' with id NFU:1
- // 'ultimate seduction' with id USD:1
- // 'ultimate seduction' with id USD:2
- // 'nuclear fusion' with id NFU:2
- // 'publish book' with id PBO:1
- // 'nuclear fusion' with id NFU:3
- deployMultipleVersionsOfProcesses();
-
- ExecutionService executionService = getEnvironmentFactory().get(ExecutionService.class);
-
- Execution execution = executionService.startExecutionByName("nuclear fusion", "TheFirstTime");
- assertNotNull(execution);
- assertEquals("TheFirstTime", execution.getKey());
- assertEquals("NFU:3/TheFirstTime", execution.getId());
- }
-
- public void testFindExecution()
- {
- // create an arbitrary execution
- Execution execution = startExecution();
- // take the id and see if the execution service can still find it back
- execution = executionService.findExecution(execution.getId());
- assertNotNull(execution);
- }
-
- public void testSetVariable()
- {
- Execution execution = startExecution();
-
- String executionId = execution.getId();
- // set variable a to value text
- executionService.setVariable(executionId, "a", "text");
- // check if we can read that value back
- assertEquals("text", executionService.getVariable(executionId, "a"));
-
- // overwrite the value of variable a with another text
- executionService.setVariable(executionId, "a", "another text");
- // see if we can read another text back from the variable
- assertEquals("another text", executionService.getVariable(executionId, "a"));
- }
-
- public void testSetVariables()
- {
- Execution execution = startExecution();
-
- Map<String, Object> variables = new HashMap<String, Object>();
- variables.put("a", new Integer(1));
- variables.put("b", "text");
-
- // set variables in bulk by providing a map
- executionService.setVariables(execution.getId(), variables);
-
- Map<String, Object> expected = new HashMap<String, Object>(variables);
-
- Set<String> variableNames = new HashSet<String>();
- variableNames.add("a");
- variableNames.add("b");
-
- // read the variables back and compare
- assertEquals(expected, executionService.getVariables(execution.getId(), variableNames));
-
- // now set variables b and c with a map
- variables = new HashMap<String, Object>();
- variables.put("b", new Integer(99));
- variables.put("c", "another text");
-
- // this should leave a untouched, overwrite b and create c
- executionService.setVariables(execution.getId(), variables);
-
- // update the expected map
- expected.put("b", new Integer(99));
- expected.put("c", "another text");
-
- // add c to the variable names that should be collected
- variableNames.add("c");
-
- // read the variables back and compare
- assertEquals(expected, executionService.getVariables(execution.getId(), variableNames));
- }
-
- // helper methods ///////////////////////////////////////////////////////////
-
- /**
- * deploys 3 versions of process with name 'nuclear fusion', 2 versions of the processes 'ultimate seduction' and
- * 'publish book'
- void deployMultipleVersionsOfProcesses()
- {
- ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
-
- ProcessDefinition processDefinition = ProcessFactory.build("nuclear fusion").key("NFU").node("initial").initial().behaviour(
- WaitState.class).done();
- DeploymentImpl deploymentImpl = new DeploymentImpl(processDefinition);
- processService.deploy(deploymentImpl);
-
- processDefinition = ProcessFactory.build("ultimate seduction").key("USD").node("initial").initial().behaviour(WaitState.class).done();
- deploymentImpl = new DeploymentImpl(processDefinition);
- processService.deploy(deploymentImpl);
-
- processDefinition = ProcessFactory.build("ultimate seduction").key("USD").node("initial").initial().behaviour(WaitState.class).done();
- deploymentImpl = new DeploymentImpl(processDefinition);
- processService.deploy(deploymentImpl);
-
- processDefinition = ProcessFactory.build("nuclear fusion").key("NFU").node("initial").initial().behaviour(WaitState.class).done();
- deploymentImpl = new DeploymentImpl(processDefinition);
- processService.deploy(deploymentImpl);
-
- processDefinition = ProcessFactory.build("publish book").key("PBO").node("initial").initial().behaviour(WaitState.class).done();
- deploymentImpl = new DeploymentImpl(processDefinition);
- processService.deploy(deploymentImpl);
-
- processDefinition = ProcessFactory.build("nuclear fusion").key("NFU").node("initial").initial().behaviour(WaitState.class).done();
- deploymentImpl = new DeploymentImpl(processDefinition);
- processService.deploy(deploymentImpl);
- }
-
- Execution startExecution()
- {
- ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
-
- ProcessDefinition processDefinition = ProcessFactory.build("nuclear fusion").node("initial").initial().behaviour(WaitState.class)
- .done();
- DeploymentImpl deploymentImpl = new DeploymentImpl(processDefinition);
- processService.deploy(deploymentImpl);
-
- ExecutionService executionService = getEnvironmentFactory().get(ExecutionService.class);
-
- return executionService.startExecutionByName("nuclear fusion");
- }
-
- */
-}
Deleted: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/ManagementServiceTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/ManagementServiceTest.java 2008-12-27 11:30:11 UTC (rev 3557)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/ManagementServiceTest.java 2008-12-27 12:58:42 UTC (rev 3558)
@@ -1,36 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.test.svc;
-
-import org.jbpm.test.DbTestCase;
-
-/**
- * @author Tom Baeyens
- */
-public class ManagementServiceTest extends DbTestCase {
-
- public void testGetJobs() {
- assertEquals(0, managementService.getTimers(0, 10).size());
- assertEquals(0, managementService.getMessages(0, 10).size());
- }
-
-}
Deleted: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/ProcessServiceTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/ProcessServiceTest.java 2008-12-27 11:30:11 UTC (rev 3557)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/ProcessServiceTest.java 2008-12-27 12:58:42 UTC (rev 3558)
@@ -1,357 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.test.svc;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jbpm.Execution;
-import org.jbpm.JbpmException;
-import org.jbpm.ProcessDefinition;
-import org.jbpm.test.DbTestCase;
-
-
-/**
- * @author Tom Baeyens
- */
-public class ProcessServiceTest extends DbTestCase {
-
- public void testProcessWithNameOnly() {
- ProcessDefinition processDefinition = deployJpdlXmlString(
- "<process name='Insurance claim'>" +
- " <start />" +
- "</process>"
- );
-
- assertNotNull(processDefinition);
- assertEquals("Insurance claim", processDefinition.getName());
- assertEquals("Insurance_claim", processDefinition.getKey());
- assertEquals(1, processDefinition.getVersion());
- assertEquals("Insurance_claim:1", processDefinition.getId());
- }
-
- public void testProcessWithNameAndKey() {
- deployJpdlXmlString(
- "<process name='Insurance claim' key='ICL'>" +
- " <start />" +
- "</process>"
- );
-
- ProcessDefinition processDefinition = processService.findLatestProcessDefinitionByKey("ICL");
-
- assertNotNull(processDefinition);
- assertEquals("Insurance claim", processDefinition.getName());
- assertEquals("ICL", processDefinition.getKey());
- assertEquals(1, processDefinition.getVersion());
- assertEquals("ICL:1", processDefinition.getId());
- }
-
- // interface methods ////////////////////////////////////////////////////////
-
- public void testFindProcessDefinitionKeys() {
- deployMultipleVersionsOfProcesses();
-
- List<String> processKeys = processService.findProcessDefinitionKeys();
-
- List<String> expected = new ArrayList<String>();
- expected.add("nuclear_fusion");
- expected.add("publish_book");
- expected.add("ultimate_seduction");
-
- assertEquals(expected, processKeys);
- }
-
-
- public void testFindProcessByKey() {
- deployJpdlXmlString(
- "<process name='Name with spaces'>" +
- " <start />" +
- "</process>"
- );
-
- ProcessDefinition processDefinition = processService.findLatestProcessDefinitionByKey("Name_with_spaces");
- assertNotNull(processDefinition);
- assertEquals("Name with spaces", processDefinition.getName());
- assertEquals("Name_with_spaces", processDefinition.getKey());
- assertEquals(1, processDefinition.getVersion());
- assertEquals("Name_with_spaces:1", processDefinition.getId());
- }
-
- public void testFindProcessDefinitions() {
- deployMultipleVersionsOfProcesses();
-
- List<ProcessDefinition> processDefinitions = processService.findProcessDefinitionsByKey("nuclear_fusion");
- assertNotNull(processDefinitions);
-
- assertEquals("expected 3 but was " + processDefinitions.size() + ": " + processDefinitions, 3, processDefinitions.size());
- assertEquals("nuclear fusion", processDefinitions.get(0).getName());
- assertEquals(3, processDefinitions.get(0).getVersion());
-
- assertEquals("nuclear fusion", processDefinitions.get(1).getName());
- assertEquals(2, processDefinitions.get(1).getVersion());
-
- assertEquals("nuclear fusion", processDefinitions.get(2).getName());
- assertEquals(1, processDefinitions.get(2).getVersion());
- }
-
- public void testFindLatestProcessDefinition() {
- deployMultipleVersionsOfProcesses();
-
- ProcessDefinition retrieved = processService.findLatestProcessDefinitionByKey("nuclear_fusion");
- assertNotNull(retrieved);
-
- assertEquals(3, retrieved.getVersion());
- assertEquals("nuclear fusion", retrieved.getName());
- assertEquals("nuclear_fusion", retrieved.getKey());
- }
-
- public void testFindProcessDefinitionById() {
- deployJpdlXmlString(
- "<process name='given' version='33'>" +
- " <start />" +
- "</process>"
- );
-
- // load it
- ProcessDefinition processDefinition = processService.findProcessDefinitionById("given:33");
- assertNotNull(processDefinition);
- assertEquals("given", processDefinition.getName());
- assertEquals(33, processDefinition.getVersion());
- }
-
- public void testDeleteProcessDefinition() {
- processService.createDeployment()
- .addString("xmlstring.jpdl.xml",
- "<process name='deleteme' version='33'>" +
- " <start />" +
- "</process>")
- .deploy();
-
- // load it
- processService.deleteProcessDefinition("deleteme:33");
-
- // check if the db is empty
- assertEquals(0, processService.createProcessDefinitionQuery().list().size());
- }
-
- public void testDeleteProcessDefinitionAndInstances() {
- processService.createDeployment()
- .addString("xmlstring.jpdl.xml",
- "<process name='deleteme' version='33'>" +
- " <start>" +
- " <flow to='w' />" +
- " </start>" +
- " <state name='w' />" +
- "</process>")
- .deploy();
-
- executionService.startExecutionByKey("deleteme");
- executionService.startExecutionByKey("deleteme");
- executionService.startExecutionByKey("deleteme");
- executionService.startExecutionByKey("deleteme");
-
- // delete it all
- processService.deleteProcessDefinitionAndInstances("deleteme:33");
-
- // check if the db is empty
- assertEquals(0, processService.createProcessDefinitionQuery().list().size());
- assertEquals(0, executionService.createExecutionQuery().list().size());
- }
-
- public void testDeleteProcessDefinitionButNotInstances() {
- deployJpdlXmlString(
- "<process name='deleteme' version='33'>" +
- " <start>" +
- " <flow to='w' />" +
- " </start>" +
- " <state name='w' />" +
- "</process>"
- );
-
- executionService.startExecutionByKey("deleteme");
- executionService.startExecutionByKey("deleteme");
- executionService.startExecutionByKey("deleteme");
- executionService.startExecutionByKey("deleteme");
-
- // delete it all
- try {
- processService.deleteProcessDefinition("deleteme:33");
- fail("expected exception");
- } catch (JbpmException e) {
- assertTextPresent("still 4 process instances for process definition deleteme:33", e.getMessage());
- }
- }
-
- // various other aspects ////////////////////////////////////////////////////
-
- public void testAutomaticVersioning() {
- deployJpdlXmlString(
- "<process name='versionme'>" +
- " <start />" +
- "</process>"
- );
-
- // look it up again
- List<ProcessDefinition> processDefinitions = processService.findProcessDefinitionsByKey("versionme");
- assertNotNull(processDefinitions);
- // verify that there is only one
- assertEquals(processDefinitions.toString(), 1, processDefinitions.size());
- ProcessDefinition processDefinition = processDefinitions.get(0);
- // and check that automatically assigned version starts with 1
- assertEquals(1, processDefinition.getVersion());
-
- deployJpdlXmlString(
- "<process name='versionme'>" +
- " <start />" +
- "</process>"
- );
-
- // look them up again
- processDefinitions = processService.findProcessDefinitionsByKey("versionme");
- // verify that there is only one
- assertEquals(processDefinitions.toString(), 2, processDefinitions.size());
- // and check that automatically assigned version starts with 1
- assertEquals(2, processDefinitions.get(0).getVersion());
- assertEquals(1, processDefinitions.get(1).getVersion());
- }
-
- public void testUserProvidedVersion() {
- deployJpdlXmlString(
- "<process name='takethis' version='234'>" +
- " <start />" +
- "</process>"
- );
-
- // load it
- List<ProcessDefinition> processDefinitions = processService.findProcessDefinitionsByKey("takethis");
- assertNotNull(processDefinitions);
- assertEquals(processDefinitions.toString(), 1, processDefinitions.size());
- ProcessDefinition processDefinition = processDefinitions.get(0);
- // verify that the user specified version was used
- // (and not overwritten by an automatically assigned versioning)
- assertEquals(234, processDefinition.getVersion());
- }
-
- public void testDuplicateUserProvidedVersion() {
- deployJpdlXmlString(
- "<process name='takethis' version='234'>" +
- " <start />" +
- "</process>"
- );
-
- try {
- deployJpdlXmlString(
- "<process name='takethis' version='234'>" +
- " <start />" +
- "</process>"
- );
- fail("expected exception");
- } catch (JbpmException e) {
- assertTextPresent("process 'takethis:234' already exists", e.getMessage());
- }
- }
-
- /**
- * deploys 3 versions of process with name 'nuclear fusion', 2 versions of the processes 'ultimate seduction' and
- * 'publish book'
- */
- void deployMultipleVersionsOfProcesses()
- {
- deployJpdlXmlString(
- "<process name='nuclear fusion'>" +
- " <start />" +
- "</process>"
- );
-
- deployJpdlXmlString(
- "<process name='ultimate seduction'>" +
- " <start />" +
- "</process>"
- );
-
- deployJpdlXmlString(
- "<process name='ultimate seduction'>" +
- " <start />" +
- "</process>"
- );
-
- deployJpdlXmlString(
- "<process name='ultimate seduction'>" +
- " <start />" +
- "</process>"
- );
-
- deployJpdlXmlString(
- "<process name='ultimate seduction'>" +
- " <start />" +
- "</process>"
- );
-
- deployJpdlXmlString(
- "<process name='publish book'>" +
- " <start />" +
- "</process>"
- );
-
- deployJpdlXmlString(
- "<process name='nuclear fusion'>" +
- " <start />" +
- "</process>"
- );
-
- deployJpdlXmlString(
- "<process name='nuclear fusion'>" +
- " <start />" +
- "</process>"
- );
- }
-
- public void testMinimalProcess() {
- deployJpdlXmlString(
- "<process name='minimal'>" +
- " <start>" +
- " <flow to='end' />" +
- " </start>" +
- " <end name='end' />" +
- "</process>"
- );
-
- Execution execution = executionService.startExecutionByKey("minimal");
-
- assertEquals("end", execution.getNodeName());
- assertTrue(execution.isEnded());
- assertFalse(execution.isActive());
- }
-
- public void testMostMinimalProcess() {
- deployJpdlXmlString(
- "<process name='minimal'>" +
- " <start />" +
- "</process>"
- );
-
- Execution execution = executionService.startExecutionByKey("minimal");
-
- assertTrue(execution.isEnded());
- assertFalse(execution.isActive());
- }
-}
Deleted: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/TaskServiceTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/TaskServiceTest.java 2008-12-27 11:30:11 UTC (rev 3557)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/TaskServiceTest.java 2008-12-27 12:58:42 UTC (rev 3558)
@@ -1,77 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.test.svc;
-
-import java.util.Date;
-
-import org.jbpm.task.Task;
-import org.jbpm.test.DbTestCase;
-
-/**
- * @author Alejandro Guizar
- */
-public class TaskServiceTest extends DbTestCase {
-
- public void testNewTask() {
- Task task = taskService.newTask();
- task = taskService.getTask(task.getId());
- assertNull("expected null, but was " + task, task);
- }
-
- public void testGenerateTaskId() {
- Task task = taskService.newTask();
- String taskId = task.getId();
- assertNull("expected null, but was " + taskId, taskId);
- // save task to generate identifier
- saveTask(task);
- assertNotNull("expected non-null task id", task.getId());
- }
-
- public void testSaveTask() {
- Task task = taskService.newTask();
- saveTask(task);
- String taskId = task.getId();
- // task was made persistent
- task = taskService.getTask(taskId);
- assertNotNull("expected non-null task", task);
- // make some change
- Date dueDate = new Date();
- task.setDueDate(dueDate);
- taskService.saveTask(task);
- // verify change is applied
- task = taskService.getTask(taskId);
- assertEquals(dueDate, task.getDueDate());
- }
-
- public void testDeleteTask() {
- Task task = taskService.newTask();
- taskService.saveTask(task);
- String taskId = task.getId();
-
- // task was made persistent
- assertNotNull("expected non-null task", taskService.getTask(taskId));
- // delete task and verify it does not exist
- taskService.deleteTask(taskId);
- task = taskService.getTask(taskId);
- assertNull("expected null, but was " + task, task);
- }
-}
Deleted: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/variables/BasicVariablesTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/variables/BasicVariablesTest.java 2008-12-27 11:30:11 UTC (rev 3557)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/variables/BasicVariablesTest.java 2008-12-27 12:58:42 UTC (rev 3558)
@@ -1,82 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.test.variables;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.jbpm.test.DbTestCase;
-
-
-/**
- * @author Tom Baeyens
- */
-public class BasicVariablesTest extends DbTestCase {
-
- public void testNoVariables() {
- deployJpdlXmlString(
- "<process name='var'>" +
- " <start name='a'>" +
- " <flow to='b' />" +
- " </start>" +
- " <state name='b'/>" +
- "</process>"
- );
-
- executionService.startExecutionByKey("var", "one");
- Set<String> variableNames = executionService.getVariableNames("var/one");
- assertNotNull(variableNames);
- assertEquals(0, variableNames.size());
- }
-
- public void testThreeVariables() {
- deployJpdlXmlString(
- "<process name='var'>" +
- " <start name='a'>" +
- " <flow to='b' />" +
- " </start>" +
- " <state name='b'/>" +
- "</process>"
- );
-
- Map<String, Object> variables = new HashMap<String, Object>();
- variables.put("customer", "John Doe");
- variables.put("type", "Accident");
- variables.put("amount", new Float(763.74));
-
- Set<String> expectedVariableNames = new HashSet<String>(variables.keySet());
- Map<String, Object> expectedVariables = new HashMap<String, Object>(variables);
-
- executionService.startExecutionByKey("var", variables, "one");
-
- Set<String> variableNames = executionService.getVariableNames("var/one");
- assertNotNull(variableNames);
-
- assertEquals(expectedVariableNames, variableNames);
-
- variables = executionService.getVariables("var/one", variableNames);
-
- assertEquals(expectedVariables, variables);
- }
-}
Deleted: jbpm4/trunk/modules/test-db/src/test/resources/hibernate.properties
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/resources/hibernate.properties 2008-12-27 11:30:11 UTC (rev 3557)
+++ jbpm4/trunk/modules/test-db/src/test/resources/hibernate.properties 2008-12-27 12:58:42 UTC (rev 3558)
@@ -1,11 +0,0 @@
-hibernate.dialect org.hibernate.dialect.HSQLDialect
-hibernate.connection.driver_class org.hsqldb.jdbcDriver
-hibernate.connection.url jdbc:hsqldb:mem:.
-hibernate.connection.username sa
-hibernate.connection.password
-hibernate.hbm2ddl.auto create-drop
-hibernate.cache.use_second_level_cache true
-hibernate.cache.provider_class org.hibernate.cache.HashtableCacheProvider
-# hibernate.show_sql true
-# hibernate.format_sql true
-# hibernate.use_sql_comments true
Deleted: jbpm4/trunk/modules/test-db/src/test/resources/jbpm.cfg.xml
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/resources/jbpm.cfg.xml 2008-12-27 11:30:11 UTC (rev 3557)
+++ jbpm4/trunk/modules/test-db/src/test/resources/jbpm.cfg.xml 2008-12-27 12:58:42 UTC (rev 3558)
@@ -1,78 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<jbpm-configuration xmlns="http://jbpm.org/xsd/cfg">
-
- <process-engine>
-
- <deployer-manager>
- <assign-file-type>
- <file extension=".jpdl.xml" type="jpdl" />
- </assign-file-type>
- <parse-jpdl />
- <check-process />
- <check-problems />
- <save />
- </deployer-manager>
-
- <process-service />
- <execution-service />
- <management-service />
- <task-service />
-
- <command-service>
- <retry-interceptor />
- <environment-interceptor />
- <standard-transaction-interceptor />
- </command-service>
-
- <hibernate-configuration>
- <properties resource="hibernate.properties" />
- <mapping resource="jbpm.pvm.typedefs.hbm.xml" />
- <mapping resource="jbpm.pvm.wire.hbm.xml" />
- <mapping resource="jbpm.pvm.definition.hbm.xml" />
- <mapping resource="jbpm.pvm.execution.hbm.xml" />
- <mapping resource="jbpm.pvm.variable.hbm.xml" />
- <mapping resource="jbpm.pvm.job.hbm.xml" />
- <mapping resource="jbpm.jpdl.hbm.xml" />
- <mapping resource="jbpm.task.hbm.xml" />
- <cache-configuration resource="jbpm.pvm.cache.xml"
- usage="nonstrict-read-write" />
- </hibernate-configuration>
-
- <hibernate-session-factory />
-
- <script-manager default-expression-language="juel"
- default-script-language="juel"
- read-contexts="execution, environment, process-engine"
- write-context="">
- <script-language name="juel" factory="com.sun.script.juel.JuelScriptEngineFactory" />
- </script-manager>
-
- <job-executor auto-start="false" />
- <job-test-helper />
-
- <id-generator />
- <variable-types resource="jbpm.pvm.types.xml" />
-
- <business-calendar>
- <monday hours="9:00-12:00 and 12:30-17:00"/>
- <tuesday hours="9:00-12:00 and 12:30-17:00"/>
- <wednesday hours="9:00-12:00 and 12:30-17:00"/>
- <thursday hours="9:00-12:00 and 12:30-17:00"/>
- <friday hours="9:00-12:00 and 12:30-17:00"/>
- <holiday period="01/07/2008 - 31/08/2008"/>
- </business-calendar>
-
- </process-engine>
-
- <environment>
- <hibernate-session />
- <transaction />
- <pvm-db-session />
- <job-db-session />
- <task-db-session />
- <message-session />
- <timer-session />
- </environment>
-
-</jbpm-configuration>
Deleted: jbpm4/trunk/modules/test-db/src/test/resources/logging.properties
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/resources/logging.properties 2008-12-27 11:30:11 UTC (rev 3557)
+++ jbpm4/trunk/modules/test-db/src/test/resources/logging.properties 2008-12-27 12:58:42 UTC (rev 3558)
@@ -1,28 +0,0 @@
-handlers= java.util.logging.ConsoleHandler
-# to add the error triggered file handler
-# handlers= java.util.logging.ConsoleHandler org.jbpm.util.ErrorTriggeredFileHandler
-
-redirect.commons.logging = enabled
-
-java.util.logging.ConsoleHandler.level = FINEST
-java.util.logging.ConsoleHandler.formatter = org.jbpm.log.LogFormatter
-
-# org.jbpm.util.ErrorTriggeredFileHandler.size = 500
-# org.jbpm.util.ErrorTriggeredFileHandler.push = OFF
-# org.jbpm.util.ErrorTriggeredFileHandler.pattern = %h/jbpm%u.log
-
-# For example, set the com.xyz.foo logger to only log SEVERE messages:
-# com.xyz.foo.level = SEVERE
-
-org.jbpm.level=FINEST
-org.jbpm.pvm.internal.tx.level=FINE
-org.jbpm.pvm.internal.wire.level=FINE
-org.jbpm.pvm.internal.util.level=FINE
-
-org.hibernate.level=INFO
-org.hibernate.cfg.HbmBinder.level=SEVERE
-org.hibernate.cfg.SettingsFactory.level=SEVERE
-org.hibernate.SQL.level=FINEST
-# org.hibernate.type.level=FINEST
-# org.hibernate.tool.hbm2ddl.SchemaExport.level=FINEST
-# org.hibernate.transaction.level=FINEST
Modified: jbpm4/trunk/modules/test-pojo/pom.xml
===================================================================
--- jbpm4/trunk/modules/test-pojo/pom.xml 2008-12-27 11:30:11 UTC (rev 3557)
+++ jbpm4/trunk/modules/test-pojo/pom.xml 2008-12-27 12:58:42 UTC (rev 3558)
@@ -48,50 +48,4 @@
</plugins>
</build>
- <!-- Profiles -->
- <profiles>
-
- <!--
- Name: no-impl
- Descr: The default implementation profile
- -->
- <profile>
- <id>no-impl</id>
- <activation>
- <property>
- <name>!impl</name>
- </property>
- </activation>
- <dependencies>
- <dependency>
- <groupId>org.jbpm.jbpm4</groupId>
- <artifactId>jbpm-pvm</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- </dependency>
- </dependencies>
- </profile>
-
- <!--
- Name: impl-ri
- Descr: The RI implementation profile
- -->
- <profile>
- <id>impl-ri</id>
- <activation>
- <property>
- <name>impl</name>
- <value>ri</value>
- </property>
- </activation>
- <dependencies>
- <dependency>
- <groupId>org.jbpm.spec</groupId>
- <artifactId>jbpm-spec-ri</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- </dependency>
- </dependencies>
- </profile>
-
- </profiles>
-
</project>
\ No newline at end of file
More information about the jbpm-commits
mailing list