use of org.activiti.engine.test.Deployment in project Activiti by Activiti.
the class EmptyProcessTest method testRunProcessWithHeader.
@Deployment(resources = { "process/empty.bpmn20.xml" })
public void testRunProcessWithHeader() throws Exception {
CamelContext ctx = applicationContext.getBean(CamelContext.class);
ProducerTemplate tpl = camelContext.createProducerTemplate();
String body = "body text";
Exchange exchange = ctx.getEndpoint("direct:startEmptyWithHeader").createExchange();
exchange.getIn().setBody(body);
tpl.send("direct:startEmptyWithHeader", exchange);
String instanceId = (String) exchange.getProperty("PROCESS_ID_PROPERTY");
assertProcessEnded(instanceId);
HistoricVariableInstance var = processEngine.getHistoryService().createHistoricVariableInstanceQuery().variableName("camelBody").singleResult();
assertNotNull(var);
assertEquals(body, var.getValue());
var = processEngine.getHistoryService().createHistoricVariableInstanceQuery().variableName("MyVar").singleResult();
assertNotNull(var);
assertEquals("Foo", var.getValue());
}
use of org.activiti.engine.test.Deployment in project Activiti by Activiti.
the class EmptyProcessTest method testObjectAsVariable.
@Deployment(resources = { "process/empty.bpmn20.xml" })
public void testObjectAsVariable() throws Exception {
CamelContext ctx = applicationContext.getBean(CamelContext.class);
ProducerTemplate tpl = ctx.createProducerTemplate();
Object expectedObj = new Long(99);
Exchange exchange = ctx.getEndpoint("direct:startEmpty").createExchange();
exchange.getIn().setBody(expectedObj);
tpl.send("direct:startEmpty", exchange);
String instanceId = (String) exchange.getProperty("PROCESS_ID_PROPERTY");
assertProcessEnded(instanceId);
HistoricVariableInstance var = processEngine.getHistoryService().createHistoricVariableInstanceQuery().variableName("camelBody").singleResult();
assertNotNull(var);
assertEquals(expectedObj, var.getValue());
}
use of org.activiti.engine.test.Deployment in project Activiti by Activiti.
the class ErrorHandlingTest method testCamelRouteWorksAsIntended.
/**
* Process instance should be removed after completion. Works as intended,
* if no exception interrupts the Camel route.
*
* @throws Exception
*/
@Deployment(resources = { "process/errorHandling.bpmn20.xml" })
public void testCamelRouteWorksAsIntended() throws Exception {
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("routing", Routing.DEFAULT);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("ErrorHandling", variables);
Job job = managementService.createJobQuery().processInstanceId(processInstance.getId()).singleResult();
assertNotNull(job);
managementService.executeJob(job.getId());
Thread.sleep(WAIT);
assertEquals("Process instance not completed", 0, runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId()).count());
}
use of org.activiti.engine.test.Deployment in project Activiti by Activiti.
the class ErrorHandlingTest method testRollbackOnException.
/**
* Expected behavior, with default error handling in Camel:
* Roll-back to previous wait state. Fails with Activiti 5.12.
*
* @throws Exception
*/
@Deployment(resources = { "process/errorHandling.bpmn20.xml" })
public void testRollbackOnException() throws Exception {
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("routing", Routing.PROVOKE_ERROR);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("ErrorHandling", variables);
assertEquals("No roll-back to previous wait state", 1, runtimeService.createExecutionQuery().processInstanceId(processInstance.getId()).activityId(PREVIOUS_WAIT_STATE).count());
assertEquals("Process instance advanced to next wait state", 0, runtimeService.createExecutionQuery().processInstanceId(processInstance.getId()).activityId(NEXT_WAIT_STATE).count());
}
use of org.activiti.engine.test.Deployment in project Activiti by Activiti.
the class ErrorMapExceptionTest method testCamelParentMap.
@Deployment(resources = { "process/mapExceptionParentMap.bpmn20.xml" })
public void testCamelParentMap() throws Exception {
camelContext.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("activiti:mapExceptionParentProcess:exceptionRoute").throwException(new MapExceptionChild("test exception"));
}
});
FlagJavaDelegate.reset();
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("mapExceptionParentProcess");
assertTrue(FlagJavaDelegate.isFlagSet());
}
Aggregations