[jbpm-commits] JBoss JBPM SVN: r2171 - in jbpm3/trunk/modules/core/src/test: java/org/jbpm/command and 12 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Thu Sep 11 02:47:08 EDT 2008
Author: thomas.diesler at jboss.com
Date: 2008-09-11 02:47:07 -0400 (Thu, 11 Sep 2008)
New Revision: 2171
Added:
jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1024/
jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1024/JBPM1024Test.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1072/
jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1072/JBPM1072Test.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1106/
jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1106/JBPM1106Test.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1135/
jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1135/JBPM1135Test.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1452/
jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1452/JBPM1452Test.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm522/
jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm522/JBPM522Test.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm983/
jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm983/JBPM983Test.java
jbpm3/trunk/modules/core/src/test/resources/org/jbpm/jbpm1135/
jbpm3/trunk/modules/core/src/test/resources/org/jbpm/jbpm1135/timerprocess.xml
jbpm3/trunk/modules/core/src/test/resources/org/jbpm/jbpm522/
Removed:
jbpm3/trunk/modules/core/src/test/java/org/jbpm/ant/
jbpm3/trunk/modules/core/src/test/java/org/jbpm/command/GetProcessInstancesCommandTest.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/context/exe/CustomSerializableVariableDbTest.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/job/executor/JobConcurrencyDbTest.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/job/executor/MultiJobExecutorDbTest.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/job/executor/NoJobExecutorDbTest.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/job/executor/TimerOnTimerDbTest.java
jbpm3/trunk/modules/core/src/test/resources/org/jbpm/ant/
jbpm3/trunk/modules/core/src/test/resources/org/jbpm/job/executor/.gpd.timerprocess.xml
jbpm3/trunk/modules/core/src/test/resources/org/jbpm/job/executor/timerprocess.xml
Log:
Move JIRA tests to their respective folders
Deleted: jbpm3/trunk/modules/core/src/test/java/org/jbpm/command/GetProcessInstancesCommandTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/command/GetProcessInstancesCommandTest.java 2008-09-11 05:59:58 UTC (rev 2170)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/command/GetProcessInstancesCommandTest.java 2008-09-11 06:47:07 UTC (rev 2171)
@@ -1,94 +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.command;
-
-import java.util.Calendar;
-import java.util.List;
-
-import org.jbpm.command.impl.CommandServiceImpl;
-import org.jbpm.db.AbstractDbTestCase;
-import org.jbpm.graph.def.ProcessDefinition;
-import org.jbpm.graph.exe.ProcessInstance;
-
-/**
- * Test case for JBPM-1106.
- * @author Alejandro Guizar
- */
-public class GetProcessInstancesCommandTest extends AbstractDbTestCase {
-
- private static CommandService commandService = new CommandServiceImpl(jbpmConfiguration);
- private ProcessDefinition processDefinition;
-
- public void setUp() throws Exception {
- super.setUp();
- processDefinition = new ProcessDefinition("Audit");
- jbpmContext.deployProcessDefinition(processDefinition);
-
- ProcessInstance processInstance = new ProcessInstance(processDefinition);
- Calendar calendar = Calendar.getInstance();
- calendar.set(2008, 8, 10, 9, 30);
- processInstance.setStart(calendar.getTime());
- jbpmContext.save(processInstance);
-
- processInstance = new ProcessInstance(processDefinition);
- calendar.set(Calendar.HOUR_OF_DAY, 16);
- processInstance.setStart(calendar.getTime());
- jbpmContext.save(processInstance);
-
- processInstance = new ProcessInstance(processDefinition);
- calendar.add(Calendar.DAY_OF_MONTH, 1);
- processInstance.setStart(calendar.getTime());
- jbpmContext.save(processInstance);
-
- processInstance = new ProcessInstance(processDefinition);
- calendar.set(Calendar.HOUR_OF_DAY, 9);
- processInstance.setStart(calendar.getTime());
- jbpmContext.save(processInstance);
-
- newTransaction();
- }
-
- public void testStartDate() {
- GetProcessInstancesCommand command = new GetProcessInstancesCommand();
- Calendar calendar = Calendar.getInstance();
- calendar.set(2008, 8, 10, 9, 0);
- command.setFromStartDate(calendar.getTime());
- calendar.add(Calendar.DAY_OF_MONTH, 1);
- command.setUntilStartDate(calendar.getTime());
-
- List processInstances = (List) commandService.execute(command);
- assertEquals(2, processInstances.size());
- }
-
- public void testStartTime() {
- GetProcessInstancesCommand command = new GetProcessInstancesCommand();
- Calendar calendar = Calendar.getInstance();
- calendar.set(2008, 8, 10, 9, 0);
- command.setFromStartDate(calendar.getTime());
- calendar.set(Calendar.HOUR_OF_DAY, 12);
- command.setUntilStartDate(calendar.getTime());
-
- List processInstances = (List) commandService.execute(command);
- assertEquals(1, processInstances.size());
- }
-
-}
Deleted: jbpm3/trunk/modules/core/src/test/java/org/jbpm/context/exe/CustomSerializableVariableDbTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/context/exe/CustomSerializableVariableDbTest.java 2008-09-11 05:59:58 UTC (rev 2170)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/context/exe/CustomSerializableVariableDbTest.java 2008-09-11 06:47:07 UTC (rev 2171)
@@ -1,54 +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.context.exe;
-
-import java.io.IOException;
-import java.io.Serializable;
-
-import org.jbpm.db.AbstractDbTestCase;
-import org.jbpm.graph.def.ProcessDefinition;
-import org.jbpm.graph.exe.ProcessInstance;
-import org.jbpm.instantiation.ProcessClassLoader;
-
-/**
- * Tests a serializable variable whose class file is stored in the process definition.
- * @author Alejandro Guizar
- * @see <a href="http://jira.jboss.com/jira/browse/JBPM-1024">JBPM-1024</a>
- */
-public class CustomSerializableVariableDbTest extends AbstractDbTestCase {
-
- public void testCustomSerializableVariableClass() throws IOException {
- // create and save the process definition
- ProcessDefinition processDefinition = ProcessDefinition.parseParResource("org/jbpm/context/exe/CustomSerializable.zip");
- graphSession.saveProcessDefinition(processDefinition);
-
- // create the process instance
- ProcessInstance processInstance = new ProcessInstance(processDefinition);
- processInstance = saveAndReload(processInstance);
-
- // get the custom object from the context instance
- Object customSerializable = processInstance.getContextInstance().getVariable("custom serializable");
- assertTrue(customSerializable instanceof Serializable);
- assertSame(ProcessClassLoader.class, customSerializable.getClass().getClassLoader().getClass());
- assertEquals("1984", customSerializable.toString());
- }
-}
Added: jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1024/JBPM1024Test.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1024/JBPM1024Test.java (rev 0)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1024/JBPM1024Test.java 2008-09-11 06:47:07 UTC (rev 2171)
@@ -0,0 +1,60 @@
+/*
+ * 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.jbpm1024;
+
+import java.io.IOException;
+import java.io.Serializable;
+
+import org.jbpm.db.AbstractDbTestCase;
+import org.jbpm.graph.def.ProcessDefinition;
+import org.jbpm.graph.exe.ProcessInstance;
+import org.jbpm.instantiation.ProcessClassLoader;
+
+/**
+ * Serializable variables are not being deserialized when retrieved from process
+ *
+ * https://jira.jboss.org/jira/browse/JBPM-1024
+ *
+ * Tests a serializable variable whose class file is stored in the process definition.
+ *
+ * @author Alejandro Guizar
+ */
+public class JBPM1024Test extends AbstractDbTestCase
+{
+
+ public void testCustomSerializableVariableClass() throws IOException
+ {
+ // create and save the process definition
+ ProcessDefinition processDefinition = ProcessDefinition.parseParResource("org/jbpm/context/exe/CustomSerializable.zip");
+ graphSession.saveProcessDefinition(processDefinition);
+
+ // create the process instance
+ ProcessInstance processInstance = new ProcessInstance(processDefinition);
+ processInstance = saveAndReload(processInstance);
+
+ // get the custom object from the context instance
+ Object customSerializable = processInstance.getContextInstance().getVariable("custom serializable");
+ assertTrue(customSerializable instanceof Serializable);
+ assertSame(ProcessClassLoader.class, customSerializable.getClass().getClassLoader().getClass());
+ assertEquals("1984", customSerializable.toString());
+ }
+}
Property changes on: jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1024/JBPM1024Test.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1072/JBPM1072Test.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1072/JBPM1072Test.java (rev 0)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1072/JBPM1072Test.java 2008-09-11 06:47:07 UTC (rev 2171)
@@ -0,0 +1,155 @@
+package org.jbpm.jbpm1072;
+
+import java.sql.SQLException;
+
+import junit.framework.TestCase;
+
+import org.jbpm.JbpmConfiguration;
+import org.jbpm.JbpmContext;
+import org.jbpm.graph.def.ActionHandler;
+import org.jbpm.graph.def.Event;
+import org.jbpm.graph.def.ProcessDefinition;
+import org.jbpm.graph.exe.ExecutionContext;
+import org.jbpm.graph.exe.ProcessInstance;
+import org.jbpm.job.executor.EventCallback;
+import org.jbpm.job.executor.JobExecutor;
+
+/**
+ * Concurrent JobExecutors can process the same job in parallel
+ *
+ * https://jira.jboss.org/jira/browse/JBPM-1072
+ *
+ * @author Jiri Pechanec
+ * @author Alejandro Guizar
+ */
+public class JBPM1072Test extends TestCase {
+
+ private static final int EXECUTOR_COUNT = 20;
+ public static final String PROCESS_NAME = "TestProcess";
+
+ private JobExecutor[] executors = new JobExecutor[EXECUTOR_COUNT];
+
+ private static JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
+
+ public static final String PROCESS_DEFINITION = "<?xml version='1.0' encoding='UTF-8'?>"
+ + "<process-definition name='" + PROCESS_NAME + "'>"
+ + "<event type='process-end'>"
+ + "<action expression='#{eventCallback.processEnd}' />"
+ + "</event>"
+ + "<start-state name='start-state1'>"
+ + "<transition to='Service 1'></transition>"
+ + "</start-state>"
+ + "<node name='Service 1'>"
+ + "<action class='"
+ + SimpleAction.class.getName()
+ + "' />"
+ + "<transition to='Service 2' />"
+ + "</node>"
+ + "<node name='Service 2' async='true'>"
+ + "<action class='"
+ + SimpleAction2.class.getName()
+ + "' />"
+ + "<transition to='end-state1' />"
+ + "</node>"
+ + "<end-state name='end-state1' />"
+ + "</process-definition>";
+
+ protected void setUp() throws SQLException
+ {
+ jbpmConfiguration.createSchema();
+
+ // deploy process definition
+ JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+ try
+ {
+ jbpmContext.deployProcessDefinition(ProcessDefinition.parseXmlString(PROCESS_DEFINITION));
+ }
+ finally
+ {
+ jbpmContext.close();
+ }
+ }
+
+ public void testMultipleJobExecutors()
+ {
+ // start job executors
+ for (int i = 0; i < executors.length; i++)
+ {
+ executors[i] = (JobExecutor)JbpmConfiguration.Configs.getObjectFactory().createObject("jbpm.job.executor");
+ executors[i].setName("JbpmJobExecutor/" + (i + 1));
+ executors[i].start();
+ }
+
+ // kick off process instance
+ JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+ try
+ {
+ ProcessInstance processInstance = jbpmContext.newProcessInstanceForUpdate(PROCESS_NAME);
+ processInstance.getContextInstance().setVariable("eventCallback", new EventCallback());
+ processInstance.signal();
+ }
+ finally
+ {
+ jbpmContext.close();
+ }
+
+ // wait for process end
+ EventCallback.waitForEvent(Event.EVENTTYPE_PROCESS_END);
+
+ // stop job executors
+ for (int i = executors.length - 1; i >= 0; i--)
+ {
+ try
+ {
+ executors[i].stopAndJoin();
+ }
+ catch (InterruptedException e)
+ {
+ // continue to next executor
+ }
+ }
+
+ assertEquals(1, SimpleAction2.getExecutionCount());
+ }
+
+ protected void tearDown()
+ {
+ jbpmConfiguration.dropSchema();
+ }
+
+ public static class SimpleAction implements ActionHandler
+ {
+
+ private static final long serialVersionUID = 1L;
+
+ public void execute(ExecutionContext exeContext) throws Exception
+ {
+ exeContext.leaveNode();
+ }
+
+ }
+
+ public static class SimpleAction2 implements ActionHandler
+ {
+
+ private static int executionCount = 0;
+
+ private static final long serialVersionUID = 1L;
+
+ public void execute(ExecutionContext exeContext) throws Exception
+ {
+ incrementCount();
+ exeContext.leaveNode();
+ }
+
+ private static synchronized int incrementCount()
+ {
+ return ++executionCount;
+ }
+
+ public static synchronized int getExecutionCount()
+ {
+ return executionCount;
+ }
+ }
+}
Property changes on: jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1072/JBPM1072Test.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1106/JBPM1106Test.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1106/JBPM1106Test.java (rev 0)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1106/JBPM1106Test.java 2008-09-11 06:47:07 UTC (rev 2171)
@@ -0,0 +1,103 @@
+/*
+ * 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.jbpm1106;
+
+import java.util.Calendar;
+import java.util.List;
+
+import org.jbpm.command.CommandService;
+import org.jbpm.command.GetProcessInstancesCommand;
+import org.jbpm.command.impl.CommandServiceImpl;
+import org.jbpm.db.AbstractDbTestCase;
+import org.jbpm.graph.def.ProcessDefinition;
+import org.jbpm.graph.exe.ProcessInstance;
+
+/**
+ * GetProcessInstancesCommand should use Query.setTimestamp instead of Query.setDate
+ *
+ * https://jira.jboss.org/jira/browse/JBPM-1106
+ *
+ * @author Alejandro Guizar
+ */
+public class JBPM1106Test extends AbstractDbTestCase
+{
+
+ private static CommandService commandService = new CommandServiceImpl(jbpmConfiguration);
+ private ProcessDefinition processDefinition;
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ processDefinition = new ProcessDefinition("Audit");
+ jbpmContext.deployProcessDefinition(processDefinition);
+
+ ProcessInstance processInstance = new ProcessInstance(processDefinition);
+ Calendar calendar = Calendar.getInstance();
+ calendar.set(2008, 8, 10, 9, 30);
+ processInstance.setStart(calendar.getTime());
+ jbpmContext.save(processInstance);
+
+ processInstance = new ProcessInstance(processDefinition);
+ calendar.set(Calendar.HOUR_OF_DAY, 16);
+ processInstance.setStart(calendar.getTime());
+ jbpmContext.save(processInstance);
+
+ processInstance = new ProcessInstance(processDefinition);
+ calendar.add(Calendar.DAY_OF_MONTH, 1);
+ processInstance.setStart(calendar.getTime());
+ jbpmContext.save(processInstance);
+
+ processInstance = new ProcessInstance(processDefinition);
+ calendar.set(Calendar.HOUR_OF_DAY, 9);
+ processInstance.setStart(calendar.getTime());
+ jbpmContext.save(processInstance);
+
+ newTransaction();
+ }
+
+ public void testStartDate()
+ {
+ GetProcessInstancesCommand command = new GetProcessInstancesCommand();
+ Calendar calendar = Calendar.getInstance();
+ calendar.set(2008, 8, 10, 9, 0);
+ command.setFromStartDate(calendar.getTime());
+ calendar.add(Calendar.DAY_OF_MONTH, 1);
+ command.setUntilStartDate(calendar.getTime());
+
+ List processInstances = (List)commandService.execute(command);
+ assertEquals(2, processInstances.size());
+ }
+
+ public void testStartTime()
+ {
+ GetProcessInstancesCommand command = new GetProcessInstancesCommand();
+ Calendar calendar = Calendar.getInstance();
+ calendar.set(2008, 8, 10, 9, 0);
+ command.setFromStartDate(calendar.getTime());
+ calendar.set(Calendar.HOUR_OF_DAY, 12);
+ command.setUntilStartDate(calendar.getTime());
+
+ List processInstances = (List)commandService.execute(command);
+ assertEquals(1, processInstances.size());
+ }
+
+}
Property changes on: jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1106/JBPM1106Test.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1135/JBPM1135Test.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1135/JBPM1135Test.java (rev 0)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1135/JBPM1135Test.java 2008-09-11 06:47:07 UTC (rev 2171)
@@ -0,0 +1,69 @@
+/*
+ * 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.jbpm1135;
+
+import org.jbpm.db.AbstractDbTestCase;
+import org.jbpm.graph.def.Event;
+import org.jbpm.graph.def.ProcessDefinition;
+import org.jbpm.graph.exe.ProcessInstance;
+import org.jbpm.job.executor.EventCallback;
+
+/**
+ * JobSession.deleteJobsForProcessInstance doesn't work if jbpm isn't the transaction manager
+ *
+ * https://jira.jboss.org/jira/browse/JBPM-1135
+ *
+ * @author Alejandro Guizar
+ */
+public class JBPM1135Test extends AbstractDbTestCase
+{
+
+ public void testTimerOnTimer()
+ {
+ ProcessDefinition processDefinition = ProcessDefinition.parseXmlResource("org/jbpm/jbpm1135/timerprocess.xml");
+ jbpmContext.deployProcessDefinition(processDefinition);
+
+ ProcessInstance processInstance = jbpmContext.newProcessInstanceForUpdate("timerProcess");
+ processInstance.getContextInstance().setVariable("eventCallback", new EventCallback());
+ processInstance.signal();
+ assertEquals("firstNode", processInstance.getRootToken().getNode().getName());
+ commitAndCloseSession();
+
+ startJobExecutor();
+ try
+ {
+ EventCallback.waitForEvent(Event.EVENTTYPE_NODE_ENTER);
+ beginSessionTransaction();
+ long processInstanceId = processInstance.getId();
+ assertEquals("secondNode", jbpmContext.loadProcessInstance(processInstanceId).getRootToken().getNode().getName());
+ commitAndCloseSession();
+
+ EventCallback.waitForEvent(Event.EVENTTYPE_PROCESS_END);
+ beginSessionTransaction();
+ assertTrue(jbpmContext.loadProcessInstance(processInstanceId).hasEnded());
+ }
+ finally
+ {
+ stopJobExecutor();
+ }
+ }
+}
Property changes on: jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1135/JBPM1135Test.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1452/JBPM1452Test.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1452/JBPM1452Test.java (rev 0)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1452/JBPM1452Test.java 2008-09-11 06:47:07 UTC (rev 2171)
@@ -0,0 +1,72 @@
+/*
+ * 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.jbpm1452;
+
+import junit.framework.TestCase;
+
+import org.jbpm.JbpmConfiguration;
+import org.jbpm.JbpmContext;
+import org.jbpm.configuration.ObjectFactory;
+import org.jbpm.graph.def.ProcessDefinition;
+import org.jbpm.graph.exe.ProcessInstance;
+
+/**
+ * JbpmConfiguration assumes the object factory has a jbpm.job.executor entry
+ *
+ * https://jira.jboss.org/jira/browse/JBPM-1452
+ *
+ * @author Alejandro Guizar
+ */
+public class JBPM1452Test extends TestCase
+{
+
+ private JbpmContext jbpmContext;
+
+ private static JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString(
+ "<jbpm-configuration>" +
+ " <null name='jbpm.job.executor' />" +
+ "</jbpm-configuration>");
+
+ public void setUp() throws Exception
+ {
+ jbpmConfiguration.createSchema();
+ jbpmContext = jbpmConfiguration.createJbpmContext();
+ }
+
+ public void tearDown() throws Exception
+ {
+ jbpmContext.close();
+ jbpmConfiguration.dropSchema();
+ }
+
+ public void testNoJobExecutor()
+ {
+ // check the job executor is properly nullified
+ ObjectFactory objectFactory = jbpmContext.getObjectFactory();
+ assertTrue("expected object factory to have object jbpm.job.executor", objectFactory.hasObject("jbpm.job.executor"));
+ assertNull(objectFactory.createObject("jbpm.job.executor"));
+ // start and end a process instance, no exception should be thrown
+ jbpmContext.deployProcessDefinition(new ProcessDefinition("Audit"));
+ ProcessInstance processInstance = jbpmContext.newProcessInstanceForUpdate("Audit");
+ processInstance.end();
+ }
+}
Property changes on: jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1452/JBPM1452Test.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm522/JBPM522Test.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm522/JBPM522Test.java (rev 0)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm522/JBPM522Test.java 2008-09-11 06:47:07 UTC (rev 2171)
@@ -0,0 +1,80 @@
+/*
+ * 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.jbpm522;
+
+import java.util.List;
+
+import org.apache.tools.ant.Main;
+
+import org.jbpm.db.AbstractDbTestCase;
+import org.jbpm.graph.def.ProcessDefinition;
+
+/**
+ * Failed attempts to deploy a process leave a process definition record
+ *
+ * https://jira.jboss.org/jira/browse/JBPM-522
+ *
+ * @author Alejandro Guizar
+ */
+public class JBPM522Test extends AbstractDbTestCase {
+
+ public void testDeployProcess() {
+ runTarget("deploy.process");
+ List processDefinitions = graphSession.findAllProcessDefinitions();
+ assertEquals(1, processDefinitions.size());
+ ProcessDefinition processDefinition = (ProcessDefinition) processDefinitions.get(0);
+ assertEquals("timerProcess", processDefinition.getName());
+ }
+
+ public void testDeployBadProcess() {
+ runTarget("deploy.bad.process");
+ List processDefinitions = graphSession.findAllProcessDefinitions();
+ assertEquals(0, processDefinitions.size());
+ }
+
+ public void testDeployProcesses() {
+ runTarget("deploy.processes");
+ List processDefinitions = graphSession.findAllProcessDefinitions();
+ assertEquals(2, processDefinitions.size());
+ ProcessDefinition processDefinition = (ProcessDefinition) processDefinitions.get(0);
+ assertEquals("classLoadingProcess", processDefinition.getName());
+ processDefinition = (ProcessDefinition) processDefinitions.get(1);
+ assertEquals("timerProcess", processDefinition.getName());
+ }
+
+ public void testDeployProcessesIncludingBad() {
+ runTarget("deploy.processes.including.bad");
+ List processDefinitions = graphSession.findAllProcessDefinitions();
+ assertEquals(0, processDefinitions.size());
+ }
+
+ private static void runTarget(String target) {
+ String[] args = {
+ "-buildfile", JBPM522Test.class.getResource("build.xml").getPath(), target
+ };
+ new Main() {
+ protected void exit(int exitCode) {
+ // prevent ant from terminating the VM
+ }
+ }.startAnt(args, System.getProperties(), Thread.currentThread().getContextClassLoader());
+ }
+}
Property changes on: jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm522/JBPM522Test.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm983/JBPM983Test.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm983/JBPM983Test.java (rev 0)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm983/JBPM983Test.java 2008-09-11 06:47:07 UTC (rev 2171)
@@ -0,0 +1,244 @@
+package org.jbpm.jbpm983;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jbpm.JbpmConfiguration;
+import org.jbpm.JbpmContext;
+import org.jbpm.graph.def.ActionHandler;
+import org.jbpm.graph.def.ProcessDefinition;
+import org.jbpm.graph.exe.ExecutionContext;
+import org.jbpm.graph.exe.ProcessInstance;
+import org.jbpm.job.executor.JobExecutor;
+
+/**
+ * Concurrent process execution fails
+ *
+ * https://jira.jboss.org/jira/browse/JBPM-983
+ *
+ * @author Tom Baeyens
+ */
+public class JBPM983Test extends TestCase
+{
+ private static Log log = LogFactory.getLog(JBPM983Test.class);
+
+ protected static JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance("org/jbpm/jbpm.test.cfg.xml");
+
+ protected void setUp() throws Exception
+ {
+ jbpmConfiguration.createSchema();
+
+ JobExecutor jobExecutor = jbpmConfiguration.getJobExecutor();
+ jobExecutor.setNbrOfThreads(5);
+ jobExecutor.start();
+
+ log.debug("");
+ log.debug("### starting " + getName() + " ####################################################");
+ }
+
+ protected void tearDown() throws Exception
+ {
+ log.debug("### " + getName() + " done ####################################################");
+ log.debug("");
+
+ jbpmConfiguration.getJobExecutor().stop();
+
+ jbpmConfiguration.dropSchema();
+ }
+
+ static String SUBPROCESS_XML = "<?xml version='1.0' encoding='UTF-8'?>"
+ + "<process-definition xmlns='urn:jbpm.org:jpdl-3.2' name='subprocess'>"
+ + "<start-state name='start-state1'>"
+ + " <description>start of the process</description>"
+ + " <transition name='start-to-check' to='fileCheck' />"
+ + "</start-state>"
+ + ""
+ + "<node name='fileCheck' async='exclusive'>"
+ + " <action name='action_filecheck' class='"
+ + TestAction.class.getName()
+ + "'>"
+ + " </action>"
+ + " <transition name='check-to-do' to='doWhatever'></transition>"
+ + "</node>"
+ + ""
+ + "<node name='doWhatever' async='exclusive'>"
+ + " <action name='action_do' class='"
+ + TestAction.class.getName()
+ + "'>"
+ + " </action>"
+ + " <transition name='check-to-end' to='end-state-success'></transition>"
+ + "</node>"
+ + ""
+ + "<end-state name='end-state-success'>"
+ + " <description>process finished normally</description>"
+ + "</end-state>"
+ + "</process-definition>";
+
+ static String PROCESS_XML = "<?xml version='1.0' encoding='UTF-8'?>"
+ + "<process-definition xmlns='urn:jbpm.org:jpdl-3.2' name='superprocess'>"
+ + "<start-state name='start-state1'>"
+ + " <description>start of the process</description>"
+ + " <transition name='start-to-check' to='fileCheck' />"
+ + "</start-state>"
+ + ""
+ + "<node name='fileCheck' async='true'>"
+ + " <action name='action_check' class='"
+ + TestAction.class.getName()
+ + "'>"
+ + " </action>"
+ + " <transition name='check-to-fork' to='fork1'></transition>"
+ + "</node>"
+ + ""
+ + "<fork name='fork1'>"
+ + " <transition name='toNode1' to='node1'></transition>"
+ + " <transition name='toNode2' to='node2'></transition>"
+ + "</fork>"
+ + ""
+ + "<process-state name='node1' async='exclusive'>"
+ + " <sub-process name='subprocess' />"
+ + " <transition name='node1toJoin1' to='join1'></transition>"
+ + "</process-state>"
+ + ""
+ + "<process-state name='node2' async='exclusive'>"
+ + " <sub-process name='subprocess' />"
+ + " <transition name='node2toJoin1' to='join1'></transition>"
+ + "</process-state>"
+ + ""
+ + "<join name='join1'>"
+ + " <transition name='joinToEnd' to='end-state-success'></transition>"
+ + "</join>"
+ + ""
+ + "<end-state name='end-state-success'>"
+ + " <description>process finished normally</description>"
+ + "</end-state>"
+ + "</process-definition>";
+
+ public void testConcurrentJobs() throws Exception
+ {
+ assertTrue(jbpmConfiguration.getJobExecutor().getNbrOfThreads() > 1);
+
+ log.info("### TEST: deploy + start processes ###");
+
+ JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+ try
+ {
+ jbpmContext.deployProcessDefinition(ProcessDefinition.parseXmlString(SUBPROCESS_XML));
+ jbpmContext.deployProcessDefinition(ProcessDefinition.parseXmlString(PROCESS_XML));
+ }
+ finally
+ {
+ jbpmContext.close();
+ }
+
+ // create test properties
+ Map testVariables = new HashMap();
+ testVariables.put("test", "true");
+
+ final int processCount = 10;
+ long[] piIds = new long[processCount];
+ for (int i = 0; i < processCount; i++)
+ {
+ log.info("#################### TEST: starting process " + i + " ####################");
+
+ jbpmContext = jbpmConfiguration.createJbpmContext();
+ try
+ {
+ ProcessInstance pi = jbpmContext.newProcessInstanceForUpdate("superprocess");
+ pi.getContextInstance().addVariables(testVariables);
+ pi.signal();
+ piIds[i] = pi.getId();
+ }
+ finally
+ {
+ jbpmContext.close();
+ }
+ }
+
+ for (int i = 0; i < processCount; i++)
+ {
+ log.info("### TEST: wait for process completion ###");
+
+ long piId = piIds[i];
+ waitFor(piId);
+
+ jbpmContext = jbpmConfiguration.createJbpmContext();
+ try
+ {
+ ProcessInstance pi = jbpmContext.loadProcessInstance(piId);
+ assertEquals("end-state-success", pi.getRootToken().getNode().getName());
+ }
+ finally
+ {
+ jbpmContext.close();
+ }
+
+ log.info("#################### TEST: finished ####################");
+ }
+ }
+
+ protected void waitFor(long piId) throws Exception
+ {
+ final int endTimeout = 30;
+ long startTime = System.currentTimeMillis();
+
+ while (true)
+ {
+ if (System.currentTimeMillis() - startTime > endTimeout * 1000)
+ {
+ fail("Aborting after " + endTimeout + " seconds.");
+ return;
+ }
+
+ log.info("waiting for workflow completion....");
+ try
+ {
+ Thread.sleep(1000);
+ }
+ catch (InterruptedException e)
+ {
+ log.error("wait for workflow was interruputed", e);
+ fail();
+ }
+
+ JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+ try
+ {
+ if (jbpmContext.loadProcessInstance(piId).hasEnded())
+ break;
+ }
+ finally
+ {
+ jbpmContext.close();
+ }
+ }
+ }
+
+ public static class TestAction implements ActionHandler
+ {
+
+ private static final long serialVersionUID = 1L;
+
+ public void execute(ExecutionContext executionContext) throws Exception
+ {
+ String processName = executionContext.getProcessDefinition().getName() + ":" + executionContext.getProcessInstance().getId();
+ String nodeName = executionContext.getToken().getNode().getName();
+ String tokenName = executionContext.getToken().toString();
+
+ log.info("ACTION (process=" + processName + ",node=" + nodeName + ",token=" + tokenName + "): begin");
+
+ for (int i = 0; i < 5; i++)
+ {
+ log.info("ACTION (process=" + processName + ",node=" + nodeName + ",token=" + tokenName + "): working...");
+ Thread.sleep(100);
+ }
+
+ log.info("ACTION (process=" + processName + ",node=" + nodeName + ",token=" + tokenName + "): end");
+
+ executionContext.leaveNode();
+ }
+ }
+}
Property changes on: jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm983/JBPM983Test.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Deleted: jbpm3/trunk/modules/core/src/test/java/org/jbpm/job/executor/JobConcurrencyDbTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/job/executor/JobConcurrencyDbTest.java 2008-09-11 05:59:58 UTC (rev 2170)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/job/executor/JobConcurrencyDbTest.java 2008-09-11 06:47:07 UTC (rev 2171)
@@ -1,238 +0,0 @@
-package org.jbpm.job.executor;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jbpm.JbpmConfiguration;
-import org.jbpm.JbpmContext;
-import org.jbpm.graph.def.ActionHandler;
-import org.jbpm.graph.def.ProcessDefinition;
-import org.jbpm.graph.exe.ExecutionContext;
-import org.jbpm.graph.exe.ProcessInstance;
-
-/**
- * test case for http://jira.jboss.com/jira/browse/JBPM-983
- */
-public class JobConcurrencyDbTest extends TestCase {
-
- private static Log log = LogFactory.getLog(JobConcurrencyDbTest.class);
-
- protected static JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance("org/jbpm/jbpm.test.cfg.xml");
-
- protected void setUp() throws Exception {
- jbpmConfiguration.createSchema();
-
- JobExecutor jobExecutor = jbpmConfiguration.getJobExecutor();
- jobExecutor.setNbrOfThreads(5);
- jobExecutor.start();
-
- log.debug("");
- log.debug("### starting " + getName() + " ####################################################");
- }
-
- protected void tearDown() throws Exception {
- log.debug("### " + getName() + " done ####################################################");
- log.debug("");
-
- jbpmConfiguration.getJobExecutor().stop();
-
- jbpmConfiguration.dropSchema();
- }
-
- static String SUBPROCESS_XML = "<?xml version='1.0' encoding='UTF-8'?>"
- + "<process-definition xmlns='urn:jbpm.org:jpdl-3.2' name='subprocess'>"
- + "<start-state name='start-state1'>"
- + " <description>start of the process</description>"
- + " <transition name='start-to-check' to='fileCheck' />"
- + "</start-state>"
- + ""
- + "<node name='fileCheck' async='exclusive'>"
- + " <action name='action_filecheck' class='"
- + TestAction.class.getName()
- + "'>"
- + " </action>"
- + " <transition name='check-to-do' to='doWhatever'></transition>"
- + "</node>"
- + ""
- + "<node name='doWhatever' async='exclusive'>"
- + " <action name='action_do' class='"
- + TestAction.class.getName()
- + "'>"
- + " </action>"
- + " <transition name='check-to-end' to='end-state-success'></transition>"
- + "</node>"
- + ""
- + "<end-state name='end-state-success'>"
- + " <description>process finished normally</description>"
- + "</end-state>"
- + "</process-definition>";
-
- static String PROCESS_XML = "<?xml version='1.0' encoding='UTF-8'?>"
- + "<process-definition xmlns='urn:jbpm.org:jpdl-3.2' name='superprocess'>"
- + "<start-state name='start-state1'>"
- + " <description>start of the process</description>"
- + " <transition name='start-to-check' to='fileCheck' />"
- + "</start-state>"
- + ""
- + "<node name='fileCheck' async='true'>"
- + " <action name='action_check' class='"
- + TestAction.class.getName()
- + "'>"
- + " </action>"
- + " <transition name='check-to-fork' to='fork1'></transition>"
- + "</node>"
- + ""
- + "<fork name='fork1'>"
- + " <transition name='toNode1' to='node1'></transition>"
- + " <transition name='toNode2' to='node2'></transition>"
- + "</fork>"
- + ""
- + "<process-state name='node1' async='exclusive'>"
- + " <sub-process name='subprocess' />"
- + " <transition name='node1toJoin1' to='join1'></transition>"
- + "</process-state>"
- + ""
- + "<process-state name='node2' async='exclusive'>"
- + " <sub-process name='subprocess' />"
- + " <transition name='node2toJoin1' to='join1'></transition>"
- + "</process-state>"
- + ""
- + "<join name='join1'>"
- + " <transition name='joinToEnd' to='end-state-success'></transition>"
- + "</join>"
- + ""
- + "<end-state name='end-state-success'>"
- + " <description>process finished normally</description>"
- + "</end-state>"
- + "</process-definition>";
-
- public void testConcurrentJobs() throws Exception {
- assertTrue(jbpmConfiguration.getJobExecutor().getNbrOfThreads() > 1);
-
- log.info("### TEST: deploy + start processes ###");
-
- JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
- try {
- jbpmContext.deployProcessDefinition(ProcessDefinition.parseXmlString(SUBPROCESS_XML));
- jbpmContext.deployProcessDefinition(ProcessDefinition.parseXmlString(PROCESS_XML));
- }
- finally {
- jbpmContext.close();
- }
-
- // create test properties
- Map testVariables = new HashMap();
- testVariables.put("test", "true");
-
- final int processCount = 10;
- long[] piIds = new long[processCount];
- for (int i = 0; i < processCount; i++) {
- log.info("#################### TEST: starting process " + i + " ####################");
-
- jbpmContext = jbpmConfiguration.createJbpmContext();
- try {
- ProcessInstance pi = jbpmContext.newProcessInstanceForUpdate("superprocess");
- pi.getContextInstance().addVariables(testVariables);
- pi.signal();
- piIds[i] = pi.getId();
- }
- finally {
- jbpmContext.close();
- }
- }
-
- for (int i = 0; i < processCount; i++) {
- log.info("### TEST: wait for process completion ###");
-
- long piId = piIds[i];
- waitFor(piId);
-
- jbpmContext = jbpmConfiguration.createJbpmContext();
- try {
- ProcessInstance pi = jbpmContext.loadProcessInstance(piId);
- assertEquals("end-state-success", pi.getRootToken().getNode().getName());
- }
- finally {
- jbpmContext.close();
- }
-
- log.info("#################### TEST: finished ####################");
- }
- }
-
- protected void waitFor(long piId) throws Exception {
- final int endTimeout = 30;
- long startTime = System.currentTimeMillis();
-
- while (true) {
- if (System.currentTimeMillis() - startTime > endTimeout * 1000) {
- fail("Aborting after " + endTimeout + " seconds.");
- return;
- }
-
- log.info("waiting for workflow completion....");
- try {
- Thread.sleep(1000);
- }
- catch (InterruptedException e) {
- log.error("wait for workflow was interruputed", e);
- fail();
- }
-
- JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
- try {
- if (jbpmContext.loadProcessInstance(piId).hasEnded())
- break;
- }
- finally {
- jbpmContext.close();
- }
- }
- }
-
- public static class TestAction implements ActionHandler {
-
- private static final long serialVersionUID = 1L;
-
- public void execute(ExecutionContext executionContext) throws Exception {
- String processName = executionContext.getProcessDefinition().getName()
- + ":"
- + executionContext.getProcessInstance().getId();
- String nodeName = executionContext.getToken().getNode().getName();
- String tokenName = executionContext.getToken().toString();
-
- log.info("ACTION (process="
- + processName
- + ",node="
- + nodeName
- + ",token="
- + tokenName
- + "): begin");
-
- for (int i = 0; i < 5; i++) {
- log.info("ACTION (process="
- + processName
- + ",node="
- + nodeName
- + ",token="
- + tokenName
- + "): working...");
- Thread.sleep(100);
- }
-
- log.info("ACTION (process="
- + processName
- + ",node="
- + nodeName
- + ",token="
- + tokenName
- + "): end");
-
- executionContext.leaveNode();
- }
- }
-}
Deleted: jbpm3/trunk/modules/core/src/test/java/org/jbpm/job/executor/MultiJobExecutorDbTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/job/executor/MultiJobExecutorDbTest.java 2008-09-11 05:59:58 UTC (rev 2170)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/job/executor/MultiJobExecutorDbTest.java 2008-09-11 06:47:07 UTC (rev 2171)
@@ -1,150 +0,0 @@
-package org.jbpm.job.executor;
-
-import java.sql.SQLException;
-
-import junit.framework.TestCase;
-
-import org.jbpm.JbpmConfiguration;
-import org.jbpm.JbpmContext;
-import org.jbpm.graph.def.ActionHandler;
-import org.jbpm.graph.def.Event;
-import org.jbpm.graph.def.ProcessDefinition;
-import org.jbpm.graph.exe.ExecutionContext;
-import org.jbpm.graph.exe.ProcessInstance;
-
-/**
- * Test case for JBPM-1072.
- * @author Jiri Pechanec
- * @author Alejandro Guizar
- */
-public class MultiJobExecutorDbTest extends TestCase {
-
- private static final int EXECUTOR_COUNT = 20;
- public static final String PROCESS_NAME = "TestProcess";
-
- private JobExecutor[] executors = new JobExecutor[EXECUTOR_COUNT];
-
- private static JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
-
- public static final String PROCESS_DEFINITION = "<?xml version='1.0' encoding='UTF-8'?>"
- + "<process-definition name='" + PROCESS_NAME + "'>"
- + "<event type='process-end'>"
- + "<action expression='#{eventCallback.processEnd}' />"
- + "</event>"
- + "<start-state name='start-state1'>"
- + "<transition to='Service 1'></transition>"
- + "</start-state>"
- + "<node name='Service 1'>"
- + "<action class='"
- + SimpleAction.class.getName()
- + "' />"
- + "<transition to='Service 2' />"
- + "</node>"
- + "<node name='Service 2' async='true'>"
- + "<action class='"
- + SimpleAction2.class.getName()
- + "' />"
- + "<transition to='end-state1' />"
- + "</node>"
- + "<end-state name='end-state1' />"
- + "</process-definition>";
-
- protected void setUp() throws SQLException
- {
- jbpmConfiguration.createSchema();
-
- // deploy process definition
- JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
- try
- {
- jbpmContext.deployProcessDefinition(ProcessDefinition.parseXmlString(PROCESS_DEFINITION));
- }
- finally
- {
- jbpmContext.close();
- }
- }
-
- public void testMultipleJobExecutors()
- {
- // start job executors
- for (int i = 0; i < executors.length; i++)
- {
- executors[i] = (JobExecutor)JbpmConfiguration.Configs.getObjectFactory().createObject("jbpm.job.executor");
- executors[i].setName("JbpmJobExecutor/" + (i + 1));
- executors[i].start();
- }
-
- // kick off process instance
- JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
- try
- {
- ProcessInstance processInstance = jbpmContext.newProcessInstanceForUpdate(PROCESS_NAME);
- processInstance.getContextInstance().setVariable("eventCallback", new EventCallback());
- processInstance.signal();
- }
- finally
- {
- jbpmContext.close();
- }
-
- // wait for process end
- EventCallback.waitForEvent(Event.EVENTTYPE_PROCESS_END);
-
- // stop job executors
- for (int i = executors.length - 1; i >= 0; i--)
- {
- try
- {
- executors[i].stopAndJoin();
- }
- catch (InterruptedException e)
- {
- // continue to next executor
- }
- }
-
- assertEquals(1, SimpleAction2.getExecutionCount());
- }
-
- protected void tearDown()
- {
- jbpmConfiguration.dropSchema();
- }
-
- public static class SimpleAction implements ActionHandler
- {
-
- private static final long serialVersionUID = 1L;
-
- public void execute(ExecutionContext exeContext) throws Exception
- {
- exeContext.leaveNode();
- }
-
- }
-
- public static class SimpleAction2 implements ActionHandler
- {
-
- private static int executionCount = 0;
-
- private static final long serialVersionUID = 1L;
-
- public void execute(ExecutionContext exeContext) throws Exception
- {
- incrementCount();
- exeContext.leaveNode();
- }
-
- private static synchronized int incrementCount()
- {
- return ++executionCount;
- }
-
- public static synchronized int getExecutionCount()
- {
- return executionCount;
- }
- }
-}
Deleted: jbpm3/trunk/modules/core/src/test/java/org/jbpm/job/executor/NoJobExecutorDbTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/job/executor/NoJobExecutorDbTest.java 2008-09-11 05:59:58 UTC (rev 2170)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/job/executor/NoJobExecutorDbTest.java 2008-09-11 06:47:07 UTC (rev 2171)
@@ -1,66 +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.job.executor;
-
-import junit.framework.TestCase;
-
-import org.jbpm.JbpmConfiguration;
-import org.jbpm.JbpmContext;
-import org.jbpm.configuration.ObjectFactory;
-import org.jbpm.graph.def.ProcessDefinition;
-import org.jbpm.graph.exe.ProcessInstance;
-
-/**
- * Test case or JBPM-1452
- * @author Alejandro Guizar
- */
-public class NoJobExecutorDbTest extends TestCase {
-
- private JbpmContext jbpmContext;
-
- private static JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString(
- "<jbpm-configuration>" +
- " <null name='jbpm.job.executor' />" +
- "</jbpm-configuration>");
-
- public void setUp() throws Exception {
- jbpmConfiguration.createSchema();
- jbpmContext = jbpmConfiguration.createJbpmContext();
- }
-
- public void tearDown() throws Exception {
- jbpmContext.close();
- jbpmConfiguration.dropSchema();
- }
-
- public void testNoJobExecutor() {
- // check the job executor is properly nullified
- ObjectFactory objectFactory = jbpmContext.getObjectFactory();
- assertTrue("expected object factory to have object jbpm.job.executor",
- objectFactory.hasObject("jbpm.job.executor"));
- assertNull(objectFactory.createObject("jbpm.job.executor"));
- // start and end a process instance, no exception should be thrown
- jbpmContext.deployProcessDefinition(new ProcessDefinition("Audit"));
- ProcessInstance processInstance = jbpmContext.newProcessInstanceForUpdate("Audit");
- processInstance.end();
- }
-}
Deleted: jbpm3/trunk/modules/core/src/test/java/org/jbpm/job/executor/TimerOnTimerDbTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/job/executor/TimerOnTimerDbTest.java 2008-09-11 05:59:58 UTC (rev 2170)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/job/executor/TimerOnTimerDbTest.java 2008-09-11 06:47:07 UTC (rev 2171)
@@ -1,64 +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.job.executor;
-
-import org.jbpm.db.AbstractDbTestCase;
-import org.jbpm.graph.def.Event;
-import org.jbpm.graph.def.ProcessDefinition;
-import org.jbpm.graph.exe.ProcessInstance;
-
-/**
- * Test case for JBPM-1135
- * @author Alejandro Guizar
- */
-public class TimerOnTimerDbTest extends AbstractDbTestCase {
-
- public void testTimerOnTimer() {
- ProcessDefinition processDefinition = ProcessDefinition.parseXmlResource("org/jbpm/job/executor/timerprocess.xml");
- jbpmContext.deployProcessDefinition(processDefinition);
-
- ProcessInstance processInstance = jbpmContext.newProcessInstanceForUpdate("timerProcess");
- processInstance.getContextInstance().setVariable("eventCallback", new EventCallback());
- processInstance.signal();
- assertEquals("firstNode", processInstance.getRootToken().getNode().getName());
- commitAndCloseSession();
-
- startJobExecutor();
- try {
- EventCallback.waitForEvent(Event.EVENTTYPE_NODE_ENTER);
- beginSessionTransaction();
- long processInstanceId = processInstance.getId();
- assertEquals("secondNode", jbpmContext.loadProcessInstance(processInstanceId)
- .getRootToken()
- .getNode()
- .getName());
- commitAndCloseSession();
-
- EventCallback.waitForEvent(Event.EVENTTYPE_PROCESS_END);
- beginSessionTransaction();
- assertTrue(jbpmContext.loadProcessInstance(processInstanceId).hasEnded());
- }
- finally {
- stopJobExecutor();
- }
- }
-}
Copied: jbpm3/trunk/modules/core/src/test/resources/org/jbpm/jbpm1135/timerprocess.xml (from rev 2169, jbpm3/trunk/modules/core/src/test/resources/org/jbpm/job/executor/timerprocess.xml)
===================================================================
--- jbpm3/trunk/modules/core/src/test/resources/org/jbpm/jbpm1135/timerprocess.xml (rev 0)
+++ jbpm3/trunk/modules/core/src/test/resources/org/jbpm/jbpm1135/timerprocess.xml 2008-09-11 06:47:07 UTC (rev 2171)
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<process-definition name="timerProcess" xmlns="urn:jbpm.org:jpdl-3.2"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jbpm.org:jpdl-3.2 http://jbpm.org/xsd/jpdl-3.2.xsd">
+
+ <event type="process-start">
+ <action expression="#{eventCallback.processStart}"/>
+ </event>
+ <event type="process-end">
+ <action expression="#{eventCallback.processEnd}"/>
+ </event>
+ <event type="node-enter">
+ <action expression="#{eventCallback.nodeEnter}" />
+ </event>
+ <event type="node-leave">
+ <action expression="#{eventCallback.nodeLeave}" />
+ </event>
+
+ <start-state name="start">
+ <transition name="doneStart" to="firstNode" />
+ </start-state>
+
+ <task-node name="firstNode" end-tasks="yes">
+ <task name="firstTask">
+ <assignment actor-id="admin" />
+ <timer duedate="1 second" transition="doneFirst" />
+ </task>
+ <transition name="doneFirst" to="secondNode" />
+ </task-node>
+
+ <task-node name="secondNode" end-tasks="yes">
+ <task name="secondTask">
+ <assignment actor-id="admin" />
+ <timer duedate="1 second" transition="doneSecond" />
+ </task>
+ <transition name="doneSecond" to="end" />
+ </task-node>
+
+ <end-state name="end" />
+
+</process-definition>
\ No newline at end of file
Copied: jbpm3/trunk/modules/core/src/test/resources/org/jbpm/jbpm522 (from rev 2169, jbpm3/trunk/modules/core/src/test/resources/org/jbpm/ant)
Deleted: jbpm3/trunk/modules/core/src/test/resources/org/jbpm/job/executor/.gpd.timerprocess.xml
===================================================================
--- jbpm3/trunk/modules/core/src/test/resources/org/jbpm/job/executor/.gpd.timerprocess.xml 2008-09-11 05:59:58 UTC (rev 2170)
+++ jbpm3/trunk/modules/core/src/test/resources/org/jbpm/job/executor/.gpd.timerprocess.xml 2008-09-11 06:47:07 UTC (rev 2171)
@@ -1,3 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<root-container/>
\ No newline at end of file
Deleted: jbpm3/trunk/modules/core/src/test/resources/org/jbpm/job/executor/timerprocess.xml
===================================================================
--- jbpm3/trunk/modules/core/src/test/resources/org/jbpm/job/executor/timerprocess.xml 2008-09-11 05:59:58 UTC (rev 2170)
+++ jbpm3/trunk/modules/core/src/test/resources/org/jbpm/job/executor/timerprocess.xml 2008-09-11 06:47:07 UTC (rev 2171)
@@ -1,41 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<process-definition name="timerProcess" xmlns="urn:jbpm.org:jpdl-3.2"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="urn:jbpm.org:jpdl-3.2 http://jbpm.org/xsd/jpdl-3.2.xsd">
-
- <event type="process-start">
- <action expression="#{eventCallback.processStart}"/>
- </event>
- <event type="process-end">
- <action expression="#{eventCallback.processEnd}"/>
- </event>
- <event type="node-enter">
- <action expression="#{eventCallback.nodeEnter}" />
- </event>
- <event type="node-leave">
- <action expression="#{eventCallback.nodeLeave}" />
- </event>
-
- <start-state name="start">
- <transition name="doneStart" to="firstNode" />
- </start-state>
-
- <task-node name="firstNode" end-tasks="yes">
- <task name="firstTask">
- <assignment actor-id="admin" />
- <timer duedate="1 second" transition="doneFirst" />
- </task>
- <transition name="doneFirst" to="secondNode" />
- </task-node>
-
- <task-node name="secondNode" end-tasks="yes">
- <task name="secondTask">
- <assignment actor-id="admin" />
- <timer duedate="1 second" transition="doneSecond" />
- </task>
- <transition name="doneSecond" to="end" />
- </task-node>
-
- <end-state name="end" />
-
-</process-definition>
\ No newline at end of file
More information about the jbpm-commits
mailing list