[jbpm-commits] JBoss JBPM SVN: r1996 - in jbpm4/pvm/trunk/modules/core/src: test/java/org/jbpm/pvm and 4 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Mon Aug 25 09:05:01 EDT 2008


Author: porcherg
Date: 2008-08-25 09:05:01 -0400 (Mon, 25 Aug 2008)
New Revision: 1996

Added:
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/db/type/
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/db/type/VariableCustomTypeTest.java
   jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/internal/db/type/
   jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/internal/db/type/environmentCustomTypes.cfg.xml
Modified:
   jbpm4/pvm/trunk/modules/core/src/main/resources/org/jbpm/pvm/hibernate.variable.hbm.xml
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/DbTests.java
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/NonDbTests.java
Log:
change DateVariable date field db mapping from date to timestamp

Modified: jbpm4/pvm/trunk/modules/core/src/main/resources/org/jbpm/pvm/hibernate.variable.hbm.xml
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/resources/org/jbpm/pvm/hibernate.variable.hbm.xml	2008-08-25 12:26:59 UTC (rev 1995)
+++ jbpm4/pvm/trunk/modules/core/src/main/resources/org/jbpm/pvm/hibernate.variable.hbm.xml	2008-08-25 13:05:01 UTC (rev 1996)
@@ -34,7 +34,7 @@
 	</class>
 
 	<subclass name="DateVariable" extends="org.jbpm.pvm.internal.type.Variable" discriminator-value="T">
-		<property name="date" column="DATE_VALUE_" type="date"/>
+		<property name="date" column="DATE_VALUE_" type="timestamp"/>
 	</subclass>
 	
 	<subclass name="DoubleVariable" extends="org.jbpm.pvm.internal.type.Variable" discriminator-value="D">

Modified: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/DbTests.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/DbTests.java	2008-08-25 12:26:59 UTC (rev 1995)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/DbTests.java	2008-08-25 13:05:01 UTC (rev 1996)
@@ -30,6 +30,7 @@
 import org.jbpm.pvm.api.tx.TxTests;
 import org.jbpm.pvm.internal.db.langext.DbLangExtTests;
 import org.jbpm.pvm.internal.db.model.DbModelTests;
+import org.jbpm.pvm.internal.db.type.VariableCustomTypeTest;
 import org.jbpm.pvm.internal.jobexecutor.JobExecutorTests;
 import org.jbpm.pvm.test.base.EnvironmentFactoryTestSetup;
 
@@ -52,6 +53,10 @@
     
     suite.addTest(new EnvironmentFactoryTestSetup(defaultConfigTests, "environment.cfg.xml"));
     suite.addTest(new EnvironmentFactoryTestSetup(DbLangExtTests.suite(), "org/jbpm/pvm/internal/db/langext/environment.cfg.xml"));
+    
+    TestSuite variableTypeTests = new TestSuite(VariableCustomTypeTest.class);
+    suite.addTest(new EnvironmentFactoryTestSetup(variableTypeTests, "org/jbpm/pvm/internal/db/type/environmentCustomTypes.cfg.xml"));
+
     // Spring tests do not use EnvironmentFactoryTestCase
     suite.addTest(SpringTests.suite());
 

Modified: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/NonDbTests.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/NonDbTests.java	2008-08-25 12:26:59 UTC (rev 1995)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/NonDbTests.java	2008-08-25 13:05:01 UTC (rev 1996)
@@ -26,6 +26,7 @@
 
 import org.jbpm.pvm.api.basicfeatures.BasicFeaturesTests;
 import org.jbpm.pvm.api.env.EnvironmentTests;
+import org.jbpm.pvm.internal.type.VariableAutoTypeResolutionTest;
 import org.jbpm.pvm.internal.wire.WireTests;
 
 
@@ -40,6 +41,7 @@
     suite.addTest(EnvironmentTests.suite());
     suite.addTest(BasicFeaturesTests.suite());
     suite.addTest(WireTests.suite());
+    suite.addTestSuite(VariableAutoTypeResolutionTest.class);
     //$JUnit-END$
     return suite;
   }

Added: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/db/type/VariableCustomTypeTest.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/db/type/VariableCustomTypeTest.java	                        (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/db/type/VariableCustomTypeTest.java	2008-08-25 13:05:01 UTC (rev 1996)
@@ -0,0 +1,88 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This 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; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.db.type;
+
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+import java.util.Map;
+
+import org.jbpm.pvm.activity.ActivityExecution;
+import org.jbpm.pvm.activity.ExternalActivity;
+import org.jbpm.pvm.client.ClientProcessDefinition;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.type.Variable;
+import org.jbpm.pvm.internal.type.variable.DateVariable;
+import org.jbpm.pvm.model.ProcessFactory;
+import org.jbpm.pvm.test.base.EnvironmentDbTestCase;
+
+/**
+ * @author Guillaume Porcher
+ */
+public class VariableCustomTypeTest extends EnvironmentDbTestCase {
+
+  public VariableCustomTypeTest() {
+    super("org/jbpm/pvm/internal/db/type/environmentCustomTypes.cfg.xml");
+  }
+
+  public static class WaitState implements ExternalActivity {
+    private static final long serialVersionUID = 1L;
+    public void execute(ActivityExecution execution) {
+      execution.waitForSignal();
+    }
+    public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) {
+      execution.take(signalName);
+    }
+  }
+  
+  
+ 
+  public void testDateVariable() {
+    ClientProcessDefinition clientProcessDefinition = ProcessFactory.build()
+    .node().initial().behaviour(WaitState.class)
+    .done();
+    
+    getDbSession().save(clientProcessDefinition);
+    
+    ExecutionImpl execution = (ExecutionImpl) clientProcessDefinition.beginProcessInstance();
+    
+    execution = reload(execution);
+     
+    Calendar calendar = new GregorianCalendar();
+    calendar.set(Calendar.YEAR, 2007);
+    calendar.set(Calendar.MONTH, 10); // (10 == november)
+    calendar.set(Calendar.DAY_OF_MONTH, 22);
+    calendar.set(Calendar.HOUR_OF_DAY, 15);
+    calendar.set(Calendar.MINUTE, 28);
+    calendar.set(Calendar.SECOND, 57);
+    calendar.set(Calendar.MILLISECOND, 374);
+    
+    execution.setVariable("v", calendar.getTime());
+    
+    execution = reload(execution);
+    
+    Variable variable = execution.getVariableObject("v");
+    assertEquals(DateVariable.class, variable.getClass());
+
+    assertEquals(calendar.getTime(), execution.getVariable("v"));
+  }
+  
+}


Property changes on: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/db/type/VariableCustomTypeTest.java
___________________________________________________________________
Name: svn:keywords
   + Id

Added: jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/internal/db/type/environmentCustomTypes.cfg.xml
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/internal/db/type/environmentCustomTypes.cfg.xml	                        (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/internal/db/type/environmentCustomTypes.cfg.xml	2008-08-25 13:05:01 UTC (rev 1996)
@@ -0,0 +1,25 @@
+<contexts>
+
+  <environment-factory>
+  
+    <hibernate-configuration>
+      <properties resource="hibernate.properties" />
+      <mappings resource="org/jbpm/pvm/pvm.hibernate.mappings.xml" />
+      <cache-configuration resource="org/jbpm/pvm/pvm.cache.xml" usage="nonstrict-read-write" />
+    </hibernate-configuration>
+    
+    <hibernate-session-factory />
+    <variable-types>
+      <type name="date" class="java.util.Date" variable-class="org.jbpm.pvm.internal.type.variable.DateVariable" />
+    </variable-types>
+  </environment-factory>
+
+  <environment>
+
+    <transaction />
+    <hibernate-session />
+    <pvm-db-session />
+
+  </environment>
+
+</contexts>


Property changes on: jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/internal/db/type/environmentCustomTypes.cfg.xml
___________________________________________________________________
Name: svn:keywords
   + Id




More information about the jbpm-commits mailing list