forked from Activiti/Activiti
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8386e83
commit f9d0daa
Showing
7 changed files
with
269 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
...va/org/activiti/spring/test/autodeployment/FailOnNoProcessAutoDeploymentStrategyTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package org.activiti.spring.test.autodeployment; | ||
|
||
import java.util.List; | ||
|
||
import org.activiti.engine.ActivitiException; | ||
import org.activiti.spring.autodeployment.FailOnNoProcessAutoDeploymentStrategy; | ||
import org.activiti.spring.impl.test.SpringActivitiTestCase; | ||
import org.junit.Test; | ||
import org.springframework.core.io.ClassPathResource; | ||
import org.springframework.core.io.Resource; | ||
import org.springframework.test.context.ContextConfiguration; | ||
|
||
@ContextConfiguration("classpath:org/activiti/spring/test/autodeployment/errorHandling/spring-context.xml") | ||
public class FailOnNoProcessAutoDeploymentStrategyTest extends SpringActivitiTestCase { | ||
|
||
private final String nameHint = "FailOnNoProcessAutoDeploymentStrategyTest"; | ||
|
||
private final String validName1 = "org/activiti/spring/test/autodeployment/errorHandling/valid.bpmn20.xml"; | ||
private final String invalidName1 = "org/activiti/spring/test/autodeployment/errorHandling/parsing-error.bpmn20.xml"; | ||
private final String invalidName2 = "org/activiti/spring/test/autodeployment/errorHandling/validation-error.bpmn20.xml"; | ||
|
||
private void cleanUp() { | ||
List<org.activiti.engine.repository.Deployment> deployments = repositoryService.createDeploymentQuery().list(); | ||
for (org.activiti.engine.repository.Deployment deployment : deployments) { | ||
repositoryService.deleteDeployment(deployment.getId(), true); | ||
} | ||
} | ||
|
||
@Test | ||
public void testValidResources() { | ||
cleanUp(); | ||
final Resource[] resources = new Resource[]{new ClassPathResource(validName1)}; | ||
FailOnNoProcessAutoDeploymentStrategy deploymentStrategy = new FailOnNoProcessAutoDeploymentStrategy(); | ||
deploymentStrategy.deployResources(nameHint, resources, repositoryService); | ||
assertEquals(1, repositoryService.createDeploymentQuery().count()); | ||
cleanUp(); | ||
} | ||
|
||
@Test | ||
public void testInvalidResources() { | ||
cleanUp(); | ||
final Resource[] resources = new Resource[]{new ClassPathResource(validName1), new ClassPathResource(invalidName1), new ClassPathResource(invalidName2)}; | ||
FailOnNoProcessAutoDeploymentStrategy deploymentStrategy = new FailOnNoProcessAutoDeploymentStrategy(); | ||
deploymentStrategy.deployResources(nameHint, resources, repositoryService); | ||
assertEquals(1, repositoryService.createDeploymentQuery().count()); | ||
cleanUp(); | ||
} | ||
|
||
@Test | ||
public void testWithParsingErrorResources() { | ||
cleanUp(); | ||
final Resource[] resources = new Resource[]{new ClassPathResource(validName1), new ClassPathResource(invalidName1)}; | ||
FailOnNoProcessAutoDeploymentStrategy deploymentStrategy = new FailOnNoProcessAutoDeploymentStrategy(); | ||
deploymentStrategy.deployResources(nameHint, resources, repositoryService); | ||
assertEquals(1, repositoryService.createDeploymentQuery().count()); | ||
cleanUp(); | ||
} | ||
|
||
@Test | ||
public void testWithValidationErrorResources() { | ||
cleanUp(); | ||
final Resource[] resources = new Resource[]{new ClassPathResource(validName1), new ClassPathResource(invalidName2)}; | ||
FailOnNoProcessAutoDeploymentStrategy deploymentStrategy = new FailOnNoProcessAutoDeploymentStrategy(); | ||
deploymentStrategy.deployResources(nameHint, resources, repositoryService); | ||
assertEquals(1, repositoryService.createDeploymentQuery().count()); | ||
cleanUp(); | ||
} | ||
|
||
@Test | ||
public void testOnlyInvalidResources() { | ||
cleanUp(); | ||
final Resource[] resources = new Resource[]{new ClassPathResource(invalidName1)}; | ||
FailOnNoProcessAutoDeploymentStrategy deploymentStrategy = new FailOnNoProcessAutoDeploymentStrategy(); | ||
try { | ||
deploymentStrategy.deployResources(nameHint, resources, repositoryService); | ||
} catch (ActivitiException e) { | ||
assertEquals("No process definition was deployed.", e.getMessage()); | ||
assertEquals(0, repositoryService.createDeploymentQuery().count()); | ||
cleanUp(); | ||
return; | ||
} | ||
fail(); | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
...est/java/org/activiti/spring/test/autodeployment/NeverFailAutoDeploymentStrategyTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package org.activiti.spring.test.autodeployment; | ||
|
||
import java.util.List; | ||
|
||
import org.activiti.spring.autodeployment.NeverFailAutoDeploymentStrategy; | ||
import org.activiti.spring.impl.test.SpringActivitiTestCase; | ||
import org.junit.Test; | ||
import org.springframework.core.io.ClassPathResource; | ||
import org.springframework.core.io.Resource; | ||
import org.springframework.test.context.ContextConfiguration; | ||
|
||
@ContextConfiguration("classpath:org/activiti/spring/test/autodeployment/errorHandling/spring-context.xml") | ||
public class NeverFailAutoDeploymentStrategyTest extends SpringActivitiTestCase { | ||
|
||
private final String nameHint = "NeverFailAutoDeploymentStrategyTest"; | ||
|
||
private final String validName1 = "org/activiti/spring/test/autodeployment/errorHandling/valid.bpmn20.xml"; | ||
private final String invalidName1 = "org/activiti/spring/test/autodeployment/errorHandling/parsing-error.bpmn20.xml"; | ||
private final String invalidName2 = "org/activiti/spring/test/autodeployment/errorHandling/validation-error.bpmn20.xml"; | ||
|
||
private void cleanUp() { | ||
List<org.activiti.engine.repository.Deployment> deployments = repositoryService.createDeploymentQuery().list(); | ||
for (org.activiti.engine.repository.Deployment deployment : deployments) { | ||
repositoryService.deleteDeployment(deployment.getId(), true); | ||
} | ||
} | ||
|
||
@Test | ||
public void testValidResources() { | ||
cleanUp(); | ||
final Resource[] resources = new Resource[]{new ClassPathResource(validName1)}; | ||
NeverFailAutoDeploymentStrategy deploymentStrategy = new NeverFailAutoDeploymentStrategy(); | ||
deploymentStrategy.deployResources(nameHint, resources, repositoryService); | ||
assertEquals(1, repositoryService.createDeploymentQuery().count()); | ||
cleanUp(); | ||
} | ||
|
||
@Test | ||
public void testInvalidResources() { | ||
cleanUp(); | ||
final Resource[] resources = new Resource[]{new ClassPathResource(validName1), new ClassPathResource(invalidName1), new ClassPathResource(invalidName2)}; | ||
NeverFailAutoDeploymentStrategy deploymentStrategy = new NeverFailAutoDeploymentStrategy(); | ||
deploymentStrategy.deployResources(nameHint, resources, repositoryService); | ||
assertEquals(1, repositoryService.createDeploymentQuery().count()); | ||
cleanUp(); | ||
} | ||
|
||
@Test | ||
public void testWithParsingErrorResources() { | ||
cleanUp(); | ||
final Resource[] resources = new Resource[]{new ClassPathResource(validName1), new ClassPathResource(invalidName1)}; | ||
NeverFailAutoDeploymentStrategy deploymentStrategy = new NeverFailAutoDeploymentStrategy(); | ||
deploymentStrategy.deployResources(nameHint, resources, repositoryService); | ||
assertEquals(1, repositoryService.createDeploymentQuery().count()); | ||
cleanUp(); | ||
} | ||
|
||
@Test | ||
public void testWithValidationErrorResources() { | ||
cleanUp(); | ||
final Resource[] resources = new Resource[]{new ClassPathResource(validName1), new ClassPathResource(invalidName2)}; | ||
NeverFailAutoDeploymentStrategy deploymentStrategy = new NeverFailAutoDeploymentStrategy(); | ||
deploymentStrategy.deployResources(nameHint, resources, repositoryService); | ||
assertEquals(1, repositoryService.createDeploymentQuery().count()); | ||
cleanUp(); | ||
} | ||
|
||
@Test | ||
public void testOnlyInvalidResources() { | ||
cleanUp(); | ||
final Resource[] resources = new Resource[]{new ClassPathResource(invalidName1)}; | ||
NeverFailAutoDeploymentStrategy deploymentStrategy = new NeverFailAutoDeploymentStrategy(); | ||
deploymentStrategy.deployResources(nameHint, resources, repositoryService); | ||
assertEquals(0, repositoryService.createDeploymentQuery().count()); | ||
cleanUp(); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
.../resources/org/activiti/spring/test/autodeployment/errorHandling/parsing-error.bpmn20.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
aaa |
36 changes: 36 additions & 0 deletions
36
...c/test/resources/org/activiti/spring/test/autodeployment/errorHandling/spring-context.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<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="dataSource" class="org.springframework.jdbc.datasource.SimpleDriverDataSource"> | ||
<property name="driverClass" value="org.h2.Driver"/> | ||
<property name="url" value="jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000"/> | ||
<property name="username" value="sa"/> | ||
<property name="password" value=""/> | ||
</bean> | ||
|
||
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> | ||
<property name="dataSource" ref="dataSource"/> | ||
</bean> | ||
|
||
<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration"> | ||
<property name="dataSource" ref="dataSource"/> | ||
<property name="transactionManager" ref="transactionManager"/> | ||
<property name="databaseSchemaUpdate" value="true"/> | ||
<property name="deploymentResources" | ||
value="classpath*:/org/activiti/spring/test/autodeployment/autodeploy.*.bpmn20.xml"/> | ||
</bean> | ||
|
||
<bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean"> | ||
<property name="processEngineConfiguration" ref="processEngineConfiguration"/> | ||
</bean> | ||
|
||
<bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService"/> | ||
<bean id="runtimeService" factory-bean="processEngine" factory-method="getRuntimeService"/> | ||
<bean id="taskService" factory-bean="processEngine" factory-method="getTaskService"/> | ||
<bean id="historyService" factory-bean="processEngine" factory-method="getHistoryService"/> | ||
<bean id="managementService" factory-bean="processEngine" factory-method="getManagementService"/> | ||
|
||
</beans> |
33 changes: 33 additions & 0 deletions
33
...src/test/resources/org/activiti/spring/test/autodeployment/errorHandling/valid.bpmn20.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" | ||
xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" | ||
xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" | ||
typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" | ||
targetNamespace="http://www.activiti.org/test"> | ||
|
||
<process id="a"> | ||
|
||
<startEvent id="start"/> | ||
<sequenceFlow id="flow1" sourceRef="start" targetRef="end"/> | ||
|
||
<endEvent id="end"/> | ||
|
||
</process> | ||
|
||
<bpmndi:BPMNDiagram id="BPMNDiagram_MyProcess"> | ||
<bpmndi:BPMNPlane bpmnElement="a" id="BPMNPlane_MyProcess"> | ||
<bpmndi:BPMNShape bpmnElement="start" id="BPMNShape_start"> | ||
<omgdc:Bounds height="35" width="35" x="130" y="180"></omgdc:Bounds> | ||
</bpmndi:BPMNShape> | ||
<bpmndi:BPMNShape bpmnElement="end" id="BPMNShape_end"> | ||
<omgdc:Bounds height="35" width="35" x="250" y="180"></omgdc:Bounds> | ||
</bpmndi:BPMNShape> | ||
<bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1"> | ||
<omgdi:waypoint x="165" y="197"></omgdi:waypoint> | ||
<omgdi:waypoint x="250" y="197"></omgdi:waypoint> | ||
</bpmndi:BPMNEdge> | ||
</bpmndi:BPMNPlane> | ||
</bpmndi:BPMNDiagram> | ||
|
||
</definitions> |
32 changes: 32 additions & 0 deletions
32
...sources/org/activiti/spring/test/autodeployment/errorHandling/validation-error.bpmn20.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<definitions expressionLanguage="http://www.w3.org/1999/XPath" | ||
id="definitions" targetNamespace="testapp" | ||
typeLanguage="http://www.w3.org/2001/XMLSchema" | ||
xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" | ||
xmlns:activiti="http://activiti.org/bpmn" | ||
xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" | ||
xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" | ||
xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" | ||
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<process id="testProcess1" name="test process"> | ||
<property id="processVariable" itemSubjectRef="xsd:string" name="processVariable"/> | ||
<startEvent activiti:async="true" id="start" name="Start"> | ||
<extensionElements> | ||
<activiti:formProperty id="task1Variable1" | ||
name="task1 Variable1" required="false" type="string"/> | ||
<activiti:formProperty id="task1Variable2" | ||
name="task1 Variable2" required="false" type="string"/> | ||
</extensionElements> | ||
</startEvent> | ||
<serviceTask id="task1" name="Task 1"> | ||
<extensionElements> | ||
<activiti:field name="variableNames"> | ||
<activiti:string> task1Variable1, task1Variable2 </activiti:string> | ||
</activiti:field> | ||
</extensionElements> | ||
</serviceTask> | ||
<endEvent id="end" name="End"/> | ||
<sequenceFlow id="flow1" sourceRef="start" targetRef="task1"/> | ||
<sequenceFlow id="flow2" sourceRef="task1" targetRef="end"/> | ||
</process> | ||
</definitions> |