applicationContext.start();
ProcessEngine processEngine = BpmPlatform.getDefaultProcessEngine();
// create a manual deployment:
Deployment deployment = processEngine.getRepositoryService()
.createDeployment()
.addClasspathResource("org/camunda/bpm/engine/spring/test/application/process.bpmn20.xml")
.deploy();
// lookup the process application spring bean:
PostDeployRegistrationPa processApplication = applicationContext.getBean("customProcessApplicaiton", PostDeployRegistrationPa.class);
Assert.assertFalse(processApplication.isPostDeployInvoked());
processApplication.deploy();
Assert.assertTrue(processApplication.isPostDeployInvoked());
// the process application was not invoked
Assert.assertFalse(processApplication.isInvoked());
// start process instance:
processEngine.getRuntimeService()
.startProcessInstanceByKey("startToEnd");
// now the process application was invoked:
Assert.assertTrue(processApplication.isInvoked());
// undeploy PA
Assert.assertFalse(processApplication.isPreUndeployInvoked());
processApplication.undeploy();
Assert.assertTrue(processApplication.isPreUndeployInvoked());
// manually undeploy the process
processEngine.getRepositoryService()
.deleteDeployment(deployment.getId(), true);
applicationContext.close();
}