[jbpm-commits] JBoss JBPM SVN: r3538 - in jbpm4/trunk/modules: test-load/src/main and 2 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Dec 23 11:55:52 EST 2008


Author: tom.baeyens at jboss.com
Date: 2008-12-23 11:55:52 -0500 (Tue, 23 Dec 2008)
New Revision: 3538

Added:
   jbpm4/trunk/modules/test-load/src/main/parked/
   jbpm4/trunk/modules/test-load/src/main/parked/JobExecutorIsolationDbTest.java
Removed:
   jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/JobExecutorIsolationDbTest.java
Modified:
   jbpm4/trunk/modules/pvm/src/main/resources/jbpm.pvm.wire.hbm.xml
   jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/JobExecutorTest.java
   jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/TestMessageCommand.java
Log:
added indexes to run fine on oracle

Modified: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.pvm.wire.hbm.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.pvm.wire.hbm.xml	2008-12-23 16:01:30 UTC (rev 3537)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.pvm.wire.hbm.xml	2008-12-23 16:55:52 UTC (rev 3538)
@@ -81,7 +81,9 @@
 		<subclass name="CollectionDescriptor" discriminator-value="coll">
 			<property name="className" column="CLASSNAME_" />
 			<list name="valueDescriptors" cascade="all-delete-orphan">
-				<key column="VALUEDESCR_" foreign-key="FK_DESCR_VALDESCR"/>
+				<key foreign-key="FK_DESCR_VALDESCR">
+          <column name="VALUEDESCR_" index="IDX_DESCR_VALDESCR"  />
+        </key>
 				<list-index column="VALUEDESCR_IDX_" />
 				<one-to-many class="AbstractDescriptor" />
 			</list>
@@ -108,18 +110,23 @@
 			<many-to-one name="factoryDescriptor"
                    class="AbstractDescriptor" 
                    column="FACTORYDESCR_" 
-                   foreign-key="DESCR_ARG_REF_FK"  
+                   foreign-key="FK_DESCR_ARG_REF"
+                   index="IDX_DESCR_ARG_REF"  
                    cascade="all"/>
 
 			<list name="argDescriptors" cascade="all-delete-orphan" >
-				<key column="OBJDESCR_" foreign-key="FK_OBJDESCR_ARGS"/>
+        <key foreign-key="FK_DESCR_ARGDESCR">
+          <column name="OBJDESCR_" index="IDX_DESCR_ARGDESCR"  />
+        </key>
 				<list-index column="OBJDESCR_IDX_" />
 				<one-to-many class="ArgDescriptor" />
 			</list>
 			
 			<list name="operations" cascade="all-delete-orphan">
-				<key column="OBJDESCR_" foreign-key="FK_OPER_OBJDESCR"/>
-				<list-index column="OBJDESCR_IDX_" />
+				<key foreign-key="FK_OPER_OBJDESCR">
+          <column name="OBJDESCR_" index="IDX_OPER_OBJDESCR"  />
+        </key>
+				<list-index column="OBJDESCR_IDX" />
 				<one-to-many class="org.jbpm.pvm.internal.wire.operation.AbstractOperation"/>
 			</list>
 		</subclass>
@@ -158,25 +165,27 @@
 		<subclass name="org.jbpm.pvm.internal.wire.operation.FieldOperation" discriminator-value="field">
 			<property name="fieldName" column="TEXT_" />
 			<many-to-one name="descriptor"
-			             column="FIELDDESCR_" 
+			             column="DESCR_" 
 			             cascade="all" 
 			             class="AbstractDescriptor" 
-                   foreign-key="FK_OPER_FIELDDESC"/>
+                   foreign-key="FK_OPER_DESC"
+                   index="IDX_OPER_DESC"/>
 		</subclass>
 
 		<subclass name="org.jbpm.pvm.internal.wire.operation.PropertyOperation" discriminator-value="prop">
 			<property name="setterName" column="TEXT_" />
 			<many-to-one name="descriptor" 
-			             column="PROPDESCR_" 
+			             column="DESCR_" 
 			             cascade="all" 
-			             class="AbstractDescriptor" 
-                   foreign-key="FK_OPER_PROPDESC" />
+			             class="AbstractDescriptor"/>
 		</subclass>
 
 		<subclass name="org.jbpm.pvm.internal.wire.operation.InvokeOperation" discriminator-value="invoke">
 			<property name="methodName" column="TEXT_" />
 			<list name="argDescriptors" cascade="all-delete-orphan">
-				<key column="OPER_" foreign-key="FK_OPER_ARGS"/>
+				<key foreign-key="FK_ARGDSCR_OPER">
+          <column name="OPER_" index="IDX_ARGDSCR_OPER" />
+        </key>
 				<list-index column="OPER_IDX_" />
 				<one-to-many class="ArgDescriptor" />
 			</list>
@@ -193,7 +202,8 @@
     <many-to-one name="descriptor" 
                  column="DESCRIPTOR_"
                  class="AbstractDescriptor" 
-                 foreign-key="FK_ARGDESCR_DESCR" 
+                 foreign-key="FK_ARGDESCR_DESCR"
+                 index="IDX_ARGDESCR_DESCR" 
                  cascade="all"/>
   </class>
 

Copied: jbpm4/trunk/modules/test-load/src/main/parked/JobExecutorIsolationDbTest.java (from rev 3439, jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/JobExecutorIsolationDbTest.java)
===================================================================
--- jbpm4/trunk/modules/test-load/src/main/parked/JobExecutorIsolationDbTest.java	                        (rev 0)
+++ jbpm4/trunk/modules/test-load/src/main/parked/JobExecutorIsolationDbTest.java	2008-12-23 16:55:52 UTC (rev 3538)
@@ -0,0 +1,88 @@
+/**
+ * Copyright (C) 2007  Bull S. A. S.
+ * Bull, Rue Jean Jaures, B.P.68, 78340, Les Clayes-sous-Bois
+ * This library 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
+ * version 2.1 of the License.
+ * This library 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
+ * program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
+ * Floor, Boston, MA  02110-1301, USA.
+ **/
+package org.jbpm.test.load;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.cmd.CommandService;
+import org.jbpm.env.Environment;
+import org.jbpm.job.Message;
+import org.jbpm.log.Log;
+import org.jbpm.pvm.internal.job.CommandMessage;
+import org.jbpm.pvm.internal.jobexecutor.JobExecutor;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.session.MessageSession;
+import org.jbpm.session.PvmDbSession;
+import org.jbpm.test.DbTestCase;
+
+
+/**
+ * This class contains job executor tests which requires to have a read commited isolation level. 
+ * 
+ * @author Guillaume Porcher
+ *
+ */
+public class JobExecutorIsolationDbTest extends DbTestCase {
+  
+  static int jobExecutorTimeoutMillis = 500;
+  static int checkInterval = 400;
+  
+  public static class SimpleTestCommand implements Command<Object> {
+    private static final Log log = Log.getLog(SimpleTestCommand.class.getName());
+
+    public Object execute(Environment environment) throws Exception {
+      log.debug("command executed !");
+      return null;
+    }
+  }
+  
+  public void testInsertMessage() {
+    System.out.println("FIXME: JBPM-1769 fix db isolation test");
+  }
+  
+  
+  /*
+   * Basic test that only shows a simple situation in which we need to have a read commited isolation level.
+   */
+  
+  // FIX rename test method back to testInsertMessage 
+  public void dontTestInsertMessage() throws InterruptedException {
+    JobExecutorTest.processedMessageIds = new ArrayList<Integer>();
+    JobExecutor jobExecutor = processEngine.get(JobExecutor.class);
+    jobExecutor.setIdleInterval(jobExecutorTimeoutMillis);
+    jobExecutor.start();
+    try {
+      processEngine.get(CommandService.class).execute(new Command<Object>() {
+        public Object execute(Environment environment) throws Exception {
+          MessageSession messageSession = environment.get(MessageSession.class);
+          CommandMessage commandMessage = new CommandMessage(new ObjectDescriptor(SimpleTestCommand.class));
+          messageSession.send(commandMessage);
+          List<Message> messages = environment.get(PvmDbSession.class).findMessages(0, 10);
+          assertNotNull(messages);
+          assertEquals(1, messages.size());
+          Thread.sleep(jobExecutorTimeoutMillis * 2);
+          messages = environment.get(PvmDbSession.class).findMessages(0, 10);
+          assertNotNull(messages);
+          assertEquals("Job has been executed before the transaction is committed !!", 1, messages.size());
+          return null;
+        }
+      });
+      Thread.sleep(jobExecutorTimeoutMillis * 2);
+    } finally {
+      jobExecutor.stop(true);
+    }
+  }
+}

Deleted: jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/JobExecutorIsolationDbTest.java
===================================================================
--- jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/JobExecutorIsolationDbTest.java	2008-12-23 16:01:30 UTC (rev 3537)
+++ jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/JobExecutorIsolationDbTest.java	2008-12-23 16:55:52 UTC (rev 3538)
@@ -1,88 +0,0 @@
-/**
- * Copyright (C) 2007  Bull S. A. S.
- * Bull, Rue Jean Jaures, B.P.68, 78340, Les Clayes-sous-Bois
- * This library 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
- * version 2.1 of the License.
- * This library 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
- * program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
- * Floor, Boston, MA  02110-1301, USA.
- **/
-package org.jbpm.test.load;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jbpm.cmd.Command;
-import org.jbpm.cmd.CommandService;
-import org.jbpm.env.Environment;
-import org.jbpm.job.Message;
-import org.jbpm.log.Log;
-import org.jbpm.pvm.internal.job.CommandMessage;
-import org.jbpm.pvm.internal.jobexecutor.JobExecutor;
-import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
-import org.jbpm.session.MessageSession;
-import org.jbpm.session.PvmDbSession;
-import org.jbpm.test.DbTestCase;
-
-
-/**
- * This class contains job executor tests which requires to have a read commited isolation level. 
- * 
- * @author Guillaume Porcher
- *
- */
-public class JobExecutorIsolationDbTest extends DbTestCase {
-  
-  static int jobExecutorTimeoutMillis = 500;
-  static int checkInterval = 400;
-  
-  public static class SimpleTestCommand implements Command<Object> {
-    private static final Log log = Log.getLog(SimpleTestCommand.class.getName());
-
-    public Object execute(Environment environment) throws Exception {
-      log.debug("command executed !");
-      return null;
-    }
-  }
-  
-  public void testInsertMessage() {
-    System.out.println("FIXME: JBPM-1769 fix db isolation test");
-  }
-  
-  
-  /*
-   * Basic test that only shows a simple situation in which we need to have a read commited isolation level.
-   */
-  
-  // FIX rename test method back to testInsertMessage 
-  public void dontTestInsertMessage() throws InterruptedException {
-    JobExecutorTest.processedMessageIds = new ArrayList<Integer>();
-    JobExecutor jobExecutor = processEngine.get(JobExecutor.class);
-    jobExecutor.setIdleInterval(jobExecutorTimeoutMillis);
-    jobExecutor.start();
-    try {
-      processEngine.get(CommandService.class).execute(new Command<Object>() {
-        public Object execute(Environment environment) throws Exception {
-          MessageSession messageSession = environment.get(MessageSession.class);
-          CommandMessage commandMessage = new CommandMessage(new ObjectDescriptor(SimpleTestCommand.class));
-          messageSession.send(commandMessage);
-          List<Message> messages = environment.get(PvmDbSession.class).findMessages(0, 10);
-          assertNotNull(messages);
-          assertEquals(1, messages.size());
-          Thread.sleep(jobExecutorTimeoutMillis * 2);
-          messages = environment.get(PvmDbSession.class).findMessages(0, 10);
-          assertNotNull(messages);
-          assertEquals("Job has been executed before the transaction is committed !!", 1, messages.size());
-          return null;
-        }
-      });
-      Thread.sleep(jobExecutorTimeoutMillis * 2);
-    } finally {
-      jobExecutor.stop(true);
-    }
-  }
-}

Modified: jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/JobExecutorTest.java
===================================================================
--- jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/JobExecutorTest.java	2008-12-23 16:01:30 UTC (rev 3537)
+++ jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/JobExecutorTest.java	2008-12-23 16:55:52 UTC (rev 3538)
@@ -36,7 +36,6 @@
 import org.jbpm.cmd.Command;
 import org.jbpm.cmd.CommandService;
 import org.jbpm.env.Environment;
-import org.jbpm.job.Job;
 import org.jbpm.log.Log;
 import org.jbpm.model.Comment;
 import org.jbpm.pvm.internal.cmd.StartExecutionCmd;
@@ -46,7 +45,6 @@
 import org.jbpm.pvm.internal.jobexecutor.JobExecutor;
 import org.jbpm.pvm.internal.model.CommentImpl;
 import org.jbpm.session.MessageSession;
-import org.jbpm.session.PvmDbSession;
 import org.jbpm.test.DbTestCase;
 
 /**
@@ -61,7 +59,7 @@
   static Map<String, Set<Long>> exclusiveThreadIds;
   static List<Integer> failOnceMessageIds;
 
-  static int nbrOfTestMessages = 10;
+  static int nbrOfTestMessages = 1000;
   static int timeoutMillis = 2 * 60 * 1000; // 10 minutes
   static int checkInterval = 400;
   static int nbrOfTestMessagesPerExecution = 5;
@@ -89,11 +87,27 @@
       jobExecutor.stop(true);
     }
 
+    List<Integer> processedMessageNumbers = commandService.execute(new Command<List<Integer>>() {
+      public List<Integer> execute(Environment environment) {
+        List<Integer> processedMessageNumbers = new ArrayList<Integer>();
+        Session session = environment.get(Session.class);
+        List<Comment> comments = session.createCriteria(CommentImpl.class).list();
+        for (Comment comment: comments) {
+          int processedMessageNumber = Integer.parseInt(comment.getMessage());
+          processedMessageNumbers.add(processedMessageNumber);
+          // make sure the db stays clean
+          session.delete(comment);
+        }
+        return processedMessageNumbers;
+      }
+    });
+    
     for (int i = 0; i < nbrOfTestMessages; i++) {
-      assertTrue("message " + i + " is not processed: " + processedMessageIds, processedMessageIds.contains(i));
+      assertTrue("message " + i + " is not processed: " + processedMessageNumbers, processedMessageNumbers.contains(i));
     }
   }
 
+  /*
   public void testMessagesPresentUponJobExecutorStartUp() {
 
     insertTestMessages();
@@ -251,6 +265,7 @@
       }
     });
   }
+  */
 
   // helper methods ///////////////////////////////////////////////////////////
 

Modified: jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/TestMessageCommand.java
===================================================================
--- jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/TestMessageCommand.java	2008-12-23 16:01:30 UTC (rev 3537)
+++ jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/TestMessageCommand.java	2008-12-23 16:55:52 UTC (rev 3538)
@@ -21,16 +21,16 @@
  */
 package org.jbpm.test.load;
 
-import java.util.List;
 import java.util.Random;
 
+import org.hibernate.Session;
 import org.jbpm.cmd.Command;
 import org.jbpm.env.Environment;
 import org.jbpm.log.Log;
 import org.jbpm.pvm.internal.job.CommandMessage;
+import org.jbpm.pvm.internal.model.CommentImpl;
 import org.jbpm.pvm.internal.wire.descriptor.IntegerDescriptor;
 import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
-import org.jbpm.session.DbSession;
 
 /**
  * @author Tom Baeyens
@@ -51,9 +51,11 @@
   }
 
   public Object execute(Environment environment) throws Exception {
-    JobExecutorTest.processedMessageIds.add(messageId);
+    String msgText = Integer.toString(messageId);
+    CommentImpl comment = new CommentImpl(msgText);
+    environment.get(Session.class).save(comment);
     
-    // let's assume that an average jobImpl takes between 0 and 150 millis to complete.
+    // let's assume that an average job takes between 0 and 150 millis to complete.
     int workTime = random.nextInt(150);
     log.debug("executing test message "+messageId+".  this is going to take "+workTime+"ms");
     try {




More information about the jbpm-commits mailing list