[jbpm-commits] JBoss JBPM SVN: r2187 - in jbpm3/trunk/modules/core/src: test/java/org/jbpm/jbpm1072 and 4 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Fri Sep 12 03:40:23 EDT 2008
Author: thomas.diesler at jboss.com
Date: 2008-09-12 03:40:23 -0400 (Fri, 12 Sep 2008)
New Revision: 2187
Modified:
jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1072/JBPM1072Test.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1452/JBPM1452Test.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm983/JBPM983Test.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/job/executor/JobLoadJoinTest.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/job/executor/JobLoadSubProcessTest.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/persistence/db/FlushDbTest.java
Log:
Remove all references to dropSchema
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java 2008-09-12 07:18:04 UTC (rev 2186)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java 2008-09-12 07:40:23 UTC (rev 2187)
@@ -43,32 +43,32 @@
private JbpmConfiguration jbpmConfiguration;
- protected JbpmContext jbpmContext = null;
- protected SchemaExport schemaExport = null;
+ protected JbpmContext jbpmContext;
+ protected SchemaExport schemaExport;
- protected Session session = null;
- protected GraphSession graphSession = null;
- protected TaskMgmtSession taskMgmtSession = null;
- protected ContextSession contextSession = null;
- protected JobSession jobSession = null;
- protected LoggingSession loggingSession = null;
+ protected Session session;
+ protected GraphSession graphSession;
+ protected TaskMgmtSession taskMgmtSession;
+ protected ContextSession contextSession;
+ protected JobSession jobSession;
+ protected LoggingSession loggingSession;
protected JobExecutor jobExecutor;
public void setUp() throws Exception
{
+ log.debug("### starting " + getClass().getName() + "." + getName() + " ####################################################");
createSchema();
createJbpmContext();
initializeMembers();
- log.debug("### starting " + getClass().getName() + "." + getName() + " ####################################################");
}
public void tearDown() throws Exception
{
- log.debug("### " + getClass().getName() + "." + getName() + " done ####################################################");
resetMembers();
closeJbpmContext();
super.tearDown();
+ log.debug("### " + getClass().getName() + "." + getName() + " done ####################################################");
}
public void beginSessionTransaction()
@@ -139,11 +139,17 @@
getJbpmConfiguration().dropSchema();
}
+ protected String getJbpmTestConfig()
+ {
+ return "org/jbpm/db/jbpm.db.test.cfg.xml";
+ }
+
protected JbpmConfiguration getJbpmConfiguration()
{
if (jbpmConfiguration == null)
{
- jbpmConfiguration = JbpmConfiguration.getInstance("org/jbpm/db/jbpm.db.test.cfg.xml");
+ String jbpmTestConfiguration = getJbpmTestConfig();
+ jbpmConfiguration = JbpmConfiguration.getInstance(jbpmTestConfiguration);
}
return jbpmConfiguration;
}
@@ -155,7 +161,8 @@
protected void closeJbpmContext()
{
- jbpmContext.close();
+ if (jbpmContext != null)
+ jbpmContext.close();
}
protected void startJobExecutor()
Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1072/JBPM1072Test.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1072/JBPM1072Test.java 2008-09-12 07:18:04 UTC (rev 2186)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1072/JBPM1072Test.java 2008-09-12 07:40:23 UTC (rev 2187)
@@ -1,12 +1,9 @@
package org.jbpm.jbpm1072;
-import java.sql.SQLException;
-
-import junit.framework.TestCase;
-
import org.jbpm.EventCallback;
import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmContext;
+import org.jbpm.db.AbstractDbTestCase;
import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.def.Event;
import org.jbpm.graph.def.ProcessDefinition;
@@ -22,15 +19,14 @@
* @author Jiri Pechanec
* @author Alejandro Guizar
*/
-public class JBPM1072Test extends TestCase {
+public class JBPM1072Test extends AbstractDbTestCase
+{
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'>"
@@ -54,20 +50,10 @@
+ "<end-state name='end-state1' />"
+ "</process-definition>";
- protected void setUp() throws SQLException
+ @Override
+ protected JbpmConfiguration getJbpmConfiguration()
{
- jbpmConfiguration.createSchema();
-
- // deploy process definition
- JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
- try
- {
- jbpmContext.deployProcessDefinition(ProcessDefinition.parseXmlString(PROCESS_DEFINITION));
- }
- finally
- {
- jbpmContext.close();
- }
+ return JbpmConfiguration.getInstance();
}
public void testMultipleJobExecutors()
@@ -81,10 +67,11 @@
}
// kick off process instance
- JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+ JbpmContext jbpmContext = getJbpmConfiguration().createJbpmContext();
try
{
- ProcessInstance processInstance = jbpmContext.newProcessInstanceForUpdate(PROCESS_NAME);
+ jbpmContext.deployProcessDefinition(ProcessDefinition.parseXmlString(PROCESS_DEFINITION));
+ ProcessInstance processInstance = jbpmContext.newProcessInstance(PROCESS_NAME);
processInstance.getContextInstance().setVariable("eventCallback", new EventCallback());
processInstance.signal();
}
@@ -112,11 +99,6 @@
assertEquals(1, SimpleAction2.getExecutionCount());
}
- protected void tearDown()
- {
- jbpmConfiguration.dropSchema();
- }
-
public static class SimpleAction implements ActionHandler
{
Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1452/JBPM1452Test.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1452/JBPM1452Test.java 2008-09-12 07:18:04 UTC (rev 2186)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1452/JBPM1452Test.java 2008-09-12 07:40:23 UTC (rev 2187)
@@ -21,11 +21,9 @@
*/
package org.jbpm.jbpm1452;
-import junit.framework.TestCase;
-
import org.jbpm.JbpmConfiguration;
-import org.jbpm.JbpmContext;
import org.jbpm.configuration.ObjectFactory;
+import org.jbpm.db.AbstractDbTestCase;
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.exe.ProcessInstance;
@@ -36,28 +34,17 @@
*
* @author Alejandro Guizar
*/
-public class JBPM1452Test extends TestCase
+public class JBPM1452Test extends AbstractDbTestCase
{
-
- private JbpmContext jbpmContext;
-
- private static JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString(
- "<jbpm-configuration>" +
- " <null name='jbpm.job.executor' />" +
- "</jbpm-configuration>");
-
- public void setUp() throws Exception
+ @Override
+ protected JbpmConfiguration getJbpmConfiguration()
{
- jbpmConfiguration.createSchema();
- jbpmContext = jbpmConfiguration.createJbpmContext();
+ return JbpmConfiguration.parseXmlString(
+ "<jbpm-configuration>" +
+ " <null name='jbpm.job.executor' />" +
+ "</jbpm-configuration>");
}
- public void tearDown() throws Exception
- {
- jbpmContext.close();
- jbpmConfiguration.dropSchema();
- }
-
public void testNoJobExecutor()
{
// check the job executor is properly nullified
Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm983/JBPM983Test.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm983/JBPM983Test.java 2008-09-12 07:18:04 UTC (rev 2186)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm983/JBPM983Test.java 2008-09-12 07:40:23 UTC (rev 2187)
@@ -3,12 +3,10 @@
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.db.AbstractDbTestCase;
import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.exe.ExecutionContext;
@@ -22,32 +20,28 @@
*
* @author Tom Baeyens
*/
-public class JBPM983Test extends TestCase
+public class JBPM983Test extends AbstractDbTestCase
{
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
+ @Override
+ protected String getJbpmTestConfig()
{
- jbpmConfiguration.createSchema();
+ return "org/jbpm/jbpm.test.cfg.xml";
+ }
- JobExecutor jobExecutor = jbpmConfiguration.getJobExecutor();
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ JobExecutor jobExecutor = getJbpmConfiguration().getJobExecutor();
jobExecutor.setNbrOfThreads(5);
jobExecutor.start();
-
- log.debug("");
- log.debug("### starting " + getName() + " ####################################################");
}
- protected void tearDown() throws Exception
+ public void tearDown() throws Exception
{
- log.debug("### " + getName() + " done ####################################################");
- log.debug("");
-
- jbpmConfiguration.getJobExecutor().stop();
-
- jbpmConfiguration.dropSchema();
+ getJbpmConfiguration().getJobExecutor().stop();
+ super.tearDown();
}
static String SUBPROCESS_XML = "<?xml version='1.0' encoding='UTF-8'?>"
@@ -119,11 +113,11 @@
public void testConcurrentJobs() throws Exception
{
- assertTrue(jbpmConfiguration.getJobExecutor().getNbrOfThreads() > 1);
+ assertTrue(getJbpmConfiguration().getJobExecutor().getNbrOfThreads() > 1);
log.info("### TEST: deploy + start processes ###");
- JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+ JbpmContext jbpmContext = getJbpmConfiguration().createJbpmContext();
try
{
jbpmContext.deployProcessDefinition(ProcessDefinition.parseXmlString(SUBPROCESS_XML));
@@ -144,7 +138,7 @@
{
log.info("#################### TEST: starting process " + i + " ####################");
- jbpmContext = jbpmConfiguration.createJbpmContext();
+ jbpmContext = getJbpmConfiguration().createJbpmContext();
try
{
ProcessInstance pi = jbpmContext.newProcessInstanceForUpdate("superprocess");
@@ -165,7 +159,7 @@
long piId = piIds[i];
waitFor(piId);
- jbpmContext = jbpmConfiguration.createJbpmContext();
+ jbpmContext = getJbpmConfiguration().createJbpmContext();
try
{
ProcessInstance pi = jbpmContext.loadProcessInstance(piId);
@@ -204,7 +198,7 @@
fail();
}
- JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+ JbpmContext jbpmContext = getJbpmConfiguration().createJbpmContext();
try
{
if (jbpmContext.loadProcessInstance(piId).hasEnded())
Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/job/executor/JobLoadJoinTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/job/executor/JobLoadJoinTest.java 2008-09-12 07:18:04 UTC (rev 2186)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/job/executor/JobLoadJoinTest.java 2008-09-12 07:40:23 UTC (rev 2187)
@@ -4,57 +4,62 @@
import java.util.HashSet;
import java.util.Set;
-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.db.AbstractDbTestCase;
import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.exe.ExecutionContext;
import org.jbpm.graph.exe.ProcessInstance;
-public class JobLoadJoinTest extends TestCase {
+public class JobLoadJoinTest extends AbstractDbTestCase
+{
private static Log log = LogFactory.getLog(JobLoadJoinTest.class);
- private static JbpmConfiguration jbpmConfiguration =
- JbpmConfiguration.getInstance("org/jbpm/job/executor/loadtests.jbpm.cfg.xml");
-
static Set finishedProcesses = Collections.synchronizedSet(new HashSet());
long start;
- protected void setUp() throws Exception {
- jbpmConfiguration.createSchema();
- start = System.currentTimeMillis();
+ @Override
+ protected String getJbpmTestConfig()
+ {
+ return "org/jbpm/job/executor/loadtests.jbpm.cfg.xml";
}
- protected void tearDown() throws Exception {
- jbpmConfiguration.dropSchema();
+ @Override
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ start = System.currentTimeMillis();
}
- private boolean timeIsUp(int maxWait) {
- return System.currentTimeMillis() - start > maxWait;
+ private boolean timeout(int maxWait)
+ {
+ return System.currentTimeMillis() - start > maxWait;
}
- public void testJobLoadWithJoin() throws Exception {
+ public void testJobLoadWithJoin() throws Exception
+ {
int processes = 20;
- int maxWait = 20000;
+ int maxWait = 20000;
deployProcess();
- jbpmConfiguration.startJobExecutor();
-
+ getJbpmConfiguration().startJobExecutor();
+
Set expectedProcesses = new HashSet();
- for (int i = 0; i < processes; i++) {
+ for (int i = 0; i < processes; i++)
+ {
Integer number = new Integer(i);
expectedProcesses.add(number);
- Thread thread = new StartNewExecutionThread(number);
+ Thread thread = new StartNewExecutionThread(getJbpmConfiguration(), number);
thread.start();
}
-
- while (! expectedProcesses.equals(finishedProcesses) && !timeIsUp(maxWait)) {
+
+ while (!expectedProcesses.equals(finishedProcesses) && !timeout(maxWait))
+ {
Thread.sleep(200);
}
log.info("number of finished processes: " + finishedProcesses);
@@ -62,32 +67,6 @@
assertEquals(expectedProcesses, finishedProcesses);
}
- public static class StartNewExecutionThread extends Thread {
- Integer number;
- public StartNewExecutionThread(Integer number) {
- this.number = number;
- }
- public void run() {
- JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
- try {
- ProcessInstance processInstance = jbpmContext.newProcessInstance("asyncjoin");
- processInstance.getContextInstance().setVariable("number", number);
- jbpmContext.save(processInstance);
- } finally {
- jbpmContext.close();
- }
- }
- }
-
- public static class ProcessFinished implements ActionHandler {
- private static final long serialVersionUID = 1L;
- public void execute(ExecutionContext executionContext) throws Exception {
- Integer number = (Integer) executionContext.getVariable("number");
- log.info("process "+number+" finished");
- finishedProcesses.add(number);
- }
- }
-
public void deployProcess() {
ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
"<process-definition name='asyncjoin' initial='yenom'>" +
@@ -116,11 +95,54 @@
" </event>" +
"</process-definition>"
);
- JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
- try {
+
+ JbpmContext jbpmContext = getJbpmConfiguration().createJbpmContext();
+ try
+ {
jbpmContext.deployProcessDefinition(processDefinition);
- } finally {
+ }
+ finally
+ {
jbpmContext.close();
}
}
+
+ public static class StartNewExecutionThread extends Thread
+ {
+ Integer number;
+ JbpmConfiguration jbpmConfiguration;
+
+ public StartNewExecutionThread(JbpmConfiguration jbpmConfiguration, Integer number)
+ {
+ this.jbpmConfiguration = jbpmConfiguration;
+ this.number = number;
+ }
+
+ public void run()
+ {
+ JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+ try
+ {
+ ProcessInstance processInstance = jbpmContext.newProcessInstance("asyncjoin");
+ processInstance.getContextInstance().setVariable("number", number);
+ jbpmContext.save(processInstance);
+ }
+ finally
+ {
+ jbpmContext.close();
+ }
+ }
+ }
+
+ public static class ProcessFinished implements ActionHandler
+ {
+ private static final long serialVersionUID = 1L;
+
+ public void execute(ExecutionContext executionContext) throws Exception
+ {
+ Integer number = (Integer)executionContext.getVariable("number");
+ log.info("process " + number + " finished");
+ finishedProcesses.add(number);
+ }
+ }
}
Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/job/executor/JobLoadSubProcessTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/job/executor/JobLoadSubProcessTest.java 2008-09-12 07:18:04 UTC (rev 2186)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/job/executor/JobLoadSubProcessTest.java 2008-09-12 07:40:23 UTC (rev 2187)
@@ -8,88 +8,66 @@
import org.apache.commons.logging.LogFactory;
import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmContext;
+import org.jbpm.db.AbstractDbTestCase;
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 junit.framework.TestCase;
-
-public class JobLoadSubProcessTest extends TestCase {
-
+public class JobLoadSubProcessTest extends AbstractDbTestCase
+{
// TODO see JobLoadJoinTest, but instead of the joins, use a process with a sub process
private static Log log = LogFactory.getLog(JobLoadSubProcessTest.class);
static Set finishedProcesses = Collections.synchronizedSet(new HashSet());
long start;
- private static JbpmConfiguration jbpmConfiguration =
- JbpmConfiguration.getInstance("org/jbpm/job/executor/loadtests.jbpm.cfg.xml");
-
- protected void setUp() throws Exception {
- jbpmConfiguration.createSchema();
- start = System.currentTimeMillis();
+ @Override
+ protected String getJbpmTestConfig()
+ {
+ return "org/jbpm/job/executor/loadtests.jbpm.cfg.xml";
}
- protected void tearDown() throws Exception {
- jbpmConfiguration.dropSchema();
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ start = System.currentTimeMillis();
}
- private boolean timeIsUp(int maxWait) {
- return System.currentTimeMillis() - start > maxWait;
+ private boolean timeIsUp(int maxWait)
+ {
+ return System.currentTimeMillis() - start > maxWait;
}
- public void testJobLoadWithJoin() throws Exception {
+ public void testJobLoadWithJoin() throws Exception
+ {
int processes = 1;
- int maxWait = 20000;
+ int maxWait = 20000;
deployProcesses();
- jbpmConfiguration.startJobExecutor();
-
+ getJbpmConfiguration().startJobExecutor();
+
Set expectedProcesses = new HashSet();
- for (int i = 0; i < processes; i++) {
+ for (int i = 0; i < processes; i++)
+ {
Integer number = new Integer(i);
expectedProcesses.add(number);
- Thread thread = new StartNewExecutionThread(number);
+ Thread thread = new StartNewExecutionThread(getJbpmConfiguration(), number);
thread.start();
}
-
- while (! expectedProcesses.equals(finishedProcesses) && !timeIsUp(maxWait)) {
+
+ while (!expectedProcesses.equals(finishedProcesses) && !timeIsUp(maxWait))
+ {
Thread.sleep(200);
}
log.info("number of finished processes: " + finishedProcesses);
log.info("number of expected processes: " + expectedProcesses);
assertEquals(expectedProcesses, finishedProcesses);
}
-
- public static class StartNewExecutionThread extends Thread {
- Integer number;
- public StartNewExecutionThread(Integer number) {
- this.number = number;
- }
- public void run() {
- JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
- try {
- ProcessInstance processInstance = jbpmContext.newProcessInstance("asyncmaster");
- processInstance.getContextInstance().setVariable("number", number);
- jbpmContext.save(processInstance);
- } finally {
- jbpmContext.close();
- }
- }
- }
- public static class ProcessFinished implements ActionHandler {
- private static final long serialVersionUID = 1L;
- public void execute(ExecutionContext executionContext) throws Exception {
- Integer number = (Integer) executionContext.getVariable("number");
- log.info("process "+number+" finished");
- finishedProcesses.add(number);
- }
- }
-
- public void deployProcesses() {
+ public void deployProcesses()
+ {
String subProcess =
"<process-definition name='asyncsub' initial='ssarg'>" +
" <node name='ssarg' async='true'>" +
@@ -100,6 +78,7 @@
" <action class='"+ProcessFinished.class.getName()+"' />" +
" </event>" +
"</process-definition>";
+
String masterProcess =
"<process-definition name='asyncmaster' initial='yenom'>" +
" <node name='yenom' async='true'>" +
@@ -116,13 +95,55 @@
" <action class='"+ProcessFinished.class.getName()+"' />" +
" </event>" +
"</process-definition>";
- JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
- try {
+
+ JbpmContext jbpmContext = getJbpmConfiguration().createJbpmContext();
+ try
+ {
jbpmContext.deployProcessDefinition(ProcessDefinition.parseXmlString(subProcess));
jbpmContext.deployProcessDefinition(ProcessDefinition.parseXmlString(masterProcess));
- } finally {
+ }
+ finally
+ {
jbpmContext.close();
}
}
-
+
+ public static class StartNewExecutionThread extends Thread
+ {
+ JbpmConfiguration jbpmConfiguration;
+ Integer number;
+
+ public StartNewExecutionThread(JbpmConfiguration jbpmConfiguration, Integer number)
+ {
+ this.jbpmConfiguration = jbpmConfiguration;
+ this.number = number;
+ }
+
+ public void run()
+ {
+ JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+ try
+ {
+ ProcessInstance processInstance = jbpmContext.newProcessInstance("asyncmaster");
+ processInstance.getContextInstance().setVariable("number", number);
+ jbpmContext.save(processInstance);
+ }
+ finally
+ {
+ jbpmContext.close();
+ }
+ }
+ }
+
+ public static class ProcessFinished implements ActionHandler
+ {
+ private static final long serialVersionUID = 1L;
+
+ public void execute(ExecutionContext executionContext) throws Exception
+ {
+ Integer number = (Integer)executionContext.getVariable("number");
+ log.info("process " + number + " finished");
+ finishedProcesses.add(number);
+ }
+ }
}
Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/persistence/db/FlushDbTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/persistence/db/FlushDbTest.java 2008-09-12 07:18:04 UTC (rev 2186)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/persistence/db/FlushDbTest.java 2008-09-12 07:40:23 UTC (rev 2187)
@@ -3,72 +3,76 @@
import java.sql.Connection;
import java.sql.DriverManager;
-import junit.framework.TestCase;
-
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmContext;
+import org.jbpm.db.AbstractDbTestCase;
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.svc.Services;
-public class FlushDbTest extends TestCase {
+public class FlushDbTest extends AbstractDbTestCase
+{
+ private JbpmConfiguration jbpmConfiguration;
+
+ @Override
+ protected JbpmConfiguration getJbpmConfiguration()
+ {
+ if (jbpmConfiguration == null)
+ {
+ StringBuffer configurationText = new StringBuffer(
+ "<jbpm-configuration>" +
+ " <jbpm-context> " +
+ " <service name='persistence'>" +
+ " <factory> " +
+ " <bean class='org.jbpm.persistence.db.DbPersistenceServiceFactory'>" +
+ " <field name='isTransactionEnabled'><boolean value='false'/></field> " +
+ " </bean> " +
+ " </factory> " +
+ " </service>" +
+ " <service name='tx' factory='org.jbpm.tx.TxServiceFactory' /> " +
+ " <service name='message' factory='org.jbpm.msg.db.DbMessageServiceFactory' />" +
+ " <service name='scheduler' factory='org.jbpm.scheduler.db.DbSchedulerServiceFactory' />" +
+ " <service name='logging' factory='org.jbpm.logging.db.DbLoggingServiceFactory' /> " +
+ " <service name='authentication' factory='org.jbpm.security.authentication.DefaultAuthenticationServiceFactory' />" +
+ " </jbpm-context> ");
- static JbpmConfiguration jbpmConfiguration = createJbpmConfiguration();
+ // make custom jbpm configuration aware of hibernate.properties
+ if (FlushDbTest.class.getClassLoader().getResource("hibernate.properties") != null)
+ configurationText.append(" <string name='resource.hibernate.properties' value='hibernate.properties' />");
- private static JbpmConfiguration createJbpmConfiguration() {
- StringBuffer configurationText = new StringBuffer(
- "<jbpm-configuration>" +
- " <jbpm-context> " +
- " <service name='persistence'>" +
- " <factory> " +
- " <bean class='org.jbpm.persistence.db.DbPersistenceServiceFactory'>" +
- " <field name='isTransactionEnabled'><boolean value='false'/></field> " +
- " </bean> " +
- " </factory> " +
- " </service>" +
- " <service name='tx' factory='org.jbpm.tx.TxServiceFactory' /> " +
- " <service name='message' factory='org.jbpm.msg.db.DbMessageServiceFactory' />" +
- " <service name='scheduler' factory='org.jbpm.scheduler.db.DbSchedulerServiceFactory' />" +
- " <service name='logging' factory='org.jbpm.logging.db.DbLoggingServiceFactory' /> " +
- " <service name='authentication' factory='org.jbpm.security.authentication.DefaultAuthenticationServiceFactory' />" +
- " </jbpm-context> ");
-
- // make custom jbpm configuration aware of hibernate.properties
- if (FlushDbTest.class.getClassLoader().getResource("hibernate.properties") != null)
- configurationText.append(" <string name='resource.hibernate.properties' value='hibernate.properties' />");
-
- configurationText.append("</jbpm-configuration>");
- return JbpmConfiguration.parseXmlString(configurationText.toString());
+ configurationText.append("</jbpm-configuration>");
+ jbpmConfiguration = JbpmConfiguration.parseXmlString(configurationText.toString());
+ }
+ return jbpmConfiguration;
}
- // static DataSource dataSource = new Jdbc.MockDataSource();
+ public void testProcessDeployment() throws Exception
+ {
+ getJbpmConfiguration().createSchema();
- public void testProcessDeployment() throws Exception {
- jbpmConfiguration.createSchema();
-
- /* getConfiguration() relies on JbpmConfiguration.Configs, which accesses either the current context or
- * the default jbpm configuration resource, but has no access to a custom jbpm configuration.
- * Because createSchema() accesses the hibernate configuration under an open context, calling getConfiguration()
- * afterwards results in obtaining a hibernate configuration aware of the custom jbpm configuration */
- DbPersistenceServiceFactory dbPersistenceServiceFactory = (DbPersistenceServiceFactory) jbpmConfiguration.getServiceFactory(Services.SERVICENAME_PERSISTENCE);
+ /*
+ * getConfiguration() relies on JbpmConfiguration.Configs, which accesses either the current context or the default jbpm configuration resource, but has no access
+ * to a custom jbpm configuration. Because createSchema() accesses the hibernate configuration under an open context, calling getConfiguration() afterwards results
+ * in obtaining a hibernate configuration aware of the custom jbpm configuration
+ */
+ DbPersistenceServiceFactory dbPersistenceServiceFactory = (DbPersistenceServiceFactory)getJbpmConfiguration().getServiceFactory(Services.SERVICENAME_PERSISTENCE);
Configuration configuration = dbPersistenceServiceFactory.getConfiguration();
SessionFactory sessionFactory = dbPersistenceServiceFactory.getSessionFactory();
-
- try {
+
+ try
+ {
String dbDriverClass = configuration.getProperty("hibernate.connection.driver_class");
String dbUrl = configuration.getProperty("hibernate.connection.url");
String dbUserName = configuration.getProperty("hibernate.connection.username");
String dbPassword = configuration.getProperty("hibernate.connection.password");
-
+
Class.forName(dbDriverClass);
- Connection connection = DriverManager.getConnection(dbUrl, dbUserName, dbPassword);
+ Connection connection = DriverManager.getConnection(dbUrl, dbUserName, dbPassword);
connection.setAutoCommit(false);
- JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+ JbpmContext jbpmContext = getJbpmConfiguration().createJbpmContext();
jbpmContext.setConnection(connection);
- ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
- "<process-definition name='hello' />"
- );
+ ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition name='hello' />");
jbpmContext.deployProcessDefinition(processDefinition);
jbpmContext.close();
connection.commit();
@@ -76,15 +80,16 @@
connection = DriverManager.getConnection(dbUrl, dbUserName, dbPassword);
connection.setAutoCommit(false);
- jbpmContext = jbpmConfiguration.createJbpmContext();
+ jbpmContext = getJbpmConfiguration().createJbpmContext();
jbpmContext.setConnection(connection);
jbpmContext.newProcessInstanceForUpdate("hello");
jbpmContext.close();
connection.commit();
connection.close();
-
- } finally {
- jbpmConfiguration.dropSchema();
+
+ }
+ finally
+ {
sessionFactory.close();
}
}
More information about the jbpm-commits
mailing list