[jbpm-commits] JBoss JBPM SVN: r2525 - in projects/spec/trunk/modules: api/src/main/java/org/jbpm/api/model/internal and 5 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Fri Oct 10 06:57:20 EDT 2008
Author: thomas.diesler at jboss.com
Date: 2008-10-10 06:57:20 -0400 (Fri, 10 Oct 2008)
New Revision: 2525
Added:
projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/ComplexGateway.java
projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/ExclusiveGateway.java
projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/Gate.java
projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/InclusiveGateway.java
projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/ParallelGateway.java
projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/GateImpl.java
projects/spec/trunk/modules/ri/src/test/java/org/jbpm/test/ri/service/persistence/ComplexGatewayPersistenceTest.java
projects/spec/trunk/modules/ri/src/test/java/org/jbpm/test/ri/service/persistence/EndEventPersistenceTest.java
projects/spec/trunk/modules/ri/src/test/java/org/jbpm/test/ri/service/persistence/ExclusiveGatewayPersistenceTest.java
projects/spec/trunk/modules/ri/src/test/java/org/jbpm/test/ri/service/persistence/InclusiveGatewayPersistenceTest.java
projects/spec/trunk/modules/ri/src/test/java/org/jbpm/test/ri/service/persistence/NodePersistenceTest.java
projects/spec/trunk/modules/ri/src/test/java/org/jbpm/test/ri/service/persistence/ParallelGatewayPersistenceTest.java
projects/spec/trunk/modules/ri/src/test/java/org/jbpm/test/ri/service/persistence/StartEventPersistenceTest.java
projects/spec/trunk/modules/ri/src/test/java/org/jbpm/test/ri/service/persistence/UserTaskPersistenceTest.java
Modified:
projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/internal/ProcessStructure.java
projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/service/ProcessDefinitionService.java
projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/service/ProcessService.java
projects/spec/trunk/modules/ri/pom.xml
projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/ComplexGatewayImpl.java
projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/EndEventImpl.java
projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/ExclusiveGatewayImpl.java
projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/GatewayImpl.java
projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/InclusiveGatewayImpl.java
projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/MessageImpl.java
projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/ParallelGatewayImpl.java
projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/ProcessDefinitionImpl.java
projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/ProcessImpl.java
projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/ProcessStructureImpl.java
projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/SequenceFlowImpl.java
projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/SignalImpl.java
projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/UserTaskImpl.java
projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/service/ProcessServiceImpl.java
projects/spec/trunk/modules/ri/src/test/java/org/jbpm/test/ri/service/persistence/TaskPersistenceTest.java
Log:
Add more persistence tests
Added: projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/ComplexGateway.java
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/ComplexGateway.java (rev 0)
+++ projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/ComplexGateway.java 2008-10-10 10:57:20 UTC (rev 2525)
@@ -0,0 +1,50 @@
+/*
+ * 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.api.model;
+
+// $Id$
+
+/**
+ * A Complex Gateway handles situations that are not easily handled through the other types of Gateways. Complex
+ * Gateways can also be used to combine a set of linked simple Gateways into a single, more compact situation. Modelers
+ * can provide complex expressions that determine the merging and/or splitting behavior of the Gateway.
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2008
+ */
+public interface ComplexGateway extends Gateway
+{
+ /**
+ * If there are multiple incoming Sequence Flow, an IncomingCondition expression
+ * MUST be set by the modeler. This will consist of an expression that can reference
+ * Sequence Flow names and/or Process Properties (Data).
+ */
+ Expression getIncommingCondition();
+
+ /**
+ * If there are multiple outgoing Sequence Flow, an OutgoingCondition expression
+ * MUST be set by the modeler. This will consist of an expression that can reference
+ * (outgoing) Sequence Flow Ids and/or Process Properties (Data).
+ */
+ Expression getOutgoingCondition();
+
+}
\ No newline at end of file
Property changes on: projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/ComplexGateway.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/ExclusiveGateway.java
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/ExclusiveGateway.java (rev 0)
+++ projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/ExclusiveGateway.java 2008-10-10 10:57:20 UTC (rev 2525)
@@ -0,0 +1,56 @@
+/*
+ * 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.api.model;
+
+//$Id$
+
+/**
+ * Exclusive Gateways (Decisions) are locations within a business process where the Sequence Flow can take two or more
+ * alternative paths. This is basically the “fork in the road” for a process. For a given performance (or instance) of the
+ * process, only one of the paths can be taken (this should not be confused with forking of paths—refer to “Forking Flow”)
+ *
+ * A Decision is not an activity from the business process perspective, but is a type of Gateway that controls
+ * the Sequence Flow between activities. It can be thought of as a question that is asked at that point in the Process. The
+ * question has a defined set of alternative answers (Gates). Each Decision Gate is associated with a condition expression
+ * found within an outgoing Sequence Flow. When a Gate is chosen during the performance of the Process, the
+ * corresponding Sequence Flow is then chosen. A Token arriving at the Decision would be directed down the appropriate
+ * path, based on the chosen Gate.
+ *
+ * The Exclusive Decision has two or more outgoing Sequence Flow, but only one of them may be taken during the
+ * performance of the Process. Thus, the Exclusive Decision defines a set of alternative paths for the Token to take as it
+ * traverses the Flow. There are two types of Exclusive Decisions: Data-Based and Event-Based.
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2008
+ */
+public interface ExclusiveGateway extends Gateway
+{
+ enum ExclusiveType
+ {
+ Data, Event
+ }
+
+ /**
+ * ExclusiveType is by default Data. The ExclusiveType MAY be set to Event.
+ */
+ ExclusiveType getExclusiveType();
+}
\ No newline at end of file
Property changes on: projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/ExclusiveGateway.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/Gate.java
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/Gate.java (rev 0)
+++ projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/Gate.java 2008-10-10 10:57:20 UTC (rev 2525)
@@ -0,0 +1,73 @@
+/*
+ * 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.api.model;
+
+//$Id$
+
+import java.util.List;
+
+/**
+ * There MAY be zero or more Gates (except where noted below). Zero Gates are
+ * allowed if the Gateway is last object in a Process flow and there are no Start or
+ * End Events for the Process. If there are zero or only one incoming Sequence
+ * Flow, then there MUST be at least two Gates.
+ *
+ * For Exclusive Data-Based Gateways
+ * When two Gates are required, one of them MAY be the DefaultGate.
+ *
+ * For Exclusive Event-Based Gateways
+ * There MUST be two or more Gates. (Note that this type of Gateway does not act
+ * only as a Merge--it is always a Decision, at least.)
+ *
+ * For Inclusive Gateways
+ * When two Gates are required, one of them MAY be the DefaultGate.
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2008
+ */
+public interface Gate
+{
+ /**
+ * Each Gate MUST have an associated (outgoing) Sequence Flow.
+ *
+ * For Exclusive Event-Based, Complex, and Parallel Gateways:
+ * The Sequence Flow MUST have its Condition attribute set to None (there is not an
+ * evaluation of a condition expression).
+ *
+ * For Exclusive Data-Based, and Inclusive Gateways:
+ * The Sequence Flow MUST have its Condition attribute set to Expression and
+ * MUST have a valid ConditionExpression. The ConditionExpression MUST be
+ * unique for all the Gates within the Gateway. If there is only one Gate (i.e., the
+ * Gateway is acting only as a Merge), then Sequence Flow MUST have its Condition
+ * set to None.
+ *
+ * For DefaultGates:
+ * The Sequence Flow MUST have its Condition attribute set to Otherwise
+ */
+ SequenceFlow getOutgoingSequenceFlow();
+
+ /**
+ * One or more assignment expressions MAY be made for each Gate. The
+ * Assignment SHALL be performed when the Gate is selected.
+ */
+ List<Assignment> getAssignments();
+}
Property changes on: projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/Gate.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/InclusiveGateway.java
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/InclusiveGateway.java (rev 0)
+++ projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/InclusiveGateway.java 2008-10-10 10:57:20 UTC (rev 2525)
@@ -0,0 +1,39 @@
+/*
+ * 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.api.model;
+
+//$Id$
+
+/**
+ * This Decision represents a branching point where Alternatives are based on conditional expressions contained within
+ * outgoing Sequence Flow. However, in this case, the True evaluation of one condition expression does not exclude the
+ * evaluation of other condition expressions. All Sequence Flow with a True evaluation will be traversed by a Token. In
+ * some sense it’s like a grouping of related independent Binary (Yes/No) Decisions--and can be modeled that way. Since
+ * each path is independent, all combinations of the paths may be taken, from zero to all. However, it should be
+ * designed so that at least one path is taken.
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2008
+ */
+public interface InclusiveGateway extends Gateway
+{
+}
\ No newline at end of file
Property changes on: projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/InclusiveGateway.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/ParallelGateway.java
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/ParallelGateway.java (rev 0)
+++ projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/ParallelGateway.java 2008-10-10 10:57:20 UTC (rev 2525)
@@ -0,0 +1,35 @@
+/*
+ * 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.api.model;
+
+// $Id$
+
+/**
+ * Parallel Gateway is required when two or more Activities need to be executed in parallel.
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2008
+ */
+public interface ParallelGateway extends Gateway
+{
+
+}
\ No newline at end of file
Property changes on: projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/ParallelGateway.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/internal/ProcessStructure.java
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/internal/ProcessStructure.java 2008-10-10 10:32:25 UTC (rev 2524)
+++ projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/internal/ProcessStructure.java 2008-10-10 10:57:20 UTC (rev 2525)
@@ -24,7 +24,6 @@
//$Id$
import java.util.List;
-import java.util.Set;
import org.jbpm.api.model.Assignment;
import org.jbpm.api.model.Message;
@@ -76,7 +75,7 @@
*
* @return An empty list if there are none
*/
- Set<Message> getMessages();
+ List<Message> getMessages();
/**
* Get an associated {@link Message} by name.
Modified: projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/service/ProcessDefinitionService.java
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/service/ProcessDefinitionService.java 2008-10-10 10:32:25 UTC (rev 2524)
+++ projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/service/ProcessDefinitionService.java 2008-10-10 10:57:20 UTC (rev 2525)
@@ -55,7 +55,7 @@
protected ProcessDefinitionService()
{
}
-
+
/**
* Locate the default ProcessDefinitionService
*/
@@ -64,24 +64,24 @@
ProcessEngine engine = ProcessEngine.getProcessEngine();
return engine.getService(ProcessDefinitionService.class);
}
-
- /**
- * Deploy a new ProcessDefinition to the ProcessDefinition service.
+
+ /**
+ * Deploy a new ProcessDefinition to the ProcessDefinition service.
*/
public ObjectName deploy(Deployment dep)
{
// Get the associated engine
ProcessEngine engine = getProcessEngine();
-
+
// Get the ProcessDefinition from the deployment
ProcessDefinition procDef = dep.getProcessDefinition(engine);
if (procDef == null)
throw new IllegalStateException("Cannot obtain ProcessDefinition from: " + dep);
-
+
ObjectName procDefID = registerProcessDefinition(procDef);
return procDefID;
}
-
+
/**
* Register a ProcessDefinition.
*/
@@ -89,22 +89,14 @@
{
if (getProcessDefinition(procDef.getKey()) != null)
throw new IllegalStateException("Process definition already registered: " + procDef);
-
+
log.debug("registerProcessDefinition: " + procDef);
-
+
// Save the ProcessDefinition through the PersistenceService
PersistenceService persService = getProcessEngine().getService(PersistenceService.class);
- Session session = persService.createSession();
- try
- {
- ObjectName procDefID = persService.saveProcessDefinition(procDef);
- procDefs.put(procDefID, procDef);
- return procDefID;
- }
- finally
- {
- session.close();
- }
+ ObjectName procDefID = persService.saveProcessDefinition(procDef);
+ procDefs.put(procDefID, procDef);
+ return procDefID;
}
/**
@@ -117,27 +109,19 @@
if (procDef != null)
{
log.debug("unregisterProcessDefinition: " + procDef);
-
+
ProcessEngine engine = getProcessEngine();
-
+
// Unregister the associated process instances
ProcessService procService = engine.getService(ProcessService.class);
for (ObjectName procID : procService.getProcesses(procDef.getName(), null))
procService.unregisterProcess(procID);
-
+
// Delete the ProcessDefinition through the PersistenceService
PersistenceService persService = engine.getService(PersistenceService.class);
- Session session = persService.createSession();
- try
- {
- persService.deleteProcessDefinition(procDef);
- procDefs.remove(procDefID);
- removed = true;
- }
- finally
- {
- session.close();
- }
+ persService.deleteProcessDefinition(procDef);
+ procDefs.remove(procDefID);
+ removed = true;
}
return removed;
}
Modified: projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/service/ProcessService.java
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/service/ProcessService.java 2008-10-10 10:32:25 UTC (rev 2524)
+++ projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/service/ProcessService.java 2008-10-10 10:57:20 UTC (rev 2525)
@@ -66,42 +66,34 @@
ProcessEngine engine = ProcessEngine.getProcessEngine();
return engine.getService(ProcessService.class);
}
-
+
/**
* Register a Process.
*/
public ObjectName registerProcess(Process proc)
{
log.debug("registerProcess: " + proc);
-
+
if (getProcess(proc.getKey()) != null)
throw new IllegalStateException("Process already registered: " + proc);
-
+
ProcessStatus procStatus = proc.getProcessStatus();
ProcessDefinition procDef = proc.getProcessDefinition();
ProcessEngine engine = getProcessEngine();
-
+
if (procStatus != ProcessStatus.None)
throw new IllegalStateException("Cannot register process in state: " + procStatus);
-
+
// Register the process definition if needed
ProcessDefinitionService procDefService = engine.getService(ProcessDefinitionService.class);
if (procDefService.getProcessDefinition(procDef.getKey()) == null)
procDefService.registerProcessDefinition(procDef);
-
+
// Save the process through the PersistenceService
PersistenceService persService = getProcessEngine().getService(PersistenceService.class);
- Session session = persService.createSession();
- try
- {
- ObjectName procID = persService.saveProcess(proc);
- registeredProcs.put(procID, proc);
- return procID;
- }
- finally
- {
- session.close();
- }
+ ObjectName procID = persService.saveProcess(proc);
+ registeredProcs.put(procID, proc);
+ return procID;
}
/**
@@ -114,20 +106,12 @@
if (proc != null)
{
log.debug("unregisterProcess: " + proc);
-
+
// Delete the process through the PersistenceService
PersistenceService persService = getProcessEngine().getService(PersistenceService.class);
- Session session = persService.createSession();
- try
- {
- persService.deleteProcess(proc);
- registeredProcs.remove(procID);
- removed = true;
- }
- finally
- {
- session.close();
- }
+ persService.deleteProcess(proc);
+ registeredProcs.remove(procID);
+ removed = true;
}
return removed;
}
Modified: projects/spec/trunk/modules/ri/pom.xml
===================================================================
--- projects/spec/trunk/modules/ri/pom.xml 2008-10-10 10:32:25 UTC (rev 2524)
+++ projects/spec/trunk/modules/ri/pom.xml 2008-10-10 10:57:20 UTC (rev 2525)
@@ -104,6 +104,17 @@
</dependency>
</dependencies>
+ <!-- Plugins -->
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
<!-- Profiles -->
<profiles>
</profiles>
Modified: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/ComplexGatewayImpl.java
===================================================================
--- projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/ComplexGatewayImpl.java 2008-10-10 10:32:25 UTC (rev 2524)
+++ projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/ComplexGatewayImpl.java 2008-10-10 10:57:20 UTC (rev 2525)
@@ -26,6 +26,7 @@
import javax.persistence.Entity;
import org.jbpm.api.NotImplementedException;
+import org.jbpm.api.model.ComplexGateway;
import org.jbpm.api.model.Expression;
import org.jbpm.api.model.internal.ProcessStructure;
@@ -38,7 +39,7 @@
* @since 08-Jul-2008
*/
@Entity(name = "ComplexGateway")
-public class ComplexGatewayImpl extends GatewayImpl
+public class ComplexGatewayImpl extends GatewayImpl implements ComplexGateway
{
private static final long serialVersionUID = 1L;
@@ -47,11 +48,11 @@
super(procStruct, name, GatewayType.Complex);
}
- public GatewayType getGatewayType()
+ // Persistence ctor
+ protected ComplexGatewayImpl()
{
- return GatewayType.Complex;
}
-
+
public Expression getIncommingCondition()
{
throw new NotImplementedException("JBPM-1636", "ComplexGateway incomming condition");
Modified: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/EndEventImpl.java
===================================================================
--- projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/EndEventImpl.java 2008-10-10 10:32:25 UTC (rev 2524)
+++ projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/EndEventImpl.java 2008-10-10 10:57:20 UTC (rev 2525)
@@ -58,9 +58,7 @@
@Entity(name = "EndEvent")
public class EndEventImpl extends EventImpl implements EndEvent, SingleInFlowSupport
{
- // provide serial version UID
private static final long serialVersionUID = 1L;
- // provide logging
final static Logger log = LoggerFactory.getLogger(EndEventImpl.class);
public EndEventImpl(ProcessStructure procStruct, String name)
Modified: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/ExclusiveGatewayImpl.java
===================================================================
--- projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/ExclusiveGatewayImpl.java 2008-10-10 10:32:25 UTC (rev 2524)
+++ projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/ExclusiveGatewayImpl.java 2008-10-10 10:57:20 UTC (rev 2525)
@@ -29,6 +29,7 @@
import javax.persistence.Entity;
import javax.persistence.Transient;
+import org.jbpm.api.model.ExclusiveGateway;
import org.jbpm.api.model.Expression;
import org.jbpm.api.model.Node;
import org.jbpm.api.model.SequenceFlow;
@@ -51,7 +52,7 @@
* @since 08-Jul-2008
*/
@Entity(name = "ExclusiveGateway")
-public class ExclusiveGatewayImpl extends GatewayImpl
+public class ExclusiveGatewayImpl extends GatewayImpl implements ExclusiveGateway
{
private static final long serialVersionUID = 1L;
@@ -66,7 +67,18 @@
super(procStruct, name, GatewayType.Exclusive);
}
+ // Persistence ctor
+ protected ExclusiveGatewayImpl()
+ {
+ }
+
@Override
+ public ExclusiveType getExclusiveType()
+ {
+ return ExclusiveType.Data;
+ }
+
+ @Override
protected ExecutionHandler getDefaultExecutionHandler()
{
final Node thisNode = this;
Added: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/GateImpl.java
===================================================================
--- projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/GateImpl.java (rev 0)
+++ projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/GateImpl.java 2008-10-10 10:57:20 UTC (rev 2525)
@@ -0,0 +1,86 @@
+/*
+ * 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.ri.model;
+
+//$Id$
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+import javax.persistence.OneToOne;
+
+import org.hibernate.annotations.IndexColumn;
+import org.jbpm.api.model.Assignment;
+import org.jbpm.api.model.Gate;
+import org.jbpm.api.model.SequenceFlow;
+
+/**
+ * There MAY be zero or more Gates (except where noted below). Zero Gates are allowed if the Gateway is last object in a
+ * Process flow and there are no Start or End Events for the Process. If there are zero or only one incoming Sequence
+ * Flow, then there MUST be at least two Gates.
+ *
+ * For Exclusive Data-Based Gateways When two Gates are required, one of them MAY be the DefaultGate.
+ *
+ * For Exclusive Event-Based Gateways There MUST be two or more Gates. (Note that this type of Gateway does not act only
+ * as a Merge--it is always a Decision, at least.)
+ *
+ * For Inclusive Gateways When two Gates are required, one of them MAY be the DefaultGate.
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 10-Oct-2008
+ */
+ at Entity(name = "Gate")
+public class GateImpl implements Gate
+{
+ // provide serial version UID
+ private static final long serialVersionUID = 1L;
+
+ @Id
+ @GeneratedValue
+ protected Integer id;
+
+ @OneToOne(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER, targetEntity = SequenceFlowImpl.class)
+ protected SequenceFlow outFlow;
+
+ @IndexColumn(name = "assignIndex")
+ @OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER, targetEntity = AssignmentImpl.class)
+ private List<Assignment> assignments = new ArrayList<Assignment>();
+
+ @Override
+ public List<Assignment> getAssignments()
+ {
+ return Collections.unmodifiableList(assignments);
+ }
+
+ @Override
+ public SequenceFlow getOutgoingSequenceFlow()
+ {
+ return outFlow;
+ }
+}
\ No newline at end of file
Property changes on: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/GateImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/GatewayImpl.java
===================================================================
--- projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/GatewayImpl.java 2008-10-10 10:32:25 UTC (rev 2524)
+++ projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/GatewayImpl.java 2008-10-10 10:57:20 UTC (rev 2525)
@@ -79,6 +79,11 @@
this.gatewayType = gatewayType;
}
+ // Persistence ctor
+ protected GatewayImpl()
+ {
+ }
+
@Override
public ObjectName getKey()
{
Modified: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/InclusiveGatewayImpl.java
===================================================================
--- projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/InclusiveGatewayImpl.java 2008-10-10 10:32:25 UTC (rev 2524)
+++ projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/InclusiveGatewayImpl.java 2008-10-10 10:57:20 UTC (rev 2525)
@@ -31,6 +31,7 @@
import javax.persistence.Entity;
import org.jbpm.api.model.Expression;
+import org.jbpm.api.model.InclusiveGateway;
import org.jbpm.api.model.Node;
import org.jbpm.api.model.SequenceFlow;
import org.jbpm.api.model.Expression.ExpressionLanguage;
@@ -54,7 +55,7 @@
* @since 08-Jul-2008
*/
@Entity(name = "InclusiveGateway")
-public class InclusiveGatewayImpl extends GatewayImpl
+public class InclusiveGatewayImpl extends GatewayImpl implements InclusiveGateway
{
private static final long serialVersionUID = 1L;
@@ -66,6 +67,11 @@
super(procStruct, name, GatewayType.Inclusive);
}
+ // Persistence ctor
+ protected InclusiveGatewayImpl()
+ {
+ }
+
@Override
protected FlowHandler getDefaultFlowHandler()
{
Modified: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/MessageImpl.java
===================================================================
--- projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/MessageImpl.java 2008-10-10 10:32:25 UTC (rev 2524)
+++ projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/MessageImpl.java 2008-10-10 10:57:20 UTC (rev 2525)
@@ -55,6 +55,9 @@
protected int id;
@Basic
+ private int msgIndex;
+
+ @Basic
private String name;
@OneToOne(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER, targetEntity = ParticipantImpl.class)
@@ -74,13 +77,28 @@
this.name = name;
}
- public MessageImpl(String name, Participant toRef, ParticipantImpl fromRef)
+ public MessageImpl(String name, Participant toRef, Participant fromRef)
{
this(name);
this.toRef = toRef;
this.fromRef = fromRef;
}
+ // Persistence ctor
+ protected MessageImpl()
+ {
+ }
+
+ int getMsgIndex()
+ {
+ return msgIndex;
+ }
+
+ void setMsgIndex(int msgIndex)
+ {
+ this.msgIndex = msgIndex;
+ }
+
public String getName()
{
return name;
Modified: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/ParallelGatewayImpl.java
===================================================================
--- projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/ParallelGatewayImpl.java 2008-10-10 10:32:25 UTC (rev 2524)
+++ projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/ParallelGatewayImpl.java 2008-10-10 10:57:20 UTC (rev 2525)
@@ -32,6 +32,7 @@
import javax.persistence.Transient;
import org.jbpm.api.model.Node;
+import org.jbpm.api.model.ParallelGateway;
import org.jbpm.api.model.SequenceFlow;
import org.jbpm.api.model.internal.ProcessStructure;
import org.jbpm.api.runtime.ExecutionHandler;
@@ -50,7 +51,7 @@
* @since 08-Jul-2008
*/
@Entity(name = "ParallelGateway")
-public class ParallelGatewayImpl extends GatewayImpl
+public class ParallelGatewayImpl extends GatewayImpl implements ParallelGateway
{
private static final long serialVersionUID = 1L;
@@ -68,6 +69,11 @@
super(procStruct, name, GatewayType.Parallel);
}
+ // Persistence ctor
+ protected ParallelGatewayImpl()
+ {
+ }
+
@Override
protected ExecutionHandler getDefaultExecutionHandler()
{
Modified: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/ProcessDefinitionImpl.java
===================================================================
--- projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/ProcessDefinitionImpl.java 2008-10-10 10:32:25 UTC (rev 2524)
+++ projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/ProcessDefinitionImpl.java 2008-10-10 10:57:20 UTC (rev 2525)
@@ -127,7 +127,7 @@
}
@Override
- public Set<Message> getMessages()
+ public List<Message> getMessages()
{
return procStruct.getMessages();
}
Modified: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/ProcessImpl.java
===================================================================
--- projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/ProcessImpl.java 2008-10-10 10:32:25 UTC (rev 2524)
+++ projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/ProcessImpl.java 2008-10-10 10:57:20 UTC (rev 2525)
@@ -130,7 +130,7 @@
}
@Override
- public Set<Message> getMessages()
+ public List<Message> getMessages()
{
return procStruct.getMessages();
}
Modified: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/ProcessStructureImpl.java
===================================================================
--- projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/ProcessStructureImpl.java 2008-10-10 10:32:25 UTC (rev 2524)
+++ projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/ProcessStructureImpl.java 2008-10-10 10:57:20 UTC (rev 2525)
@@ -25,7 +25,6 @@
import java.util.ArrayList;
import java.util.Collections;
-import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -80,8 +79,9 @@
@OneToOne(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER, targetEntity = PropertySupportImpl.class)
protected PropertySupport propSupport = new PropertySupportImpl();
+ @IndexColumn(name = "msgIndex")
@OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER, targetEntity = MessageImpl.class)
- private Set<Message> messages = new HashSet<Message>();
+ private List<Message> messages = new ArrayList<Message>();
@IndexColumn(name = "assignIndex")
@OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER, targetEntity = AssignmentImpl.class)
@@ -179,17 +179,19 @@
}
@Override
- public Set<Message> getMessages()
+ public List<Message> getMessages()
{
- return Collections.unmodifiableSet(messages);
+ return Collections.unmodifiableList(messages);
}
- public void addMessage(Message msg)
+ public void addMessage(Message message)
{
- if (getMessage(msg.getName()) != null)
- throw new InvalidProcessException("Duplicate message: " + msg);
+ if (getMessage(message.getName()) != null)
+ throw new InvalidProcessException("Duplicate message: " + message);
- messages.add(msg);
+ MessageImpl messageImpl = (MessageImpl)message;
+ messageImpl.setMsgIndex(messages.size());
+ messages.add(message);
}
@Override
Modified: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/SequenceFlowImpl.java
===================================================================
--- projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/SequenceFlowImpl.java 2008-10-10 10:32:25 UTC (rev 2524)
+++ projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/SequenceFlowImpl.java 2008-10-10 10:57:20 UTC (rev 2525)
@@ -51,8 +51,7 @@
// provide serial version UID
private static final long serialVersionUID = 1L;
- @Id
- @GeneratedValue
+ @Id @GeneratedValue
protected Integer id;
@Basic
Modified: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/SignalImpl.java
===================================================================
--- projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/SignalImpl.java 2008-10-10 10:32:25 UTC (rev 2524)
+++ projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/SignalImpl.java 2008-10-10 10:57:20 UTC (rev 2525)
@@ -79,6 +79,11 @@
this.message = message;
}
+ // Persistence ctor
+ protected SignalImpl()
+ {
+ }
+
public ObjectName getFromRef()
{
return ObjectNameFactory.create(fromRef);
Modified: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/UserTaskImpl.java
===================================================================
--- projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/UserTaskImpl.java 2008-10-10 10:32:25 UTC (rev 2524)
+++ projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/UserTaskImpl.java 2008-10-10 10:57:20 UTC (rev 2525)
@@ -27,7 +27,10 @@
import java.util.List;
import javax.management.ObjectName;
+import javax.persistence.CascadeType;
import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.OneToOne;
import javax.persistence.Transient;
import org.jbpm.api.InvalidProcessException;
@@ -57,13 +60,12 @@
{
private static final long serialVersionUID = 1L;
- // provide logging
final static Logger log = LoggerFactory.getLogger(UserTaskImpl.class);
- @Transient
+ @OneToOne(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER, targetEntity = MessageImpl.class)
protected MessageImpl outMessageRef;
- @Transient
+ @OneToOne(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER, targetEntity = MessageImpl.class)
protected MessageImpl inMessageRef;
@Transient
@@ -71,13 +73,13 @@
@Transient
private transient Token suspendedToken;
-
+
@Transient
private transient TokenExecutor tokenExecutor;
-
+
@Transient
private transient UserTaskCallback userCallback;
-
+
public UserTaskImpl(ProcessStructure procStruct, String name)
{
super(procStruct, TaskType.User, name);
@@ -122,19 +124,18 @@
this.inMessageRef = message;
}
-
@Override
public void execute(RuntimeContext rtContext)
{
Token token = rtContext.getToken();
tokenExecutor = rtContext.getTokenExecutor();
-
+
if (receivedMessages.size() == 0)
{
MessageSender messageSender = new MessageSender(this, outMessageRef);
messageSender.sendMessage(token);
}
-
+
if (receivedMessages.size() > 0)
{
// Copy the expected properties from the received message
@@ -160,15 +161,17 @@
if (inMessageRef.getName().equals(msgName))
{
log.debug("catchMessage in " + this + " => " + message);
-
+
// Verify expected properties
for (String propName : inMessageRef.getPropertyNames())
{
if (message.getProperty(propName) == null)
throw new IllegalArgumentException("Received message does not contain expected property: " + propName);
}
-
+
// Store the received message
+ MessageImpl messageImpl = (MessageImpl)message;
+ messageImpl.setMsgIndex(receivedMessages.size());
receivedMessages.add(message);
// Activate the suspended token
@@ -228,7 +231,7 @@
protected void unregister(Process proc)
{
super.unregister(proc);
-
+
if (userCallback != null)
userCallback.detach(this);
}
Modified: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/service/ProcessServiceImpl.java
===================================================================
--- projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/service/ProcessServiceImpl.java 2008-10-10 10:32:25 UTC (rev 2524)
+++ projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/service/ProcessServiceImpl.java 2008-10-10 10:57:20 UTC (rev 2525)
@@ -29,9 +29,11 @@
import javax.management.ObjectName;
+import org.hibernate.Session;
import org.jbpm.api.client.ProcessEngine;
import org.jbpm.api.model.Process;
import org.jbpm.api.model.Process.ProcessStatus;
+import org.jbpm.api.service.PersistenceService;
import org.jbpm.api.service.ProcessService;
import org.jbpm.ri.model.ProcessImpl;
import org.jbpm.ri.runtime.NodeInterceptor;
@@ -80,6 +82,11 @@
procImpl.register(proc);
procImpl.setProcessStatus(ProcessStatus.Ready);
+
+ // Save the process through the PersistenceService
+ PersistenceService persService = getProcessEngine().getService(PersistenceService.class);
+ persService.saveProcess(proc);
+
return procID;
}
Added: projects/spec/trunk/modules/ri/src/test/java/org/jbpm/test/ri/service/persistence/ComplexGatewayPersistenceTest.java
===================================================================
--- projects/spec/trunk/modules/ri/src/test/java/org/jbpm/test/ri/service/persistence/ComplexGatewayPersistenceTest.java (rev 0)
+++ projects/spec/trunk/modules/ri/src/test/java/org/jbpm/test/ri/service/persistence/ComplexGatewayPersistenceTest.java 2008-10-10 10:57:20 UTC (rev 2525)
@@ -0,0 +1,52 @@
+/*
+ * 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.test.ri.service.persistence;
+
+// $Id$
+
+import javax.management.ObjectName;
+
+import org.jbpm.api.model.ComplexGateway;
+import org.jbpm.api.model.Gateway.GatewayType;
+import org.jbpm.ri.model.ComplexGatewayImpl;
+
+/**
+ * Test the HibernatePersistenceService for ComplexGateway
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 10-Oct-2008
+ */
+public class ComplexGatewayPersistenceTest extends NodePersistenceTest
+{
+ public void testNoneComplexGateway() throws Exception
+ {
+ ComplexGateway orgNode = new ComplexGatewayImpl(null, "Gateway");
+
+ ObjectName nodeID = saveNode(orgNode);
+
+ ComplexGateway wasNode = loadNode(ComplexGatewayImpl.class, nodeID);
+ assertEquals("Gateway", wasNode.getName());
+ assertEquals(GatewayType.Complex, wasNode.getGatewayType());
+
+ deleteNode(wasNode);
+ }
+}
Property changes on: projects/spec/trunk/modules/ri/src/test/java/org/jbpm/test/ri/service/persistence/ComplexGatewayPersistenceTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/spec/trunk/modules/ri/src/test/java/org/jbpm/test/ri/service/persistence/EndEventPersistenceTest.java
===================================================================
--- projects/spec/trunk/modules/ri/src/test/java/org/jbpm/test/ri/service/persistence/EndEventPersistenceTest.java (rev 0)
+++ projects/spec/trunk/modules/ri/src/test/java/org/jbpm/test/ri/service/persistence/EndEventPersistenceTest.java 2008-10-10 10:57:20 UTC (rev 2525)
@@ -0,0 +1,100 @@
+/*
+ * 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.test.ri.service.persistence;
+
+// $Id$
+
+import javax.management.ObjectName;
+
+import org.jbpm.api.model.Message;
+import org.jbpm.api.model.Signal;
+import org.jbpm.api.model.EndEvent;
+import org.jbpm.api.model.Event.EventDetailType;
+import org.jbpm.api.model.Signal.SignalType;
+import org.jbpm.ri.model.MessageImpl;
+import org.jbpm.ri.model.SignalImpl;
+import org.jbpm.ri.model.EndEventImpl;
+
+/**
+ * Test the HibernatePersistenceService for EndEvent
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 10-Oct-2008
+ */
+public class EndEventPersistenceTest extends NodePersistenceTest
+{
+ public void testNoneEndEvent() throws Exception
+ {
+ EndEvent orgNode = new EndEventImpl(null, "End");
+
+ ObjectName nodeID = saveNode(orgNode);
+
+ EndEvent wasNode = loadNode(EndEventImpl.class, nodeID);
+ assertEquals("End", wasNode.getName());
+ assertEquals(EventDetailType.None, wasNode.getDetailType());
+
+ deleteNode(wasNode);
+ }
+
+ public void testSignalEndEvent() throws Exception
+ {
+ EndEventImpl orgNode = new EndEventImpl(null, "End");
+
+ orgNode.setResultType(EventDetailType.Signal);
+ orgNode.setSignalRef(new SignalImpl(SignalType.USER_SIGNAL, getTestID(), "sigMessage"));
+
+ ObjectName nodeID = saveNode(orgNode);
+
+ EndEvent wasNode = loadNode(EndEventImpl.class, nodeID);
+ assertEquals("End", wasNode.getName());
+ assertEquals(EventDetailType.Signal, wasNode.getDetailType());
+
+ Signal wasSig = wasNode.getSignalRef();
+ assertEquals(SignalType.USER_SIGNAL, wasSig.getSignalType());
+ assertEquals(getTestID(), wasSig.getFromRef());
+ assertEquals("sigMessage", wasSig.getMessage());
+
+ deleteNode(wasNode);
+ }
+
+ public void testMessageEndEvent() throws Exception
+ {
+ EndEventImpl orgNode = new EndEventImpl(null, "End");
+
+ orgNode.setResultType(EventDetailType.Message);
+ MessageImpl outMsg = new MessageImpl("outMsg");
+ outMsg.addProperty("outProp", "outVal");
+ orgNode.setMessageRef(outMsg);
+
+ ObjectName nodeID = saveNode(orgNode);
+
+ EndEvent wasNode = loadNode(EndEventImpl.class, nodeID);
+ assertEquals("End", wasNode.getName());
+ assertEquals(EventDetailType.Message, wasNode.getDetailType());
+
+ Message wasMsg = wasNode.getMessageRef();
+ assertEquals("outMsg", wasMsg.getName());
+ assertEquals("outVal", wasMsg.getProperty("outProp").getValue());
+
+ deleteNode(wasNode);
+ }
+}
Property changes on: projects/spec/trunk/modules/ri/src/test/java/org/jbpm/test/ri/service/persistence/EndEventPersistenceTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/spec/trunk/modules/ri/src/test/java/org/jbpm/test/ri/service/persistence/ExclusiveGatewayPersistenceTest.java
===================================================================
--- projects/spec/trunk/modules/ri/src/test/java/org/jbpm/test/ri/service/persistence/ExclusiveGatewayPersistenceTest.java (rev 0)
+++ projects/spec/trunk/modules/ri/src/test/java/org/jbpm/test/ri/service/persistence/ExclusiveGatewayPersistenceTest.java 2008-10-10 10:57:20 UTC (rev 2525)
@@ -0,0 +1,52 @@
+/*
+ * 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.test.ri.service.persistence;
+
+// $Id$
+
+import javax.management.ObjectName;
+
+import org.jbpm.api.model.ExclusiveGateway;
+import org.jbpm.api.model.Gateway.GatewayType;
+import org.jbpm.ri.model.ExclusiveGatewayImpl;
+
+/**
+ * Test the HibernatePersistenceService for ExclusiveGateway
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 10-Oct-2008
+ */
+public class ExclusiveGatewayPersistenceTest extends NodePersistenceTest
+{
+ public void testNoneExclusiveGateway() throws Exception
+ {
+ ExclusiveGateway orgNode = new ExclusiveGatewayImpl(null, "Gateway");
+
+ ObjectName nodeID = saveNode(orgNode);
+
+ ExclusiveGateway wasNode = loadNode(ExclusiveGatewayImpl.class, nodeID);
+ assertEquals("Gateway", wasNode.getName());
+ assertEquals(GatewayType.Exclusive, wasNode.getGatewayType());
+
+ deleteNode(wasNode);
+ }
+}
Property changes on: projects/spec/trunk/modules/ri/src/test/java/org/jbpm/test/ri/service/persistence/ExclusiveGatewayPersistenceTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/spec/trunk/modules/ri/src/test/java/org/jbpm/test/ri/service/persistence/InclusiveGatewayPersistenceTest.java
===================================================================
--- projects/spec/trunk/modules/ri/src/test/java/org/jbpm/test/ri/service/persistence/InclusiveGatewayPersistenceTest.java (rev 0)
+++ projects/spec/trunk/modules/ri/src/test/java/org/jbpm/test/ri/service/persistence/InclusiveGatewayPersistenceTest.java 2008-10-10 10:57:20 UTC (rev 2525)
@@ -0,0 +1,52 @@
+/*
+ * 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.test.ri.service.persistence;
+
+// $Id$
+
+import javax.management.ObjectName;
+
+import org.jbpm.api.model.InclusiveGateway;
+import org.jbpm.api.model.Gateway.GatewayType;
+import org.jbpm.ri.model.InclusiveGatewayImpl;
+
+/**
+ * Test the HibernatePersistenceService for InclusiveGateway
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 10-Oct-2008
+ */
+public class InclusiveGatewayPersistenceTest extends NodePersistenceTest
+{
+ public void testNoneInclusiveGateway() throws Exception
+ {
+ InclusiveGateway orgNode = new InclusiveGatewayImpl(null, "Gateway");
+
+ ObjectName nodeID = saveNode(orgNode);
+
+ InclusiveGateway wasNode = loadNode(InclusiveGatewayImpl.class, nodeID);
+ assertEquals("Gateway", wasNode.getName());
+ assertEquals(GatewayType.Inclusive, wasNode.getGatewayType());
+
+ deleteNode(wasNode);
+ }
+}
Property changes on: projects/spec/trunk/modules/ri/src/test/java/org/jbpm/test/ri/service/persistence/InclusiveGatewayPersistenceTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/spec/trunk/modules/ri/src/test/java/org/jbpm/test/ri/service/persistence/NodePersistenceTest.java
===================================================================
--- projects/spec/trunk/modules/ri/src/test/java/org/jbpm/test/ri/service/persistence/NodePersistenceTest.java (rev 0)
+++ projects/spec/trunk/modules/ri/src/test/java/org/jbpm/test/ri/service/persistence/NodePersistenceTest.java 2008-10-10 10:57:20 UTC (rev 2525)
@@ -0,0 +1,104 @@
+/*
+ * 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.test.ri.service.persistence;
+
+// $Id$
+
+import javax.management.ObjectName;
+
+import org.hibernate.Hibernate;
+import org.hibernate.Session;
+import org.hibernate.StaleStateException;
+import org.hibernate.Transaction;
+import org.jbpm.api.model.Node;
+import org.jbpm.api.service.PersistenceService;
+import org.jbpm.api.test.CTSTestCase;
+import org.jbpm.ri.service.HibernatePersistenceServiceImpl;
+
+/**
+ * Abstract HibernatePersistenceService test for Nodes
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 10-Oct-2008
+ */
+public abstract class NodePersistenceTest extends CTSTestCase
+{
+ protected HibernatePersistenceServiceImpl service;
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ service = (HibernatePersistenceServiceImpl)PersistenceService.locatePersistenceService();
+ }
+
+ protected ObjectName saveNode(Node node)
+ {
+ Session session = service.createSession();
+ Transaction tx = session.beginTransaction();
+ try
+ {
+ service.saveNode(session, node);
+ tx.commit();
+
+ return node.getKey();
+ }
+ finally
+ {
+ session.close();
+ }
+ }
+
+ protected <T extends Node> T loadNode(Class<T> nodeClass, ObjectName nodeID)
+ {
+ Session session = service.createSession();
+ try
+ {
+ T node = service.loadNode(session, nodeClass, nodeID);
+ Hibernate.initialize(node);
+ return node;
+ }
+ finally
+ {
+ session.close();
+ }
+ }
+
+ protected void deleteNode(Node node)
+ {
+ Session session = service.createSession();
+ Transaction tx = session.beginTransaction();
+ try
+ {
+ service.deleteNode(session, node);
+ tx.commit();
+ }
+ catch(StaleStateException ex)
+ {
+ // ignore, because the node was already deleted by a cascade
+ }
+ finally
+ {
+ session.close();
+ }
+ }
+}
Property changes on: projects/spec/trunk/modules/ri/src/test/java/org/jbpm/test/ri/service/persistence/NodePersistenceTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/spec/trunk/modules/ri/src/test/java/org/jbpm/test/ri/service/persistence/ParallelGatewayPersistenceTest.java
===================================================================
--- projects/spec/trunk/modules/ri/src/test/java/org/jbpm/test/ri/service/persistence/ParallelGatewayPersistenceTest.java (rev 0)
+++ projects/spec/trunk/modules/ri/src/test/java/org/jbpm/test/ri/service/persistence/ParallelGatewayPersistenceTest.java 2008-10-10 10:57:20 UTC (rev 2525)
@@ -0,0 +1,52 @@
+/*
+ * 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.test.ri.service.persistence;
+
+// $Id$
+
+import javax.management.ObjectName;
+
+import org.jbpm.api.model.ParallelGateway;
+import org.jbpm.api.model.Gateway.GatewayType;
+import org.jbpm.ri.model.ParallelGatewayImpl;
+
+/**
+ * Test the HibernatePersistenceService for ParallelGateway
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 10-Oct-2008
+ */
+public class ParallelGatewayPersistenceTest extends NodePersistenceTest
+{
+ public void testNoneParallelGateway() throws Exception
+ {
+ ParallelGateway orgNode = new ParallelGatewayImpl(null, "Gateway");
+
+ ObjectName nodeID = saveNode(orgNode);
+
+ ParallelGateway wasNode = loadNode(ParallelGatewayImpl.class, nodeID);
+ assertEquals("Gateway", wasNode.getName());
+ assertEquals(GatewayType.Parallel, wasNode.getGatewayType());
+
+ deleteNode(wasNode);
+ }
+}
Property changes on: projects/spec/trunk/modules/ri/src/test/java/org/jbpm/test/ri/service/persistence/ParallelGatewayPersistenceTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/spec/trunk/modules/ri/src/test/java/org/jbpm/test/ri/service/persistence/StartEventPersistenceTest.java
===================================================================
--- projects/spec/trunk/modules/ri/src/test/java/org/jbpm/test/ri/service/persistence/StartEventPersistenceTest.java (rev 0)
+++ projects/spec/trunk/modules/ri/src/test/java/org/jbpm/test/ri/service/persistence/StartEventPersistenceTest.java 2008-10-10 10:57:20 UTC (rev 2525)
@@ -0,0 +1,100 @@
+/*
+ * 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.test.ri.service.persistence;
+
+// $Id$
+
+import javax.management.ObjectName;
+
+import org.jbpm.api.model.Message;
+import org.jbpm.api.model.Signal;
+import org.jbpm.api.model.StartEvent;
+import org.jbpm.api.model.Event.EventDetailType;
+import org.jbpm.api.model.Signal.SignalType;
+import org.jbpm.ri.model.MessageImpl;
+import org.jbpm.ri.model.SignalImpl;
+import org.jbpm.ri.model.StartEventImpl;
+
+/**
+ * Test the HibernatePersistenceService for StartEvent
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 10-Oct-2008
+ */
+public class StartEventPersistenceTest extends NodePersistenceTest
+{
+ public void testNoneStartEvent() throws Exception
+ {
+ StartEvent orgNode = new StartEventImpl(null, "Start");
+
+ ObjectName nodeID = saveNode(orgNode);
+
+ StartEvent wasNode = loadNode(StartEventImpl.class, nodeID);
+ assertEquals("Start", wasNode.getName());
+ assertEquals(EventDetailType.None, wasNode.getDetailType());
+
+ deleteNode(wasNode);
+ }
+
+ public void testSignalStartEvent() throws Exception
+ {
+ StartEventImpl orgNode = new StartEventImpl(null, "Start");
+
+ orgNode.setTriggerType(EventDetailType.Signal);
+ orgNode.setSignalRef(new SignalImpl(SignalType.USER_SIGNAL, getTestID(), "sigMessage"));
+
+ ObjectName nodeID = saveNode(orgNode);
+
+ StartEvent wasNode = loadNode(StartEventImpl.class, nodeID);
+ assertEquals("Start", wasNode.getName());
+ assertEquals(EventDetailType.Signal, wasNode.getDetailType());
+
+ Signal wasSig = wasNode.getSignalRef();
+ assertEquals(SignalType.USER_SIGNAL, wasSig.getSignalType());
+ assertEquals(getTestID(), wasSig.getFromRef());
+ assertEquals("sigMessage", wasSig.getMessage());
+
+ deleteNode(wasNode);
+ }
+
+ public void testMessageStartEvent() throws Exception
+ {
+ StartEventImpl orgNode = new StartEventImpl(null, "Start");
+
+ orgNode.setTriggerType(EventDetailType.Message);
+ MessageImpl inMsg = new MessageImpl("inMsg");
+ inMsg.addProperty("inProp", "inVal");
+ orgNode.setMessageRef(inMsg);
+
+ ObjectName nodeID = saveNode(orgNode);
+
+ StartEvent wasNode = loadNode(StartEventImpl.class, nodeID);
+ assertEquals("Start", wasNode.getName());
+ assertEquals(EventDetailType.Message, wasNode.getDetailType());
+
+ Message wasMsg = wasNode.getMessageRef();
+ assertEquals("inMsg", wasMsg.getName());
+ assertEquals("inVal", wasMsg.getProperty("inProp").getValue());
+
+ deleteNode(wasNode);
+ }
+}
Property changes on: projects/spec/trunk/modules/ri/src/test/java/org/jbpm/test/ri/service/persistence/StartEventPersistenceTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: projects/spec/trunk/modules/ri/src/test/java/org/jbpm/test/ri/service/persistence/TaskPersistenceTest.java
===================================================================
--- projects/spec/trunk/modules/ri/src/test/java/org/jbpm/test/ri/service/persistence/TaskPersistenceTest.java 2008-10-10 10:32:25 UTC (rev 2524)
+++ projects/spec/trunk/modules/ri/src/test/java/org/jbpm/test/ri/service/persistence/TaskPersistenceTest.java 2008-10-10 10:57:20 UTC (rev 2525)
@@ -28,10 +28,6 @@
import javax.management.ObjectName;
-import org.hibernate.Hibernate;
-import org.hibernate.Session;
-import org.hibernate.StaleStateException;
-import org.hibernate.Transaction;
import org.jbpm.api.model.Assignment;
import org.jbpm.api.model.Expression;
import org.jbpm.api.model.InputSet;
@@ -47,8 +43,6 @@
import org.jbpm.api.runtime.SignalHandler;
import org.jbpm.api.runtime.Token;
import org.jbpm.api.runtime.TokenExecutor;
-import org.jbpm.api.service.PersistenceService;
-import org.jbpm.api.test.CTSTestCase;
import org.jbpm.ri.model.AssignmentImpl;
import org.jbpm.ri.model.ExpressionImpl;
import org.jbpm.ri.model.InputSetImpl;
@@ -56,7 +50,6 @@
import org.jbpm.ri.model.PropertyImpl;
import org.jbpm.ri.model.SequenceFlowImpl;
import org.jbpm.ri.model.TaskImpl;
-import org.jbpm.ri.service.HibernatePersistenceServiceImpl;
/**
* Test the HibernatePersistenceService for Tasks
@@ -64,57 +57,48 @@
* @author thomas.diesler at jboss.com
* @since 08-Jul-2008
*/
-public class TaskPersistenceTest extends CTSTestCase
+public class TaskPersistenceTest extends NodePersistenceTest
{
- HibernatePersistenceServiceImpl service;
-
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
- service = (HibernatePersistenceServiceImpl)PersistenceService.locatePersistenceService();
- }
-
public void testSimpleTask() throws Exception
{
- Task orgTask = new TaskImpl(null, TaskType.None, "Task");
+ Task orgNode = new TaskImpl(null, TaskType.None, "Task");
- ObjectName taskID = saveNode(orgTask);
+ ObjectName nodeID = saveNode(orgNode);
- Task wasTask = loadNode(taskID);
- assertEquals("Task", wasTask.getName());
- assertEquals(TaskType.None, wasTask.getTaskType());
+ Task wasNode = loadNode(TaskImpl.class, nodeID);
+ assertEquals("Task", wasNode.getName());
+ assertEquals(TaskType.None, wasNode.getTaskType());
- deleteNode(wasTask);
+ deleteNode(wasNode);
}
public void testTaskProperties() throws Exception
{
- TaskImpl orgTask = new TaskImpl(null, TaskType.None, "Task");
- orgTask.addProperty("propOne", "valOne");
- orgTask.addProperty("propTwo", "valTwo");
+ TaskImpl orgNode = new TaskImpl(null, TaskType.None, "Task");
+ orgNode.addProperty("propOne", "valOne");
+ orgNode.addProperty("propTwo", "valTwo");
- ObjectName taskID = saveNode(orgTask);
+ ObjectName nodeID = saveNode(orgNode);
- Task wasTask = loadNode(taskID);
- Set<String> propNames = wasTask.getPropertyNames();
+ Task wasNode = loadNode(TaskImpl.class, nodeID);
+ Set<String> propNames = wasNode.getPropertyNames();
assertEquals(2, propNames.size());
- assertEquals("valOne", wasTask.getProperty("propOne").getValue());
- assertEquals("valTwo", wasTask.getProperty("propTwo").getValue());
+ assertEquals("valOne", wasNode.getProperty("propOne").getValue());
+ assertEquals("valTwo", wasNode.getProperty("propTwo").getValue());
- deleteNode(wasTask);
+ deleteNode(wasNode);
}
public void testTaskAssignments() throws Exception
{
- TaskImpl orgTask = new TaskImpl(null, TaskType.None, "Task");
- orgTask.addAssignment(new AssignmentImpl(AssignTime.Start, new ExpressionImpl("foo"), new PropertyImpl("propFoo", null)));
- orgTask.addAssignment(new AssignmentImpl(AssignTime.End, new ExpressionImpl("bar"), new PropertyImpl("propBar", null)));
+ TaskImpl orgNode = new TaskImpl(null, TaskType.None, "Task");
+ orgNode.addAssignment(new AssignmentImpl(AssignTime.Start, new ExpressionImpl("foo"), new PropertyImpl("propFoo", null)));
+ orgNode.addAssignment(new AssignmentImpl(AssignTime.End, new ExpressionImpl("bar"), new PropertyImpl("propBar", null)));
- ObjectName taskID = saveNode(orgTask);
+ ObjectName nodeID = saveNode(orgNode);
- Task wasTask = loadNode(taskID);
- List<Assignment> ass = wasTask.getAssignments();
+ Task wasNode = loadNode(TaskImpl.class, nodeID);
+ List<Assignment> ass = wasNode.getAssignments();
assertEquals(2, ass.size());
Assignment assOne = ass.get(0);
Assignment assTwo = ass.get(1);
@@ -125,7 +109,7 @@
assertEquals("bar", assTwo.getFrom().getExpressionBody());
assertEquals("propBar", assTwo.getTo().getName());
- deleteNode(wasTask);
+ deleteNode(wasNode);
}
public void testInOutFlows() throws Exception
@@ -140,8 +124,8 @@
ObjectName aID = saveNode(taskA);
ObjectName bID = saveNode(taskB);
- Task wasA = loadNode(aID);
- Task wasB = loadNode(bID);
+ Task wasA = loadNode(TaskImpl.class, aID);
+ Task wasB = loadNode(TaskImpl.class, bID);
SequenceFlow outFlowA = wasA.getOutFlow();
assertEquals("TaskB", outFlowA.getTargetName());
@@ -180,18 +164,18 @@
}
}
- TaskImpl orgTask = new TaskImpl(null, TaskType.None, "Task");
- orgTask.setExecutionHandler(ExecHandler.class);
+ TaskImpl orgNode = new TaskImpl(null, TaskType.None, "Task");
+ orgNode.setExecutionHandler(ExecHandler.class);
- ObjectName taskID = saveNode(orgTask);
+ ObjectName nodeID = saveNode(orgNode);
- Task wasTask = loadNode(taskID);
+ Task wasNode = loadNode(TaskImpl.class, nodeID);
- ExecutionHandler execHandler = wasTask.getExecutionHandler();
+ ExecutionHandler execHandler = wasNode.getExecutionHandler();
assertNotNull(execHandler);
assertTrue(execHandler instanceof ExecutionHandler);
- deleteNode(wasTask);
+ deleteNode(wasNode);
}
public void testSignalHandler() throws Exception
@@ -222,18 +206,18 @@
}
}
- TaskImpl orgTask = new TaskImpl(null, TaskType.None, "Task");
- orgTask.setSignalHandler(SigHandler.class);
+ TaskImpl orgNode = new TaskImpl(null, TaskType.None, "Task");
+ orgNode.setSignalHandler(SigHandler.class);
- ObjectName taskID = saveNode(orgTask);
+ ObjectName nodeID = saveNode(orgNode);
- Task wasTask = loadNode(taskID);
+ Task wasNode = loadNode(TaskImpl.class, nodeID);
- SignalHandler sigHandler = wasTask.getSignalHandler();
+ SignalHandler sigHandler = wasNode.getSignalHandler();
assertNotNull(sigHandler);
assertTrue(sigHandler instanceof SignalHandler);
- deleteNode(wasTask);
+ deleteNode(wasNode);
}
public void testFlowHandler() throws Exception
@@ -259,140 +243,89 @@
}
}
- TaskImpl orgTask = new TaskImpl(null, TaskType.None, "Task");
- orgTask.setFlowHandler(FlowHandlerImpl.class);
+ TaskImpl orgNode = new TaskImpl(null, TaskType.None, "Task");
+ orgNode.setFlowHandler(FlowHandlerImpl.class);
- ObjectName taskID = saveNode(orgTask);
+ ObjectName nodeID = saveNode(orgNode);
- Task wasTask = loadNode(taskID);
+ Task wasNode = loadNode(TaskImpl.class, nodeID);
- FlowHandler flowHandler = wasTask.getFlowHandler();
+ FlowHandler flowHandler = wasNode.getFlowHandler();
assertNotNull(flowHandler);
assertTrue(flowHandler instanceof FlowHandler);
- deleteNode(wasTask);
+ deleteNode(wasNode);
}
public void testInputSet() throws Exception
{
- TaskImpl orgTask = new TaskImpl(null, TaskType.None, "Task");
+ TaskImpl orgNode = new TaskImpl(null, TaskType.None, "Task");
InputSetImpl inSetOne = new InputSetImpl();
inSetOne.addProperty("oneName", "oneValue");
- orgTask.addInputSet(inSetOne);
+ orgNode.addInputSet(inSetOne);
InputSetImpl inSetTwo = new InputSetImpl();
inSetTwo.addProperty("twoName", "twoValue");
- orgTask.addInputSet(inSetTwo);
+ orgNode.addInputSet(inSetTwo);
- ObjectName taskID = saveNode(orgTask);
+ ObjectName nodeID = saveNode(orgNode);
- Task wasTask = loadNode(taskID);
+ Task wasNode = loadNode(TaskImpl.class, nodeID);
- List<InputSet> inSets = wasTask.getInputSets();
+ List<InputSet> inSets = wasNode.getInputSets();
assertEquals(2, inSets.size());
InputSet wasOne = inSets.get(0);
assertEquals("oneValue", wasOne.getProperty("oneName").getValue());
InputSet wasTwo = inSets.get(1);
assertEquals("twoValue", wasTwo.getProperty("twoName").getValue());
- deleteNode(wasTask);
+ deleteNode(wasNode);
}
public void testOutputSet() throws Exception
{
- TaskImpl orgTask = new TaskImpl(null, TaskType.None, "Task");
+ TaskImpl orgNode = new TaskImpl(null, TaskType.None, "Task");
OutputSetImpl outSetOne = new OutputSetImpl();
outSetOne.addProperty("oneName", "oneValue");
- orgTask.addOutputSet(outSetOne);
+ orgNode.addOutputSet(outSetOne);
OutputSetImpl outSetTwo = new OutputSetImpl();
outSetTwo.addProperty("twoName", "twoValue");
- orgTask.addOutputSet(outSetTwo);
+ orgNode.addOutputSet(outSetTwo);
- ObjectName taskID = saveNode(orgTask);
+ ObjectName nodeID = saveNode(orgNode);
- Task wasTask = loadNode(taskID);
+ Task wasNode = loadNode(TaskImpl.class, nodeID);
- List<OutputSet> outSets = wasTask.getOutputSets();
+ List<OutputSet> outSets = wasNode.getOutputSets();
assertEquals(2, outSets.size());
OutputSet wasOne = outSets.get(0);
assertEquals("oneValue", wasOne.getProperty("oneName").getValue());
OutputSet wasTwo = outSets.get(1);
assertEquals("twoValue", wasTwo.getProperty("twoName").getValue());
- deleteNode(wasTask);
+ deleteNode(wasNode);
}
public void testIORules() throws Exception
{
- TaskImpl orgTask = new TaskImpl(null, TaskType.None, "Task");
- orgTask.addIORule(new ExpressionImpl("ioOne"));
- orgTask.addIORule(new ExpressionImpl("ioTwo"));
+ TaskImpl orgNode = new TaskImpl(null, TaskType.None, "Task");
+ orgNode.addIORule(new ExpressionImpl("ioOne"));
+ orgNode.addIORule(new ExpressionImpl("ioTwo"));
- ObjectName taskID = saveNode(orgTask);
+ ObjectName nodeID = saveNode(orgNode);
- Task wasTask = loadNode(taskID);
+ Task wasNode = loadNode(TaskImpl.class, nodeID);
- List<Expression> rules = wasTask.getIORules();
+ List<Expression> rules = wasNode.getIORules();
assertEquals(2, rules.size());
Expression wasOne = rules.get(0);
assertEquals("ioOne", wasOne.getExpressionBody());
Expression wasTwo = rules.get(1);
assertEquals("ioTwo", wasTwo.getExpressionBody());
- deleteNode(wasTask);
+ deleteNode(wasNode);
}
-
- private ObjectName saveNode(Node node)
- {
- Session session = service.createSession();
- Transaction tx = session.beginTransaction();
- try
- {
- service.saveNode(session, node);
- tx.commit();
-
- return node.getKey();
- }
- finally
- {
- session.close();
- }
- }
-
- private Task loadNode(ObjectName nodeID)
- {
- Session session = service.createSession();
- try
- {
- Task task = service.loadNode(session, TaskImpl.class, nodeID);
- Hibernate.initialize(task);
- return task;
- }
- finally
- {
- session.close();
- }
- }
-
- private void deleteNode(Node node)
- {
- Session session = service.createSession();
- Transaction tx = session.beginTransaction();
- try
- {
- service.deleteNode(session, node);
- tx.commit();
- }
- catch(StaleStateException ex)
- {
- // ignore, because the node was already deleted by a cascade
- }
- finally
- {
- session.close();
- }
- }
}
Added: projects/spec/trunk/modules/ri/src/test/java/org/jbpm/test/ri/service/persistence/UserTaskPersistenceTest.java
===================================================================
--- projects/spec/trunk/modules/ri/src/test/java/org/jbpm/test/ri/service/persistence/UserTaskPersistenceTest.java (rev 0)
+++ projects/spec/trunk/modules/ri/src/test/java/org/jbpm/test/ri/service/persistence/UserTaskPersistenceTest.java 2008-10-10 10:57:20 UTC (rev 2525)
@@ -0,0 +1,70 @@
+/*
+ * 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.test.ri.service.persistence;
+
+// $Id$
+
+import javax.management.ObjectName;
+
+import org.jbpm.api.model.Message;
+import org.jbpm.api.model.UserTask;
+import org.jbpm.api.model.Task.TaskType;
+import org.jbpm.ri.model.MessageImpl;
+import org.jbpm.ri.model.UserTaskImpl;
+
+/**
+ * Test the HibernatePersistenceService for UserTasks
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 10-Oct-2008
+ */
+public class UserTaskPersistenceTest extends NodePersistenceTest
+{
+ public void testUserTask() throws Exception
+ {
+ UserTaskImpl orgNode = new UserTaskImpl(null, "Task");
+
+ MessageImpl outMsg = new MessageImpl("outMsg");
+ outMsg.addProperty("outProp", "outVal");
+ orgNode.setOutMessageRef(outMsg);
+
+ MessageImpl inMsg = new MessageImpl("inMsg");
+ inMsg.addProperty("inProp", "inVal");
+ orgNode.setInMessageRef(inMsg);
+
+ ObjectName nodeID = saveNode(orgNode);
+
+ UserTask wasNode = loadNode(UserTaskImpl.class, nodeID);
+ assertEquals("Task", wasNode.getName());
+ assertEquals(TaskType.User, wasNode.getTaskType());
+
+ Message wasOut = wasNode.getOutMessageRef();
+ assertEquals("outMsg", wasOut.getName());
+ assertEquals("outVal", wasOut.getProperty("outProp").getValue());
+
+ Message wasIn = wasNode.getInMessageRef();
+ assertEquals("inMsg", wasIn.getName());
+ assertEquals("inVal", wasIn.getProperty("inProp").getValue());
+
+ deleteNode(wasNode);
+ }
+}
Property changes on: projects/spec/trunk/modules/ri/src/test/java/org/jbpm/test/ri/service/persistence/UserTaskPersistenceTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
More information about the jbpm-commits
mailing list