[jbpm-commits] JBoss JBPM SVN: r2833 - in jbpm3/branches/jbpm-3.3.0.GA/modules/core: src/main/java/org/jbpm and 7 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Sun Nov 9 09:30:26 EST 2008
Author: alex.guizar at jboss.com
Date: 2008-11-09 09:30:26 -0500 (Sun, 09 Nov 2008)
New Revision: 2833
Modified:
jbpm3/branches/jbpm-3.3.0.GA/modules/core/pom.xml
jbpm3/branches/jbpm-3.3.0.GA/modules/core/src/main/java/org/jbpm/JbpmConfiguration.java
jbpm3/branches/jbpm-3.3.0.GA/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java
jbpm3/branches/jbpm-3.3.0.GA/modules/core/src/test/java/org/jbpm/context/exe/CustomVariableLongIdDbTest.java
jbpm3/branches/jbpm-3.3.0.GA/modules/core/src/test/java/org/jbpm/context/exe/CustomVariableStringIdDbTest.java
jbpm3/branches/jbpm-3.3.0.GA/modules/core/src/test/java/org/jbpm/jbpm1452/JBPM1452Test.java
jbpm3/branches/jbpm-3.3.0.GA/modules/core/src/test/java/org/jbpm/jbpm983/JBPM983Test.java
jbpm3/branches/jbpm-3.3.0.GA/modules/core/src/test/java/org/jbpm/job/executor/JobExecutorDbTest.java
jbpm3/branches/jbpm-3.3.0.GA/modules/core/src/test/java/org/jbpm/logging/exe/LoggingConfigDbTest.java
jbpm3/branches/jbpm-3.3.0.GA/modules/core/src/test/java/org/jbpm/seam/JobExecutorCustomizationTest.java
Log:
JBPM-1816: sanitized tests that leaked JDBC connections
Modified: jbpm3/branches/jbpm-3.3.0.GA/modules/core/pom.xml
===================================================================
--- jbpm3/branches/jbpm-3.3.0.GA/modules/core/pom.xml 2008-11-09 12:57:29 UTC (rev 2832)
+++ jbpm3/branches/jbpm-3.3.0.GA/modules/core/pom.xml 2008-11-09 14:30:26 UTC (rev 2833)
@@ -342,20 +342,16 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludes>
- <!-- [JBPM-1764] JobExecutorDbTest does not work on Sybase -->
- <exclude>org/jbpm/job/executor/JobExecutorDbTest</exclude>
- <!-- [JBPM-1810] Fix clean, drop, create schema with JbpmSchema -->
- <exclude>org/jbpm/db/JbpmSchemaDbTest.java</exclude>
-
- <exclude>org/jbpm/db/DeleteProcessInstanceDbTest.java</exclude>
+ <!-- [JBPM-1764] Deadlocks make job execution tests fail on Sybase -->
+ <exclude>org/jbpm/job/executor/JobExecutorDbTest.java</exclude>
<exclude>org/jbpm/graph/exe/SubProcessPlusConcurrencyDbTest.java</exclude>
<exclude>org/jbpm/jbpm1072/JBPM1072Test.java</exclude>
<exclude>org/jbpm/jbpm1755/JBPM1755Test.java</exclude>
<exclude>org/jbpm/jbpm983/JBPM983Test.java</exclude>
- <exclude>org/jbpm/job/executor/JobExecutorDbTest.java</exclude>
<exclude>org/jbpm/optimisticlocking/LockingTest.java</exclude>
- <exclude>org/jbpm/scheduler/exe/UnsafeSessionUsageTest.java</exclude>
<exclude>org/jbpm/seam/JobExecutorCustomizationTest.java</exclude>
+ <!-- [JBPM-1810] Fix clean, drop, create schema with JbpmSchema -->
+ <exclude>org/jbpm/db/JbpmSchemaDbTest.java</exclude>
</excludes>
</configuration>
</plugin>
Modified: jbpm3/branches/jbpm-3.3.0.GA/modules/core/src/main/java/org/jbpm/JbpmConfiguration.java
===================================================================
--- jbpm3/branches/jbpm-3.3.0.GA/modules/core/src/main/java/org/jbpm/JbpmConfiguration.java 2008-11-09 12:57:29 UTC (rev 2832)
+++ jbpm3/branches/jbpm-3.3.0.GA/modules/core/src/main/java/org/jbpm/JbpmConfiguration.java 2008-11-09 14:30:26 UTC (rev 2833)
@@ -548,12 +548,9 @@
try {
synchronized (instances) {
- Iterator iter = instances.keySet().iterator();
- while (iter.hasNext()) {
- String resource = (String) iter.next();
- if (this == instances.get(resource)) {
- instances.remove(resource);
- break;
+ for (Iterator i = instances.values().iterator(); i.hasNext();) {
+ if (this == i.next()) {
+ i.remove();
}
}
}
@@ -564,9 +561,8 @@
Map serviceFactories = jbpmContext.getServices().getServiceFactories();
if (serviceFactories != null) {
- Iterator iter = serviceFactories.values().iterator();
- while (iter.hasNext()) {
- ServiceFactory serviceFactory = (ServiceFactory) iter.next();
+ for (Iterator i = serviceFactories.values().iterator(); i.hasNext();) {
+ ServiceFactory serviceFactory = (ServiceFactory) i.next();
serviceFactory.close();
}
}
Modified: jbpm3/branches/jbpm-3.3.0.GA/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java
===================================================================
--- jbpm3/branches/jbpm-3.3.0.GA/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java 2008-11-09 12:57:29 UTC (rev 2832)
+++ jbpm3/branches/jbpm-3.3.0.GA/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java 2008-11-09 14:30:26 UTC (rev 2833)
@@ -83,8 +83,7 @@
JbpmSchema jbpmSchema = new JbpmSchema(configuration);
Map jbpmTablesRecordCount = jbpmSchema.getJbpmTablesRecordCount();
- Iterator iter = jbpmTablesRecordCount.entrySet().iterator();
- while (iter.hasNext())
+ for (Iterator iter = jbpmTablesRecordCount.entrySet().iterator(); iter.hasNext();)
{
Map.Entry entry = (Map.Entry)iter.next();
String tableName = (String)entry.getKey();
@@ -94,7 +93,7 @@
{
hasLeftOvers = true;
// [JBPM-1812] Fix tests that don't cleanup the database
- // System.err.println("FIXME: " + getClass().getName() + "." + getName() + " left " + count + " records in " + tableName);
+ System.err.println("FIXME: " + getClass().getName() + "." + getName() + " left " + count + " records in " + tableName);
}
}
Modified: jbpm3/branches/jbpm-3.3.0.GA/modules/core/src/test/java/org/jbpm/context/exe/CustomVariableLongIdDbTest.java
===================================================================
--- jbpm3/branches/jbpm-3.3.0.GA/modules/core/src/test/java/org/jbpm/context/exe/CustomVariableLongIdDbTest.java 2008-11-09 12:57:29 UTC (rev 2832)
+++ jbpm3/branches/jbpm-3.3.0.GA/modules/core/src/test/java/org/jbpm/context/exe/CustomVariableLongIdDbTest.java 2008-11-09 14:30:26 UTC (rev 2833)
@@ -21,7 +21,6 @@
*/
package org.jbpm.context.exe;
-import org.hibernate.cfg.Configuration;
import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmContext;
import org.jbpm.context.def.ContextDefinition;
@@ -31,49 +30,35 @@
import org.jbpm.persistence.db.DbPersistenceServiceFactory;
import org.jbpm.svc.Services;
-public class CustomVariableLongIdDbTest extends AbstractDbTestCase
-{
+public class CustomVariableLongIdDbTest extends AbstractDbTestCase {
- static JbpmConfiguration customLongJbpmConfiguration = createJbpmConfiguration();
-
- private static JbpmConfiguration createJbpmConfiguration()
- {
- // make custom jbpm configuration aware of hibernate.properties
- String configurationResource = CustomVariableLongIdDbTest.class.getClassLoader().getResource("hibernate.properties") != null ? "org/jbpm/db/jbpm.db.test.cfg.xml"
- : "org/jbpm/jbpm.test.cfg.xml";
- JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseResource(configurationResource);
-
- DbPersistenceServiceFactory dbPersistenceServiceFactory = (DbPersistenceServiceFactory)jbpmConfiguration.getServiceFactory(Services.SERVICENAME_PERSISTENCE);
- JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
- try
- {
- /*
- * 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. The context is created only to enforce the use of the custom jbpm configuration.
- */
- Configuration configuration = dbPersistenceServiceFactory.getConfiguration();
- configuration.addClass(CustomLongClass.class);
+ protected JbpmConfiguration getJbpmConfiguration() {
+ if (jbpmConfiguration == null) {
+ jbpmConfiguration = JbpmConfiguration.parseResource(getJbpmTestConfig());
+ JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+ try {
+ DbPersistenceServiceFactory persistenceServiceFactory = (DbPersistenceServiceFactory) jbpmContext.getServices()
+ .getServiceFactory(Services.SERVICENAME_PERSISTENCE);
+ persistenceServiceFactory.getConfiguration().addClass(CustomLongClass.class);
+ }
+ finally {
+ jbpmContext.close();
+ }
}
- finally
- {
- jbpmContext.close();
- }
return jbpmConfiguration;
}
- protected JbpmConfiguration getJbpmConfiguration()
- {
- return customLongJbpmConfiguration;
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ jbpmConfiguration.close();
}
- public void testCustomVariableClassWithLongId()
- {
+ public void testCustomVariableClassWithLongId() {
// create and save the process definition
ProcessDefinition processDefinition = new ProcessDefinition();
processDefinition.addDefinition(new ContextDefinition());
graphSession.saveProcessDefinition(processDefinition);
- try
- {
+ try {
// create the process instance
ProcessInstance processInstance = new ProcessInstance(processDefinition);
// set the jbpmSession in the context because its used to determine the
@@ -88,12 +73,11 @@
contextInstance = processInstance.getContextInstance();
// get the custom hibernatable object from the variableInstances
- customLongObject = (CustomLongClass)contextInstance.getVariable("custom hibernate object");
+ customLongObject = (CustomLongClass) contextInstance.getVariable("custom hibernate object");
assertNotNull(customLongObject);
assertEquals("customname", customLongObject.getName());
}
- finally
- {
+ finally {
jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
}
Modified: jbpm3/branches/jbpm-3.3.0.GA/modules/core/src/test/java/org/jbpm/context/exe/CustomVariableStringIdDbTest.java
===================================================================
--- jbpm3/branches/jbpm-3.3.0.GA/modules/core/src/test/java/org/jbpm/context/exe/CustomVariableStringIdDbTest.java 2008-11-09 12:57:29 UTC (rev 2832)
+++ jbpm3/branches/jbpm-3.3.0.GA/modules/core/src/test/java/org/jbpm/context/exe/CustomVariableStringIdDbTest.java 2008-11-09 14:30:26 UTC (rev 2833)
@@ -21,7 +21,6 @@
*/
package org.jbpm.context.exe;
-import org.hibernate.cfg.Configuration;
import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmContext;
import org.jbpm.context.def.ContextDefinition;
@@ -31,52 +30,39 @@
import org.jbpm.persistence.db.DbPersistenceServiceFactory;
import org.jbpm.svc.Services;
-public class CustomVariableStringIdDbTest extends AbstractDbTestCase
-{
+public class CustomVariableStringIdDbTest extends AbstractDbTestCase {
- static JbpmConfiguration customStringJbpmConfiguration = createJbpmConfiguration();
-
- private static JbpmConfiguration createJbpmConfiguration()
- {
- // make custom jbpm configuration aware of hibernate.properties
- String configurationResource = CustomVariableStringIdDbTest.class.getClassLoader().getResource("hibernate.properties") != null ? "org/jbpm/db/jbpm.db.test.cfg.xml"
- : "org/jbpm/jbpm.test.cfg.xml";
- JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseResource(configurationResource);
-
- DbPersistenceServiceFactory dbPersistenceServiceFactory = (DbPersistenceServiceFactory)jbpmConfiguration.getServiceFactory(Services.SERVICENAME_PERSISTENCE);
- JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
- try
- {
- /*
- * 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. The context is created only to enforce the use of the custom jbpm configuration.
- */
- Configuration configuration = dbPersistenceServiceFactory.getConfiguration();
- configuration.addClass(CustomStringClass.class);
+ protected JbpmConfiguration getJbpmConfiguration() {
+ if (jbpmConfiguration == null) {
+ jbpmConfiguration = JbpmConfiguration.parseResource(getJbpmTestConfig());
+ JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+ try {
+ DbPersistenceServiceFactory persistenceServiceFactory = (DbPersistenceServiceFactory) jbpmContext.getServices()
+ .getServiceFactory(Services.SERVICENAME_PERSISTENCE);
+ persistenceServiceFactory.getConfiguration().addClass(CustomStringClass.class);
+ }
+ finally {
+ jbpmContext.close();
+ }
}
- finally
- {
- jbpmContext.close();
- }
return jbpmConfiguration;
}
- protected JbpmConfiguration getJbpmConfiguration()
- {
- return customStringJbpmConfiguration;
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ jbpmConfiguration.close();
}
- public void testCustomVariableClassWithStringId()
- {
+ public void testCustomVariableClassWithStringId() {
// create and save the process definition
ProcessDefinition processDefinition = new ProcessDefinition();
processDefinition.addDefinition(new ContextDefinition());
graphSession.saveProcessDefinition(processDefinition);
- try
- {
+ try {
// create the process instance
ProcessInstance processInstance = new ProcessInstance(processDefinition);
- // set the jbpmSession in the context because its used to determine the jbpm-type for the custom object.
+ // set the jbpmSession in the context because its used to determine the
+ // jbpm-type for the custom object.
ContextInstance contextInstance = processInstance.getContextInstance();
// create the custom object
@@ -87,12 +73,11 @@
contextInstance = processInstance.getContextInstance();
// get the custom hibernatable object from the variableInstances
- customStringObject = (CustomStringClass)contextInstance.getVariable("custom hibernate object");
+ customStringObject = (CustomStringClass) contextInstance.getVariable("custom hibernate object");
assertNotNull(customStringObject);
assertEquals("customname", customStringObject.getName());
}
- finally
- {
+ finally {
jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
}
}
Modified: jbpm3/branches/jbpm-3.3.0.GA/modules/core/src/test/java/org/jbpm/jbpm1452/JBPM1452Test.java
===================================================================
--- jbpm3/branches/jbpm-3.3.0.GA/modules/core/src/test/java/org/jbpm/jbpm1452/JBPM1452Test.java 2008-11-09 12:57:29 UTC (rev 2832)
+++ jbpm3/branches/jbpm-3.3.0.GA/modules/core/src/test/java/org/jbpm/jbpm1452/JBPM1452Test.java 2008-11-09 14:30:26 UTC (rev 2833)
@@ -60,6 +60,7 @@
protected void tearDown() throws Exception {
graphSession.deleteProcessDefinition(processDefinitionId);
super.tearDown();
+ jbpmConfiguration.close();
}
public void testNoJobExecutor() {
Modified: jbpm3/branches/jbpm-3.3.0.GA/modules/core/src/test/java/org/jbpm/jbpm983/JBPM983Test.java
===================================================================
--- jbpm3/branches/jbpm-3.3.0.GA/modules/core/src/test/java/org/jbpm/jbpm983/JBPM983Test.java 2008-11-09 12:57:29 UTC (rev 2832)
+++ jbpm3/branches/jbpm-3.3.0.GA/modules/core/src/test/java/org/jbpm/jbpm983/JBPM983Test.java 2008-11-09 14:30:26 UTC (rev 2833)
@@ -25,11 +25,6 @@
private long subProcessDefinitionId;
private long processDefinitionId;
- @Override
- protected String getJbpmTestConfig() {
- return "org/jbpm/jbpm.test.cfg.xml";
- }
-
protected void setUp() throws Exception {
super.setUp();
@@ -49,6 +44,7 @@
protected void tearDown() throws Exception {
stopJobExecutor();
+ getJbpmConfiguration().getJobExecutor().setNbrOfThreads(1);
graphSession.deleteProcessDefinition(processDefinitionId);
graphSession.deleteProcessDefinition(subProcessDefinitionId);
Modified: jbpm3/branches/jbpm-3.3.0.GA/modules/core/src/test/java/org/jbpm/job/executor/JobExecutorDbTest.java
===================================================================
--- jbpm3/branches/jbpm-3.3.0.GA/modules/core/src/test/java/org/jbpm/job/executor/JobExecutorDbTest.java 2008-11-09 12:57:29 UTC (rev 2832)
+++ jbpm3/branches/jbpm-3.3.0.GA/modules/core/src/test/java/org/jbpm/job/executor/JobExecutorDbTest.java 2008-11-09 14:30:26 UTC (rev 2833)
@@ -22,11 +22,6 @@
static List<Long> allocatedProcessIds = Collections.synchronizedList(new ArrayList<Long>());
@Override
- protected String getJbpmTestConfig() {
- return "org/jbpm/jbpm.test.cfg.xml";
- }
-
- @Override
protected void setUp() throws Exception {
super.setUp();
deployProcess();
@@ -35,6 +30,7 @@
@Override
protected void tearDown() throws Exception {
+ getJbpmConfiguration().getJobExecutor().setNbrOfThreads(1);
deleteProcess();
super.tearDown();
}
Modified: jbpm3/branches/jbpm-3.3.0.GA/modules/core/src/test/java/org/jbpm/logging/exe/LoggingConfigDbTest.java
===================================================================
--- jbpm3/branches/jbpm-3.3.0.GA/modules/core/src/test/java/org/jbpm/logging/exe/LoggingConfigDbTest.java 2008-11-09 12:57:29 UTC (rev 2832)
+++ jbpm3/branches/jbpm-3.3.0.GA/modules/core/src/test/java/org/jbpm/logging/exe/LoggingConfigDbTest.java 2008-11-09 14:30:26 UTC (rev 2833)
@@ -7,18 +7,27 @@
import org.jbpm.graph.exe.ProcessInstance;
public class LoggingConfigDbTest extends AbstractDbTestCase {
-
+
@Override
protected JbpmConfiguration getJbpmConfiguration() {
- return JbpmConfiguration.parseResource("org/jbpm/logging/exe/nologging.jbpm.cfg.xml");
+ if (jbpmConfiguration == null) {
+ jbpmConfiguration = JbpmConfiguration.parseResource("org/jbpm/logging/exe/nologging.jbpm.cfg.xml");
+ }
+ return jbpmConfiguration;
}
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ jbpmConfiguration.close();
+ }
+
public void testLoggingconfiguration() {
jbpmContext.deployProcessDefinition(new ProcessDefinition("logging"));
ProcessInstance processInstance = jbpmContext.newProcessInstance("logging");
processInstance.getContextInstance().setVariable("a", "1");
newTransaction();
-
+
Query query = session.createQuery("from org.jbpm.logging.log.ProcessLog");
assertEquals(0, query.list().size());
}
Modified: jbpm3/branches/jbpm-3.3.0.GA/modules/core/src/test/java/org/jbpm/seam/JobExecutorCustomizationTest.java
===================================================================
--- jbpm3/branches/jbpm-3.3.0.GA/modules/core/src/test/java/org/jbpm/seam/JobExecutorCustomizationTest.java 2008-11-09 12:57:29 UTC (rev 2832)
+++ jbpm3/branches/jbpm-3.3.0.GA/modules/core/src/test/java/org/jbpm/seam/JobExecutorCustomizationTest.java 2008-11-09 14:30:26 UTC (rev 2833)
@@ -16,6 +16,12 @@
return "org/jbpm/seam/custom.job.executor.jbpm.cfg.xml";
}
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ jbpmConfiguration.close();
+ }
+
public void testCustomJobExecutor() {
JobExecutor jobExecutor = getJbpmConfiguration().getJobExecutor();
assertEquals(CustomJobExecutor.class, jobExecutor.getClass());
More information about the jbpm-commits
mailing list