[jbpm-commits] JBoss JBPM SVN: r3622 - in jbpm3/trunk/modules/examples: src/test/java/org/jbpm/examples/assignment and 2 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Thu Jan 8 20:33:08 EST 2009
Author: alex.guizar at jboss.com
Date: 2009-01-08 20:33:08 -0500 (Thu, 08 Jan 2009)
New Revision: 3622
Modified:
jbpm3/trunk/modules/examples/pom.xml
jbpm3/trunk/modules/examples/src/test/java/org/jbpm/examples/assignment/RulesAssignmentHandler.java
jbpm3/trunk/modules/examples/src/test/java/org/jbpm/examples/rulesaction/Customer.java
jbpm3/trunk/modules/examples/src/test/java/org/jbpm/examples/taskinstance/CustomTaskInstanceTest.java
Log:
JBPM-1827: Fix example test failure against Sybase
Modified: jbpm3/trunk/modules/examples/pom.xml
===================================================================
--- jbpm3/trunk/modules/examples/pom.xml 2009-01-08 14:24:23 UTC (rev 3621)
+++ jbpm3/trunk/modules/examples/pom.xml 2009-01-09 01:33:08 UTC (rev 3622)
@@ -28,6 +28,7 @@
<relativePath>../../pom.xml</relativePath>
</parent>
+
<!-- Dependencies -->
<dependencies>
<!-- jBPM Dependencies -->
@@ -53,7 +54,7 @@
<artifactId>hibernate</artifactId>
<scope>provided</scope>
</dependency>
-
+
<!-- Test Dependencies -->
<dependency>
<groupId>org.drools</groupId>
@@ -101,33 +102,4 @@
</plugins>
</build>
- <profiles>
- <!--
- Name: sybase
- Descr: Sybase Database Setup
- -->
- <profile>
- <id>sybase</id>
- <activation>
- <property>
- <name>database</name>
- <value>sybase</value>
- </property>
- </activation>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <excludes>
- <!-- [JBPM-1827] Investigate example test failures against Sybase -->
- <exclude>org/jbpm/examples/taskinstance/CustomTaskInstanceTest.java</exclude>
- </excludes>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-
</project>
Modified: jbpm3/trunk/modules/examples/src/test/java/org/jbpm/examples/assignment/RulesAssignmentHandler.java
===================================================================
--- jbpm3/trunk/modules/examples/src/test/java/org/jbpm/examples/assignment/RulesAssignmentHandler.java 2009-01-08 14:24:23 UTC (rev 3621)
+++ jbpm3/trunk/modules/examples/src/test/java/org/jbpm/examples/assignment/RulesAssignmentHandler.java 2009-01-09 01:33:08 UTC (rev 3622)
@@ -13,7 +13,6 @@
import org.drools.compiler.PackageBuilder;
import org.hibernate.Query;
import org.hibernate.Session;
-import org.jbpm.JbpmConfiguration;
import org.jbpm.context.exe.ContextInstance;
import org.jbpm.graph.exe.ExecutionContext;
import org.jbpm.identity.Entity;
Modified: jbpm3/trunk/modules/examples/src/test/java/org/jbpm/examples/rulesaction/Customer.java
===================================================================
--- jbpm3/trunk/modules/examples/src/test/java/org/jbpm/examples/rulesaction/Customer.java 2009-01-08 14:24:23 UTC (rev 3621)
+++ jbpm3/trunk/modules/examples/src/test/java/org/jbpm/examples/rulesaction/Customer.java 2009-01-09 01:33:08 UTC (rev 3622)
@@ -3,58 +3,62 @@
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
- */
+ */
package org.jbpm.examples.rulesaction;
import java.io.Serializable;
+public class Customer implements Serializable {
-public class Customer
- implements Serializable
-{
- long id;
+ long id;
- String name;
- Integer region;
- Integer age;
- Long income;
+ String name;
+ Integer region;
+ Integer age;
+ Long income;
- public Customer() {
- }
-
- public Customer(String name, Integer region, Integer age, Long income) {
- setName(name);
- setRegion(region);
- setAge(age);
- setIncome(income);
- }
+ private static final long serialVersionUID = 1L;
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
+ public Customer() {
+ }
- public Integer getRegion() {
- return region;
- }
- public void setRegion(Integer region) {
- this.region = region;
- }
-
- public Integer getAge() {
- return age;
- }
- public void setAge(Integer age) {
- this.age = age;
- }
+ public Customer(String name, Integer region, Integer age, Long income) {
+ setName(name);
+ setRegion(region);
+ setAge(age);
+ setIncome(income);
+ }
- public Long getIncome() {
- return income;
- }
- public void setIncome(Long income) {
- this.income = income;
- }
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Integer getRegion() {
+ return region;
+ }
+
+ public void setRegion(Integer region) {
+ this.region = region;
+ }
+
+ public Integer getAge() {
+ return age;
+ }
+
+ public void setAge(Integer age) {
+ this.age = age;
+ }
+
+ public Long getIncome() {
+ return income;
+ }
+
+ public void setIncome(Long income) {
+ this.income = income;
+ }
+
}
Modified: jbpm3/trunk/modules/examples/src/test/java/org/jbpm/examples/taskinstance/CustomTaskInstanceTest.java
===================================================================
--- jbpm3/trunk/modules/examples/src/test/java/org/jbpm/examples/taskinstance/CustomTaskInstanceTest.java 2009-01-08 14:24:23 UTC (rev 3621)
+++ jbpm3/trunk/modules/examples/src/test/java/org/jbpm/examples/taskinstance/CustomTaskInstanceTest.java 2009-01-09 01:33:08 UTC (rev 3622)
@@ -22,13 +22,13 @@
package org.jbpm.examples.taskinstance;
import java.util.Date;
-import java.util.Iterator;
import java.util.List;
import junit.framework.TestCase;
-import org.hibernate.Query;
+import org.hibernate.Criteria;
import org.hibernate.Session;
+import org.hibernate.criterion.Restrictions;
import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmContext;
import org.jbpm.context.exe.ContextInstance;
@@ -45,8 +45,7 @@
/**
* This example shows how to extend the TaskInstance by adding a custom property.
*/
-public class CustomTaskInstanceTest extends TestCase
-{
+public class CustomTaskInstanceTest extends TestCase {
JbpmConfiguration jbpmConfiguration = null;
// JbpmConfiguration.getInstance();
@@ -55,20 +54,17 @@
JbpmContext jbpmContext;
- Session s;
-
ProcessInstance processInstance = null;
ContextInstance contextInstance = null;
- public void setUp()
- {
-
+ protected void setUp() {
// the jbpm.cfg.xml file is modified to add the CustomTaskInstanceFactory
// so we will read in the file from the config directory of this example
jbpmConfiguration = JbpmConfiguration.parseResource("taskinstance/jbpm.cfg.xml");
- dbPersistenceServiceFactory = (DbPersistenceServiceFactory)jbpmConfiguration.getServiceFactory(Services.SERVICENAME_PERSISTENCE);
+ dbPersistenceServiceFactory = (DbPersistenceServiceFactory) jbpmConfiguration
+ .getServiceFactory(Services.SERVICENAME_PERSISTENCE);
// the CustomTaskInstance mapping file reference
// <mapping resource="org/jbpm/taskinstance/CustomTaskInstance.hbm.xml"/>
@@ -83,53 +79,44 @@
jbpmContext = jbpmConfiguration.createJbpmContext();
}
- public void tearDown()
- {
+ protected void tearDown() {
jbpmContext.close();
dbPersistenceServiceFactory.dropSchema();
jbpmContext = null;
}
- public void newTransaction()
- {
+ void newTransaction() {
jbpmContext.close();
jbpmContext = jbpmConfiguration.createJbpmContext();
}
- public void deployProcess()
- {
+ void deployProcess() {
jbpmContext = jbpmConfiguration.createJbpmContext();
- try
- {
- ProcessDefinition processDefinition = ProcessDefinition.parseXmlResource("taskinstance/processdefinition.xml");
+ try {
+ ProcessDefinition processDefinition = ProcessDefinition
+ .parseXmlResource("taskinstance/processdefinition.xml");
jbpmContext.deployProcessDefinition(processDefinition);
}
- finally
- {
+ finally {
jbpmContext.close();
}
}
- public void loadIdentities()
- {
+ void loadIdentities() {
jbpmContext = jbpmConfiguration.createJbpmContext();
- try
- {
+ try {
Entity[] entities = IdentityXmlParser.parseEntitiesResource("identity.db.xml");
IdentitySession identitySession = new IdentitySession(jbpmContext.getSession());
- for (int i = 0; i < entities.length; i++)
- {
+ for (int i = 0; i < entities.length; i++) {
identitySession.saveEntity(entities[i]);
}
}
- finally
- {
+ finally {
jbpmContext.close();
}
}
- public void testCustomTaskInstance()
- {
+ public void testCustomTaskInstance() {
// create processInstance
newTransaction();
long processInstanceId = createNewProcessInstance();
@@ -158,8 +145,7 @@
assertNotNull(processEnd);
}
- public long createNewProcessInstance()
- {
+ long createNewProcessInstance() {
String processDefinitionName = "CustomTaskInstance";
processInstance = jbpmContext.newProcessInstanceForUpdate(processDefinitionName);
long processInstanceId = processInstance.getId();
@@ -169,20 +155,12 @@
Token token = processInstance.getRootToken();
token.signal();
return processInstanceId;
-
}
- public long acquireTask()
- {
-
- List<CustomTaskInstance> tasklist = findPooledTaskListByCustomId("reviewers", "abc");
- Iterator taskIterator = tasklist.iterator();
-
- CustomTaskInstance taskInstance = null;
+ long acquireTask() {
+ List<CustomTaskInstance> taskList = findPooledTaskListByCustomId("reviewers", "abc");
long taskInstanceId = 0;
- while (taskIterator.hasNext())
- {
- taskInstance = (CustomTaskInstance)taskIterator.next();
+ for (CustomTaskInstance taskInstance : taskList) {
taskInstanceId = taskInstance.getId();
taskInstance.start();
taskInstance.setActorId("tom");
@@ -192,29 +170,23 @@
return taskInstanceId;
}
- public void completeTask(long taskInstanceId)
- {
- s = jbpmContext.getSession();
- CustomTaskInstance taskInstance = (CustomTaskInstance)s.load(CustomTaskInstance.class, new Long(taskInstanceId));
-
+ void completeTask(long taskInstanceId) {
+ CustomTaskInstance taskInstance = (CustomTaskInstance) jbpmContext.getSession()
+ .load(CustomTaskInstance.class, new Long(taskInstanceId));
taskInstance.end();
-
}
- private static final String findPooledTaskInstancesByCustomId =
- "select distinct ti " + "from " + CustomTaskInstance.class.getName() + " ti " +
- " join ti.pooledActors pooledActor where pooledActor.actorId = :pooledActorId and ti.actorId is null and ti.end is null " +
- " and ti.isCancelled = false and ti.customId = :customId";
-
- public List<CustomTaskInstance> findPooledTaskListByCustomId(String actorId, String customId)
- {
- List<CustomTaskInstance> taskList = null;
- s = jbpmContext.getSession();
- Query query = s.createQuery(findPooledTaskInstancesByCustomId);
- query.setString("pooledActorId", actorId);
- query.setString("customId", customId);
- taskList = query.list();
- return taskList;
+ List<CustomTaskInstance> findPooledTaskListByCustomId(String actorId, String customId) {
+ Session session = jbpmContext.getSession();
+ return session.createCriteria(CustomTaskInstance.class)
+ // .setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY)
+ .add(Restrictions.isNull("actorId"))
+ .add(Restrictions.isNull("end"))
+ .add(Restrictions.eq("isCancelled", false))
+ .add(Restrictions.eq("customId", customId))
+ .createCriteria("pooledActors")
+ .add(Restrictions.eq("actorId", actorId))
+ .list();
}
}
More information about the jbpm-commits
mailing list