[jbpm-commits] JBoss JBPM SVN: r3505 - in jbpm4/trunk: modules/examples and 4 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Mon Dec 22 12:32:29 EST 2008


Author: tom.baeyens at jboss.com
Date: 2008-12-22 12:32:29 -0500 (Mon, 22 Dec 2008)
New Revision: 3505

Modified:
   jbpm4/trunk/build.xml
   jbpm4/trunk/modules/examples/pom.xml
   jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/sql/SqlTest.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/Blob.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/BlobStrategyBlob.java
   jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/type/VariableAutoTypeResolutionTest.java
   jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/Db.java
   jbpm4/trunk/pom.xml
Log:
made examples run on oracle

Modified: jbpm4/trunk/build.xml
===================================================================
--- jbpm4/trunk/build.xml	2008-12-22 15:37:18 UTC (rev 3504)
+++ jbpm4/trunk/build.xml	2008-12-22 17:32:29 UTC (rev 3505)
@@ -65,10 +65,6 @@
   	<delete dir="${distro.installation.dir}/jbpm-${distro.version}" />
   	<unzip src="modules/distro/target/jbpm-${distro.version}.zip" dest="${distro.installation.dir}" />
     <unzip src="${distro.eclipse}" dest="${distro.installation.dir}/jbpm-${distro.version}" />
-    <unzip src="${distro.gef}" dest="${distro.installation.dir}/jbpm-${distro.version}" />
-    <unzip src="${distro.installation.dir}/jbpm-${distro.version}/gpd/jbpm-gpd-site.zip" 
-    	     dest="${distro.installation.dir}/jbpm-${distro.version}/eclipse" 
-           overwrite="false" />
     <exec executable="cmd" os="Windows Vista, Windows XP,Windows 2000,Windows 98">
       <arg line="/C start &quot;${distro.installation.dir}/jbpm-${distro.version}/eclipse/eclipse.exe&quot; &quot;-data&quot; &quot;${distro.installation.dir}/jbpm-${distro.version}/workspace&quot;" />
     </exec>

Modified: jbpm4/trunk/modules/examples/pom.xml
===================================================================
--- jbpm4/trunk/modules/examples/pom.xml	2008-12-22 15:37:18 UTC (rev 3504)
+++ jbpm4/trunk/modules/examples/pom.xml	2008-12-22 17:32:29 UTC (rev 3505)
@@ -53,11 +53,5 @@
     </dependency>
     
   </dependencies>
-  
-  <!-- Plugins -->
-  <build>
-    <plugins>
-    </plugins>
-  </build>
-  
+
 </project>
\ No newline at end of file

Modified: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/sql/SqlTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/sql/SqlTest.java	2008-12-22 15:37:18 UTC (rev 3504)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/sql/SqlTest.java	2008-12-22 17:32:29 UTC (rev 3505)
@@ -22,10 +22,7 @@
 package org.jbpm.examples.sql;
 
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
-import java.util.Set;
 
 import org.jbpm.Execution;
 import org.jbpm.test.DbTestCase;
@@ -42,18 +39,14 @@
     Execution execution = executionService.startExecutionByKey("Sql");
     String executionId = execution.getId();
     
-    Set<String> variableNames = executionService.getVariableNames(executionId);
-    Map<String, Object> variables = executionService.getVariables(executionId, variableNames);
-
-    Map<String, Object> expectedVariables = new HashMap<String, Object>();
-    List<String> nodeNames = new ArrayList<String>();
-    nodeNames.add("get process names");
-    nodeNames.add("count nodes");
-    expectedVariables.put("nodes with o", nodeNames);
-
-    expectedVariables.put("nodes", new Integer(4));
-
-    assertEquals(expectedVariables, variables);
+    List<String> expectedNodeNames = new ArrayList<String>();
+    expectedNodeNames.add("get process names");
+    expectedNodeNames.add("count nodes");
+    Object nodeNames = executionService.getVariable(executionId, "nodes with o");
+    assertEquals(expectedNodeNames, nodeNames);
+    
+    Object nodes = executionService.getVariable(executionId, "nodes");
+    assertEquals("4", nodes.toString());
   }
 
 }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/Blob.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/Blob.java	2008-12-22 15:37:18 UTC (rev 3504)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/Blob.java	2008-12-22 17:32:29 UTC (rev 3505)
@@ -9,11 +9,17 @@
 
   private static final long serialVersionUID = 1L;
   
-  public static final BlobStrategy DEFAULT_BLOB_STRATEGY = new BlobStrategyChopped();
+  public static final BlobStrategy DEFAULT_BLOB_STRATEGY = new BlobStrategyBlob();
 
   // MAP WITH HIBERNATE AS COMPONENT
 
   protected java.sql.Blob blob;
+  
+  // cachedBytes is used by the BlobStrategyBlob as hibernate doesn't allow 
+  // blobs to be read in the same session as they are created in.
+  // So cachedBytes should not be persisted 
+  protected byte[] cachedBytes;
+  
   protected byte[] bytes;
   protected List<byte[]> chops;
   protected String fileName;
@@ -67,4 +73,10 @@
   public void setFileName(String fileName) {
     this.fileName = fileName;
   }
+  public byte[] getCachedBytes() {
+    return cachedBytes;
+  }
+  public void setCachedBytes(byte[] cachedBytes) {
+    this.cachedBytes = cachedBytes;
+  }
 }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/BlobStrategyBlob.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/BlobStrategyBlob.java	2008-12-22 15:37:18 UTC (rev 3504)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/BlobStrategyBlob.java	2008-12-22 17:32:29 UTC (rev 3505)
@@ -9,11 +9,16 @@
   
   public void set(byte[] bytes, Blob blob) {
     if (bytes!=null) {
+      blob.setCachedBytes(bytes);
       blob.setBlob(Hibernate.createBlob(bytes));
     }
   }
 
   public byte[] get(Blob blob) {
+    if (blob.getCachedBytes()!=null) {
+      return blob.getCachedBytes();
+    }
+    
     java.sql.Blob sqlBlob = blob.getBlob();
     if (sqlBlob!=null) {
       try {

Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/type/VariableAutoTypeResolutionTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/type/VariableAutoTypeResolutionTest.java	2008-12-22 15:37:18 UTC (rev 3504)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/type/VariableAutoTypeResolutionTest.java	2008-12-22 17:32:29 UTC (rev 3505)
@@ -31,6 +31,7 @@
 import java.util.List;
 import java.util.Map;
 
+import org.jbpm.JbpmException;
 import org.jbpm.activity.ActivityExecution;
 import org.jbpm.activity.ExternalActivity;
 import org.jbpm.pvm.internal.model.ExecutionImpl;
@@ -246,19 +247,13 @@
     
     Variable variable = execution.getVariableObject("v");
     assertEquals(BlobVariable.class, variable.getClass());
-    BlobVariable blobVariable = (BlobVariable) variable;
-    List<byte[]> chops = (List<byte[]>) blobVariable.getBlob().getChops();
     
-    int index = 0;
-    for (byte[] chop: chops) {
-      byte[] expected = new byte[chop.length];
-      System.arraycopy(bytes, index, expected, 0, chop.length);
-      assertTrue(Arrays.equals(expected, chop));
-      index += chop.length;
-    }
-    assertEquals(bytes.length, index);
-    
-    assertTrue(Arrays.equals(bytes, (byte[]) execution.getVariable("v")));
+    BlobVariable blobVariable = (BlobVariable) variable;
+
+    byte[] blobVariableBytes = (byte[]) blobVariable.getValue();
+    byte[] expected = bytes;
+
+    assertTrue(Arrays.equals(expected, blobVariableBytes));
   }
 
   public void testCharsVariable() {
@@ -296,7 +291,7 @@
     }
   }
 
-  public void testSerializableVariable() {
+  public void testSerializableVariable() throws Exception {
     ExecutionImpl execution = (ExecutionImpl) ProcessFactory.build()
         .node().initial().behaviour(WaitState.class)
         .done()
@@ -309,20 +304,19 @@
     
     assertEquals(BlobVariable.class, variable.getClass());
     BlobVariable blobVariable = (BlobVariable) variable;
-    List<byte[]> chops = (List<byte[]>) blobVariable.getBlob().getChops();
+
+    // blobVariable.getObject(); is used to get the bare bytes.
+    // blobVariable.getValue() would also use the converter and 
+    // then the deserialized object is returned
+    // ...good idea i'll test that as well below :-)
+    byte[] blobVariableBytes = (byte[]) blobVariable.getObject();
+    byte[] expected = serialize(testSerializable);
+
+    assertTrue(Arrays.equals(expected, blobVariableBytes));
     
-    byte[] bytes = serialize(testSerializable);
-    
-    int index = 0;
-    for (byte[] chop: chops) {
-      byte[] expected = new byte[chop.length];
-      System.arraycopy(bytes, index, expected, 0, chop.length);
-      assertTrue(Arrays.equals(expected, chop));
-      index += chop.length;
-    }
-    assertEquals(bytes.length, index);
-    
-    assertEquals(testSerializable, execution.getVariable("v"));
+    Object deserialized = blobVariable.getValue();
+    assertNotNull(deserialized);
+    assertEquals(testSerializable, deserialized);
   }
 
   private byte[] serialize(TestSerializable testSerializable) {

Modified: jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/Db.java
===================================================================
--- jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/Db.java	2008-12-22 15:37:18 UTC (rev 3504)
+++ jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/Db.java	2008-12-22 17:32:29 UTC (rev 3505)
@@ -21,10 +21,13 @@
  */
 package org.jbpm.test;
 
+import java.sql.Types;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 
+import org.hibernate.Hibernate;
+import org.hibernate.SQLQuery;
 import org.hibernate.Session;
 import org.hibernate.SessionFactory;
 import org.hibernate.cfg.Configuration;
@@ -33,6 +36,7 @@
 import org.hibernate.engine.SessionFactoryImplementor;
 import org.hibernate.mapping.ForeignKey;
 import org.hibernate.mapping.Table;
+import org.hibernate.type.Type;
 import org.jbpm.ProcessEngine;
 import org.jbpm.env.EnvironmentFactory;
 import org.jbpm.log.Log;
@@ -160,8 +164,10 @@
     Session session = sessionFactory.openSession();
     try {
       for (String tableName : tableNames) {
-        String countSql = "select count(*) from "+tableName;
-        Integer recordCount = (Integer) session.createSQLQuery(countSql).uniqueResult();
+        String countSql = "select count(*) recordCount from "+tableName;
+        SQLQuery sqlQuery = session.createSQLQuery(countSql);
+        sqlQuery.addScalar("recordCount", Hibernate.INTEGER);
+        Integer recordCount = (Integer) sqlQuery.uniqueResult();
         if (recordCount>0) {
           recordsLeft = true;
           log.error("FIXME: "+recordCount+" records left in table "+tableName);

Modified: jbpm4/trunk/pom.xml
===================================================================
--- jbpm4/trunk/pom.xml	2008-12-22 15:37:18 UTC (rev 3504)
+++ jbpm4/trunk/pom.xml	2008-12-22 17:32:29 UTC (rev 3505)
@@ -317,13 +317,20 @@
       </build>
     </profile>
 
-      <profile>
+    <profile>
       <id>database</id>
       <activation>
         <property>
           <name>database</name>
         </property>
       </activation>
+      <dependencies>
+        <dependency>
+          <groupId>org.jbpm.jbpm4</groupId>
+          <artifactId>jbpm-db</artifactId>
+          <version>${version}</version>
+        </dependency>
+      </dependencies>
       <build>
         <plugins>
         




More information about the jbpm-commits mailing list