JBoss JBPM SVN: r6025 - jbpm4/trunk/modules/devguide/src/main/docbook/en/modules.
by do-not-reply@jboss.org
Author: jbarrez
Date: 2009-12-22 14:31:50 -0500 (Tue, 22 Dec 2009)
New Revision: 6025
Modified:
jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch03-Bpmn2.xml
Log:
Went over the BPMN 2.0 documentation and changed text where deemed necessary
Modified: jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch03-Bpmn2.xml
===================================================================
--- jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch03-Bpmn2.xml 2009-12-22 18:05:27 UTC (rev 6024)
+++ jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch03-Bpmn2.xml 2009-12-22 19:31:50 UTC (rev 6025)
@@ -8,12 +8,12 @@
<title>What is BPMN 2.0?</title>
<para>
- The Business Process Modeling Notation (BPMN) is a standard for a
- graphical notation of business processes models. The standard is
- maitained by the Object Management Group (OMG)
+ The Business Process Modeling Notation (BPMN) is a standard for the
+ graphical notation of business process models. The standard is
+ maitained by the Object Management Group (OMG).
</para>
<para>
- Basically, the BPMN spec defines how a task must look like, which constructs can
+ Basically, the BPMN specification defines how a task must look like, which constructs can
be connected to each other, etc. in a meaning that cannot be
misinterpreted.
</para>
@@ -27,14 +27,14 @@
symbols.
</para>
<para>
- Version 2.0 of the BPMN specification, which is currently in beta phase and is
- scheduled to be finalized in June 2010, allows to add precise technical
+ Version 2.0 of the BPMN specification, which is currently in finalization phase and is
+ scheduled to be finished soon, allows to add precise technical
details to the shapes and symbols available in BPMN and at the same
time specify what the execution semantics of BPMN 'elements' are. By
using an XML language to specify the executable semantics of a business
process, the BPMN specification has evolved into a language for
business processes that can be executed on any BPMN2 compliant process
- engine - while still having the powerful graphical notations.
+ engine - while still having the powerful graphical notation.
</para>
</section>
@@ -50,8 +50,8 @@
incorporate parts of the BPMN2 spec would be jBPM 4.3.
</para>
<para>
- The goal of this effort is to build a native BPMN2 runtime engine (or
- better said implementing 'BPMN2 exectuable') leveraging the Process
+ The goal of this effort is to build a <emphasis role="bold">native BPMN2 runtime engine </emphasis>
+ (or better said implementing 'BPMN2 exectuable') leveraging the Process
Virtual Machine (PVM).
Do note that the primary focus of this release is native executability,
not the graphical notation - but we recognize its importance for
@@ -60,11 +60,10 @@
<para>
<emphasis role="bold">
- One of the goals of the BPMN2 implementation is to have an experience and usage which
- is comparable to the that of JPDL. User who are already familiar with jBPM will find that
+ Users who are already familiar with jBPM will find that
<itemizedlist>
<listitem>the configuration mechanism remains unchanged</listitem>
- <listitem>the API is the same of very similar to the existing one</listitem>
+ <listitem>the API is the same or very similar to the existing one</listitem>
<listitem>testing BPMN2 process still can be done with regular Java testing frameworks</listitem>
<listitem>the database schema remains unchanged</listitem>
</itemizedlist>
@@ -81,7 +80,7 @@
<para>
One of the first questions that might, rightfully, come to mind is why
- BPMN2 is being implemented while there is jPDL. Both are languages that
+ BPMN2 is being implemented while there is jPDL. Both are languages
have as goal to define executable business processes. From a high-level
technical point of view, both languages are equivalent. The main
distinction is that BPMN2 is as vendor-neutral as you can have with
@@ -106,7 +105,7 @@
<listitem>BPMN2 is implementation-unaware. The downside of this is that
integrating with Java technology will always be easier with JPDL. So,
from a Java developer's perspective JPDL is simpler and feels more
- natural (some of the 'layers' of BPEL/WSDL are in BPMN as well)</listitem>
+ natural (some of the 'layers' of BPEL/WSDL are in BPMN as well).</listitem>
<listitem>A focus of JPDL is XML readability. BPMN2 processes will still be
readable to a certain level, but tooling or a more detailed knowledge
of the spec will definitely be required to achieve the same level of
@@ -116,7 +115,7 @@
the language itself overly complicated.</listitem>
<listitem>BPMN2 contains a large set of constructs described in the
specification. However, the "binding" of interfaces to code is left
- open in the spec (comparable with XPDL), even is WDSL is considered the
+ open in the spec (comparable with XPDL), even if WDSL is often considered the
default. This means that a process portability can be lost when porting
the process to an engine that doesn't support the same binding
mechanism. Calling Java classes for example is already going to be such
@@ -161,7 +160,7 @@
model simple business processes.</listitem>
<listitem><emphasis role="bold">Advanced</emphasis>: contains more powerful or
expressive constructs, but this comes with higher modeling and execution semantics
- learning curve. 80% of the business processes are implementable with constructs from this
+ learning curve. The majority of business processes are implementable with constructs from this
and the previous category.</listitem>
<listitem><emphasis role="bold">Complex</emphasis>: constructs in this category are
used in specific and/or rare cases, or their semantics are difficult to understand.</listitem>
@@ -220,7 +219,7 @@
The root of an BPMN 2.0 XML process is the <emphasis role="bold">definitions</emphasis>
elements. As the name states, the subelements will contain the actual definitions of
the business process(es). Every <emphasis role="bold">process</emphasis> child
- will be able to have an <emphasis role="bold">id</emphasis>
+ will be able to have an <emphasis role="bold">id</emphasis> and
<emphasis role="bold">name</emphasis>. An empty business process in BPMN 2.0
looks as follows. Also note that it is handy to have the BPMN2.xsd on the classpath, to
enable XML completion.
@@ -233,7 +232,12 @@
expressionLanguage="http://www.w3.org/1999/XPath"
targetNamespace="http://jbpm.org/example/bpmn2">
- <process id="myBusinessProcess" name="My business processs">
+ <process id="myBusinessProcess" name="My business processs">
+
+ ...
+
+ </process>
+<definitions>
</programlisting>
If an id is defined for a process element, it will be used as business key for that
process (ie. starting a process can be done by calling executionService.startProcessInstanceByKey("myBusinessProcess"),
@@ -253,9 +257,9 @@
<para>
Together with activitites and gateways, events are used in practically every business process.
Events allow process modelers to describe business processes in a very natural way, such as
- <emphasis role="italic">'This process starts when I receive a customer order'</emphasis>,
- <emphasis role="italic">'If the task is not finished in 2 days, terminate the process'</emphasis>
- or <emphasis role="italic">'When I receive a cancel e-mail when the process is running,
+ <emphasis>'This process starts when I receive a customer order'</emphasis>,
+ <emphasis>'If the task is not finished in 2 days, terminate the process'</emphasis>
+ or <emphasis>'When I receive a cancel e-mail when the process is running,
handle the e-mail using this sub-process'</emphasis>. Notice that typical businesses
always work in a very event-driven way. People are not hard-coded sequential creatures,
but they tend to react on things that happen in their environment (ie. events).
@@ -324,16 +328,16 @@
<para>
The corresponding executable XML for this process looks like this (omitting the
- <emphasis role="italic">definitions</emphasis> root element for clarity)
+ <emphasis>definitions</emphasis> root element for clarity)
<programlisting>
<process id="noneStartEndEvent" name="BPMN2 Example none start and end event">
- <startEvent id="start" />
+ <emphasis role="bold"><startEvent id="start" /></emphasis>
<sequenceFlow id="flow1" name="fromStartToEnd"
sourceRef="start" targetRef="end" />
- <endEvent id="end" name="End" />
+ <emphasis role="bold"><endEvent id="end" name="End" /></emphasis>
</process>
</programlisting>
@@ -365,16 +369,16 @@
A terminate end event is defined as follows. An id is required, a name is optional.
<programlisting>
<endEvent id="terminateEnd" name="myTerminateEnd">
- <terminateEventDefinition/>
+ <emphasis role="bold"><terminateEventDefinition/></emphasis>
</endEvent>
</programlisting>
</para>
<para>
- A terminate end event is depicted as a typical end event (circle with thick border),
+ A terminate end event is depicted as an end event (circle with thick border),
with a full circle as icon inside. In the following example, completing the 'task1'
will end the process instance, while completing the 'task2' will only end the path
- of execution which enters the end event.
+ of execution which enters the end event, leaving the task1 open.
<mediaobject><imageobject><imagedata align="center" fileref="images/bpmn2.terminate.end.event.example.png"/></imageobject></mediaobject>
See the examples shipped with the jBPM distribution for the unit test and XML counterpart
of this business process.
@@ -417,23 +421,22 @@
${}</emphasis>.
<programlisting>
<sequenceFlow id=....>
- <conditionExpression xsi:type="tFormalExpression">${amount >= 500} />
+ <emphasis role="bold"><conditionExpression xsi:type="tFormalExpression">${amount >= 500} /></emphasis>
</sequenceFlow>
</programlisting>
Note that is currently is necessary to add the <emphasis role="bold">
xsi:type="tFormalExpression"</emphasis> to the <emphasis role="bold">
- conditionExpression</emphasis>. This is not 100% BPMN specification compliant, but we'll
- work this out in a next release.
+ conditionExpression</emphasis>. This can change in a future release.
</para>
<para>
Activities (such as the user task) and gateways (such as the exclusive gateway) can have a
default sequence flow. This default sequence flow is taken only when all the other outgoing
sequence flow from an activity or gateway have a condition that evaluate to false. A
- default sequence flow is graphically visualized as a sequence flow with a 'slash marker".
+ default sequence flow is graphically visualized as a sequence flow with a 'slash marker'.
<mediaobject><imageobject><imagedata align="center" fileref="images/bpmn2.default.sequence.flow.png"/></imageobject></mediaobject>
The default sequence flow is specified by filling in the <emphasis role="bold">'default'
- </emphasis> attribute of the activity or gateway.
+ attribute </emphasis> of the activity or gateway.
</para>
<para>
@@ -448,7 +451,7 @@
<para>
A gateway in BPMN is used to control the flow through the process. More specifically,
- when a token (the BPMN 2.0 conceptual notion of an execution) arrives in a gateway, they can be merged
+ when a token (the BPMN 2.0 conceptual notion of an execution) arrives in a gateway, it can be merged
or split depending on the gateway type.
</para>
@@ -488,7 +491,7 @@
know which type of behaviour a certain gateway has (for example for a parallel gateway if
we have joining of forking behaviour). However, the 'gatewayDirection' attribute is used at parsing
time as a constraint check for the incoming/outgoing sequence flow. So using this
- attirbute will lower the chance on errors in reference for sequence flow, but is not
+ attribute will lower the chance on errors when referencing sequence flow, but is not
required.
</para>
@@ -506,7 +509,7 @@
<para>
The corresponding JPDL construct with the same semantics is the
- <emphasis role="bold"><decision></emphasis> activity. The full technical name of the
+ <emphasis role="bold">decision</emphasis> activity. The full technical name of the
exclusive gateway is the <emphasis role="bold">'exclusive data-based gateway'</emphasis>,
but it is also often called the <emphasis role="bold">XOR Gateway</emphasis>.
The XOR gateway is depicted as a diamond with a 'X' icon inside. An empty diamond
@@ -531,21 +534,27 @@
<sequenceFlow id="flow1" name="fromStartToExclusiveGateway"
sourceRef="start" targetRef="decideBasedOnAmountGateway" />
- <exclusiveGateway id="decideBasedOnAmountGateway" name="decideBasedOnAmount" />
+ <emphasis role="bold"><exclusiveGateway id="decideBasedOnAmountGateway" name="decideBasedOnAmount" /></emphasis>
<sequenceFlow id="flow2" name="fromGatewayToEndNotEnough"
sourceRef="decideBasedOnAmountGateway" targetRef="endNotEnough">
- <conditionExpression xsi:type="tFormalExpression">${amount < 100}</conditionExpression>
+ <emphasis role="bold"><conditionExpression xsi:type="tFormalExpression">
+ ${amount < 100}
+ </conditionExpression></emphasis>
</sequenceFlow>
<sequenceFlow id="flow3" name="fromGatewayToEnEnough"
sourceRef="decideBasedOnAmountGateway" targetRef="endEnough">
- <conditionExpression xsi:type="tFormalExpression">${amount <= 500 && amount >= 100}</conditionExpression>
+ <emphasis role="bold"><conditionExpression xsi:type="tFormalExpression">
+ ${amount <= 500 && amount >= 100}
+ </conditionExpression></emphasis>
</sequenceFlow>
<sequenceFlow id="flow4" name="fromGatewayToMoreThanEnough"
sourceRef="decideBasedOnAmountGateway" targetRef="endMoreThanEnough">
- <conditionExpression xsi:type="tFormalExpression">${amount > 500}</conditionExpression>
+ <emphasis role="bold"><conditionExpression xsi:type="tFormalExpression">
+ ${amount > 500}
+ </conditionExpression></emphasis>
</sequenceFlow>
<endEvent id="endNotEnough" name="not enough" />
@@ -556,7 +565,7 @@
</process>
</programlisting>
- This process needs a variable such that the expression can be evauluated at runtime.
+ This process needs a variable such that the expression can be evaluated at runtime.
Variables can be provided when starting the process instance (similar to JPDL):
<programlisting>
Map<String, Object> vars = new HashMap<String, Object>();
@@ -567,13 +576,12 @@
<para>
The exclusive gateway requires that all outgoing sequence flow have conditions defined
- on them. An exception to this rule is the default sequence flow, as defined above.
- The exclusive gateway also has a shortcut attribute to define such a default sequence flow.
+ on them. An exception to this rule is the default sequence flow.
Use the <emphasis role="bold">default attribute</emphasis> to reference an existing
<emphasis role="bold">id of a sequence flow</emphasis>. This sequence flow will be taken
when the conditions on the other outgoing sequence flow all evaluate to false.
<programlisting>
-<exclusiveGateway id="decision" name="decideBasedOnAmountAndBankType" default="myFlow"/>
+<exclusiveGateway id="decision" name="decideBasedOnAmountAndBankType" <emphasis role="bold">default="myFlow"</emphasis>/>
<sequenceFlow id="myFlow" name="fromGatewayToStandard"
sourceRef="decision" targetRef="standard">
@@ -614,7 +622,7 @@
</para>
<para>
- The following diagrom shows how a parallel gateway can be used. After process start,
+ The following diagram shows how a parallel gateway can be used. After process start,
both the 'prepare shipment' and 'bill customer' user tasks will be active.
The parallel gateway is depicted as a diamond shape with a plus icon inside, both for the
splitting and joining behaviour.
@@ -629,8 +637,8 @@
sourceRef="Start"
targetRef="parallelGatewaySplit" />
- <parallelGateway id="parallelGatewaySplit" name="Split"
- gatewayDirection="diverging"/>
+ <emphasis role="bold"><parallelGateway id="parallelGatewaySplit" name="Split"
+ gatewayDirection="diverging"/></emphasis>
<sequenceFlow id="flow2a" name="Leg 1"
sourceRef="parallelGatewaySplit"
@@ -654,8 +662,8 @@
sourceRef="billCustomer"
targetRef="parallelGatewayJoin" />
- <parallelGateway id="parallelGatewayJoin" name="Join"
- gatewayDirection="converging"/>
+ <emphasis role="bold"><parallelGateway id="parallelGatewayJoin" name="Join"
+ gatewayDirection="converging"/></emphasis>
<sequenceFlow id="flow4"
sourceRef="parallelGatewayJoin"
@@ -675,8 +683,7 @@
<title>Tasks</title>
<para>
- A BPMN task is a so-called 'atomic' activity, meaning that it cannot be broken into
- more detailed constructs. A task represents work that needs to be done by an external
+ A task represents work that needs to be done by an external
entity, such as a human actor or an automated service.
</para>
@@ -686,7 +693,7 @@
type of work. When the process engine encounters a task in JPDL, it will create a task in some human
actor's task list and it will behave as a wait state. In BPMN 2.0 however, there are several
task types, some indicating a wait state (eg. the <emphasis role="bold">User Task</emphasis>
- and some indicating an automatic activity (eg. the <emphasis role="bold">Service Task</emphasis>.
+ and some indicating an automatic activity (eg. the <emphasis role="bold">Service Task</emphasis>).
So take good care not to confuse the meaning of the task concept when switching languages.
</para>
@@ -713,10 +720,11 @@
<para>
Defining a service task requires quite a few lines of XML (the BPEL influence is certainly
- visible). Of course, in the near future, we expect that tooling will simplify this area
+ visible here). Of course, in the near future, we expect that tooling will simplify this area
a lot. A service task is defined as follows:
<programlisting>
-<serviceTask id="MyServiceTask" name="My service task" implementation="Other" operationRef="myOperation" />
+<serviceTask id="MyServiceTask" name="My service task"
+ implementation="Other" operationRef="myOperation" />
</programlisting>
The service task has a required <emphasis role="bold">id</emphasis> and an optional
<emphasis role="bold">name</emphasis>. The <emphasis role="bold">implementation</emphasis>
@@ -729,7 +737,7 @@
The service task will invoke a certain operation that is referenced by the
<emphasis role="bold">operationRef</emphasis> attribute using the id of an
<emphasis role="bold">operation</emphasis>. Such an operation is part of an
- <emphasis role="bold">interface</emphasis> as shown below. Every operations has
+ <emphasis role="bold">interface</emphasis> as shown below. Every operation has
at least one <emphasis role="bold">input message</emphasis> and at most one
<emphasis role="bold">output message</emphasis>.
<programlisting>
@@ -747,7 +755,7 @@
that must be called. The input/output message that represent the parameters/return value of
the Java method are defined as follows:
<programlisting>
-<message id="inputMessag" name="input message" structureRef="myItemDefinition1" />
+<message id="inputMessage" name="input message" structureRef="myItemDefinition1" />
</programlisting>
Several elements in BPMN are so-called 'item-aware', including this message construct.
This means that they are involved in storing or reading items during process execution.
@@ -768,7 +776,7 @@
</itemDefinition>
</programlisting>
- Do note that this is not standard BPMN 2.0 as by the specification (hence the 'jbpm' prefix).
+ Do note that this is not fully standard BPMN 2.0 as by the specification (hence the 'jbpm' prefix).
In fact, according to the specification, the ItemDefinition shouldn't contain more
than a data structure definition. The actual mapping between input paramaters, with a ceratin
data structure, is done in the <emphasis role="bold">ioSpecification</emphasis> section
@@ -779,7 +787,7 @@
<para>
<emphasis role="bold">Important note: Interfaces, ItemDefinitions and messages are
- defined outside the <process>.</emphasis> See the example <emphasis role="bold">
+ defined outside a <process>.</emphasis> See the example <emphasis role="bold">
ServiceTaskTest</emphasis> for a concrete process and unit test.
</para>
@@ -806,8 +814,8 @@
scriptLanguage</emphasis> and a <emphasis role="bold">script</emphasis>.
Since we're using JSR-223 ('Scripting for the Java platform'), changing the script language involves
<itemizedlist>
- <listitem>changing the scriptLanguage attribute to the JSR-223 compliant name</listitem>
- <listitem>adding the ScriptEngine implementation of the specification to the classpath</listitem>
+ <listitem>changing the <emphasis role="bold">scriptLanguage</emphasis> attribute to the JSR-223 compliant name</listitem>
+ <listitem>adding the ScriptEngine implementation of the JSR specification to the classpath</listitem>
</itemizedlist>
The XML above is visualized as follows (adding a none start and end event).
</para>
@@ -815,12 +823,13 @@
<mediaobject><imageobject><imagedata align="center" fileref="images/bpmn2.script.task.png"/></imageobject></mediaobject>
<para>
- As shown in the example, process variables are usable inside the scripts. We can now start
- a process instance, while also supplying some random input variables:
+ As shown in the example, process variables can be used inside the scripts. We can now start
+ a process instance for this example process, while also supplying some random input variables:
<programlisting>
Map<String, Object> variables = new HashMap<String, Object>();
Integer[] values = { 11, 23, 56, 980, 67543, 8762524 };
-variables.put("input", values);
+variables.put("input", values);
+executionService.startProcessInstanceBykey("scriptTaskExample", variables);
</programlisting>
In the output console, we can now see the script being executed:
<programlisting>
@@ -865,7 +874,7 @@
<para>
A <emphasis role="bold">receive task</emphasis> is a task that waits for the arrival of
an external message. Besides the obvious use case involving webservices, the specification
- is liberal in what to do in other environment. The web service use case is not yet
+ is liberal in what to do in other environments. The web service use case is not yet
implemented, but the receive task can already be used in a Java environment.
</para>
@@ -1008,7 +1017,7 @@
</programlisting>
The mechanism regarding task forms for BPMN 2.0 is complete equivalent to that of JPDL.
The form itself is a <ulink url="http://freemarker.org/">Freemarker</ulink> template file
- that needs to be incorporated in the deployment. For example, the 'verify_request' form
+ that needs to be incorporated in the deployment. For example, the 'verify_request.ftl' form
looks like as follows.
<programlisting>
<html>
@@ -1016,23 +1025,23 @@
<form action="${form.action}" method="POST" enctype="multipart/form-data">
- <h3>Your employee, ${employee_name} would like to go on vacation</h3>
- Number of days: ${number_of_days}<br/>
+ <h3>Your employee, <emphasis role="bold">${employee_name}</emphasis> would like to go on vacation</h3>
+ Number of days: <emphasis role="bold">${number_of_days}<</emphasis>br/>
<hr>
In case you reject, please provide a reason:<br/>
- <input type="textarea" name="reason"/><br/>
+ <emphasis role="bold"><input type="textarea" name="reason"/><br/></emphasis>
- <input type="submit" name="verificationResult" value="OK">
- <input type="submit" name="verificationResult" value="Not OK">
+ <emphasis role="bold"><input type="submit" name="verificationResult" value="OK">
+ <input type="submit" name="verificationResult" value="Not OK"></emphasis>
</form>
</body>
</html>
</programlisting>
Note that <emphasis role="bold">process variables can be
- used using the ${my_process_variable} construct.</emphasis> Also note that named
+ accessed using the ${my_process_variable} construct.</emphasis> Also note that named
input controls (eg. input field, submit button) can be used to
<emphasis role="bold">define new process variables</emphasis>.
For example, the text input of the following field will be stored as the process
@@ -1048,7 +1057,7 @@
<sequenceFlow id="flow3" name="fromVerifyRequestToEnd"
sourceRef="verifyRequest" targetRef="theEnd">
<conditionExpression xsi:type="tFormalExpression">
- ${verificationResult == 'OK'}
+ <emphasis role="bold">${verificationResult == 'OK'}</emphasis>
</conditionExpression>
</sequenceFlow>
</programlisting>
14 years, 4 months
JBoss JBPM SVN: r6022 - in jbpm4/trunk: modules/test-base/src/main/java/org/jbpm/test and 11 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-12-22 12:49:40 -0500 (Tue, 22 Dec 2009)
New Revision: 6022
Added:
jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JmsExtensions.java
jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JmsTopicListener.java
jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/jms/JmsQueueTest.java
jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/jms/JmsTopicTest.java
jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/jms/queueprocess.jpdl.xml
jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/jms/topicprocess.jpdl.xml
jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/java/org/jbpm/test/jms/QueueMapMessageTest.java
jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/java/org/jbpm/test/jms/QueueObjectMessageTest.java
jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/java/org/jbpm/test/jms/QueueTextMessageTest.java
jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/resources/org/jbpm/test/jms/queue.map.process.jpdl.xml
jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/resources/org/jbpm/test/jms/queue.object.process.jpdl.xml
jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/resources/org/jbpm/test/jms/queue.text.process.jpdl.xml
jbpm4/trunk/qa/debug.enterprise.setup.bat
jbpm4/trunk/qa/debug.jboss.setup.bat
jbpm4/trunk/qa/enterprise/
jbpm4/trunk/qa/enterprise/jbpm-test-destinations-service.xml
Removed:
jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/MockRunnerExtensions.java
jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/jms/JmsTest.java
jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/jms/process.jpdl.xml
jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/java/org/jbpm/test/jms/JbpmJmsTestCase.java
jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/java/org/jbpm/test/jms/map/
jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/java/org/jbpm/test/jms/object/
jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/java/org/jbpm/test/jms/text/
jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/resources/jbpm-test-destinations-service.xml
jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/resources/org/jbpm/test/jms/map/process.jpdl.xml
jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/resources/org/jbpm/test/jms/object/process.jpdl.xml
jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/resources/org/jbpm/test/jms/text/process.jpdl.xml
jbpm4/trunk/qa/debug.on.jboss.setup.bat
Modified:
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JmsActivity.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JmsBinding.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JpdlBinding.java
jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JbpmTestCase.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/timer/TaskTimerTaskTest.java
jbpm4/trunk/qa/build.xml
Log:
JBPM-2695 added jms testing and udpates
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JmsActivity.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JmsActivity.java 2009-12-22 16:59:58 UTC (rev 6021)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JmsActivity.java 2009-12-22 17:49:40 UTC (rev 6022)
@@ -24,6 +24,7 @@
import java.io.Serializable;
import java.util.List;
+import javax.jms.Destination;
import javax.jms.MapMessage;
import javax.jms.Message;
import javax.jms.ObjectMessage;
@@ -34,6 +35,11 @@
import javax.jms.QueueSession;
import javax.jms.Session;
import javax.jms.TextMessage;
+import javax.jms.Topic;
+import javax.jms.TopicConnection;
+import javax.jms.TopicConnectionFactory;
+import javax.jms.TopicPublisher;
+import javax.jms.TopicSession;
import javax.naming.InitialContext;
import org.jbpm.api.JbpmException;
@@ -60,44 +66,90 @@
protected MapDescriptor mapDescriptor = null;
protected String connectionFactoryName = null;
protected String destinationName = null;
+ protected boolean transacted = true;
+ protected int acknowledgeMode = Session.AUTO_ACKNOWLEDGE;
public void perform(OpenExecution execution) {
try {
InitialContext initialContext = new InitialContext();
- QueueConnectionFactory connectionFactory = (QueueConnectionFactory) initialContext.lookup(connectionFactoryName);
- QueueConnection queueConnection = connectionFactory.createQueueConnection();
+ Destination destination = (Destination) initialContext.lookup(destinationName);
+ if (destination instanceof Queue) {
+ QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory) initialContext.lookup(connectionFactoryName);
+ sendToQueue((Queue) destination, queueConnectionFactory);
+
+ } else if (destination instanceof Topic) {
+ TopicConnectionFactory topicConnectionFactory = (TopicConnectionFactory) initialContext.lookup(connectionFactoryName);
+ sendToTopic((Topic) destination, topicConnectionFactory);
+
+ } else {
+ throw new JbpmException("invalid destination type for '"+destinationName+"': "+destination.getClass().getName());
+ }
+
+ } catch (Exception e) {
+ logAndRethrow(e);
+ }
+ }
+
+ private void sendToQueue(Queue queue, QueueConnectionFactory queueConnectionFactory) throws Exception {
+ QueueConnection queueConnection = queueConnectionFactory.createQueueConnection();
+ try {
+
+ QueueSession queueSession = queueConnection.createQueueSession(transacted, acknowledgeMode);
try {
- QueueSession queueSession = queueConnection.createQueueSession(true, Session.AUTO_ACKNOWLEDGE);
+ QueueSender queueSender = queueSession.createSender(queue);
try {
+ Message message = createMessage(queueSession);
+ queueSender.send(message);
- Queue queue = (Queue) initialContext.lookup(destinationName);
- QueueSender queueSender = queueSession.createSender(queue);
- try {
- Message message = createMessage(queueSession);
- queueSender.send(message);
-
- } catch (Exception e) {
- logAndRethrow(e);
- } finally {
- queueSender.close();
- }
+ } catch (Exception e) {
+ logAndRethrow(e);
+ } finally {
+ queueSender.close();
+ }
+ } catch (Exception e) {
+ logAndRethrow(e);
+ } finally {
+ queueSession.close();
+ }
+
+ } catch (Exception e) {
+ logAndRethrow(e);
+ } finally {
+ queueConnection.close();
+ }
+ }
+
+ private void sendToTopic(Topic topic, TopicConnectionFactory topicConnectionFactory) throws Exception {
+ TopicConnection topicConnection = topicConnectionFactory.createTopicConnection();
+ try {
+
+ TopicSession topicSession = topicConnection.createTopicSession(transacted, acknowledgeMode);
+ try {
+
+ TopicPublisher topicPublisher = topicSession.createPublisher(topic);
+ try {
+ Message message = createMessage(topicSession);
+ topicPublisher.send(message);
+
} catch (Exception e) {
logAndRethrow(e);
} finally {
- queueSession.close();
+ topicPublisher.close();
}
-
+
} catch (Exception e) {
logAndRethrow(e);
} finally {
- queueConnection.close();
+ topicSession.close();
}
-
+
} catch (Exception e) {
logAndRethrow(e);
+ } finally {
+ topicConnection.close();
}
}
@@ -155,24 +207,31 @@
public void setType(String type) {
this.type = type;
}
-
public void setText(String text) {
this.textExpression = text;
}
-
public void setExpression(String expression) {
this.objectExpression = expression;
}
-
public void setMapDescriptor(MapDescriptor mapDescriptor) {
this.mapDescriptor = mapDescriptor;
}
-
public void setConnectionFactoryName(String connectionFactoryName) {
this.connectionFactoryName = connectionFactoryName;
}
-
public void setDestinationName(String destinationName) {
this.destinationName = destinationName;
}
+ public boolean isTransacted() {
+ return transacted;
+ }
+ public void setTransacted(boolean transacted) {
+ this.transacted = transacted;
+ }
+ public int getAcknowledgeMode() {
+ return acknowledgeMode;
+ }
+ public void setAcknowledgeMode(int acknowledgeMode) {
+ this.acknowledgeMode = acknowledgeMode;
+ }
}
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JmsBinding.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JmsBinding.java 2009-12-22 16:59:58 UTC (rev 6021)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JmsBinding.java 2009-12-22 17:49:40 UTC (rev 6022)
@@ -21,6 +21,8 @@
*/
package org.jbpm.jpdl.internal.activity;
+import javax.jms.Session;
+
import org.jbpm.jpdl.internal.xml.JpdlParser;
import org.jbpm.pvm.internal.util.XmlUtil;
import org.jbpm.pvm.internal.wire.Descriptor;
@@ -31,62 +33,77 @@
/**
* @author Koen Aers
*/
-public class JmsBinding extends JpdlBinding
-{
+public class JmsBinding extends JpdlBinding {
public static final String TAG = "jms";
- public JmsBinding()
- {
+ public JmsBinding() {
super(TAG);
}
- protected JmsBinding(String tagName)
- {
+ protected JmsBinding(String tagName) {
super(tagName);
}
- public Object parseJpdl(Element element, Parse parse, JpdlParser parser)
- {
+ public Object parseJpdl(Element element, Parse parse, JpdlParser parser) {
JmsActivity jmsActivity = createJmsActivity();
+ // attributes /////////////////////////////////////////////////////////////
+
+ String connectionFactoryName = XmlUtil.attribute(element, "connection-factory", true, parse);
+ jmsActivity.setConnectionFactoryName(connectionFactoryName);
+
+ String destinationName = XmlUtil.attribute(element, "destination", true, parse);
+ jmsActivity.setDestinationName(destinationName);
+
+ Boolean transacted = XmlUtil.attributeBoolean(element, "transacted", false, parse, null);
+ if (transacted != null) {
+ jmsActivity.setTransacted(transacted);
+ }
+
+ String acknowledge = XmlUtil.attribute(element, "acknowledge");
+ if (acknowledge != null) {
+ if (acknowledge.equalsIgnoreCase("auto")) {
+ jmsActivity.setAcknowledgeMode(Session.AUTO_ACKNOWLEDGE);
+ } else if (acknowledge.equalsIgnoreCase("client")) {
+ jmsActivity.setAcknowledgeMode(Session.CLIENT_ACKNOWLEDGE);
+ } else if (acknowledge.equalsIgnoreCase("dups-ok")) {
+ jmsActivity.setAcknowledgeMode(Session.DUPS_OK_ACKNOWLEDGE);
+ } else {
+ parse.addProblem("unknown jms acknowledge: '"+acknowledge+"'", element);
+ }
+ }
+
+ // elements ///////////////////////////////////////////////////////////////
+
Element textElement = XmlUtil.element(element, "text", false, parse);
- if (textElement != null)
- {
+ if (textElement != null) {
String text = XmlUtil.getContentText(textElement);
jmsActivity.setType("text");
jmsActivity.setText(text);
}
Element objectElement = XmlUtil.element(element, "object", false, parse);
- if (objectElement != null)
- {
+ if (objectElement != null) {
jmsActivity.setType("object");
jmsActivity.setExpression(XmlUtil.attribute(objectElement, "expr"));
}
-
- Element mapElement = XmlUtil.element(element, "map", false, parse);
+
+ Element mapElement = XmlUtil.element(element, "map", false, parse);
if (mapElement != null) {
jmsActivity.setType("map");
Descriptor descriptor = parser.parseDescriptor(mapElement, parse);
- if (descriptor instanceof MapDescriptor) {
- jmsActivity.setMapDescriptor((MapDescriptor)descriptor);
+ if (descriptor instanceof MapDescriptor) {
+ jmsActivity.setMapDescriptor((MapDescriptor) descriptor);
} else {
parse.addProblem("the parser did not return a descriptor of type MapDescriptor");
}
}
- String connectionFactoryName = XmlUtil.attribute(element, "connection-factory", true, parse);
- jmsActivity.setConnectionFactoryName(connectionFactoryName);
-
- String destinationName = XmlUtil.attribute(element, "destination", true, parse);
- jmsActivity.setDestinationName(destinationName);
-
return jmsActivity;
}
- protected JmsActivity createJmsActivity()
- {
+ protected JmsActivity createJmsActivity() {
return new JmsActivity();
}
}
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JpdlBinding.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JpdlBinding.java 2009-12-22 16:59:58 UTC (rev 6021)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JpdlBinding.java 2009-12-22 17:49:40 UTC (rev 6022)
@@ -70,28 +70,30 @@
return true;
}
- public void parseTransitions(Element element, ActivityImpl activity, Parse parse, JpdlParser jpdlParser) {
- List<Element> transitionElements = XmlUtil.elements(element, "transition");
- UnresolvedTransitions unresolvedTransitions = parse.contextStackFind(UnresolvedTransitions.class);
- for (Element transitionElement: transitionElements) {
- String transitionName = XmlUtil.attribute(transitionElement, "name", false, parse);
-
- Element timerElement = XmlUtil.element(transitionElement, "timer");
- if (timerElement!=null) {
- if (transitionName!=null) {
- TimerDefinitionImpl timerDefinitionImpl = jpdlParser.parseTimerDefinition(timerElement, parse, activity);
- timerDefinitionImpl.setSignalName(transitionName);
- } else {
- parse.addProblem("a transition name is required when a timer is placed on a transition", element);
- }
- }
-
- TransitionImpl transition = activity.createOutgoingTransition();
- transition.setName(transitionName);
-
- unresolvedTransitions.add(transition, transitionElement);
-
- jpdlParser.parseOnEvent(transitionElement, parse, transition, Event.TAKE);
- }
- }
+// TODO remove this dead code
+//
+// public void parseTransitions(Element element, ActivityImpl activity, Parse parse, JpdlParser jpdlParser) {
+// List<Element> transitionElements = XmlUtil.elements(element, "transition");
+// UnresolvedTransitions unresolvedTransitions = parse.contextStackFind(UnresolvedTransitions.class);
+// for (Element transitionElement: transitionElements) {
+// String transitionName = XmlUtil.attribute(transitionElement, "name", false, parse);
+//
+// Element timerElement = XmlUtil.element(transitionElement, "timer");
+// if (timerElement!=null) {
+// if (transitionName!=null) {
+// TimerDefinitionImpl timerDefinitionImpl = jpdlParser.parseTimerDefinition(timerElement, parse, activity);
+// timerDefinitionImpl.setSignalName(transitionName);
+// } else {
+// parse.addProblem("a transition name is required when a timer is placed on a transition", element);
+// }
+// }
+//
+// TransitionImpl transition = activity.createOutgoingTransition();
+// transition.setName(transitionName);
+//
+// unresolvedTransitions.add(transition, transitionElement);
+//
+// jpdlParser.parseOnEvent(transitionElement, parse, transition, Event.TAKE);
+// }
+// }
}
Modified: jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JbpmTestCase.java
===================================================================
--- jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JbpmTestCase.java 2009-12-22 16:59:58 UTC (rev 6021)
+++ jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JbpmTestCase.java 2009-12-22 17:49:40 UTC (rev 6022)
@@ -25,6 +25,8 @@
import java.util.List;
import java.util.Set;
+import javax.jms.Session;
+
import org.jbpm.api.Configuration;
import org.jbpm.api.Execution;
import org.jbpm.api.ExecutionService;
@@ -104,14 +106,38 @@
}
}
- public void createQueue(String connectionFactoryJndiName, String queueJndiName) {
- MockRunnerExtensions.createQueue(connectionFactoryJndiName, queueJndiName);
+ public static void jmsCreateQueue(String connectionFactoryJndiName, String queueJndiName) {
+ JmsExtensions.createQueue(connectionFactoryJndiName, queueJndiName);
}
+
+ public static Object jmsConsumeMessageFromQueue(String connectionFactoryJndiName, String queueJndiName) {
+ return jmsConsumeMessageFromQueue(connectionFactoryJndiName, queueJndiName, true, Session.AUTO_ACKNOWLEDGE, 1000);
+ }
+
+ public static Object jmsConsumeMessageFromQueue(String connectionFactoryJndiName, String queueJndiName, boolean transacted, int acknowledgeMode, long timeout) {
+ return JmsExtensions.consumeMessageFromQueue(connectionFactoryJndiName, queueJndiName, transacted, acknowledgeMode, timeout);
+ }
+
+ public static void jmsRemoveQueue(String connectionFactoryJndiName, String queueJndiName) {
+ JmsExtensions.removeQueue(connectionFactoryJndiName, queueJndiName);
+ }
+
+ public static void jmsCreateTopic(String connectionFactoryJndiName, String topicJndiName) {
+ JmsExtensions.createTopic(connectionFactoryJndiName, topicJndiName);
+ }
- public List getJmsMessagesFromQueue(String connectionFactoryJndiName, String queueJndiName) {
- return MockRunnerExtensions.consumeMessage(connectionFactoryJndiName, queueJndiName);
+ public static List<Object> jmsStartTopicListener(String connectionFactoryJndiName, String topicJndiName) {
+ return JmsExtensions.startTopicListener(connectionFactoryJndiName, topicJndiName);
}
+ public static void jmsStopTopicListener(String connectionFactoryJndiName, String topicJndiName) {
+ JmsExtensions.stopTopicListener(connectionFactoryJndiName, topicJndiName);
+ }
+
+ public static void jmsRemoveTopic(String connectionFactoryJndiName, String topicJndiName) {
+ JmsExtensions.removeTopic(connectionFactoryJndiName, topicJndiName);
+ }
+
protected String verifyDbClean() {
String errorMsg = null;
String recordsLeftMsg = Db.verifyClean(processEngine);
Copied: jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JmsExtensions.java (from rev 6015, jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/MockRunnerExtensions.java)
===================================================================
--- jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JmsExtensions.java (rev 0)
+++ jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JmsExtensions.java 2009-12-22 17:49:40 UTC (rev 6022)
@@ -0,0 +1,197 @@
+/*
+ * 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;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.Queue;
+import javax.jms.QueueConnection;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.QueueSession;
+import javax.jms.Session;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import junit.framework.TestCase;
+
+import org.jbpm.api.JbpmException;
+
+import com.mockrunner.ejb.JNDIUtil;
+import com.mockrunner.jms.JMSTestModule;
+import com.mockrunner.mock.jms.JMSMockObjectFactory;
+import com.mockrunner.mock.jms.MockQueue;
+import com.mockrunner.mock.jms.MockQueueConnectionFactory;
+import com.mockrunner.mock.jms.MockTopic;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public abstract class JmsExtensions {
+
+ static {
+ try {
+ new InitialContext().getEnvironment();
+ } catch (NamingException e) {
+ try {
+ JNDIUtil.initMockContextFactory();
+ } catch (Exception e2) {
+ e.printStackTrace();
+ throw new RuntimeException("coudn't initialize mock jndi: "+e2.getMessage(), e2);
+ }
+ }
+ }
+
+ static Map<String, JMSMockObjectFactory> jmsMockObjectFactories = new HashMap<String, JMSMockObjectFactory>();
+ static Map<String, JMSTestModule> jmsTestModules = new HashMap<String, JMSTestModule>();
+
+ public static void createQueue(String connectionFactoryJndiName, String queueJndiName) {
+ MockQueue queue = getJmsTestModule(connectionFactoryJndiName)
+ .getDestinationManager()
+ .createQueue(queueJndiName);
+
+ bindToJndi(queueJndiName, queue);
+ }
+
+ public static void removeQueue(String connectionFactoryJndiName, String queueJndiName) {
+ getJmsTestModule(connectionFactoryJndiName)
+ .getDestinationManager()
+ .removeQueue(queueJndiName);
+
+ unbindFromJndi(queueJndiName);
+ }
+
+ public static void createTopic(String connectionFactoryJndiName, String topicJndiName) {
+ MockTopic topic = getJmsTestModule(connectionFactoryJndiName)
+ .getDestinationManager()
+ .createTopic(topicJndiName);
+
+ bindToJndi(topicJndiName, topic);
+ }
+
+ public static void removeTopic(String connectionFactoryJndiName, String topicJndiName) {
+ getJmsTestModule(connectionFactoryJndiName)
+ .getDestinationManager()
+ .removeTopic(topicJndiName);
+
+ unbindFromJndi(topicJndiName);
+ }
+
+ protected static void bindToJndi(String jndiName, Object object) {
+ try {
+ new InitialContext().bind(jndiName, object);
+ } catch (Exception e) {
+ throw new JbpmException("couldn't bind object '"+object+"' to jndi name '"+jndiName+"': "+e.getMessage(), e);
+ }
+ }
+
+ protected static void unbindFromJndi(String jndiName) {
+ try {
+ new InitialContext().unbind(jndiName);
+ } catch (Exception e) {
+ throw new JbpmException("couldn't unbind object from jndi name '"+jndiName+"': "+e.getMessage(), e);
+ }
+ }
+
+ private static JMSTestModule getJmsTestModule(String connectionFactoryJndiName) {
+ JMSTestModule jmsTestModule = jmsTestModules.get(connectionFactoryJndiName);
+ if (jmsTestModule==null) {
+ JMSMockObjectFactory jmsMockObjectFactory = getMockObjectFactory(connectionFactoryJndiName);
+ jmsTestModule = new JMSTestModule(jmsMockObjectFactory);
+ jmsTestModules.put(connectionFactoryJndiName, jmsTestModule);
+ }
+ return jmsTestModule;
+ }
+
+ private static JMSMockObjectFactory getMockObjectFactory(String connectionFactoryJndiName) {
+ JMSMockObjectFactory jmsMockObjectFactory = jmsMockObjectFactories.get(connectionFactoryJndiName);
+ if (jmsMockObjectFactory==null) {
+ jmsMockObjectFactory = new JMSMockObjectFactory();
+ jmsMockObjectFactories.put(connectionFactoryJndiName, jmsMockObjectFactory);
+ MockQueueConnectionFactory mockQueueConnectionFactory = jmsMockObjectFactory.getMockQueueConnectionFactory();
+ try {
+ new InitialContext().bind(connectionFactoryJndiName, mockQueueConnectionFactory);
+ } catch (Exception e) {
+ throw new JbpmException("couldn't bind mock queue connection factory '"+connectionFactoryJndiName+"': "+e.getMessage(), e);
+ }
+ }
+ return jmsMockObjectFactory;
+ }
+
+ public static List<Object> startTopicListener(String connectionFactoryJndiName, String topicJndiName) {
+ JmsTopicListener jmsTopicListener = JmsTopicListener.getJmsTopicListener(connectionFactoryJndiName, topicJndiName);
+ if (jmsTopicListener==null) {
+ jmsTopicListener = new JmsTopicListener(connectionFactoryJndiName, topicJndiName);
+ }
+
+ return jmsTopicListener.getMessages();
+ }
+
+ public static void stopTopicListener(String connectionFactoryJndiName, String topicJndiName) {
+ JmsTopicListener jmsTopicListener = JmsTopicListener.getJmsTopicListener(connectionFactoryJndiName, topicJndiName);
+ if (jmsTopicListener!=null) {
+ jmsTopicListener.stop();
+ }
+ }
+
+ public static Object consumeMessageFromQueue(String connectionFactoryJndiName, String queueJndiName, boolean transacted, int acknowledgeMode, long timeout) {
+ try {
+ InitialContext context = new InitialContext();
+ QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory) context.lookup(connectionFactoryJndiName);
+ Queue queue = (Queue)context.lookup(queueJndiName);
+ QueueConnection queueConnection = queueConnectionFactory.createQueueConnection();
+ try {
+ queueConnection.start();
+ try {
+ QueueSession queueSession = queueConnection.createQueueSession(transacted, acknowledgeMode);
+ try {
+ MessageConsumer messageConsumer = queueSession.createConsumer(queue);
+ try {
+ Message message = messageConsumer.receive(timeout);
+ if (message==null) {
+ TestCase.fail("no message on queue "+queueJndiName);
+ }
+ return message;
+ } finally {
+ messageConsumer.close();
+ }
+ } finally {
+ queueSession.close();
+ }
+ } finally {
+ queueConnection.stop();
+ }
+ } finally {
+ queueConnection.close();
+ }
+
+ } catch (RuntimeException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new RuntimeException("couldn't receive message from queue '"+queueJndiName+"': "+e.getMessage(), e);
+ }
+ }
+}
Property changes on: jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JmsExtensions.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JmsTopicListener.java
===================================================================
--- jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JmsTopicListener.java (rev 0)
+++ jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JmsTopicListener.java 2009-12-22 17:49:40 UTC (rev 6022)
@@ -0,0 +1,133 @@
+/*
+ * 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;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.QueueSession;
+import javax.jms.Topic;
+import javax.jms.TopicConnection;
+import javax.jms.TopicConnectionFactory;
+import javax.jms.TopicSession;
+import javax.jms.TopicSubscriber;
+import javax.naming.InitialContext;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class JmsTopicListener implements MessageListener {
+
+ static Map<Object, JmsTopicListener> topicListeners = new HashMap<Object, JmsTopicListener>();
+
+ TopicConnectionFactory topicConnectionFactory = null;
+ Topic topic = null;
+ TopicConnection topicConnection = null;
+ TopicSession topicSession = null;
+ TopicSubscriber topicSubscriber = null;
+
+ List<Object> messages = null;
+
+ public void onMessage(Message message) {
+ messages.add(message);
+ }
+
+ public static Object createJmsTopicListenerKey(String connectionFactoryJndiName, String topicJndiName) {
+ List<String> topicListenerKey = new ArrayList<String>();
+ topicListenerKey.add(connectionFactoryJndiName);
+ topicListenerKey.add(topicJndiName);
+ return topicListenerKey;
+ }
+
+ public static JmsTopicListener getJmsTopicListener(String connectionFactoryJndiName, String topicJndiName) {
+ return topicListeners.get(createJmsTopicListenerKey(connectionFactoryJndiName, topicJndiName));
+ }
+
+ public JmsTopicListener(String connectionFactoryJndiName, String topicJndiName) {
+ start(connectionFactoryJndiName, topicJndiName);
+ topicListeners.put(createJmsTopicListenerKey(connectionFactoryJndiName, topicJndiName), this);
+ }
+
+ private void start(String connectionFactoryJndiName, String topicJndiName) {
+ try {
+ messages = Collections.synchronizedList(new ArrayList<Object>());
+
+ InitialContext context = new InitialContext();
+ topicConnectionFactory = (TopicConnectionFactory) context.lookup(connectionFactoryJndiName);
+ topic = (Topic) context.lookup(topicJndiName);
+ topicConnection = topicConnectionFactory.createTopicConnection();
+ topicSession = topicConnection.createTopicSession(true, QueueSession.AUTO_ACKNOWLEDGE);
+ topicSubscriber = topicSession.createSubscriber(topic);
+ topicSubscriber.setMessageListener(this);
+
+ topicConnection.start();
+
+ } catch (Exception e) {
+ stop();
+ throw new RuntimeException("couldn't subscribe message listener to topic '"+topicJndiName+"': "+e.getMessage(), e);
+ }
+ }
+
+ public void stop() {
+ if (topicConnection!=null) {
+ try {
+ topicConnection.stop();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ if (topicSubscriber!=null) {
+ try {
+ topicSubscriber.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ topicSubscriber = null;
+ }
+ if (topicSession!=null) {
+ try {
+ topicSession.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ topicSession = null;
+ }
+ if (topicConnection!=null) {
+ try {
+ topicConnection.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ topicConnection = null;
+ }
+ }
+
+ public List<Object> getMessages() {
+ return messages;
+ }
+}
Property changes on: jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JmsTopicListener.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/MockRunnerExtensions.java
===================================================================
--- jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/MockRunnerExtensions.java 2009-12-22 16:59:58 UTC (rev 6021)
+++ jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/MockRunnerExtensions.java 2009-12-22 17:49:40 UTC (rev 6022)
@@ -1,101 +0,0 @@
-/*
- * 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;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-import org.jbpm.api.JbpmException;
-
-import com.mockrunner.ejb.JNDIUtil;
-import com.mockrunner.jms.JMSTestModule;
-import com.mockrunner.mock.jms.JMSMockObjectFactory;
-import com.mockrunner.mock.jms.MockQueue;
-import com.mockrunner.mock.jms.MockQueueConnectionFactory;
-
-
-/**
- * @author Tom Baeyens
- */
-public abstract class MockRunnerExtensions {
-
- static {
- try {
- new InitialContext().getEnvironment();
- } catch (NamingException e) {
- try {
- JNDIUtil.initMockContextFactory();
- } catch (Exception e2) {
- e.printStackTrace();
- throw new RuntimeException("coudn't initialize mock jndi: "+e2.getMessage(), e2);
- }
- }
- }
-
- static Map<String, JMSMockObjectFactory> jmsMockObjectFactories = new HashMap<String, JMSMockObjectFactory>();
- static Map<String, JMSTestModule> jmsTestModules = new HashMap<String, JMSTestModule>();
-
- public static void createQueue(String connectionFactoryJndiName, String queueJndiName) {
- MockQueue queue = getJmsTestModule(connectionFactoryJndiName)
- .getDestinationManager()
- .createQueue(queueJndiName);
-
- try {
- new InitialContext().bind(queueJndiName, queue);
- } catch (Exception e) {
- throw new JbpmException("couldn't bind mock queue '"+queueJndiName+"': "+e.getMessage(), e);
- }
- }
-
- private static JMSTestModule getJmsTestModule(String connectionFactoryJndiName) {
- JMSTestModule jmsTestModule = jmsTestModules.get(connectionFactoryJndiName);
- if (jmsTestModule==null) {
- JMSMockObjectFactory jmsMockObjectFactory = getMockObjectFactory(connectionFactoryJndiName);
- jmsTestModule = new JMSTestModule(jmsMockObjectFactory);
- jmsTestModules.put(connectionFactoryJndiName, jmsTestModule);
- }
- return jmsTestModule;
- }
-
- private static JMSMockObjectFactory getMockObjectFactory(String connectionFactoryJndiName) {
- JMSMockObjectFactory jmsMockObjectFactory = jmsMockObjectFactories.get(connectionFactoryJndiName);
- if (jmsMockObjectFactory==null) {
- jmsMockObjectFactory = new JMSMockObjectFactory();
- jmsMockObjectFactories.put(connectionFactoryJndiName, jmsMockObjectFactory);
- MockQueueConnectionFactory mockQueueConnectionFactory = jmsMockObjectFactory.getMockQueueConnectionFactory();
- try {
- new InitialContext().bind(connectionFactoryJndiName, mockQueueConnectionFactory);
- } catch (Exception e) {
- throw new JbpmException("couldn't bind mock queue connection factory '"+connectionFactoryJndiName+"': "+e.getMessage(), e);
- }
- }
- return jmsMockObjectFactory;
- }
-
- public static List consumeMessage(String connectionFactoryJndiName, String queueJndiName) {
- return getJmsTestModule(connectionFactoryJndiName).getCurrentMessageListFromQueue(queueJndiName);
- }
-}
Copied: jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/jms/JmsQueueTest.java (from rev 6015, jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/jms/JmsTest.java)
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/jms/JmsQueueTest.java (rev 0)
+++ jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/jms/JmsQueueTest.java 2009-12-22 17:49:40 UTC (rev 6022)
@@ -0,0 +1,60 @@
+/*
+ * 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.jms;
+
+import javax.jms.MapMessage;
+
+import org.jbpm.test.JbpmCustomCfgTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class JmsQueueTest extends JbpmCustomCfgTestCase {
+
+ String deploymentId;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ deploymentId = repositoryService.createDeployment()
+ .addResourceFromClasspath("org/jbpm/test/jms/queueprocess.jpdl.xml")
+ .deploy();
+
+ jmsCreateQueue("jms/ConnectionFactory", "queue/ProductQueue");
+ }
+
+ protected void tearDown() throws Exception {
+ jmsRemoveQueue("jms/ConnectionFactory", "queue/ProductQueue");
+
+ repositoryService.deleteDeploymentCascade(deploymentId);
+
+ super.tearDown();
+ }
+
+ public void testQueueMessage() throws Exception {
+ executionService.startProcessInstanceByKey("JmsQueue");
+
+ MapMessage mapMessage = (MapMessage) jmsConsumeMessageFromQueue("jms/ConnectionFactory", "queue/ProductQueue");
+ assertEquals("shampoo", mapMessage.getString("product"));
+ }
+}
Property changes on: jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/jms/JmsQueueTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/jms/JmsTest.java
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/jms/JmsTest.java 2009-12-22 16:59:58 UTC (rev 6021)
+++ jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/jms/JmsTest.java 2009-12-22 17:49:40 UTC (rev 6022)
@@ -1,63 +0,0 @@
-/*
- * 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.jms;
-
-import java.util.List;
-
-import javax.jms.MapMessage;
-
-import org.jbpm.test.JbpmCustomCfgTestCase;
-
-
-/**
- * @author Tom Baeyens
- */
-public class JmsTest extends JbpmCustomCfgTestCase {
-
- String deploymentId;
-
- protected void setUp() throws Exception {
- super.setUp();
-
- deploymentId = repositoryService.createDeployment()
- .addResourceFromClasspath("org/jbpm/test/jms/process.jpdl.xml")
- .deploy();
-
- createQueue("jms/ConnectionFactory", "queue/ProductQueue");
- }
-
- protected void tearDown() throws Exception {
- repositoryService.deleteDeploymentCascade(deploymentId);
-
- super.tearDown();
- }
-
- public void testSendJmsMessage() throws Exception {
- executionService.startProcessInstanceByKey("Jms");
-
- List messages = getJmsMessagesFromQueue("jms/ConnectionFactory", "queue/ProductQueue");
- assertEquals(messages.toString(), 1, messages.size());
-
- MapMessage mapMessage = (MapMessage) messages.get(0);
- assertEquals("shampoo", mapMessage.getString("product"));
- }
-}
Added: jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/jms/JmsTopicTest.java
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/jms/JmsTopicTest.java (rev 0)
+++ jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/jms/JmsTopicTest.java 2009-12-22 17:49:40 UTC (rev 6022)
@@ -0,0 +1,68 @@
+/*
+ * 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.jms;
+
+import java.util.List;
+
+import javax.jms.MapMessage;
+
+import org.jbpm.test.JbpmCustomCfgTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class JmsTopicTest extends JbpmCustomCfgTestCase {
+
+ String deploymentId;
+ List<Object> messages;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ deploymentId = repositoryService.createDeployment()
+ .addResourceFromClasspath("org/jbpm/test/jms/topicprocess.jpdl.xml")
+ .deploy();
+
+ jmsCreateTopic("jms/ConnectionFactory", "topic/ProductTopic");
+ messages = jmsStartTopicListener("jms/ConnectionFactory", "topic/ProductTopic");
+ }
+
+ protected void tearDown() throws Exception {
+ jmsStopTopicListener("jms/ConnectionFactory", "topic/ProductTopic");
+ jmsRemoveTopic("jms/ConnectionFactory", "topic/ProductTopic");
+
+ repositoryService.deleteDeploymentCascade(deploymentId);
+
+ super.tearDown();
+ }
+
+ public void testTestTopicMessage() throws Exception {
+ executionService.startProcessInstanceByKey("JmsTopic");
+
+ assertEquals(messages.toString(), 1, messages.size());
+
+ MapMessage mapMessage = (MapMessage) messages.get(0);
+ assertEquals("shampoo", mapMessage.getString("product"));
+ }
+
+}
Property changes on: jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/jms/JmsTopicTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/jms/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/jms/process.jpdl.xml 2009-12-22 16:59:58 UTC (rev 6021)
+++ jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/jms/process.jpdl.xml 2009-12-22 17:49:40 UTC (rev 6022)
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<process name="Jms">
-
- <start g="20,20,48,48">
- <transition to="send message" />
- </start>
-
- <jms name="send message"
- connection-factory="jms/ConnectionFactory"
- destination="queue/ProductQueue"
- g="96,16,83,52">
- <map>
- <entry>
- <key><string value="product"/></key>
- <value><string value="shampoo"/></value>
- </entry>
- </map>
- <transition to="wait" />
- </jms>
-
- <state name="wait" g="352,17,88,52"/>
-
-</process>
Copied: jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/jms/queueprocess.jpdl.xml (from rev 6015, jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/jms/process.jpdl.xml)
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/jms/queueprocess.jpdl.xml (rev 0)
+++ jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/jms/queueprocess.jpdl.xml 2009-12-22 17:49:40 UTC (rev 6022)
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="JmsQueue">
+
+ <start g="20,20,48,48">
+ <transition to="send message" />
+ </start>
+
+ <jms name="send message"
+ connection-factory="jms/ConnectionFactory"
+ destination="queue/ProductQueue"
+ g="96,16,83,52">
+ <map>
+ <entry>
+ <key><string value="product"/></key>
+ <value><string value="shampoo"/></value>
+ </entry>
+ </map>
+ <transition to="wait" />
+ </jms>
+
+ <state name="wait" g="352,17,88,52"/>
+
+</process>
Property changes on: jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/jms/queueprocess.jpdl.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/jms/topicprocess.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/jms/topicprocess.jpdl.xml (rev 0)
+++ jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/jms/topicprocess.jpdl.xml 2009-12-22 17:49:40 UTC (rev 6022)
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="JmsTopic">
+
+ <start g="20,20,48,48">
+ <transition to="send message" />
+ </start>
+
+ <jms name="send message"
+ connection-factory="jms/ConnectionFactory"
+ destination="topic/ProductTopic"
+ g="96,16,83,52">
+ <map>
+ <entry>
+ <key><string value="product"/></key>
+ <value><string value="shampoo"/></value>
+ </entry>
+ </map>
+ <transition to="wait" />
+ </jms>
+
+ <state name="wait" g="352,17,88,52"/>
+
+</process>
Property changes on: jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/jms/topicprocess.jpdl.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/timer/TaskTimerTaskTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/timer/TaskTimerTaskTest.java 2009-12-22 16:59:58 UTC (rev 6021)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/timer/TaskTimerTaskTest.java 2009-12-22 17:49:40 UTC (rev 6022)
@@ -37,53 +37,45 @@
*/
public class TaskTimerTaskTest extends JbpmTestCase {
- // Test case for JBPM-2537
public void testTaskClosedWhenTimerFires() {
deployJpdlXmlString(
- "<process name='test1'>" +
- " <start g='-9,192,48,48' name='start1'>" +
- " <transition g='-44,-18' name='to task3' to='task3' />" +
+ "<process name='TaskTimer'>" +
+ " <start name='start'>" +
+ " <transition to='do work' />" +
" </start>" +
- " <task g='272,189,92,52' name='task1'>" +
- " <transition g='-42,-18' name='to end1' to='end1' />" +
- " <transition g='-45,-18' name='to wait' to='waitHere'>" +
+ " <task name='do work' assignee='johndoe'>" +
+ " <transition name='done' to='go home' />" +
+ " <transition name='lunch' to='go to cafeteria'>" +
" <timer duedate='10 seconds' />" +
" </transition>" +
" </task>" +
- " <task g='454,316,92,52' name='task2'>" +
- " <transition g='-42,-18' name='to end2' to='end2' />" +
- " </task>" +
- " <task g='113,189,92,52' name='task3'>" +
- " <transition g='-44,-18' to='task1' name='to end1' />" +
- " </task>" +
- " <state name='waitHere'>" +
- " <transition to='end1' />" +
- " </state>" +
- " <end g='490,192,48,48' name='end1' />" +
- " <end g='626,319,48,48' name='end2' />" +
+ " <state name='go home' />" +
+ " <state name='go to cafeteria' />" +
"</process>");
- ProcessInstance processInstance = executionService.startProcessInstanceByKey("test1");
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("TaskTimer");
- Task currentTask = taskService.createTaskQuery().uniqueResult();
- assertEquals("task3", currentTask.getName());
- taskService.completeTask(currentTask.getId());
+ assertEquals(1, taskService.createTaskQuery()
+ .assignee("johndoe")
+ .list()
+ .size() );
- currentTask = taskService.createTaskQuery().uniqueResult();
- assertEquals("task1", currentTask.getName());
+ Job timer = managementService.createJobQuery()
+ .processInstanceId(processInstance.getId())
+ .timers()
+ .uniqueResult();
- Job timeout = managementService.createJobQuery().timers().uniqueResult();
- managementService.executeJob(timeout.getId());
+ assertNotNull(timer);
- assertActivityActive(processInstance.getId(), "waitHere");
+ managementService.executeJob(timer.getId());
- // Task1 should be completed now
- List<Task> currentTasks = taskService.createTaskQuery().list();
-
- // TODO: Uncomment when fixing issue!
- // assertTrue("Error: there are still tasks active: "
- // + listAllOpenTasks(processInstance.getId()), currentTasks.isEmpty());
+ assertActivityActive(processInstance.getId(), "go to cafeteria");
+// TODO JBPM-2537
+// assertEquals(0, taskService.createTaskQuery()
+// .assignee("johndoe")
+// .list()
+// .size() );
}
Deleted: jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/java/org/jbpm/test/jms/JbpmJmsTestCase.java
===================================================================
--- jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/java/org/jbpm/test/jms/JbpmJmsTestCase.java 2009-12-22 16:59:58 UTC (rev 6021)
+++ jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/java/org/jbpm/test/jms/JbpmJmsTestCase.java 2009-12-22 17:49:40 UTC (rev 6022)
@@ -1,56 +0,0 @@
-package org.jbpm.test.jms;
-
-import javax.jms.MessageConsumer;
-import javax.jms.Queue;
-import javax.jms.QueueConnection;
-import javax.jms.QueueConnectionFactory;
-import javax.jms.QueueSession;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-
-import junit.framework.Test;
-
-import org.apache.cactus.ServletTestSuite;
-import org.jbpm.test.JbpmTestCase;
-
-public abstract class JbpmJmsTestCase extends JbpmTestCase {
-
- String deploymentId;
-
- protected QueueConnection queueConnection = null;
- protected QueueSession queueSession = null;
- protected MessageConsumer messageConsumer = null;
-
- public static Test suite() {
- ServletTestSuite servletTestSuite = new ServletTestSuite();
- servletTestSuite.addTestSuite(JbpmJmsTestCase.class);
- return servletTestSuite;
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- setUpJms();
- }
-
- protected void setUpJms() throws Exception {
- Context context = new InitialContext();
- QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory)context.lookup("ConnectionFactory");
- Queue queue = (Queue)context.lookup("queue/jbpm-test-queue");
- queueConnection = (QueueConnection)queueConnectionFactory.createConnection();
- queueSession = queueConnection.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
- queueConnection.start();
- messageConsumer = queueSession.createConsumer(queue);
- }
-
- protected void tearDown() throws Exception {
- tearDownJms();
- super.tearDown();
- }
-
- protected void tearDownJms() throws Exception {
- queueConnection.stop();
- queueSession.close();
- queueConnection.close();
- }
-
-}
Copied: jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/java/org/jbpm/test/jms/QueueMapMessageTest.java (from rev 6015, jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/java/org/jbpm/test/jms/map/MapMessageTest.java)
===================================================================
--- jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/java/org/jbpm/test/jms/QueueMapMessageTest.java (rev 0)
+++ jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/java/org/jbpm/test/jms/QueueMapMessageTest.java 2009-12-22 17:49:40 UTC (rev 6022)
@@ -0,0 +1,33 @@
+package org.jbpm.test.jms;
+
+import javax.jms.MapMessage;
+
+import junit.framework.Test;
+
+import org.apache.cactus.ServletTestSuite;
+import org.jbpm.test.JbpmTestCase;
+
+public class QueueMapMessageTest extends JbpmTestCase {
+
+ public static Test suite() {
+ ServletTestSuite servletTestSuite = new ServletTestSuite();
+ servletTestSuite.addTestSuite(QueueMapMessageTest.class);
+ return servletTestSuite;
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ registerDeployment(repositoryService.createDeployment()
+ .addResourceFromClasspath("org/jbpm/test/jms/queue.map.process.jpdl.xml")
+ .deploy());
+ }
+
+ public void testJmsText() throws Exception {
+ executionService.startProcessInstanceByKey("JMS_map_queue");
+ MapMessage mapMessage = (MapMessage) jmsConsumeMessageFromQueue("XAConnectionFactory", "queue/jbpm-test-queue");
+ assertTrue(mapMessage.itemExists("x"));
+ assertEquals("foo", mapMessage.getObject("x"));
+ }
+
+}
Property changes on: jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/java/org/jbpm/test/jms/QueueMapMessageTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/java/org/jbpm/test/jms/QueueObjectMessageTest.java (from rev 6015, jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/java/org/jbpm/test/jms/object/ObjectMessageTest.java)
===================================================================
--- jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/java/org/jbpm/test/jms/QueueObjectMessageTest.java (rev 0)
+++ jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/java/org/jbpm/test/jms/QueueObjectMessageTest.java 2009-12-22 17:49:40 UTC (rev 6022)
@@ -0,0 +1,37 @@
+package org.jbpm.test.jms;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.jms.ObjectMessage;
+
+import junit.framework.Test;
+
+import org.apache.cactus.ServletTestSuite;
+import org.jbpm.test.JbpmTestCase;
+
+public class QueueObjectMessageTest extends JbpmTestCase {
+
+ public static Test suite() {
+ ServletTestSuite servletTestSuite = new ServletTestSuite();
+ servletTestSuite.addTestSuite(QueueObjectMessageTest.class);
+ return servletTestSuite;
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ registerDeployment(repositoryService.createDeployment()
+ .addResourceFromClasspath("org/jbpm/test/jms/queue.object.process.jpdl.xml")
+ .deploy());
+ }
+
+ public void testQueueMessage() throws Exception {
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("object", "this is the object");
+ executionService.startProcessInstanceByKey("JMS_object_queue", variables);
+ ObjectMessage objectMessage = (ObjectMessage) jmsConsumeMessageFromQueue("XAConnectionFactory", "queue/jbpm-test-queue");
+ assertEquals("this is the object", objectMessage.getObject());
+ }
+
+}
Property changes on: jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/java/org/jbpm/test/jms/QueueObjectMessageTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/java/org/jbpm/test/jms/QueueTextMessageTest.java (from rev 6015, jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/java/org/jbpm/test/jms/text/TextMessageTest.java)
===================================================================
--- jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/java/org/jbpm/test/jms/QueueTextMessageTest.java (rev 0)
+++ jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/java/org/jbpm/test/jms/QueueTextMessageTest.java 2009-12-22 17:49:40 UTC (rev 6022)
@@ -0,0 +1,30 @@
+package org.jbpm.test.jms;
+
+import javax.jms.TextMessage;
+
+import junit.framework.Test;
+
+import org.apache.cactus.ServletTestSuite;
+import org.jbpm.test.JbpmTestCase;
+
+public class QueueTextMessageTest extends JbpmTestCase {
+
+ public static Test suite() {
+ ServletTestSuite servletTestSuite = new ServletTestSuite();
+ servletTestSuite.addTestSuite(QueueTextMessageTest.class);
+ return servletTestSuite;
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ registerDeployment(repositoryService.createDeployment()
+ .addResourceFromClasspath("org/jbpm/test/jms/queue.text.process.jpdl.xml")
+ .deploy());
+ }
+
+ public void testQueueMessage() throws Exception {
+ executionService.startProcessInstanceByKey("JMS_text_queue");
+ TextMessage textMessage = (TextMessage) jmsConsumeMessageFromQueue("XAConnectionFactory", "queue/jbpm-test-queue");
+ assertEquals("This is the body", textMessage.getText());
+ }
+}
Property changes on: jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/java/org/jbpm/test/jms/QueueTextMessageTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/resources/jbpm-test-destinations-service.xml
===================================================================
--- jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/resources/jbpm-test-destinations-service.xml 2009-12-22 16:59:58 UTC (rev 6021)
+++ jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/resources/jbpm-test-destinations-service.xml 2009-12-22 17:49:40 UTC (rev 6022)
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<server>
- <mbean code="org.jboss.jms.server.destination.QueueService"
- name="jboss.messaging.destination:service=Queue,name=jbpm-test-queue"
- xmbean-dd="xmdesc/Queue-xmbean.xml">
- <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
- <depends>jboss.messaging:service=PostOffice</depends>
- </mbean>
-</server>
\ No newline at end of file
Deleted: jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/resources/org/jbpm/test/jms/map/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/resources/org/jbpm/test/jms/map/process.jpdl.xml 2009-12-22 16:59:58 UTC (rev 6021)
+++ jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/resources/org/jbpm/test/jms/map/process.jpdl.xml 2009-12-22 17:49:40 UTC (rev 6022)
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<process name="JMS_map_queue" xmlns="http://jbpm.org/4.3/jpdl">
-
- <start g="20,20,48,48">
- <transition to="send message" />
- </start>
-
- <jms name="send message"
- connection-factory="ConnectionFactory"
- destination="queue/jbpm-test-queue"
- g="96,16,83,52">
- <map>
- <entry>
- <key><string value="x"/></key>
- <value><string value="foo"/></value>
- </entry>
- </map>
- <transition to="wait" />
- </jms>
-
- <state name="wait" g="352,17,88,52"/>
-
-</process>
Deleted: jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/resources/org/jbpm/test/jms/object/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/resources/org/jbpm/test/jms/object/process.jpdl.xml 2009-12-22 16:59:58 UTC (rev 6021)
+++ jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/resources/org/jbpm/test/jms/object/process.jpdl.xml 2009-12-22 17:49:40 UTC (rev 6022)
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<process name="JMS_object_queue" xmlns="http://jbpm.org/4.3/jpdl">
-
- <start g="20,20,48,48">
- <transition to="send message" />
- </start>
-
- <jms name="send message"
- connection-factory="ConnectionFactory"
- destination="queue/jbpm-test-queue"
- g="96,16,83,52">
- <object expr="${object}"/>
- <transition to="wait" />
- </jms>
-
- <state name="wait" g="352,17,88,52"/>
-
-</process>
Copied: jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/resources/org/jbpm/test/jms/queue.map.process.jpdl.xml (from rev 6015, jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/resources/org/jbpm/test/jms/map/process.jpdl.xml)
===================================================================
--- jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/resources/org/jbpm/test/jms/queue.map.process.jpdl.xml (rev 0)
+++ jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/resources/org/jbpm/test/jms/queue.map.process.jpdl.xml 2009-12-22 17:49:40 UTC (rev 6022)
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="JMS_map_queue">
+
+ <start g="20,20,48,48">
+ <transition to="send message" />
+ </start>
+
+ <jms name="send message"
+ connection-factory="XAConnectionFactory"
+ destination="queue/jbpm-test-queue"
+ g="96,16,83,52">
+ <map>
+ <entry>
+ <key><string value="x"/></key>
+ <value><string value="foo"/></value>
+ </entry>
+ </map>
+ <transition to="wait" />
+ </jms>
+
+ <state name="wait" g="352,17,88,52"/>
+
+</process>
Property changes on: jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/resources/org/jbpm/test/jms/queue.map.process.jpdl.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/resources/org/jbpm/test/jms/queue.object.process.jpdl.xml (from rev 6015, jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/resources/org/jbpm/test/jms/object/process.jpdl.xml)
===================================================================
--- jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/resources/org/jbpm/test/jms/queue.object.process.jpdl.xml (rev 0)
+++ jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/resources/org/jbpm/test/jms/queue.object.process.jpdl.xml 2009-12-22 17:49:40 UTC (rev 6022)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="JMS_object_queue">
+
+ <start g="20,20,48,48">
+ <transition to="send message" />
+ </start>
+
+ <jms name="send message"
+ connection-factory="XAConnectionFactory"
+ destination="queue/jbpm-test-queue"
+ g="96,16,83,52">
+ <object expr="${object}"/>
+ <transition to="wait" />
+ </jms>
+
+ <state name="wait" g="352,17,88,52"/>
+
+</process>
Property changes on: jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/resources/org/jbpm/test/jms/queue.object.process.jpdl.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/resources/org/jbpm/test/jms/queue.text.process.jpdl.xml (from rev 6015, jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/resources/org/jbpm/test/jms/text/process.jpdl.xml)
===================================================================
--- jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/resources/org/jbpm/test/jms/queue.text.process.jpdl.xml (rev 0)
+++ jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/resources/org/jbpm/test/jms/queue.text.process.jpdl.xml 2009-12-22 17:49:40 UTC (rev 6022)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="JMS_text_queue">
+
+ <start g="20,20,48,48">
+ <transition to="send message" />
+ </start>
+
+ <jms name="send message"
+ connection-factory="XAConnectionFactory"
+ destination="queue/jbpm-test-queue"
+ g="96,16,83,52">
+ <text>This is the body</text>
+ <transition to="wait" />
+ </jms>
+
+ <state name="wait" g="352,17,88,52"/>
+
+</process>
Property changes on: jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/resources/org/jbpm/test/jms/queue.text.process.jpdl.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/resources/org/jbpm/test/jms/text/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/resources/org/jbpm/test/jms/text/process.jpdl.xml 2009-12-22 16:59:58 UTC (rev 6021)
+++ jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/resources/org/jbpm/test/jms/text/process.jpdl.xml 2009-12-22 17:49:40 UTC (rev 6022)
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<process name="JMS_text_queue" xmlns="http://jbpm.org/4.3/jpdl">
-
- <start g="20,20,48,48">
- <transition to="send message" />
- </start>
-
- <jms name="send message"
- connection-factory="ConnectionFactory"
- destination="queue/jbpm-test-queue"
- g="96,16,83,52">
- <text>This is the body</text>
- <transition to="wait" />
- </jms>
-
- <state name="wait" g="352,17,88,52"/>
-
-</process>
Modified: jbpm4/trunk/qa/build.xml
===================================================================
--- jbpm4/trunk/qa/build.xml 2009-12-22 16:59:58 UTC (rev 6021)
+++ jbpm4/trunk/qa/build.xml 2009-12-22 17:49:40 UTC (rev 6022)
@@ -28,10 +28,6 @@
<property name="jbpm.distro.dir" value="../modules/distro/target" />
<property name="jbpm.distro.path" value="${jbpm.distro.dir}/jbpm-${jbpm.version}.zip" />
- <condition property="is.hsqldb">
- <equals arg1="${database}" arg2="hsqldb" />
- </condition>
-
<condition property="is.oracle">
<equals arg1="${database}" arg2="oracle" />
</condition>
@@ -59,6 +55,10 @@
<ant antfile="${jbpm.home}/install/build.xml" target="drop.jbpm.schema" />
</target>
+ <!-- ################ -->
+ <!-- ### TOMCAT ### -->
+ <!-- ################ -->
+
<!-- TOMCAT SETUP -->
<target name="testsuite.tomcat.setup"
depends="reinstall.jbpm">
@@ -105,57 +105,88 @@
<ant antfile="${jbpm.home}/install/build.xml" target="stop.hsqldb.server" />
</target>
+ <!-- ################ -->
+ <!-- ### JBOSS ### -->
+ <!-- ################ -->
+
<!-- JBOSS SETUP -->
<target name="testsuite.jboss.setup"
- depends="jboss.test.setup.base"
+ depends="internal.jboss.test.setup.base"
description="reinstalls jbpm, reinstalls jboss, installs jbpm into jboss, starts jboss and then creates the jbpm schema">
- <!-- start hsqldb -->
<ant antfile="${jbpm.home}/install/build.xml" target="start.hsqldb.server" />
<ant antfile="${jbpm.home}/install/build.xml" target="create.jbpm.schema" />
-
- <!-- start jboss -->
<ant antfile="${jbpm.home}/install/build.xml" target="start.jboss" />
</target>
+ <!-- JBOSS TEARDOWN -->
+ <target name="testsuite.jboss.teardown"
+ description="drops the jbpm schema and stops jboss">
+ <ant antfile="${jbpm.home}/install/build.xml" target="stop.jboss" />
+ <ant antfile="${jbpm.home}/install/build.xml" target="drop.jbpm.schema" />
+ <ant antfile="${jbpm.home}/install/build.xml" target="stop.hsqldb.server" />
+ </target>
+
+ <!-- JBOSS SETUP DEBUG -->
<target name="testsuite.jboss.setup.for.debug"
- depends="jboss.test.setup.base"
+ depends="internal.jboss.test.setup.base"
description="reinstalls jbpm, reinstalls jboss, installs jbpm into jboss, starts jboss and then creates the jbpm schema">
- <!-- start hsqldb -->
<ant antfile="${jbpm.home}/install/build.xml" target="start.hsqldb.server" />
<ant antfile="${jbpm.home}/install/build.xml" target="create.jbpm.schema" />
- <!-- enable debug on jboss -->
<ant antfile="${jbpm.home}/install/build.xml" target="enable.jboss.debug" />
</target>
- <!-- JBOSS TEARDOWN -->
- <target name="testsuite.jboss.teardown"
- description="drops the jbpm schema and stops jboss">
- <ant antfile="${jbpm.home}/install/build.xml" target="stop.jboss" />
- <ant antfile="${jbpm.home}/install/build.xml" target="drop.jbpm.schema" />
- <ant antfile="${jbpm.home}/install/build.xml" target="stop.hsqldb.server" />
+ <!-- JBOSS INTERNAL SETUP BASE -->
+ <target name="internal.jboss.test.setup.base"
+ depends="reinstall.jbpm">
+ <ant antfile="${jbpm.home}/install/build.xml" target="reinstall.jboss" />
+ <ant antfile="${jbpm.home}/install/build.xml" target="install.jbpm.into.jboss" />
+ <ant antfile="${jbpm.home}/install/build.xml" target="create.user.webapp" />
+ <ant antfile="${jbpm.home}/install/build.xml" target="install.hsqldb.server" />
+
+ <!-- to build the jbpm test webapp we start by copying the user webapp -->
+ <mkdir dir="${jboss.home}/server/default/deploy/jbpm-test-webapp.war" />
+ <copy todir="${jboss.home}/server/default/deploy/jbpm-test-webapp.war">
+ <fileset dir="${jbpm.home}/install/generated/user-webapp"/>
+ </copy>
+
+ <!-- customize the jbpm configuration for the testsuite -->
+ <copy todir="${jboss.home}/server/default/deploy/jbpm/jbpm-service.sar" overwrite="true">
+ <fileset dir="jboss.jbpm.cfg" />
+ </copy>
+
+ <!-- customize the configuration for the jbpm-test-webapp -->
+ <copy todir="${jboss.home}/server/default/deploy/jbpm-test-webapp.war" overwrite="true">
+ <fileset dir="cactus.webapp.cfg" />
+ </copy>
+
+ <!-- delete the jbpm configuration files -->
+ <delete dir="${jboss.home}/server/default/deploy/jbpm-test-webapp.war/WEB-INF/classes" />
+ <delete file="${jboss.home}/server/default/deploy/jbpm-test-webapp.war/WEB-INF/lib/jta.jar" />
+
+ <!-- add examples.jar -->
+ <ant antfile="${jbpm.home}/examples/build.xml" target="examples.jar" />
+ <copy file="${jbpm.home}/examples/target/examples.jar" todir="${jboss.home}/server/default/deploy/jbpm-test-webapp.war/WEB-INF/lib" />
+
+ <!-- add junit.jar -->
+ <copy file="${jbpm.home}/lib/junit.jar" todir="${jboss.home}/server/default/deploy/jbpm-test-webapp.war/WEB-INF/lib" />
+
+ <!-- add the cactus libs -->
+ <copy todir="${jboss.home}/server/default/deploy/jbpm-test-webapp.war/WEB-INF/lib">
+ <fileset dir="../modules/test-cactus/target/jbpm.test.webapp.libs" />
+ </copy>
</target>
-
+
+
+ <!-- ################# -->
+ <!-- ### ENTERPRISE ## -->
+ <!-- ################# -->
+
<!-- ENTERPRISE SETUP -->
<target name="testsuite.enterprise.setup"
- depends="jboss.test.setup.base"
+ depends="internal.enterprise.test.setup.base"
description="reinstalls jbpm, reinstalls jboss, installs jbpm into jboss, starts jboss and then creates the jbpm schema">
-
- <!-- create the test queue -->
- <copy file="../modules/test-enterprise/test-enterprise-suite/src/test/resources/jbpm-test-destinations-service.xml"
- todir="${jboss.home}/server/default/deploy/jbpm-test" />
-
- <!-- deploy the test ejbs -->
- <copy file="../modules/test-enterprise/test-enterprise-ejb/target/jbpm-test-enterprise-ejb-${jbpm.version}.jar"
- todir="${jboss.home}/server/default/deploy/jbpm-test"/>
-
- <!-- copy the test classes to the test web app -->
- <copy file="../modules/test-enterprise/test-enterprise-suite/target/jbpm-test-enterprise-suite-${jbpm.version}-tests.jar"
- todir="${jboss.home}/server/default/deploy/jbpm-test-webapp.war/WEB-INF/lib" />
-
- <!-- start hsqldb -->
<ant antfile="${jbpm.home}/install/build.xml" target="start.hsqldb.server" />
<ant antfile="${jbpm.home}/install/build.xml" target="create.jbpm.schema" />
- <!-- start jboss -->
<ant antfile="${jbpm.home}/install/build.xml" target="start.jboss" />
</target>
@@ -166,7 +197,31 @@
<ant antfile="${jbpm.home}/install/build.xml" target="drop.jbpm.schema" />
<ant antfile="${jbpm.home}/install/build.xml" target="stop.hsqldb.server" />
</target>
-
+
+ <target name="testsuite.enterprise.setup.for.debug"
+ depends="internal.enterprise.test.setup.base"
+ description="reinstalls jbpm, reinstalls jboss, installs jbpm into jboss, starts jboss and then creates the jbpm schema">
+ <ant antfile="${jbpm.home}/install/build.xml" target="start.hsqldb.server" />
+ <ant antfile="${jbpm.home}/install/build.xml" target="create.jbpm.schema" />
+ <ant antfile="${jbpm.home}/install/build.xml" target="enable.jboss.debug" />
+ </target>
+
+ <target name="internal.enterprise.test.setup.base"
+ depends="internal.jboss.test.setup.base"
+ description="reinstalls jbpm, reinstalls jboss, installs jbpm into jboss, starts jboss and then creates the jbpm schema">
+ <!-- create the test queue -->
+ <copy file="enterprise/jbpm-test-destinations-service.xml"
+ todir="${jboss.home}/server/default/deploy/jbpm-test" />
+
+ <!-- deploy the test ejbs -->
+ <copy file="../modules/test-enterprise/test-enterprise-ejb/target/jbpm-test-enterprise-ejb-${jbpm.version}.jar"
+ todir="${jboss.home}/server/default/deploy/jbpm-test"/>
+
+ <!-- copy the test classes to the test web app -->
+ <copy file="../modules/test-enterprise/test-enterprise-suite/target/jbpm-test-enterprise-suite-${jbpm.version}-tests.jar"
+ todir="${jboss.home}/server/default/deploy/jbpm-test-webapp.war/WEB-INF/lib" />
+ </target>
+
<!-- ################ -->
<!-- ### UPGRADE ### -->
@@ -174,11 +229,14 @@
<property name="old.jbpm.home" value="${jbpm.parent.dir}/jbpm-${old.jbpm.version}" />
<target name="testsuite.upgrade.setup" depends="reinstall.jbpm">
<fail message="old.jbpm.version is a mandatory property" unless="old.jbpm.version" />
- <!-- install old jbpm version -->
+
+ <!-- install old jbpm version -->
<delete dir="${old.jbpm.home}" />
<unzip src="upgrade/target/jbpm-distro-${old.jbpm.version}.jar" dest="${jbpm.parent.dir}" />
+
<!-- copy the oracle driver jar -->
- <antcall target="copy.oracle.driver" />
+ <antcall target="copy.oracle.driver" />
+
<!-- create jdbc properties files for PVM2 based on the originals -->
<delete dir="upgrade/target/jdbc" />
<mkdir dir="upgrade/target/jdbc" />
@@ -193,18 +251,21 @@
<copy todir="upgrade/target/jdbc" overwrite="true" failonerror="false">
<fileset dir="${user.home}/.jbpm4/jdbc" />
</copy>
- <!-- install the jbpm-test-upgrade lib -->
+
+ <!-- install the jbpm-test-upgrade lib -->
<delete dir="upgrade/target/jbpm-test-upgrade" />
<mkdir dir="upgrade/target/jbpm-test-upgrade" />
<unzip dest="upgrade/target/jbpm-test-upgrade" src="upgrade/target/jbpm-test-upgrade.jar" />
- <delete file="upgrade/target/jbpm-test-upgrade/hibernate.properties" />
+ <delete file="upgrade/target/jbpm-test-upgrade/hibernate.properties" />
+
<!-- create jbpm schema using the old jbpm distro -->
<condition property="is.old.jbpm.40">
<equals arg1="${old.jbpm.version}" arg2="4.0" />
</condition>
<antcall target="create.jbpm.schema.in.jbpm.40" />
<antcall target="create.jbpm.schema.in.jbpm.41plus" />
- <!-- start couple of processes using the old jbpm version -->
+
+ <!-- start couple of processes using the old jbpm version -->
<copy todir="upgrade/target/jbpm-test-upgrade" overwrite="true">
<fileset dir="upgrade/cfg" />
</copy>
@@ -219,15 +280,16 @@
</fileset>
</classpath>
</java>
- <!-- upgrade -->
+
+ <!-- upgrade -->
<copy todir="${jbpm.home}/install/jdbc" overwrite="true">
<fileset dir="upgrade/target/jdbc" />
</copy>
- <ant antfile="${jbpm.home}/install/build.xml" target="upgrade.jbpm.schema" inheritall="false">
- <property name="database" value="${database}" />
+ <ant antfile="${jbpm.home}/install/build.xml" target="upgrade.jbpm.schema" inheritall="false">
+ <property name="database" value="${database}" />
<property name="tx" value="standalone.testsuite" />
<!--property name="logging" value="debug" /-->
- </ant>
+ </ant>
</target>
<target name="copy.oracle.driver" if="is.oracle">
@@ -235,21 +297,26 @@
<copy file="upgrade/target/ojdbc14.jar" todir="${jbpm.home}/lib" />
</target>
+
+ <!--
+ <condition property="is.hsqldb">
+ <equals arg1="${database}" arg2="hsqldb" />
+ </condition>
<target name="start.hsqldb" if="is.hsqldb">
<delete dir="upgrade/target/hsqldb" />
- <mkdir dir="upgrade/target/hsqldb" />
- <java classname="org.hsqldb.Server" dir="upgrade/target/hsqldb" fork="true">
- <arg line="-address localhost -port 1701 -dbname.0 jbpmDatabase" />
- <classpath>
- <fileset dir="upgrade/target">
- <include name="hsqldb.jar"/>
- </fileset>
- </classpath>
- </java>
+ <mkdir dir="upgrade/target/hsqldb" />
+ <java classname="org.hsqldb.Server" dir="upgrade/target/hsqldb" fork="true">
+ <arg line="-address localhost -port 1701 -dbname.0 jbpmDatabase" />
+ <classpath>
+ <fileset dir="upgrade/target">
+ <include name="hsqldb.jar"/>
+ </fileset>
+ </classpath>
+ </java>
</target>
-
+
<target name="stop.hsqldb" if="is.hsqldb">
- <property file="upgrade/target/jdbc/${database}.properties" />
+ <property file="upgrade/target/jdbc/${database}.properties" />
<path id="hsqldb.classpath">
<fileset dir="upgrade/target">
<include name="hsqldb.jar"/>
@@ -263,6 +330,7 @@
autocommit="true"
classpathref="hsqldb.classpath">SHUTDOWN</sql>
</target>
+ -->
<target name="create.jbpm.schema.in.jbpm.40" if="is.old.jbpm.40">
<echo message="creating schema in jbpm 4.0" />
@@ -270,17 +338,17 @@
<copy todir="${old.jbpm.home}/db/jdbc">
<fileset dir="upgrade/target/jdbc" />
</copy>
- <replace file="upgrade/target/jbpm-test-upgrade/jbpm.cfg.xml">
- <replacetoken><![CDATA[<import resource="jbpm.businesscalendar.cfg.xml" />]]></replacetoken>
- <replacevalue></replacevalue>
- </replace>
- <ant antfile="${old.jbpm.home}/db/build.xml" target="create.jbpm.schema" inheritall="false">
- <property name="database" value="${database}" />
- </ant>
+ <replace file="upgrade/target/jbpm-test-upgrade/jbpm.cfg.xml">
+ <replacetoken><![CDATA[<import resource="jbpm.businesscalendar.cfg.xml" />]]></replacetoken>
+ <replacevalue></replacevalue>
+ </replace>
+ <ant antfile="${old.jbpm.home}/db/build.xml" target="create.jbpm.schema" inheritall="false">
+ <property name="database" value="${database}" />
+ </ant>
<copy file="${old.jbpm.home}/db/hibernate.cfg/${database}.hibernate.cfg.xml"
- tofile="upgrade/target/jbpm-test-upgrade/jbpm.hibernate.cfg.xml"
- overwrite="true">
- <filterset filtersfile="upgrade/target/jdbc/${database}.properties" />
+ tofile="upgrade/target/jbpm-test-upgrade/jbpm.hibernate.cfg.xml"
+ overwrite="true">
+ <filterset filtersfile="upgrade/target/jdbc/${database}.properties" />
</copy>
</target>
@@ -302,62 +370,15 @@
<target name="testsuite.upgrade.teardown">
<ant antfile="${jbpm.home}/install/build.xml" target="drop.jbpm.schema" inheritall="false" />
- <antcall target="stop.hsqldb" />
+ <ant antfile="${jbpm.home}/install/build.xml" target="stop.hsqldb.server" />
</target>
+
<!-- ############################################ -->
<!-- ### REUSABLE TARGETS ### -->
<!-- ### These targets can be called directly ### -->
<!-- ############################################ -->
- <!-- re-install jbpm and setup jboss for cactus testing -->
- <target name="jboss.test.setup.base"
- depends="reinstall.jbpm">
- <ant antfile="${jbpm.home}/install/build.xml" target="reinstall.jboss" />
- <ant antfile="${jbpm.home}/install/build.xml" target="install.jbpm.into.jboss" />
- <ant antfile="${jbpm.home}/install/build.xml" target="create.user.webapp" />
- <ant antfile="${jbpm.home}/install/build.xml" target="install.hsqldb.server" />
-
- <!-- make the example test classes and test delegation classes available as a user lib
- <ant antfile="${jbpm.home}/examples/build.xml" target="examples.jar" />
- <mkdir dir="${jboss.server.config.dir}/deploy/jbpm/userlibs" />
- <copy file="${jbpm.home}/examples/target/examples.jar"
- todir="${jboss.server.config.dir}/deploy/jbpm/userlibs" />
- -->
-
- <!-- to build the jbpm test webapp we start by copying the user webapp -->
- <mkdir dir="${jboss.home}/server/default/deploy/jbpm-test-webapp.war" />
- <copy todir="${jboss.home}/server/default/deploy/jbpm-test-webapp.war">
- <fileset dir="${jbpm.home}/install/generated/user-webapp"/>
- </copy>
-
- <!-- customize the jbpm configuration for the testsuite -->
- <copy todir="${jboss.home}/server/default/deploy/jbpm/jbpm-service.sar" overwrite="true">
- <fileset dir="jboss.jbpm.cfg" />
- </copy>
-
- <!-- customize the configuration for the jbpm-test-webapp -->
- <copy todir="${jboss.home}/server/default/deploy/jbpm-test-webapp.war" overwrite="true">
- <fileset dir="cactus.webapp.cfg" />
- </copy>
-
- <!-- delete the jbpm configuration files -->
- <delete dir="${jboss.home}/server/default/deploy/jbpm-test-webapp.war/WEB-INF/classes" />
- <delete file="${jboss.home}/server/default/deploy/jbpm-test-webapp.war/WEB-INF/lib/jta.jar" />
-
- <!-- add examples.jar -->
- <ant antfile="${jbpm.home}/examples/build.xml" target="examples.jar" />
- <copy file="${jbpm.home}/examples/target/examples.jar" todir="${jboss.home}/server/default/deploy/jbpm-test-webapp.war/WEB-INF/lib" />
-
- <!-- add junit.jar -->
- <copy file="${jbpm.home}/lib/junit.jar" todir="${jboss.home}/server/default/deploy/jbpm-test-webapp.war/WEB-INF/lib" />
-
- <!-- add the cactus libs -->
- <copy todir="${jboss.home}/server/default/deploy/jbpm-test-webapp.war/WEB-INF/lib">
- <fileset dir="../modules/test-cactus/target/jbpm.test.webapp.libs" />
- </copy>
- </target>
-
<!-- REINSTALL JBPM -->
<target name="reinstall.jbpm"
description="deletes the jbpm installation and then reinstalls jbpm">
Added: jbpm4/trunk/qa/debug.enterprise.setup.bat
===================================================================
--- jbpm4/trunk/qa/debug.enterprise.setup.bat (rev 0)
+++ jbpm4/trunk/qa/debug.enterprise.setup.bat 2009-12-22 17:49:40 UTC (rev 6022)
@@ -0,0 +1,9 @@
+cmd /C mvn -U -Pdistro,integration clean install
+cmd /C ant -f qa/build.xml -Djboss.version=5.1.0.GA testsuite.enterprise.setup.for.debug
+start "JBOSS DEBUG" /DC:\Software\jbpm-4.3-SNAPSHOT\jboss-5.1.0.GA\bin run.bat
+cd modules\test-enterprise\test-enterprise-suite
+
+@echo off
+echo
+echo after jboss booted and you connected your eclipse to it in a debug session execute following command
+echo mvn -Pruntest test
Copied: jbpm4/trunk/qa/debug.jboss.setup.bat (from rev 6015, jbpm4/trunk/qa/debug.on.jboss.setup.bat)
===================================================================
--- jbpm4/trunk/qa/debug.jboss.setup.bat (rev 0)
+++ jbpm4/trunk/qa/debug.jboss.setup.bat 2009-12-22 17:49:40 UTC (rev 6022)
@@ -0,0 +1,4 @@
+@echo off
+
+cmd /C mvn -U -Pdistro,enterprise clean install
+cmd /C ant -f qa/build.xml -Djboss.version=5.1.0.GA testsuite.enterprise.setup.for.debug
Deleted: jbpm4/trunk/qa/debug.on.jboss.setup.bat
===================================================================
--- jbpm4/trunk/qa/debug.on.jboss.setup.bat 2009-12-22 16:59:58 UTC (rev 6021)
+++ jbpm4/trunk/qa/debug.on.jboss.setup.bat 2009-12-22 17:49:40 UTC (rev 6022)
@@ -1,4 +0,0 @@
-@echo off
-
-cmd /C mvn -U -Pdistro,integration clean install
-cmd /C ant -f qa/build.xml -Djboss.version=5.1.0.GA testsuite.jboss.setup.for.debug
Copied: jbpm4/trunk/qa/enterprise/jbpm-test-destinations-service.xml (from rev 6015, jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/resources/jbpm-test-destinations-service.xml)
===================================================================
--- jbpm4/trunk/qa/enterprise/jbpm-test-destinations-service.xml (rev 0)
+++ jbpm4/trunk/qa/enterprise/jbpm-test-destinations-service.xml 2009-12-22 17:49:40 UTC (rev 6022)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<server>
+ <mbean code="org.jboss.jms.server.destination.QueueService"
+ name="jboss.messaging.destination:service=Queue,name=jbpm-test-queue"
+ xmbean-dd="xmdesc/Queue-xmbean.xml">
+ <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+ <depends>jboss.messaging:service=PostOffice</depends>
+ </mbean>
+</server>
\ No newline at end of file
Property changes on: jbpm4/trunk/qa/enterprise/jbpm-test-destinations-service.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
14 years, 4 months
JBoss JBPM SVN: r6021 - jbpm4/trunk/modules/api/src/main/resources.
by do-not-reply@jboss.org
Author: koen.aers(a)jboss.com
Date: 2009-12-22 11:59:58 -0500 (Tue, 22 Dec 2009)
New Revision: 6021
Modified:
jbpm4/trunk/modules/api/src/main/resources/jpdl-4.3.xsd
Log:
added 'transacted' and 'acknowledge' attributes to 'jms' type
Modified: jbpm4/trunk/modules/api/src/main/resources/jpdl-4.3.xsd
===================================================================
--- jbpm4/trunk/modules/api/src/main/resources/jpdl-4.3.xsd 2009-12-22 15:38:01 UTC (rev 6020)
+++ jbpm4/trunk/modules/api/src/main/resources/jpdl-4.3.xsd 2009-12-22 16:59:58 UTC (rev 6021)
@@ -1315,6 +1315,12 @@
<attribute name="destination" type="string">
<annotation><documentation>jndi name of the destination to send the message to</documentation></annotation>
</attribute>
+ <attribute name="transacted" type="tns:booleanValueType" default="false">
+ <annotation><documentation>indicates whether the message should be sent in a transactional way</documentation></annotation>
+ </attribute>
+ <attribute name="acknowledge" type="tns:acknowledgeType" default="auto">
+ <annotation><documentation>indicates the acknowledgment mode</documentation></annotation>
+ </attribute>
</complexType>
<complexType name="mailRecipientType">
@@ -1342,7 +1348,15 @@
</restriction>
</simpleType>
+ <simpleType name="acknowledgeType">
+ <restriction base="string">
+ <enumeration value="auto" />
+ <enumeration value="client" />
+ <enumeration value="dups-ok" />
+ </restriction>
+ </simpleType>
+
<simpleType name="templateType">
<annotation><documentation>Reference to the email template</documentation></annotation>
<restriction base="string"></restriction>
14 years, 4 months
JBoss JBPM SVN: r6020 - jbpm4/trunk/modules/devguide/src/main/docbook/en/modules.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-12-22 10:38:01 -0500 (Tue, 22 Dec 2009)
New Revision: 6020
Modified:
jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch02-Incubation.xml
Log:
JBPM-2695 added jms testing docs
Modified: jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch02-Incubation.xml
===================================================================
--- jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch02-Incubation.xml 2009-12-22 15:10:53 UTC (rev 6019)
+++ jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch02-Incubation.xml 2009-12-22 15:38:01 UTC (rev 6020)
@@ -894,12 +894,24 @@
</tgroup>
</table>
- <para>
- The <literal>connection-factory</literal> and <literal>destination</literal> attributes are
+ <para>There are 3 types of JMS messages that you can send to to the destination: text, object
+ and map. The <literal>connection-factory</literal> and <literal>destination</literal> attributes are
mandatory and respectively contain the names of the connection factory and destination (queue or topic)
- that will be used to lookup the corresponding objects in jndi. The specified message will be sent
- to the destination that was obtained by this lookup.
+ that will be used to lookup the corresponding objects in JNDI. The lookup is done like this:
</para>
+ <programlisting>InitialContext initialContext = new InitialContext();
+Destination destination = (Destination) initialContext.lookup(destinationName);</programlisting>
+ <para>So if you're running inside an appserver, then the <literal>new InitialContext()</literal>
+ will see the queue's and topics configured in the appserver.</para>
+ <para>When your're using the JMS mocking
+ in standalone test mode, then the queues and topics that you created with <literal>JbpmTestCase.jmsCreateQueue</literal>
+ and <literal>JbpmTestCase.jmsCreateTopic</literal> will be available.</para>
+ <para>When you're running as a remote application client, then you have to
+ <ulink url="http://java.sun.com/products/jndi/tutorial/beyond/env/source.html">specify
+ the jndi environment with system properties</ulink>.</para>
+ <para>The <literal>jms</literal> activity will use the JMS queue apis if the destination
+ is an <literal>instanceof</literal> Queue. Analogue for topics.
+ </para>
<table><title><literal>jms</literal> elements:</title>
<tgroup cols="3" rowsep="1" colsep="1">
@@ -947,6 +959,43 @@
<mediaobject><imageobject><imagedata align="center" fileref="images/process.jms.png"/></imageobject></mediaobject>
+ <section id="mockjmsproviderforeasytesting">
+ <title>Mock JMS provider for easy testing</title>
+ <para>Apart from configuring a real JMS and making sure it is available in JNDI,
+ a <literal>jms</literal> activity can also be tested with a mock JMS provider.
+ That might be easier to perform scenario testing of your process.</para>
+ <para>Following test helper methods are based solely on plain JMS apis and hence they work in
+ a standalone environment as well as in an appserver environment:</para>
+ <itemizedlist>
+ <listitem>Object jmsConsumeMessageFromQueue(String connectionFactoryJndiName, String queueJndiName)</listitem>
+ <listitem>TODO jmsStartTopicListener(String connectionFactoryJndiName, String topicJndiName)</listitem>
+ <listitem>void jmsStopTopicListener(String connectionFactoryJndiName, String topicJndiName)</listitem>
+ </itemizedlist>
+ <para>For example, after the process execution has executed the <literal>jms</literal> activity,
+ messages can be asserted like this:</para>
+ <programlisting>MapMessage mapMessage = (MapMessage) jmsConsumeMessageFromQueue("jms/ConnectionFactory", "queue/ProductQueue");
+assertEquals("shampoo", mapMessage.getString("product"));</programlisting>
+ <para>The following jms helper methods are based on mockrunner and hence they only work in a standalone
+ environment:</para>
+ <para>(we're collaborating with mockrunner people to have these methods also work in an appserver environment)</para>
+ <itemizedlist>
+ <listitem>void jmsCreateQueue(String connectionFactoryJndiName, String queueJndiName)</listitem>
+ <listitem>void jmsRemoveQueue(String connectionFactoryJndiName, String queueJndiName)</listitem>
+ <listitem>void jmsCreateTopic(String connectionFactoryJndiName, String topicJndiName)</listitem>
+ <listitem>void jmsRemoveTopic(String connectionFactoryJndiName, String topicJndiName)</listitem>
+ </itemizedlist>
+ <para>For example, a queue can be created and removed in the setup and tearDown methods of a test like this:</para>
+ <programlisting>protected void setUp() throws Exception {
+ super.setUp();
+ jmsCreateQueue("jms/ConnectionFactory", "queue/ProductQueue");
+}
+
+protected void tearDown() throws Exception {
+ jmsRemoveQueue("jms/ConnectionFactory", "queue/ProductQueue");
+ super.tearDown();
+}</programlisting>
+ </section>
+
<section id="jms.text">
<title>Text messages</title>
@@ -980,8 +1029,7 @@
The payload of the message is the text string "This is the body".
</para>
- <programlisting>public void testTextMessage() throws Exception
-{
+ <programlisting>public void testTextMessage() throws Exception {
Context context = new InitialContext();
Connection connection = (Connection)context.lookup("ConnectionFactory");
connection.start();
14 years, 4 months
JBoss JBPM SVN: r6019 - in jbpm4/trunk/modules: test-enterprise/test-enterprise-suite/src/test/resources/org/jbpm/test/jms/map and 2 other directories.
by do-not-reply@jboss.org
Author: koen.aers(a)jboss.com
Date: 2009-12-22 10:10:53 -0500 (Tue, 22 Dec 2009)
New Revision: 6019
Modified:
jbpm4/trunk/modules/api/src/main/resources/jpdl-4.3.xsd
jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/resources/org/jbpm/test/jms/map/process.jpdl.xml
jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/resources/org/jbpm/test/jms/object/process.jpdl.xml
jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/resources/org/jbpm/test/jms/text/process.jpdl.xml
Log:
- xsd update: add jms element
- update the jms processes to contain namespace
Modified: jbpm4/trunk/modules/api/src/main/resources/jpdl-4.3.xsd
===================================================================
--- jbpm4/trunk/modules/api/src/main/resources/jpdl-4.3.xsd 2009-12-22 13:32:20 UTC (rev 6018)
+++ jbpm4/trunk/modules/api/src/main/resources/jpdl-4.3.xsd 2009-12-22 15:10:53 UTC (rev 6019)
@@ -328,6 +328,23 @@
</complexType>
</element>
+ <!-- ~~~ JMS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+ <element name="jms">
+ <annotation><documentation>Sends an email
+ </documentation></annotation>
+ <complexType>
+ <complexContent>
+ <extension base="tns:jmsType">
+ <sequence>
+ <element ref="tns:on" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="tns:transition" minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ <attributeGroup ref="tns:activityAttributes" />
+ </extension>
+ </complexContent>
+ </complexType>
+ </element>
+
<!-- ~~~ JAVA ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<element name="java">
<annotation><documentation>Invokes a method on a java object.
@@ -607,37 +624,7 @@
</complexType>
</element>
- <element name="map">
- <annotation><documentation>A java.util.Map</documentation></annotation>
- <complexType>
- <choice minOccurs="0" maxOccurs="unbounded">
- <element name="entry">
- <complexType>
- <choice minOccurs="0">
- <element name="key" minOccurs="0">
- <complexType>
- <group ref="tns:wireObjectGroup" />
- </complexType>
- </element>
- <element name="value" minOccurs="0">
- <complexType>
- <group ref="tns:wireObjectGroup" />
- </complexType>
- </element>
- </choice>
- </complexType>
- </element>
- </choice>
- <attribute name="class" type="string" default="java.util.HashMap">
- <annotation><documentation>Implementation class for this map.
- </documentation></annotation>
- </attribute>
- <attribute name="synchronized" type="tns:booleanValueType" default="false">
- <annotation><documentation>Indicates if this collection should be synchronized
- with Collections.synchronizedList(List)</documentation></annotation>
- </attribute>
- </complexType>
- </element>
+ <element name="map" type="tns:mapType"/>
<element name="set">
<annotation><documentation>A java.util.Set
@@ -943,6 +930,36 @@
</documentation></annotation>
</attribute>
</complexType>
+
+ <complexType name="mapType">
+ <annotation><documentation>A java.util.Map</documentation></annotation>
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element name="entry">
+ <complexType>
+ <sequence minOccurs="0">
+ <element name="key" minOccurs="0">
+ <complexType>
+ <group ref="tns:wireObjectGroup" />
+ </complexType>
+ </element>
+ <element name="value" minOccurs="0">
+ <complexType>
+ <group ref="tns:wireObjectGroup" />
+ </complexType>
+ </element>
+ </sequence>
+ </complexType>
+ </element>
+ </choice>
+ <attribute name="class" type="string" default="java.util.HashMap">
+ <annotation><documentation>Implementation class for this map.
+ </documentation></annotation>
+ </attribute>
+ <attribute name="synchronized" type="tns:booleanValueType" default="false">
+ <annotation><documentation>Indicates if this collection should be synchronized
+ with Collections.synchronizedList(List)</documentation></annotation>
+ </attribute>
+ </complexType>
<complexType name="javaType">
<sequence>
@@ -1286,6 +1303,20 @@
<attribute name="template" type="tns:templateType" />
</complexType>
+ <complexType name="jmsType">
+ <choice minOccurs="1" maxOccurs="1">
+ <element name="object" type="tns:wireObjectType"/>
+ <element name="text" type="string"/>
+ <element name="map" type="tns:mapType"/>
+ </choice>
+ <attribute name="connection-factory" type="string">
+ <annotation><documentation>jndi name of the jms connection factory</documentation></annotation>
+ </attribute>
+ <attribute name="destination" type="string">
+ <annotation><documentation>jndi name of the destination to send the message to</documentation></annotation>
+ </attribute>
+ </complexType>
+
<complexType name="mailRecipientType">
<attribute name="addresses" type="string">
<annotation><documentation>list of email address separated by ',' (comma) ';' (semicolon) '|' or whitespace</documentation></annotation>
Modified: jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/resources/org/jbpm/test/jms/map/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/resources/org/jbpm/test/jms/map/process.jpdl.xml 2009-12-22 13:32:20 UTC (rev 6018)
+++ jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/resources/org/jbpm/test/jms/map/process.jpdl.xml 2009-12-22 15:10:53 UTC (rev 6019)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-<process name="JMS_map_queue">
+<process name="JMS_map_queue" xmlns="http://jbpm.org/4.3/jpdl">
<start g="20,20,48,48">
<transition to="send message" />
Modified: jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/resources/org/jbpm/test/jms/object/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/resources/org/jbpm/test/jms/object/process.jpdl.xml 2009-12-22 13:32:20 UTC (rev 6018)
+++ jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/resources/org/jbpm/test/jms/object/process.jpdl.xml 2009-12-22 15:10:53 UTC (rev 6019)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-<process name="JMS_object_queue">
+<process name="JMS_object_queue" xmlns="http://jbpm.org/4.3/jpdl">
<start g="20,20,48,48">
<transition to="send message" />
Modified: jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/resources/org/jbpm/test/jms/text/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/resources/org/jbpm/test/jms/text/process.jpdl.xml 2009-12-22 13:32:20 UTC (rev 6018)
+++ jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/resources/org/jbpm/test/jms/text/process.jpdl.xml 2009-12-22 15:10:53 UTC (rev 6019)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-<process name="JMS_text_queue">
+<process name="JMS_text_queue" xmlns="http://jbpm.org/4.3/jpdl">
<start g="20,20,48,48">
<transition to="send message" />
14 years, 4 months
JBoss JBPM SVN: r6018 - in jbpm4/trunk/modules: test-db/src/test/java/org/jbpm/test/history and 1 other directories.
by do-not-reply@jboss.org
Author: jbarrez
Date: 2009-12-22 08:32:20 -0500 (Tue, 22 Dec 2009)
New Revision: 6018
Modified:
jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/custombusinesscalendarcfg/CustomBusinessCalendarCfgTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/AvgDurationTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/HistoryTaskQueryTest.java
Log:
Fixing Hudson: Clock.setCurrentTime(null) has to be called in a tearDown() of a test when using the Clock.setCurrentTime(some date) method
Modified: jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/custombusinesscalendarcfg/CustomBusinessCalendarCfgTest.java
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/custombusinesscalendarcfg/CustomBusinessCalendarCfgTest.java 2009-12-22 13:00:18 UTC (rev 6017)
+++ jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/custombusinesscalendarcfg/CustomBusinessCalendarCfgTest.java 2009-12-22 13:32:20 UTC (rev 6018)
@@ -35,6 +35,12 @@
* @author Tom Baeyens
*/
public class CustomBusinessCalendarCfgTest extends JbpmCustomCfgTestCase {
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ Clock.setCurrentTime(null);
+ }
public void testCustomBusinessCalendarCfg() {
deployJpdlXmlString(
Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/AvgDurationTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/AvgDurationTest.java 2009-12-22 13:00:18 UTC (rev 6017)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/AvgDurationTest.java 2009-12-22 13:32:20 UTC (rev 6018)
@@ -24,6 +24,8 @@
import java.util.Map;
import org.jbpm.api.Execution;
+import org.jbpm.api.ProcessDefinition;
+import org.jbpm.pvm.internal.util.Clock;
import org.jbpm.test.JbpmTestCase;
@@ -33,7 +35,7 @@
public class AvgDurationTest extends JbpmTestCase {
public void testAvgDuration() throws Exception {
- deployJpdlXmlString(
+ String deploymentId = deployJpdlXmlString(
"<process name='Insurance claim' key='ICL'>" +
" <start>" +
" <transition to='one' />" +
@@ -55,7 +57,8 @@
executeProcess();
executeProcess();
- Map<String, Long> avgDurations = historyService.avgDurationPerActivity("ICL-1");
+ ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().uniqueResult();
+ Map<String, Long> avgDurations = historyService.avgDurationPerActivity(processDefinition.getId());
Long avgDurationOne = avgDurations.get("one");
Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/HistoryTaskQueryTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/HistoryTaskQueryTest.java 2009-12-22 13:00:18 UTC (rev 6017)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/HistoryTaskQueryTest.java 2009-12-22 13:32:20 UTC (rev 6018)
@@ -44,6 +44,12 @@
*/
public class HistoryTaskQueryTest extends JbpmTestCase {
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ Clock.setCurrentTime(null);
+ }
+
public void testOrderByName() {
testOrderBy(HistoryTaskQuery.PROPERTY_ASSIGNEE, Arrays.asList("Alex", "Joram", "Tom"));
}
14 years, 4 months
JBoss JBPM SVN: r6017 - in jbpm4/trunk/modules: api/src/main/java/org/jbpm/api/history and 3 other directories.
by do-not-reply@jboss.org
Author: jbarrez
Date: 2009-12-22 08:00:18 -0500 (Tue, 22 Dec 2009)
New Revision: 6017
Added:
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/ProcessInstanceQueryTest.java
Modified:
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/DeploymentQuery.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/JobQuery.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/ProcessDefinitionQuery.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/ProcessInstanceQuery.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/TaskQuery.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryActivityInstanceQuery.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryProcessInstanceQuery.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryTaskQuery.java
jbpm4/trunk/modules/distro/src/main/files/readme.html
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/AbstractQuery.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/DeploymentQueryImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryActivityInstanceQueryImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryProcessInstanceQueryImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryTaskQueryImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/JobQueryImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessInstanceQueryImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/TaskQueryImpl.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/DeploymentQueryTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/HistoryActivityInstanceQueryTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/HistoryProcessInstanceQueryTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/HistoryTaskQueryTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/JobQueryTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/TaskQueryTest.java
Log:
JBPM-2567: allow count() on all query types
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/DeploymentQuery.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/DeploymentQuery.java 2009-12-22 09:43:59 UTC (rev 6016)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/DeploymentQuery.java 2009-12-22 13:00:18 UTC (rev 6017)
@@ -29,15 +29,11 @@
*/
public interface DeploymentQuery {
- /** sorting by name does not work on oracle. that's why it is deprecated.
- * will be removed in jBPM 4.3 */
- @Deprecated
- String PROPERTY_NAME = "name";
String PROPERTY_TIMESTAMP = "timestamp";
String PROPERTY_STATE = "state";
/** only include a specific deployment by id */
- DeploymentQuery deploymentDbid(long dbid);
+ DeploymentQuery deploymentId(String id);
/** only select suspended deployments */
DeploymentQuery suspended();
@@ -50,5 +46,9 @@
DeploymentQuery page(int firstResult, int maxResults);
List<Deployment> list();
+
Deployment uniqueResult();
+
+ /** Returns the count for this query. */
+ Long count();
}
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/JobQuery.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/JobQuery.java 2009-12-22 09:43:59 UTC (rev 6016)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/JobQuery.java 2009-12-22 13:00:18 UTC (rev 6017)
@@ -69,4 +69,8 @@
/** execute the query and get the unique result */
Job uniqueResult();
+
+ /** Returns the count for the query. */
+ Long count();
+
}
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/ProcessDefinitionQuery.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/ProcessDefinitionQuery.java 2009-12-22 09:43:59 UTC (rev 6016)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/ProcessDefinitionQuery.java 2009-12-22 13:00:18 UTC (rev 6017)
@@ -76,4 +76,5 @@
/** execute the query and obtain the unique {@link ProcessDefinition} */
ProcessDefinition uniqueResult();
+
}
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/ProcessInstanceQuery.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/ProcessInstanceQuery.java 2009-12-22 09:43:59 UTC (rev 6016)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/ProcessInstanceQuery.java 2009-12-22 13:00:18 UTC (rev 6017)
@@ -62,4 +62,8 @@
/** execute the query and obtain the unique {@link ProcessInstance} */
ProcessInstance uniqueResult();
+
+ /** execute the query and return the count */
+ Long count();
+
}
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/TaskQuery.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/TaskQuery.java 2009-12-22 09:43:59 UTC (rev 6016)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/TaskQuery.java 2009-12-22 13:00:18 UTC (rev 6017)
@@ -83,6 +83,9 @@
/** order selected tasks descending for certain {@link #PROPERTY_NAME properties} */
TaskQuery orderDesc(String property);
+ /** does a count(*) on the given query. */
+ Long count();
+
/** execute the query and obtain the list of {@link Task}s */
List<Task> list();
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryActivityInstanceQuery.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryActivityInstanceQuery.java 2009-12-22 09:43:59 UTC (rev 6016)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryActivityInstanceQuery.java 2009-12-22 13:00:18 UTC (rev 6017)
@@ -78,4 +78,7 @@
/** execute the query and obtain the unique {@link HistoryActivityInstance} */
HistoryActivityInstance uniqueResult();
+
+ /** Returns the count of this query. */
+ Long count();
}
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryProcessInstanceQuery.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryProcessInstanceQuery.java 2009-12-22 09:43:59 UTC (rev 6016)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryProcessInstanceQuery.java 2009-12-22 13:00:18 UTC (rev 6017)
@@ -69,4 +69,8 @@
/** execute the query and obtain the unique {@link HistoryProcessInstance} */
HistoryProcessInstance uniqueResult();
+
+ /** Return the count of the query. */
+ Long count();
+
}
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryTaskQuery.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryTaskQuery.java 2009-12-22 09:43:59 UTC (rev 6016)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryTaskQuery.java 2009-12-22 13:00:18 UTC (rev 6017)
@@ -89,4 +89,8 @@
/** execute the query and obtain the unique {@link HistoryTask} */
HistoryTask uniqueResult();
+
+ /** Return the count for this query. */
+ Long count();
+
}
Modified: jbpm4/trunk/modules/distro/src/main/files/readme.html
===================================================================
--- jbpm4/trunk/modules/distro/src/main/files/readme.html 2009-12-22 09:43:59 UTC (rev 6016)
+++ jbpm4/trunk/modules/distro/src/main/files/readme.html 2009-12-22 13:00:18 UTC (rev 6017)
@@ -35,7 +35,21 @@
</tr>
</table>
+<h1>Release Notes for jBPM 4.3</h1>
+
+<h2>API changes</h2>
+
+<ul>
+ <li>
+ DeploymentQuery.PROPERTY_NAME has been removed due to errors when sorting on name on Oracle.
+ </li>
+ <li>
+ DeploymentQuery.deploymentDbId(long dbid) has been changed to DeploymentQuery.deploymentId(String id)
+ to be conistent with the query API.
+ </li>
+</ul>
+
<h1>Release Notes for jBPM 4.2</h1>
<h2>Known limitations</h2>
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/AbstractQuery.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/AbstractQuery.java 2009-12-22 09:43:59 UTC (rev 6016)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/AbstractQuery.java 2009-12-22 13:00:18 UTC (rev 6017)
@@ -49,6 +49,7 @@
protected String orderByClause = null;
protected Page page = null;
protected boolean isWhereAdded = false;
+ protected boolean count = false;
protected abstract void applyParameters(Query query);
@@ -112,10 +113,28 @@
}
/**
+ * Returns the count of the query.
+ * Query types that want to use this count method should
+ * - add the operation signature to their interface
+ * - use the 'count' variable in their hql() method.
+ */
+ public Long count() {
+ count = true;
+
+ // Page and count cannot be used together, because paging is applied after the query is formed
+ if (page != null) {
+ throw new JbpmException("page(firstResult, maxResult) and count() cannot be used together");
+ }
+
+ return (Long) untypedUniqueResult();
+ }
+
+ /**
* Resets the query so it can be reused after an invocation.
*/
private void resetQuery() {
isWhereAdded = false;
+ count = false;
}
protected void appendWhereClause(String whereClause, StringBuilder hql) {
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/DeploymentQueryImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/DeploymentQueryImpl.java 2009-12-22 09:43:59 UTC (rev 6016)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/DeploymentQueryImpl.java 2009-12-22 13:00:18 UTC (rev 6017)
@@ -34,18 +34,25 @@
*/
public class DeploymentQueryImpl extends AbstractQuery implements DeploymentQuery {
- protected Long deploymentDbid = null;
+ protected String deploymentId = null;
protected Boolean suspended = null;
public String hql() {
StringBuilder hql = new StringBuilder();
- hql.append("select d ");
+
+ hql.append("select ");
+ if (count) {
+ hql.append("count(d) ");
+ } else {
+ hql.append("d ");
+ }
+
hql.append("from ");
hql.append(DeploymentImpl.class.getName());
hql.append(" as d ");
- if (deploymentDbid!=null) {
- appendWhereClause("d.dbid = "+deploymentDbid+" ", hql);
+ if (deploymentId!=null) {
+ appendWhereClause("d.dbid = "+deploymentId+" ", hql);
}
if (suspended!=null) {
@@ -64,8 +71,8 @@
protected void applyParameters(Query query) {
}
- public DeploymentQuery deploymentDbid(long deploymentDbid) {
- this.deploymentDbid = deploymentDbid;
+ public DeploymentQuery deploymentId(String deploymentId) {
+ this.deploymentId = deploymentId;
return this;
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryActivityInstanceQueryImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryActivityInstanceQueryImpl.java 2009-12-22 09:43:59 UTC (rev 6016)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryActivityInstanceQueryImpl.java 2009-12-22 13:00:18 UTC (rev 6017)
@@ -48,7 +48,14 @@
public String hql() {
StringBuilder hql = new StringBuilder();
- hql.append("select hai ");
+
+ hql.append("select ");
+ if (count) {
+ hql.append("count(hai) ");
+ } else {
+ hql.append("hai ");
+ }
+
hql.append("from ");
hql.append(HistoryActivityInstanceImpl.class.getName());
hql.append(" as hai ");
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryProcessInstanceQueryImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryProcessInstanceQueryImpl.java 2009-12-22 09:43:59 UTC (rev 6016)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryProcessInstanceQueryImpl.java 2009-12-22 13:00:18 UTC (rev 6017)
@@ -42,7 +42,14 @@
public String hql() {
StringBuilder hql = new StringBuilder();
- hql.append("select hpi ");
+
+ hql.append("select ");
+ if (count) {
+ hql.append("count(hpi) ");
+ } else {
+ hql.append("hpi ");
+ }
+
hql.append("from ");
hql.append(HistoryProcessInstanceImpl.class.getName());
hql.append(" as hpi ");
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryTaskQueryImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryTaskQueryImpl.java 2009-12-22 09:43:59 UTC (rev 6016)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryTaskQueryImpl.java 2009-12-22 13:00:18 UTC (rev 6017)
@@ -28,6 +28,7 @@
import org.jbpm.api.history.HistoryTask;
import org.jbpm.api.history.HistoryTaskQuery;
import org.jbpm.pvm.internal.history.model.HistoryTaskImpl;
+import org.jbpm.pvm.internal.util.Clock;
/**
@@ -47,7 +48,14 @@
public String hql() {
StringBuilder hql = new StringBuilder();
- hql.append("select ht ");
+
+ hql.append("select ");
+ if (count) {
+ hql.append("count(ht) ");
+ } else {
+ hql.append("ht ");
+ }
+
hql.append("from ");
hql.append(HistoryTaskImpl.class.getName());
hql.append(" as ht ");
@@ -79,13 +87,13 @@
if (tookLongerThen!=null) {
appendWhereClause(" ht.duration > :tookLongerThen ", hql);
}
-
+
if (startedBefore!=null) {
- appendWhereClause(" ht.startTime < :startedBefore ", hql);
+ appendWhereClause(" ht.createTime < :startedBefore ", hql);
}
if (startedAfter!=null) {
- appendWhereClause(" ht.startTime > :startedAfter ", hql);
+ appendWhereClause(" ht.createTime > :startedAfter ", hql);
}
appendOrderByClause(hql);
@@ -103,11 +111,11 @@
}
if (startedBefore!=null) {
- query.setTime("startedBefore", startedBefore);
+ query.setTimestamp("startedBefore", startedBefore);
}
if (startedAfter!=null) {
- query.setTime("startedAfter", startedAfter);
+ query.setTimestamp("startedAfter", startedAfter);
}
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/JobQueryImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/JobQueryImpl.java 2009-12-22 09:43:59 UTC (rev 6016)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/JobQueryImpl.java 2009-12-22 13:00:18 UTC (rev 6017)
@@ -45,7 +45,14 @@
public String hql() {
StringBuilder hql = new StringBuilder();
- hql.append("select j ");
+
+ hql.append("select ");
+ if (count) {
+ hql.append("count(j) ");
+ } else {
+ hql.append("j ");
+ }
+
hql.append("from ");
if (messagesOnly) {
hql.append(MessageImpl.class.getName());
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessInstanceQueryImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessInstanceQueryImpl.java 2009-12-22 09:43:59 UTC (rev 6016)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessInstanceQueryImpl.java 2009-12-22 13:00:18 UTC (rev 6017)
@@ -50,7 +50,14 @@
public String hql() {
StringBuilder hql = new StringBuilder();
- hql.append("select processInstance ");
+
+ hql.append("select ");
+ if (count) {
+ hql.append("count(processInstance) ");
+ } else {
+ hql.append("processInstance ");
+ }
+
hql.append("from ");
hql.append(ExecutionImpl.class.getName());
hql.append(" as processInstance ");
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/TaskQueryImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/TaskQueryImpl.java 2009-12-22 09:43:59 UTC (rev 6016)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/TaskQueryImpl.java 2009-12-22 13:00:18 UTC (rev 6017)
@@ -136,7 +136,14 @@
public String hql() {
StringBuilder hql = new StringBuilder();
- hql.append("select task ");
+ hql.append("select ");
+
+ if (count) {
+ hql.append("count(task) ");
+ } else {
+ hql.append("task ");
+ }
+
hql.append("from ");
hql.append(TaskImpl.class.getName());
hql.append(" as task ");
Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/DeploymentQueryTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/DeploymentQueryTest.java 2009-12-22 09:43:59 UTC (rev 6016)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/DeploymentQueryTest.java 2009-12-22 13:00:18 UTC (rev 6017)
@@ -22,7 +22,6 @@
package org.jbpm.test.query;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -35,6 +34,7 @@
/**
* @author Tom Baeyens
+ * @author Joram Barrez
*/
public class DeploymentQueryTest extends JbpmTestCase {
@@ -84,6 +84,39 @@
deleteCascade(deploymentIds);
}
+
+
+ private void deleteCascade(List<String> deploymentIds) {
+ for (String deploymentId : deploymentIds) {
+ repositoryService.deleteDeploymentCascade(deploymentId);
+ }
+ }
+
+ public void testOrderByTimeStamp() {
+ testOrderByNaturalOrdening(DeploymentQuery.PROPERTY_TIMESTAMP, 3);
+ }
+
+ public void testCount() {
+ List<String> deploymentIds = deployTestProcesses();
+
+ assertEquals(new Long(3L), repositoryService.createDeploymentQuery().count());
+ for (String deploymentId : deploymentIds) {
+ assertEquals(new Long(1L), repositoryService.createDeploymentQuery().deploymentId(deploymentId).count());
+ }
+
+ Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(deploymentIds.get(0)).uniqueResult();
+ repositoryService.suspendDeployment(deployment.getId());
+
+ assertEquals(new Long(1L), repositoryService.createDeploymentQuery().suspended().count());
+ assertEquals(new Long(2L), repositoryService.createDeploymentQuery().notSuspended().count());
+
+ deleteCascade(deploymentIds);
+ }
+
+ /* --------------
+ * HELPER METHODS
+ * -------------- */
+
private Set<String> getDeploymentNames(List<Deployment> deployments) {
Set<String> deploymentNames = new HashSet<String>();
for (Deployment deployment: deployments) {
@@ -141,16 +174,6 @@
return processIds;
}
- private void deleteCascade(List<String> deploymentIds) {
- for (String deploymentId : deploymentIds) {
- repositoryService.deleteDeploymentCascade(deploymentId);
- }
- }
-
- public void testOrderByTimeStamp() {
- testOrderByNaturalOrdening(DeploymentQuery.PROPERTY_TIMESTAMP, 3);
- }
-
private void testOrderBy(String property, List expectedValues) {
testOrderBy(property, expectedValues, null, false);
}
Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/HistoryActivityInstanceQueryTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/HistoryActivityInstanceQueryTest.java 2009-12-22 09:43:59 UTC (rev 6016)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/HistoryActivityInstanceQueryTest.java 2009-12-22 13:00:18 UTC (rev 6017)
@@ -172,6 +172,28 @@
testOrderByNaturalOrdening(HistoryActivityInstanceQuery.PROPERTY_EXECUTIONID, 9);
}
+ public void testCount() {
+ List<String> procInstIds = deployStartAndSignalTestProcesses();
+
+ assertEquals(new Long(9L), historyService.createHistoryActivityInstanceQuery().count());
+ assertEquals(new Long(4L), historyService.createHistoryActivityInstanceQuery().activityName("a").count());
+ assertEquals(new Long(3L), historyService.createHistoryActivityInstanceQuery().activityName("b").count());
+ assertEquals(new Long(2L), historyService.createHistoryActivityInstanceQuery().activityName("c").count());
+ assertEquals(new Long(0L), historyService.createHistoryActivityInstanceQuery().activityName("d").count());
+
+ assertEquals(new Long(3L), historyService.createHistoryActivityInstanceQuery().executionId(procInstIds.get(0)).count());
+ assertEquals(new Long(3L), historyService.createHistoryActivityInstanceQuery().executionId(procInstIds.get(1)).count());
+ assertEquals(new Long(2L), historyService.createHistoryActivityInstanceQuery().executionId(procInstIds.get(2)).count());
+ assertEquals(new Long(1L), historyService.createHistoryActivityInstanceQuery().executionId(procInstIds.get(3)).count());
+
+ assertEquals(new Long(1L), historyService.createHistoryActivityInstanceQuery()
+ .executionId(procInstIds.get(0)).activityName("a").count());
+ assertEquals(new Long(1L), historyService.createHistoryActivityInstanceQuery()
+ .executionId(procInstIds.get(0)).activityName("b").count());
+ assertEquals(new Long(1L), historyService.createHistoryActivityInstanceQuery()
+ .executionId(procInstIds.get(0)).activityName("c").count());
+ }
+
/**
* Generates some history data.
*
@@ -180,6 +202,8 @@
* - 1 process instance in state c (signalled a,b)
* - 1 process instance in state b (signalled a)
* - 1 process instance in state a (just started)
+ *
+ * (in this exact order!)
*/
private List<String> deployStartAndSignalTestProcesses() {
deployTestProcess();
Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/HistoryProcessInstanceQueryTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/HistoryProcessInstanceQueryTest.java 2009-12-22 09:43:59 UTC (rev 6016)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/HistoryProcessInstanceQueryTest.java 2009-12-22 13:00:18 UTC (rev 6017)
@@ -24,8 +24,10 @@
*/
package org.jbpm.test.query;
+import java.util.ArrayList;
import java.util.List;
+import org.jbpm.api.ProcessDefinition;
import org.jbpm.api.history.HistoryProcessInstance;
import org.jbpm.api.history.HistoryProcessInstanceQuery;
import org.jbpm.test.JbpmTestCase;
@@ -37,6 +39,41 @@
*/
public class HistoryProcessInstanceQueryTest extends JbpmTestCase {
+ public void testQueryByProcessInstanceId() {
+ List<String> procInstIds = createTestHistoryProcessInstances(4);
+ for (String processInstanceId : procInstIds) {
+ assertNotNull(historyService.createHistoryProcessInstanceQuery().processInstanceId(processInstanceId).uniqueResult());
+ }
+ }
+
+ public void testQueryByProcessDefinitionId() {
+ createTestHistoryProcessInstances(5);
+ ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().uniqueResult();
+ assertEquals(5, historyService.createHistoryProcessInstanceQuery()
+ .processDefinitionId(processDefinition.getId()).list().size());
+ }
+
+ public void testQueryByBusinessKey() {
+ final int nrOfInstances = 3;
+ createTestHistoryProcessInstances(nrOfInstances);
+ for (int i = 0; i < nrOfInstances; i++) {
+ assertNotNull(historyService.createHistoryProcessInstanceQuery().processInstanceKey("theProcess-" + i).uniqueResult());
+ }
+ }
+
+ public void testCount() {
+ List<String> procInstIds = createTestHistoryProcessInstances(7);
+
+ assertEquals(new Long(0L), historyService.createHistoryProcessInstanceQuery().processDefinitionId("-1").count());
+
+ assertEquals(new Long(7L), historyService.createHistoryProcessInstanceQuery().count());
+
+ for (String id : procInstIds) {
+ assertEquals(new Long(1L), historyService.createHistoryProcessInstanceQuery().processInstanceId(id).count());
+ }
+
+ }
+
public void testOrderByStartTime() {
testOrderByNaturalOrdening(HistoryProcessInstanceQuery.PROPERTY_STARTTIME, 4);
}
@@ -56,7 +93,7 @@
// Don't delete because it isn't used. Could be handy in the future!
private void testOrderBy(String property, List<Object> expectedValues) {
- createTestHistoryProcessInstances();
+ createTestHistoryProcessInstances(4);
List<HistoryProcessInstance> histProcListAsc =
historyService.createHistoryProcessInstanceQuery()
@@ -72,7 +109,7 @@
}
private void testOrderByNaturalOrdening(String property, int expectedNrOfResults) {
- createTestHistoryProcessInstances();
+ createTestHistoryProcessInstances(4);
List<HistoryProcessInstance> histProcListAsc =
historyService.createHistoryProcessInstanceQuery()
@@ -87,7 +124,7 @@
QueryAssertions.assertOrderIsNatural(HistoryProcessInstance.class, property, histProcListAsc, histProcListDesc, expectedNrOfResults);
}
- private void createTestHistoryProcessInstances() {
+ private List<String> createTestHistoryProcessInstances(int nrOfInstances) {
deployJpdlXmlString(
"<process name='theProcess'>" +
" <start>" +
@@ -96,9 +133,11 @@
" <end name='end' />" +
"</process>");
- for (int i = 0; i < 4; i++) {
- executionService.startProcessInstanceByKey("theProcess");
+ List<String> procInstIds = new ArrayList<String>();
+ for (int i = 0; i < nrOfInstances; i++) {
+ procInstIds.add(executionService.startProcessInstanceByKey("theProcess", "theProcess-" + i).getId());
}
+ return procInstIds;
}
Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/HistoryTaskQueryTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/HistoryTaskQueryTest.java 2009-12-22 09:43:59 UTC (rev 6016)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/HistoryTaskQueryTest.java 2009-12-22 13:00:18 UTC (rev 6017)
@@ -27,12 +27,14 @@
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import org.jbpm.api.history.HistoryTask;
import org.jbpm.api.history.HistoryTaskQuery;
+import org.jbpm.pvm.internal.util.Clock;
import org.jbpm.test.JbpmTestCase;
import org.jbpm.test.assertion.QueryAssertions;
@@ -69,36 +71,6 @@
public void testOrderByState() {
testOrderByNaturalOrdening(HistoryTaskQuery.PROPERTY_STATE, 3);
}
-
- private void createTestHistoryTasks() {
- String processXml1 =
- "<process name='theProcess1'>" +
- " <start>" +
- " <transition to='theTask' />" +
- " </start>" +
- " <task name='theTask' assignee='Alex'>" +
- " <transition to='theEnd' />" +
- " </task>" +
- " <end name='theEnd' />" +
- "</process>";
-
- String processXml3 = processXml1.replace("1", "2").replace("Alex", "Tom");
- String processXml2 = processXml1.replace("1", "3").replace("Alex", "Joram");
-
- deployJpdlXmlString(processXml1);
- deployJpdlXmlString(processXml2);
- deployJpdlXmlString(processXml3);
-
- executionService.startProcessInstanceByKey("theProcess1");
- executionService.startProcessInstanceByKey("theProcess2");
- executionService.startProcessInstanceByKey("theProcess3");
-
- taskService.completeTask(taskService.findPersonalTasks("Alex").get(0).getId());
- taskService.completeTask(taskService.findPersonalTasks("Joram").get(0).getId());
- taskService.completeTask(taskService.findPersonalTasks("Tom").get(0).getId());
-
- taskService.findPersonalTasks("Alex");
- }
private void testOrderBy(String property, List expectedValues) {
testOrderBy(property, expectedValues, null, false);
@@ -108,6 +80,25 @@
testOrderBy(property, null, expectedNrOfResults, true);
}
+ public void testCount() {
+ List<String> taskIds = createTestHistoryTasks();
+
+ assertEquals(new Long(3L), historyService.createHistoryTaskQuery().count());
+ assertEquals(new Long(1L), historyService.createHistoryTaskQuery().assignee("Tom").count());
+
+ for (String taskid : taskIds) {
+ assertEquals(new Long(1L), historyService.createHistoryTaskQuery().taskId(taskid).count());
+ }
+
+ assertEquals(new Long(0L), historyService.createHistoryTaskQuery().startedBefore(new Date(CLOCK_TEST_TIME - 10000L)).count());
+ assertEquals(new Long(1L),
+ historyService.createHistoryTaskQuery().startedAfter(new Date(CLOCK_TEST_TIME - 10000L))
+ .taskId(taskIds.get(0)).count());
+ assertEquals(new Long(0L),
+ historyService.createHistoryTaskQuery().startedAfter(new Date(CLOCK_TEST_TIME - 10000L))
+ .taskId("-1").count());
+ }
+
@SuppressWarnings("unchecked")
private void testOrderBy(String property, List expectedValues,
Integer expectedNrOfResults, boolean naturalOrderCheck) {
@@ -128,6 +119,45 @@
}
+ private static final Long CLOCK_TEST_TIME = 30000L;
+
+ private List<String> createTestHistoryTasks() {
+ String processXml1 =
+ "<process name='theProcess1'>" +
+ " <start>" +
+ " <transition to='theTask' />" +
+ " </start>" +
+ " <task name='theTask' assignee='Alex'>" +
+ " <transition to='theEnd' />" +
+ " </task>" +
+ " <end name='theEnd' />" +
+ "</process>";
+
+ Clock.setCurrentTime(new Date(CLOCK_TEST_TIME));
+
+ String processXml3 = processXml1.replace("1", "2").replace("Alex", "Tom");
+ String processXml2 = processXml1.replace("1", "3").replace("Alex", "Joram");
+
+ deployJpdlXmlString(processXml1);
+ deployJpdlXmlString(processXml2);
+ deployJpdlXmlString(processXml3);
+
+ executionService.startProcessInstanceByKey("theProcess1");
+ executionService.startProcessInstanceByKey("theProcess2");
+ executionService.startProcessInstanceByKey("theProcess3");
+
+ List<String> taskIds = new ArrayList<String>();
+ taskIds.add(taskService.findPersonalTasks("Alex").get(0).getId());
+ taskIds.add(taskService.findPersonalTasks("Joram").get(0).getId());
+ taskIds.add(taskService.findPersonalTasks("Tom").get(0).getId());
+
+ for (String taskId : taskIds) {
+ taskService.completeTask(taskId);
+ }
+
+ return taskIds;
+ }
+
private Date stringToDate(String dateString) {
DateFormat dateFormat = new SimpleDateFormat("dd/mm/yyyy");
try {
Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/JobQueryTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/JobQueryTest.java 2009-12-22 09:43:59 UTC (rev 6016)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/JobQueryTest.java 2009-12-22 13:00:18 UTC (rev 6017)
@@ -1,6 +1,28 @@
+/*
+ * 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.query;
import java.io.Serializable;
+import java.util.ArrayList;
import java.util.List;
import org.jbpm.api.JobQuery;
@@ -8,11 +30,14 @@
import org.jbpm.test.JbpmTestCase;
import org.jbpm.test.assertion.QueryAssertions;
-
+/**
+ * @author Tom Baeyens
+ * @author Joram Barrez
+ */
public class JobQueryTest extends JbpmTestCase {
public void testQueryOutstandingTimers() {
- startTestProcessInstances();
+ startTestProcessInstances(4);
List<Job> timers = managementService.createJobQuery()
.timers()
@@ -43,27 +68,6 @@
assertEquals(4, jobs.size());
}
- private void startTestProcessInstances() {
- deployJpdlXmlString(
- "<process name='TimerQueryTest' >" +
- " <start>" +
- " <transition to='t' />" +
- " </start>" +
- " <state name='t'>" +
- " <transition name='timeout' to='t'>" +
- " <timer duedate='20 seconds' />" +
- " </transition>" +
- " </state>" +
- "</process>"
- );
-
- executionService.startProcessInstanceByKey("TimerQueryTest");
- executionService.startProcessInstanceByKey("TimerQueryTest");
- executionService.startProcessInstanceByKey("TimerQueryTest");
- executionService.startProcessInstanceByKey("TimerQueryTest");
- }
-
-
public static class Dog implements Serializable {
private static final long serialVersionUID = 1L;
public void bark() {
@@ -120,10 +124,44 @@
}
public void testOrderByDueDate() {
- startTestProcessInstances();
+ startTestProcessInstances(4);
List<Job> jobsAsc = managementService.createJobQuery().orderAsc(JobQuery.PROPERTY_DUEDATE).list();
List<Job> jobsDesc = managementService.createJobQuery().orderDesc(JobQuery.PROPERTY_DUEDATE).list();
QueryAssertions.assertOrderIsNatural(Job.class, JobQuery.PROPERTY_DUEDATE, jobsAsc, jobsDesc, 4);
}
+ public void testCount() {
+ List<String> procInstIds = startTestProcessInstances(6);
+
+ assertEquals(new Long(6L), managementService.createJobQuery().count());
+ assertEquals(new Long(6L), managementService.createJobQuery().timers().count());
+
+ for (String id : procInstIds) {
+ assertEquals(new Long(1L), managementService.createJobQuery().processInstanceId(id).count());
+ assertEquals(new Long(1L), managementService.createJobQuery().processInstanceId(id).timers().count());
+ }
+
+ }
+
+ private List<String> startTestProcessInstances(int nrOfInstances) {
+ deployJpdlXmlString(
+ "<process name='TimerQueryTest' >" +
+ " <start>" +
+ " <transition to='t' />" +
+ " </start>" +
+ " <state name='t'>" +
+ " <transition name='timeout' to='t'>" +
+ " <timer duedate='20 hours' />" +
+ " </transition>" +
+ " </state>" +
+ "</process>"
+ );
+
+ List<String> ids = new ArrayList<String>();
+ for (int i = 0; i < nrOfInstances; i++) {
+ ids.add(executionService.startProcessInstanceByKey("TimerQueryTest").getId());
+ }
+ return ids;
+ }
+
}
Added: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/ProcessInstanceQueryTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/ProcessInstanceQueryTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/ProcessInstanceQueryTest.java 2009-12-22 13:00:18 UTC (rev 6017)
@@ -0,0 +1,253 @@
+/*
+ * 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.query;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jbpm.api.Deployment;
+import org.jbpm.api.JbpmException;
+import org.jbpm.api.ProcessDefinition;
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.api.ProcessInstanceQuery;
+import org.jbpm.test.JbpmTestCase;
+
+
+public class ProcessInstanceQueryTest extends JbpmTestCase {
+
+ private static final String TEST_PROCESS_1_KEY = "testProcess1";
+
+ private static final String TEST_PROCESS_1 =
+ "<process name='" + TEST_PROCESS_1_KEY + "'>" +
+ " <start>" +
+ " <transition to='a' />" +
+ " </start>" +
+ " <state name='a'>" +
+ " <transition to='end' />" +
+ " </state>" +
+ " <end name='end' />" +
+ "</process>";
+
+ private static final String TEST_PROCESS_2_KEY = "testProcess2";
+
+ private static final String TEST_PROCESS_2 =
+ "<process name='" + TEST_PROCESS_2_KEY + "'>" +
+ " <start>" +
+ " <transition to='f' />" +
+ " </start>" +
+ " <fork name='f'>" +
+ " <transition to='assemble product' />" +
+ " <transition to='print documents' />" +
+ " </fork>" +
+ " <task name='assemble product' assignee='johndoe'>" +
+ " <transition to='j' />" +
+ " </task>" +
+ " <task name='print documents' assignee='johndoe'>" +
+ " <transition to='j' />" +
+ " </task>" +
+ " <join name='j'>" +
+ " <transition to='end' />" +
+ " </join>" +
+ " <end name='end' />" +
+ "</process>";
+
+ public void testQueryByProcessInstanceId() {
+ Map<String, ArrayList<String>> processInstanceIds = startTestProcesses(3, 7);
+ List<String> idsForTestProcess1 = processInstanceIds.get(TEST_PROCESS_1_KEY);
+ List<String> idsForTestProcess2 = processInstanceIds.get(TEST_PROCESS_2_KEY);
+
+ for (String processInstanceId : idsForTestProcess1) {
+ ProcessInstance pi = executionService.createProcessInstanceQuery()
+ .processInstanceId(processInstanceId).uniqueResult();
+ assertNotNull(pi);
+
+ }
+
+ for (String processInstanceId : idsForTestProcess2) {
+ ProcessInstance pi = executionService.createProcessInstanceQuery()
+ .processInstanceId(processInstanceId).uniqueResult();
+ assertNotNull(pi);
+
+ }
+ }
+
+ public void testQueryByProcessInstanceKey() {
+ startTestProcesses(7, 8);
+
+ for (int i = 0; i < 7; i++) {
+ ProcessInstance pi = executionService.createProcessInstanceQuery()
+ .processInstanceKey(TEST_PROCESS_1_KEY + "-" + i).uniqueResult();
+ assertNotNull(pi);
+ }
+
+ for (int i = 0; i < 8; i++) {
+ ProcessInstance pi = executionService.createProcessInstanceQuery()
+ .processInstanceKey(TEST_PROCESS_2_KEY + "-" + i).uniqueResult();
+ assertNotNull(pi);
+ }
+
+ }
+
+ public void testQueryByProcessDefinitionId() {
+ startTestProcesses(10, 6);
+ ProcessDefinition definitionProcess1 =
+ repositoryService.createProcessDefinitionQuery().processDefinitionKey(TEST_PROCESS_1_KEY).uniqueResult();
+ ProcessDefinition definitionProcess2 =
+ repositoryService.createProcessDefinitionQuery().processDefinitionKey(TEST_PROCESS_2_KEY).uniqueResult();
+
+ List<ProcessInstance> processInstances =
+ executionService.createProcessInstanceQuery().processDefinitionId(definitionProcess1.getId()).list();
+ assertEquals(10, processInstances.size());
+
+ processInstances =
+ executionService.createProcessInstanceQuery().processDefinitionId(definitionProcess2.getId()).list();
+ assertEquals(6, processInstances.size());
+ }
+
+ public void testQueryBySuspended() {
+ startTestProcesses(6, 0); // Don't start any instance of test process 2
+
+ Deployment deployment = repositoryService.createDeploymentQuery().uniqueResult();
+ repositoryService.suspendDeployment(deployment.getId());
+
+ List<ProcessInstance> processInstances = executionService.createProcessInstanceQuery().suspended().list();
+ assertEquals(6, processInstances.size());
+ }
+
+ public void testQueryByNotSuspended() {
+ startTestProcesses(5, 5);
+
+ ProcessInstanceQuery query = executionService.createProcessInstanceQuery().notSuspended();
+ List<ProcessInstance> processInstances = query.list();
+ assertEquals(10, processInstances.size());
+
+ List<Deployment> deployments = repositoryService.createDeploymentQuery().list();
+ assertEquals(2, deployments.size());
+ repositoryService.suspendDeployment(deployments.get(0).getId());
+
+ processInstances = query.list();
+ assertEquals(5, processInstances.size());
+ }
+
+ public void testQueryByPage() {
+ startTestProcesses(8, 12);
+
+ for (int i = 0; i < 20; i += 2) {
+ List<ProcessInstance> processInstances = executionService.createProcessInstanceQuery().page(i, 2).list();
+ assertEquals(2, processInstances.size());
+ }
+ }
+
+ public void testOrderByAscKey() {
+ startTestProcesses(6, 10);
+
+ List<ProcessInstance> processInstances =
+ executionService.createProcessInstanceQuery().orderAsc(ProcessInstanceQuery.PROPERTY_KEY).list();
+ assertEquals(16, processInstances.size());
+
+ for (int i = 0; i < processInstances.size(); i++) {
+
+ if (i < 6 ) {
+ assertTrue(processInstances.get(i).getKey().startsWith(TEST_PROCESS_1_KEY));
+ } else {
+ assertTrue(processInstances.get(i).getKey().startsWith(TEST_PROCESS_2_KEY));
+ }
+
+ }
+ }
+
+ public void testOrderByDescKey() {
+ startTestProcesses(5, 9);
+
+ List<ProcessInstance> processInstances =
+ executionService.createProcessInstanceQuery().orderDesc(ProcessInstanceQuery.PROPERTY_KEY).list();
+ assertEquals(14, processInstances.size());
+
+ for (int i = 0; i < processInstances.size(); i++) {
+
+ if (i < 9 ) {
+ assertTrue(processInstances.get(i).getKey().startsWith(TEST_PROCESS_2_KEY));
+ } else {
+ assertTrue(processInstances.get(i).getKey().startsWith(TEST_PROCESS_1_KEY));
+ }
+
+ }
+ }
+
+ public void testCount() {
+ Map<String, ArrayList<String>> processInstanceIds = startTestProcesses(4, 6);
+ List<String> idsForTestProcess1 = processInstanceIds.get(TEST_PROCESS_1_KEY);
+
+ assertEquals(new Long(10L), executionService.createProcessInstanceQuery().count());
+
+ for (String processInstanceId : idsForTestProcess1) {
+ assertEquals(new Long(1L), executionService.createProcessInstanceQuery().processInstanceId(processInstanceId).count());
+ }
+
+ for (int i = 0; i < 6; i++) {
+ assertEquals(new Long(1L), executionService.createProcessInstanceQuery().processInstanceKey(TEST_PROCESS_2_KEY + "-" + i).count());
+ }
+
+ try {
+ executionService.createProcessInstanceQuery().page(0, 3).count();
+ fail("expected exception");
+ } catch (JbpmException e) { }
+
+ }
+
+
+ /**
+ * Returns a map containing a processKey - processInstanceId mapping.
+ * eg. TEST_PROCESS_1 - {"1", "5", "7", "8"}
+ *
+ * Process instance will also have a business key of the form 'processDefKey-nr', where
+ * nr is from 0 to the given nr of required processes.
+ */
+ private Map<String, ArrayList<String>> startTestProcesses(int nrOfTestProcess1, int nrOfTestProcess2) {
+ if (nrOfTestProcess1 > 0) {
+ deployJpdlXmlString(TEST_PROCESS_1);
+ }
+ if (nrOfTestProcess2 > 0) {
+ deployJpdlXmlString(TEST_PROCESS_2);
+ }
+
+ Map<String, ArrayList<String>> result = new HashMap<String, ArrayList<String>>();
+ result.put(TEST_PROCESS_1_KEY, new ArrayList<String>());
+ result.put(TEST_PROCESS_2_KEY, new ArrayList<String>());
+
+ for (int i = 0; i < nrOfTestProcess1; i++) {
+ ProcessInstance pi = executionService.startProcessInstanceByKey(TEST_PROCESS_1_KEY, TEST_PROCESS_1_KEY + "-" + i);
+ result.get(TEST_PROCESS_1_KEY).add(pi.getId());
+ }
+
+
+ for (int i = 0; i < nrOfTestProcess2; i++) {
+ ProcessInstance pi = executionService.startProcessInstanceByKey(TEST_PROCESS_2_KEY, TEST_PROCESS_2_KEY + "-" + i);
+ result.get(TEST_PROCESS_2_KEY).add(pi.getId());
+ }
+
+ return result;
+ }
+
+}
Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/TaskQueryTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/TaskQueryTest.java 2009-12-22 09:43:59 UTC (rev 6016)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/TaskQueryTest.java 2009-12-22 13:00:18 UTC (rev 6017)
@@ -109,7 +109,30 @@
testOrderBy(TaskQuery.PROPERTY_PROGRESS, new Integer[] {2, 15, 75, 99});
}
+ public void testCount() {
+ List<Task> tasks = new ArrayList<Task>();
+
+ final String assignee = "task1";
+ for (int i= 0; i < 30; i++) {
+ Task task = taskService.newTask();
+
+ // assign half of the tasks
+ if ( i % 2 == 0) {
+ task.setAssignee(assignee);
+ }
+
+ taskService.saveTask(task);
+ tasks.add(task);
+ }
+
+ TaskQuery taskQuery = taskService.createTaskQuery();
+ assertEquals(new Long(30L), taskQuery.count());
+ assertEquals(new Long(15L), taskQuery.assignee(assignee).count());
+
+ deleteTasks(tasks);
+ }
+
/* -------------------------------------------------------------------
* HELPER METHODS
* ------------------------------------------------------------------- */
14 years, 4 months
JBoss JBPM SVN: r6016 - jbpm4/trunk/modules/distro/src/main/files/install.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-12-22 04:43:59 -0500 (Tue, 22 Dec 2009)
New Revision: 6016
Modified:
jbpm4/trunk/modules/distro/src/main/files/install/build.xml
Log:
JBPM-2654 fixed copying of jdbc driver jar in installation target install.jbpm.into.jboss
Modified: jbpm4/trunk/modules/distro/src/main/files/install/build.xml
===================================================================
--- jbpm4/trunk/modules/distro/src/main/files/install/build.xml 2009-12-22 03:47:27 UTC (rev 6015)
+++ jbpm4/trunk/modules/distro/src/main/files/install/build.xml 2009-12-22 09:43:59 UTC (rev 6016)
@@ -360,7 +360,7 @@
<unzip src="${jbpm.home}/lib/report-engine.zip" dest="${birt.dir}"/>
<unzip src="${jbpm.home}/lib/jbpm-console-reports.jar" dest="${birt.dir}"/>
- <property name="container.lib.dir" value="${jboss.server.config.dir}/deploy/jbpm/jbpm-service.sar" />
+ <property name="database.driver.destination.dir" value="${jboss.server.config.dir}/deploy/jbpm/jbpm-service.sar" />
<antcall target="internal.copy.database.driver" />
<!-- Signavio -->
14 years, 4 months