Petals-SE-Activiti 0.5.0-SNAPSHOT

compared with
Key
This line was removed.
This word was removed. This word was added.
This line was added.

Changes (10)

View Page History
h1. Unit testing

An extension of JUnit is available:
* to validate your WSDL,
* to test unitary your XSLs.
The unit testing can occur at several levels in your Activiti service unit:
* to check the annotation compliance of the WSDL with the attendees of the component,
* to unit test your XSL generating outputs,
* to unit test your process definition.

h2. Validating your WSDL
A dedicated framework is available as an extension of JUnit providing facilities:
* to validate your WSDL:
** in a WSDL point of view,
** and checking the compliance of the WSDL with the attendees of the component,
* to verify easily the XSL used to generate output replies.

{color:red}*TODO*{color}
h2. Checking the compliance of the WSDL

h2. Unit-testing your XSD

A framework is available to unit-test the service unit deployed on the SE Activiti. It provides facilities for:
* check the compliance of the WSDL with the attendees of the component,
* verify easily the XSL used to generate output replies.

h3. Checking the compliance of the WSDL

The unit test framework contains an assertion '{{assertIsCompliant}}' to verify easily the compliance of your WSDL with the attendees of the mode 'service':
{code:lang=java}
{code}

h3. Testing your XSL
h2. Unit-testing your XSLs

{color:red}*TODO*{color}

h2. Unit-testing your process definition

Activiti provides a JUnit framework to write unit tests about business processes. You can find several articles on this subject on Internet, for example [here|http://docs.alfresco.com/activiti/topics/apiUnitTesting.html].
We don't discuss how to use the Activiti JUnit framework but how to integrate it into a service unit project.

First, you must embedd an Activiti engine for your test, adding an dependency on it with scope {{test}} into your POM file. Don't forget to add also the JDBC driver, H2 for example:
{code}
<dependency>
<groupId>org.ow2.petals.activiti</groupId>
<artifactId>activiti-engine</artifactId>
<version>5.18.0-PETALS-0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.178</version>
<scope>test</scope>
</dependency>
{code}
{tip}Caution to use the same version of the Activiti engine as the one embedded into the Petals SE Activiti{tip}

Next, your database must be linked to the Activiti engine through a Spring configuration located into the file {{src/test/resources/activiti.cfg.xml}} containing something like:
{code}
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

<bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration">
<property name="jdbcUrl" value="jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000" />
<property name="jdbcDriver" value="org.h2.Driver" />
<property name="jdbcUsername" value="sa" />
<property name="jdbcPassword" value="" />
</bean>
</beans>
{code}

So, with this, you will be able to test the deployment of your process definition and check process instance creations using the Activiti JUnit framework:
{code}
public class ProcessDeploymentTest {

@Rule
public final ActivitiRule activitiRule = new ActivitiRule();

@Test
@Deployment(resources = {"jbi/vacationRequest.bpmn20.xml"})
public void theProcessIsDeployable() {
final ProcessDefinition processDefinition = this.activitiRule.getRepositoryService()
.createProcessDefinitionQuery().processDefinitionKey("vacationRequest").singleResult();
assertNotNull(processDefinition);
}
}
{code}

If your process definition includes Petals service invocations, you must use mock for these services. For this first version of the Petals SE Activiti, nothing is available to create these mocks


h1. Annex: Sample WSDL