[jbpm-commits] JBoss JBPM SVN: r2845 - 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
Mon Nov 10 07:46:33 EST 2008


Author: thomas.diesler at jboss.com
Date: 2008-11-10 07:46:33 -0500 (Mon, 10 Nov 2008)
New Revision: 2845

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:
Rollback -r2833: [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-10 11:30:45 UTC (rev 2844)
+++ jbpm3/branches/jbpm-3.3.0.GA/modules/core/pom.xml	2008-11-10 12:46:33 UTC (rev 2845)
@@ -342,16 +342,20 @@
             <artifactId>maven-surefire-plugin</artifactId>
             <configuration>
               <excludes>
-                <!-- [JBPM-1764] Deadlocks make job execution tests fail on Sybase -->
-                <exclude>org/jbpm/job/executor/JobExecutorDbTest.java</exclude>
+                <!-- [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>
                 <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-10 11:30:45 UTC (rev 2844)
+++ jbpm3/branches/jbpm-3.3.0.GA/modules/core/src/main/java/org/jbpm/JbpmConfiguration.java	2008-11-10 12:46:33 UTC (rev 2845)
@@ -548,9 +548,12 @@
     try {
 
       synchronized (instances) {
-        for (Iterator i = instances.values().iterator(); i.hasNext();) {
-          if (this == i.next()) {
-            i.remove();
+        Iterator iter = instances.keySet().iterator();
+        while (iter.hasNext()) {
+          String resource = (String) iter.next();
+          if (this == instances.get(resource)) {
+            instances.remove(resource);
+            break;
           }
         }
       }
@@ -561,8 +564,9 @@
 
       Map serviceFactories = jbpmContext.getServices().getServiceFactories();
       if (serviceFactories != null) {
-        for (Iterator i = serviceFactories.values().iterator(); i.hasNext();) {
-          ServiceFactory serviceFactory = (ServiceFactory) i.next();
+        Iterator iter = serviceFactories.values().iterator();
+        while (iter.hasNext()) {
+          ServiceFactory serviceFactory = (ServiceFactory) iter.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-10 11:30:45 UTC (rev 2844)
+++ jbpm3/branches/jbpm-3.3.0.GA/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java	2008-11-10 12:46:33 UTC (rev 2845)
@@ -83,7 +83,8 @@
     JbpmSchema jbpmSchema = new JbpmSchema(configuration);
 
     Map jbpmTablesRecordCount = jbpmSchema.getJbpmTablesRecordCount();
-    for (Iterator iter = jbpmTablesRecordCount.entrySet().iterator(); iter.hasNext();)
+    Iterator iter = jbpmTablesRecordCount.entrySet().iterator();
+    while (iter.hasNext())
     {
       Map.Entry entry = (Map.Entry)iter.next();
       String tableName = (String)entry.getKey();
@@ -93,7 +94,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-10 11:30:45 UTC (rev 2844)
+++ jbpm3/branches/jbpm-3.3.0.GA/modules/core/src/test/java/org/jbpm/context/exe/CustomVariableLongIdDbTest.java	2008-11-10 12:46:33 UTC (rev 2845)
@@ -21,6 +21,7 @@
  */
 package org.jbpm.context.exe;
 
+import org.hibernate.cfg.Configuration;
 import org.jbpm.JbpmConfiguration;
 import org.jbpm.JbpmContext;
 import org.jbpm.context.def.ContextDefinition;
@@ -30,35 +31,49 @@
 import org.jbpm.persistence.db.DbPersistenceServiceFactory;
 import org.jbpm.svc.Services;
 
-public class CustomVariableLongIdDbTest extends AbstractDbTestCase {
+public class CustomVariableLongIdDbTest extends AbstractDbTestCase
+{
 
-  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();
-      }
+  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);
     }
+    finally
+    {
+      jbpmContext.close();
+    }
     return jbpmConfiguration;
   }
 
-  protected void tearDown() throws Exception {
-    super.tearDown();
-    jbpmConfiguration.close();
+  protected JbpmConfiguration getJbpmConfiguration()
+  {
+    return customLongJbpmConfiguration;
   }
 
-  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
@@ -73,11 +88,12 @@
       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-10 11:30:45 UTC (rev 2844)
+++ jbpm3/branches/jbpm-3.3.0.GA/modules/core/src/test/java/org/jbpm/context/exe/CustomVariableStringIdDbTest.java	2008-11-10 12:46:33 UTC (rev 2845)
@@ -21,6 +21,7 @@
  */
 package org.jbpm.context.exe;
 
+import org.hibernate.cfg.Configuration;
 import org.jbpm.JbpmConfiguration;
 import org.jbpm.JbpmContext;
 import org.jbpm.context.def.ContextDefinition;
@@ -30,39 +31,52 @@
 import org.jbpm.persistence.db.DbPersistenceServiceFactory;
 import org.jbpm.svc.Services;
 
-public class CustomVariableStringIdDbTest extends AbstractDbTestCase {
+public class CustomVariableStringIdDbTest extends AbstractDbTestCase
+{
 
-  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();
-      }
+  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);
     }
+    finally
+    {
+      jbpmContext.close();
+    }
     return jbpmConfiguration;
   }
 
-  protected void tearDown() throws Exception {
-    super.tearDown();
-    jbpmConfiguration.close();
+  protected JbpmConfiguration getJbpmConfiguration()
+  {
+    return customStringJbpmConfiguration;
   }
 
-  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
@@ -73,11 +87,12 @@
       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-10 11:30:45 UTC (rev 2844)
+++ jbpm3/branches/jbpm-3.3.0.GA/modules/core/src/test/java/org/jbpm/jbpm1452/JBPM1452Test.java	2008-11-10 12:46:33 UTC (rev 2845)
@@ -60,7 +60,6 @@
   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-10 11:30:45 UTC (rev 2844)
+++ jbpm3/branches/jbpm-3.3.0.GA/modules/core/src/test/java/org/jbpm/jbpm983/JBPM983Test.java	2008-11-10 12:46:33 UTC (rev 2845)
@@ -25,6 +25,11 @@
   private long subProcessDefinitionId;
   private long processDefinitionId;
 
+  @Override
+  protected String getJbpmTestConfig() {
+    return "org/jbpm/jbpm.test.cfg.xml";
+  }
+
   protected void setUp() throws Exception {
     super.setUp();
 
@@ -44,7 +49,6 @@
 
   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-10 11:30:45 UTC (rev 2844)
+++ jbpm3/branches/jbpm-3.3.0.GA/modules/core/src/test/java/org/jbpm/job/executor/JobExecutorDbTest.java	2008-11-10 12:46:33 UTC (rev 2845)
@@ -22,6 +22,11 @@
   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();    
@@ -30,7 +35,6 @@
 
   @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-10 11:30:45 UTC (rev 2844)
+++ jbpm3/branches/jbpm-3.3.0.GA/modules/core/src/test/java/org/jbpm/logging/exe/LoggingConfigDbTest.java	2008-11-10 12:46:33 UTC (rev 2845)
@@ -7,27 +7,18 @@
 import org.jbpm.graph.exe.ProcessInstance;
 
 public class LoggingConfigDbTest extends AbstractDbTestCase {
-
+  
   @Override
   protected JbpmConfiguration getJbpmConfiguration() {
-    if (jbpmConfiguration == null) {
-      jbpmConfiguration = JbpmConfiguration.parseResource("org/jbpm/logging/exe/nologging.jbpm.cfg.xml");
-    }
-    return jbpmConfiguration;
+    return JbpmConfiguration.parseResource("org/jbpm/logging/exe/nologging.jbpm.cfg.xml");
   }
 
-  @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-10 11:30:45 UTC (rev 2844)
+++ jbpm3/branches/jbpm-3.3.0.GA/modules/core/src/test/java/org/jbpm/seam/JobExecutorCustomizationTest.java	2008-11-10 12:46:33 UTC (rev 2845)
@@ -16,12 +16,6 @@
     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