[jbpm-commits] JBoss JBPM SVN: r4053 - in jbpm4/branches/ainze: modules/spring/src/test/java/org/jbpm/spring/test and 5 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Thu Feb 26 10:03:53 EST 2009
Author: ainze
Date: 2009-02-26 10:03:53 -0500 (Thu, 26 Feb 2009)
New Revision: 4053
Added:
jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/execution/
jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/execution/FindExecutionTest.java
jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/execution/SignalExecutionTest.java
jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/execution/StartExecutionTest.java
jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/mgmt/
jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/mgmt/ManagementServiceTest.java
jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/process/
jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/process/ProcessDefinitionQueryTest.java
jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/task/
jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/task/TaskCreateUpdateDeleteTest.java
jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/task/TaskListTest.java
jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/task/TaskQueryTest.java
jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/variables/
jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/variables/BasicVariablesTest.java
jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/variables/VariableBasicTypesTest.java
Modified:
jbpm4/branches/ainze/pom.xml
Log:
initial spring integration
Added: jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/execution/FindExecutionTest.java
===================================================================
--- jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/execution/FindExecutionTest.java (rev 0)
+++ jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/execution/FindExecutionTest.java 2009-02-26 15:03:53 UTC (rev 4053)
@@ -0,0 +1,56 @@
+/*
+ * 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.spring.test.execution;
+
+import org.jbpm.Execution;
+import org.jbpm.spring.test.AbstractTransactionalSpringJbpmTestCase;
+
+/**
+ * @author Tom Baeyens
+ */
+public class FindExecutionTest extends AbstractTransactionalSpringJbpmTestCase {
+
+
+ @Override
+ protected String[] getConfigLocations() {
+ return new String[]{"org/jbpm/spring/test/applicationContext.xml"};
+ }
+
+ public void testFindExecutionById() {
+ deployJpdlXmlString(
+ "<process name='p'>" +
+ " <start>" +
+ " <transition to='a' />" +
+ " </start>" +
+ " <state name='a' />" +
+ "</process>"
+ );
+
+ Execution execution = executionService.startProcessInstanceByKey("p");
+
+ // take the id and see if the execution service can still find it back
+ execution = executionService.findExecution(execution.getId());
+ assertNotNull(execution);
+ assertEquals("a", execution.getActivityName());
+ }
+
+}
Property changes on: jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/execution/FindExecutionTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/execution/SignalExecutionTest.java
===================================================================
--- jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/execution/SignalExecutionTest.java (rev 0)
+++ jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/execution/SignalExecutionTest.java 2009-02-26 15:03:53 UTC (rev 4053)
@@ -0,0 +1,260 @@
+/*
+ * 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.spring.test.execution;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.jbpm.Execution;
+import org.jbpm.spring.test.AbstractTransactionalSpringJbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class SignalExecutionTest extends AbstractTransactionalSpringJbpmTestCase {
+
+
+ @Override
+ protected String[] getConfigLocations() {
+ return new String[]{"org/jbpm/spring/test/applicationContext.xml"};
+ }
+
+ public void testSignalExecutionByKey() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <transition to='a' />" +
+ " </start>" +
+ " <state name='a'>" +
+ " <transition to='b' />" +
+ " </state>" +
+ " <state name='b'>" +
+ " <transition to='c' />" +
+ " </state>" +
+ " <state name='c' />" +
+ "</process>"
+ );
+
+ Execution execution = executionService.startProcessInstanceByKey("ICL", "82436");
+
+ assertEquals("a", execution.getActivityName());
+
+ execution = executionService.signalExecutionByKey("ICL", "82436");
+
+ assertEquals("b", execution.getActivityName());
+
+ execution = executionService.signalExecutionByKey("ICL", "82436");
+
+ assertEquals("c", execution.getActivityName());
+ }
+
+ public void testSignalExecutionById() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <transition to='a' />" +
+ " </start>" +
+ " <state name='a'>" +
+ " <transition to='b' />" +
+ " </state>" +
+ " <state name='b'>" +
+ " <transition to='c' />" +
+ " </state>" +
+ " <state name='c' />" +
+ "</process>"
+ );
+
+ Execution execution = executionService.startProcessInstanceByKey("ICL", "82436");
+
+ assertEquals("a", execution.getActivityName());
+
+ execution = executionService.signalExecutionById("ICL/82436");
+
+ assertEquals("b", execution.getActivityName());
+
+ execution = executionService.signalExecutionById("ICL/82436");
+
+ assertEquals("c", execution.getActivityName());
+ }
+
+ public void testSignalExecutionWithVariables() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <transition to='a' />" +
+ " </start>" +
+ " <state name='a'>" +
+ " <transition to='b' />" +
+ " </state>" +
+ " <state name='b' />" +
+ "</process>"
+ );
+
+ Execution execution = executionService.startProcessInstanceByKey("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.getActivityName());
+
+ 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>" +
+ " <transition to='a' />" +
+ " </start>" +
+ " <state name='a' />" +
+ "</process>"
+ );
+
+ Execution execution = executionService.startProcessInstanceByKey("p");
+ execution = executionService.signalExecutionById(execution.getId());
+ assertEquals("a", execution.getActivityName());
+ }
+
+ /*
+
+ 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").activity("initial").initial().behaviour(
+ WaitState.class).done();
+ DeploymentImpl deploymentImpl = new DeploymentImpl(processDefinition);
+ processService.deploy(deploymentImpl);
+
+ processDefinition = ProcessFactory.build("ultimate seduction").key("USD").activity("initial").initial().behaviour(WaitState.class).done();
+ deploymentImpl = new DeploymentImpl(processDefinition);
+ processService.deploy(deploymentImpl);
+
+ processDefinition = ProcessFactory.build("ultimate seduction").key("USD").activity("initial").initial().behaviour(WaitState.class).done();
+ deploymentImpl = new DeploymentImpl(processDefinition);
+ processService.deploy(deploymentImpl);
+
+ processDefinition = ProcessFactory.build("nuclear fusion").key("NFU").activity("initial").initial().behaviour(WaitState.class).done();
+ deploymentImpl = new DeploymentImpl(processDefinition);
+ processService.deploy(deploymentImpl);
+
+ processDefinition = ProcessFactory.build("publish book").key("PBO").activity("initial").initial().behaviour(WaitState.class).done();
+ deploymentImpl = new DeploymentImpl(processDefinition);
+ processService.deploy(deploymentImpl);
+
+ processDefinition = ProcessFactory.build("nuclear fusion").key("NFU").activity("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").activity("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/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/execution/SignalExecutionTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/execution/StartExecutionTest.java
===================================================================
--- jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/execution/StartExecutionTest.java (rev 0)
+++ jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/execution/StartExecutionTest.java 2009-02-26 15:03:53 UTC (rev 4053)
@@ -0,0 +1,224 @@
+/*
+ * 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.spring.test.execution;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.jbpm.Execution;
+import org.jbpm.ProcessDefinition;
+import org.jbpm.spring.test.AbstractTransactionalSpringJbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class StartExecutionTest extends AbstractTransactionalSpringJbpmTestCase {
+
+ @Override
+ protected String[] getConfigLocations() {
+ return new String[]{"org/jbpm/spring/test/applicationContext.xml"};
+ }
+
+ public void testStartNewExecutionByKey() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <transition to='a' />" +
+ " </start>" +
+ " <state name='a' />" +
+ "</process>"
+ );
+
+ Execution execution = executionService.startProcessInstanceByKey("ICL");
+
+ assertNotNull(execution);
+ assertEquals("a", execution.getActivityName());
+ }
+
+ public void testStartNewExecutionInLatestProcessDefinition() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <transition to='a' />" +
+ " </start>" +
+ " <state name='a' />" +
+ "</process>"
+ );
+
+ Execution execution = executionService.startProcessInstanceByKey("ICL");
+
+ assertNotNull(execution);
+ assertEquals("a", execution.getActivityName());
+
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <transition to='b' />" +
+ " </start>" +
+ " <state name='b' />" +
+ "</process>"
+ );
+
+ execution = executionService.startProcessInstanceByKey("ICL");
+
+ assertNotNull(execution);
+ assertEquals("b", execution.getActivityName());
+ }
+
+ public void testStartExecutionInLatestByNameWithVariables() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <transition to='a' />" +
+ " </start>" +
+ " <state name='a' />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <transition to='b' />" +
+ " </start>" +
+ " <state name='b' />" +
+ "</process>"
+ );
+
+ // 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.startProcessInstanceByKey("ICL", variables);
+ String executionId = execution.getId();
+ assertEquals("b", execution.getActivityName());
+
+ // 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(execution.getId().startsWith("ICL/"));
+ }
+
+ public void testStartNewProcessInstanceWithAKey() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <transition to='a' />" +
+ " </start>" +
+ " <state name='a' />" +
+ "</process>"
+ );
+
+ Execution execution = executionService.startProcessInstanceByKey("ICL", "one");
+
+ assertNotNull(execution);
+ assertEquals("ICL/one", execution.getId());
+ }
+
+ public void testStartNewProcessInstanceWithVariables() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <transition 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.startProcessInstanceByKey("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);
+ }
+
+ public void testStartExecutionById() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <transition to='a' />" +
+ " </start>" +
+ " <state name='a' />" +
+ "</process>"
+ );
+
+ ProcessDefinition processDefinition = processService.findProcessDefinitionsByKey("ICL").get(0);
+
+ // start an execution for the process with the given id
+ Execution execution = executionService.startProcessInstanceById("ICL:1");
+ assertNotNull(execution);
+
+ // checking the state
+ assertEquals("a", execution.getActivityName());
+
+ // 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
+ assertTrue(execution.getId().startsWith("ICL/"));
+ // the last part of the execution key should be the dbid.
+ Long.parseLong(execution.getId().substring(4));
+ }
+
+ public void testStartExecutionByIdWithVariables() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <transition to='a' />" +
+ " </start>" +
+ " <state name='a' />" +
+ "</process>"
+ );
+
+ // create the map with variables
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("a", new Integer(1));
+ variables.put("b", "text");
+
+ // provide the variables in the start execution method
+ Execution execution = executionService.startProcessInstanceById("ICL:1", variables);
+ String executionId = execution.getId();
+
+ assertEquals(new Integer(1), executionService.getVariable(executionId, "a"));
+ assertEquals("text", executionService.getVariable(executionId, "b"));
+ }
+}
Property changes on: jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/execution/StartExecutionTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/mgmt/ManagementServiceTest.java
===================================================================
--- jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/mgmt/ManagementServiceTest.java (rev 0)
+++ jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/mgmt/ManagementServiceTest.java 2009-02-26 15:03:53 UTC (rev 4053)
@@ -0,0 +1,41 @@
+/*
+ * 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.spring.test.mgmt;
+
+import org.jbpm.spring.test.AbstractTransactionalSpringJbpmTestCase;
+
+/**
+ * @author Tom Baeyens
+ */
+public class ManagementServiceTest extends AbstractTransactionalSpringJbpmTestCase {
+
+
+ @Override
+ protected String[] getConfigLocations() {
+ return new String[]{"org/jbpm/spring/test/applicationContext.xml"};
+ }
+
+ public void testGetJobs() {
+// assertEquals(0, managementService.getTimers(0, 10).size());
+// assertEquals(0, managementService.getMessages(0, 10).size());
+ }
+}
Property changes on: jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/mgmt/ManagementServiceTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/process/ProcessDefinitionQueryTest.java
===================================================================
--- jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/process/ProcessDefinitionQueryTest.java (rev 0)
+++ jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/process/ProcessDefinitionQueryTest.java 2009-02-26 15:03:53 UTC (rev 4053)
@@ -0,0 +1,145 @@
+/*
+ * 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.spring.test.process;
+
+import java.util.List;
+
+import org.jbpm.ProcessDefinition;
+import org.jbpm.ProcessDefinitionQuery;
+import org.jbpm.spring.test.AbstractTransactionalSpringJbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ProcessDefinitionQueryTest extends AbstractTransactionalSpringJbpmTestCase {
+
+
+ @Override
+ protected String[] getConfigLocations() {
+ return new String[]{"org/jbpm/spring/test/applicationContext.xml"};
+ }
+
+ public void testQueryProcessDefinitionsEmpty() {
+ List<ProcessDefinition> processDefinitions = processService
+ .createProcessDefinitionQuery()
+ .execute();
+
+ assertEquals(0, processDefinitions.size());
+ }
+
+ public void testQueryProcessDefinitionsNameLike() {
+ deployJpdlXmlString(
+ "<process name='make print'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='use phone'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='make friends'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='clean whiteboard'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='fix coffeemaker'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ List<ProcessDefinition> processDefinitions = processService.createProcessDefinitionQuery()
+ .nameLike("%make%")
+ .orderAsc(ProcessDefinitionQuery.PROPERTY_NAME)
+ .execute();
+
+ assertEquals("fix coffeemaker", processDefinitions.get(0).getName());
+ assertEquals("make friends", processDefinitions.get(1).getName());
+ assertEquals("make print", processDefinitions.get(2).getName());
+ }
+
+ public void testQueryProcessDefinitionsKeyLike() {
+ deployJpdlXmlString(
+ "<process name='make print'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='use phone'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='make friends'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='make friends'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='make friends'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='clean whiteboard'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='fix coffeemaker'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ List<ProcessDefinition> processDefinitions = processService.createProcessDefinitionQuery()
+ .keyLike("make%")
+ .orderAsc(ProcessDefinitionQuery.PROPERTY_NAME)
+ .orderDesc(ProcessDefinitionQuery.PROPERTY_VERSION)
+ .execute();
+
+ assertEquals("make_friends:3", processDefinitions.get(0).getId());
+ assertEquals("make_friends:2", processDefinitions.get(1).getId());
+ assertEquals("make_friends:1", processDefinitions.get(2).getId());
+ assertEquals("make_print:1", processDefinitions.get(3).getId());
+ }
+}
Property changes on: jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/process/ProcessDefinitionQueryTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/task/TaskCreateUpdateDeleteTest.java
===================================================================
--- jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/task/TaskCreateUpdateDeleteTest.java (rev 0)
+++ jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/task/TaskCreateUpdateDeleteTest.java 2009-02-26 15:03:53 UTC (rev 4053)
@@ -0,0 +1,74 @@
+/*
+ * 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.spring.test.task;
+
+import java.util.Date;
+
+import org.jbpm.spring.test.AbstractTransactionalSpringJbpmTestCase;
+import org.jbpm.task.Task;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class TaskCreateUpdateDeleteTest extends AbstractTransactionalSpringJbpmTestCase {
+
+ @Override
+ protected String[] getConfigLocations() {
+ return new String[]{"org/jbpm/spring/test/applicationContext.xml"};
+ }
+
+ public void testNewTask() {
+ // creation of a new non-persisted task
+ Task task = taskService.newTask();
+ task = taskService.getTask(task.getDbid());
+ assertNull(task);
+ }
+
+ public void testSaveTask() {
+ Task task = taskService.newTask();
+ taskService.saveTask(task);
+ Long taskId = task.getDbid();
+ // 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);
+ Long taskId = task.getDbid();
+
+ // 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);
+ }
+}
Property changes on: jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/task/TaskCreateUpdateDeleteTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/task/TaskListTest.java
===================================================================
--- jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/task/TaskListTest.java (rev 0)
+++ jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/task/TaskListTest.java 2009-02-26 15:03:53 UTC (rev 4053)
@@ -0,0 +1,120 @@
+/*
+ * 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.spring.test.task;
+
+import java.util.List;
+
+import org.jbpm.spring.test.AbstractTransactionalSpringJbpmTestCase;
+import org.jbpm.task.Task;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class TaskListTest extends AbstractTransactionalSpringJbpmTestCase {
+
+ @Override
+ protected String[] getConfigLocations() {
+ return new String[]{"org/jbpm/spring/test/applicationContext.xml"};
+ }
+
+ public void testPersonalTaskList() {
+ Task task = taskService.newTask();
+ task.setName("do laundry");
+ task.setAssignee("johndoe");
+ taskService.saveTask(task);
+
+ task = taskService.newTask();
+ task.setName("get good idea");
+ task.setAssignee("joesmoe");
+ taskService.saveTask(task);
+
+ task = taskService.newTask();
+ task.setName("find venture capital");
+ task.setAssignee("joesmoe");
+ taskService.saveTask(task);
+
+ task = taskService.newTask();
+ task.setName("start new business");
+ task.setAssignee("joesmoe");
+ taskService.saveTask(task);
+
+ List<Task> taskList = taskService.getPersonalTaskList("johndoe", 0, 10);
+ assertNotNull(taskList);
+
+ assertEquals("do laundry", taskList.get(0).getName());
+ assertEquals(1, taskList.size());
+
+ taskList = taskService.getPersonalTaskList("joesmoe", 0, 10);
+ assertNotNull(taskList);
+
+// assertContainsTask(taskList, "get good idea");
+// assertContainsTask(taskList, "start new business");
+// assertContainsTask(taskList, "find venture capital");
+
+ assertEquals(3, taskList.size());
+ }
+
+ public void testPersonalTaskListDefaultSortOrder() {
+ Task task = taskService.newTask();
+ task.setName("get good idea");
+ task.setAssignee("joesmoe");
+ task.setPriority(3);
+ taskService.saveTask(task);
+
+ task = taskService.newTask();
+ task.setName("find venture capital");
+ task.setAssignee("joesmoe");
+ task.setPriority(2);
+ taskService.saveTask(task);
+
+ task = taskService.newTask();
+ task.setName("start new business");
+ task.setAssignee("joesmoe");
+ task.setPriority(1);
+ taskService.saveTask(task);
+
+ task = taskService.newTask();
+ task.setName("take a day off");
+ task.setAssignee("joesmoe");
+ task.setPriority(-5);
+ taskService.saveTask(task);
+
+ task = taskService.newTask();
+ task.setName("make profit");
+ task.setAssignee("joesmoe");
+ task.setPriority(10);
+ taskService.saveTask(task);
+
+ List<Task> taskList = taskService.getPersonalTaskList("joesmoe", 0, 10);
+ assertNotNull(taskList);
+
+ // default sort order is based on the priority
+ assertEquals("make profit", taskList.get(0).getName());
+ assertEquals("get good idea", taskList.get(1).getName());
+ assertEquals("find venture capital", taskList.get(2).getName());
+ assertEquals("start new business", taskList.get(3).getName());
+ assertEquals("take a day off", taskList.get(4).getName());
+
+ assertEquals(5, taskList.size());
+ }
+}
Property changes on: jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/task/TaskListTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/task/TaskQueryTest.java
===================================================================
--- jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/task/TaskQueryTest.java (rev 0)
+++ jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/task/TaskQueryTest.java 2009-02-26 15:03:53 UTC (rev 4053)
@@ -0,0 +1,116 @@
+/*
+ * 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.spring.test.task;
+
+import java.util.List;
+
+import org.jbpm.TaskQuery;
+import org.jbpm.spring.test.AbstractTransactionalSpringJbpmTestCase;
+import org.jbpm.task.Task;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class TaskQueryTest extends AbstractTransactionalSpringJbpmTestCase {
+
+ @Override
+ protected String[] getConfigLocations() {
+ return new String[]{"org/jbpm/spring/test/applicationContext.xml"};
+ }
+
+ public void testSimplestTaskQuery() {
+ Task task = taskService.newTask();
+ task.setName("do laundry");
+ task.setAssignee("johndoe");
+ task.setPriority(3);
+ taskService.saveTask(task);
+
+ task = taskService.newTask();
+ task.setName("change dyper");
+ task.setAssignee("johndoe");
+ task.setPriority(1);
+ taskService.saveTask(task);
+
+ task = taskService.newTask();
+ task.setName("start new business");
+ task.setAssignee("joesmoe");
+ task.setPriority(4);
+ taskService.saveTask(task);
+
+ task = taskService.newTask();
+ task.setName("find venture capital");
+ task.setPriority(4);
+ taskService.saveTask(task);
+
+ List<Task> taskList = taskService
+ .createTaskQuery()
+ .execute();
+ assertNotNull(taskList);
+
+// assertContainsTask(taskList, "do laundry");
+// assertContainsTask(taskList, "change dyper");
+// assertContainsTask(taskList, "start new business");
+// assertContainsTask(taskList, "find venture capital");
+
+ assertEquals(4, taskList.size());
+ }
+
+ public void testSimplestTaskQuerySortBy() {
+ Task task = taskService.newTask();
+ task.setName("do laundry");
+ task.setAssignee("johndoe");
+ task.setPriority(3);
+ taskService.saveTask(task);
+
+ task = taskService.newTask();
+ task.setName("change dyper");
+ task.setAssignee("johndoe");
+ task.setPriority(1);
+ taskService.saveTask(task);
+
+ task = taskService.newTask();
+ task.setName("start new business");
+ task.setAssignee("joesmoe");
+ task.setPriority(4);
+ taskService.saveTask(task);
+
+ task = taskService.newTask();
+ task.setName("find venture capital");
+ task.setPriority(7);
+ taskService.saveTask(task);
+
+ List<Task> taskList = taskService
+ .createTaskQuery()
+ .orderAsc(TaskQuery.PROPERTY_NAME)
+ .execute();
+ assertNotNull(taskList);
+
+ assertEquals("change dyper", taskList.get(0).getName());
+ assertEquals("do laundry", taskList.get(1).getName());
+ assertEquals("find venture capital", taskList.get(2).getName());
+ assertEquals("start new business", taskList.get(3).getName());
+
+ assertEquals(4, taskList.size());
+ }
+
+}
Property changes on: jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/task/TaskQueryTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/variables/BasicVariablesTest.java
===================================================================
--- jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/variables/BasicVariablesTest.java (rev 0)
+++ jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/variables/BasicVariablesTest.java 2009-02-26 15:03:53 UTC (rev 4053)
@@ -0,0 +1,121 @@
+/*
+ * 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.spring.test.variables;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.jbpm.spring.test.AbstractTransactionalSpringJbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class BasicVariablesTest extends AbstractTransactionalSpringJbpmTestCase {
+
+ @Override
+ protected String[] getConfigLocations() {
+ return new String[]{"org/jbpm/spring/test/applicationContext.xml"};
+ }
+
+ public void testStartProcessInstanceWithoutVariables() {
+ deployJpdlXmlString(
+ "<process name='var'>" +
+ " <start name='a'>" +
+ " <transition to='b' />" +
+ " </start>" +
+ " <state name='b'/>" +
+ "</process>"
+ );
+
+ executionService.startProcessInstanceByKey("var", "one");
+ Set<String> variableNames = executionService.getVariableNames("var/one");
+ assertNotNull(variableNames);
+ assertEquals(0, variableNames.size());
+ }
+
+ public void testStartProcessInstanceWithThreeVariables() {
+ deployJpdlXmlString(
+ "<process name='var'>" +
+ " <start name='a'>" +
+ " <transition 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.startProcessInstanceByKey("var", variables, "one");
+
+ Set<String> variableNames = executionService.getVariableNames("var/one");
+ assertNotNull(variableNames);
+
+ assertEquals(expectedVariableNames, variableNames);
+
+ variables = executionService.getVariables("var/one", variableNames);
+
+ assertEquals(expectedVariables, variables);
+ }
+
+ public void testSetAndUpdateVariable() {
+ deployJpdlXmlString(
+ "<process name='var'>" +
+ " <start name='a'>" +
+ " <transition to='b' />" +
+ " </start>" +
+ " <state name='b'/>" +
+ "</process>"
+ );
+
+ executionService.startProcessInstanceByKey("var", "one");
+ executionService.setVariable("var/one", "msg", "hello");
+ assertEquals("hello", executionService.getVariable("var/one", "msg"));
+ executionService.setVariable("var/one", "msg", "world");
+ assertEquals("world", executionService.getVariable("var/one", "msg"));
+ }
+
+ public void testUpdateVariableToDifferentType() {
+ deployJpdlXmlString(
+ "<process name='var'>" +
+ " <start name='a'>" +
+ " <transition to='b' />" +
+ " </start>" +
+ " <state name='b'/>" +
+ "</process>"
+ );
+
+ executionService.startProcessInstanceByKey("var", "one");
+ executionService.setVariable("var/one", "msg", "hello");
+ assertEquals("hello", executionService.getVariable("var/one", "msg"));
+ executionService.setVariable("var/one", "msg", new Integer(5));
+ assertEquals(new Integer(5), executionService.getVariable("var/one", "msg"));
+ }
+}
Property changes on: jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/variables/BasicVariablesTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/variables/VariableBasicTypesTest.java
===================================================================
--- jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/variables/VariableBasicTypesTest.java (rev 0)
+++ jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/variables/VariableBasicTypesTest.java 2009-02-26 15:03:53 UTC (rev 4053)
@@ -0,0 +1,127 @@
+/*
+ * 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.spring.test.variables;
+
+import java.io.Serializable;
+import java.util.Date;
+
+import org.jbpm.spring.test.AbstractTransactionalSpringJbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class VariableBasicTypesTest extends AbstractTransactionalSpringJbpmTestCase {
+
+ @Override
+ protected String[] getConfigLocations() {
+ return new String[]{"org/jbpm/spring/test/applicationContext.xml"};
+ }
+
+ public void checkVariableValue(Object variableValue) {
+ deployJpdlXmlString(
+ "<process name='var'>" +
+ " <start name='a'>" +
+ " <transition to='b' />" +
+ " </start>" +
+ " <state name='b'/>" +
+ "</process>"
+ );
+
+ executionService.startProcessInstanceByKey("var", "one");
+ executionService.setVariable("var/one", "msg", variableValue);
+ assertEquals(variableValue, executionService.getVariable("var/one", "msg"));
+ }
+
+ public void testVariableTypeString() {
+ checkVariableValue("hello");
+ }
+
+ public void testVariableTypeCharacter() {
+ checkVariableValue(new Character('x'));
+ }
+
+ public void testVariableTypeBoolean() {
+ checkVariableValue(Boolean.TRUE);
+ }
+
+ public void testVariableTypeByte() {
+ checkVariableValue(new Byte((byte)5));
+ }
+
+ public void testVariableTypeShort() {
+ checkVariableValue(new Short((short)5));
+ }
+
+ public void testVariableTypeInteger() {
+ checkVariableValue(new Integer(5));
+ }
+
+ public void testVariableTypeLong() {
+ checkVariableValue(new Long(5));
+ }
+
+ public void testVariableTypeFloat() {
+ checkVariableValue(new Float(5.7));
+ }
+
+ public void testVariableTypeDouble() {
+ checkVariableValue(new Double(5.7));
+ }
+
+ public void testVariableTypeDate() {
+ checkVariableValue(new Date());
+ }
+
+ public static class SerializeMe implements Serializable {
+ private static final long serialVersionUID = 1L;
+ String text;
+ public SerializeMe(String text) {
+ this.text = text;
+ }
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((text == null) ? 0 : text.hashCode());
+ return result;
+ }
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ SerializeMe other = (SerializeMe) obj;
+ if (text == null) {
+ if (other.text != null)
+ return false;
+ } else if (!text.equals(other.text))
+ return false;
+ return true;
+ }
+ }
+
+ public void testVariableTypeSerializable() {
+ checkVariableValue(new SerializeMe("hello world"));
+ }
+}
Property changes on: jbpm4/branches/ainze/modules/spring/src/test/java/org/jbpm/spring/test/variables/VariableBasicTypesTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jbpm4/branches/ainze/pom.xml
===================================================================
--- jbpm4/branches/ainze/pom.xml 2009-02-26 14:31:06 UTC (rev 4052)
+++ jbpm4/branches/ainze/pom.xml 2009-02-26 15:03:53 UTC (rev 4053)
@@ -36,7 +36,8 @@
<module>modules/pvm</module>
<module>modules/examples</module>
<module>modules/jpdl</module>
- <module>modules/enterprise</module>
+ <module>modules/enterprise</module>
+ <module>modules/spring</module>
<module>modules/test-base</module>
<module>modules/test-db</module>
<module>modules/test-pojo</module>
More information about the jbpm-commits
mailing list