org.camunda.bpm.BpmPlatform Java Examples

The following examples show how to use org.camunda.bpm.BpmPlatform. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MscManagedProcessEngine.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void createProcessEngineJndiBinding(StartContext context) {
  
  final ProcessEngineManagedReferenceFactory managedReferenceFactory = new ProcessEngineManagedReferenceFactory(processEngine);
  
  final ServiceName processEngineServiceBindingServiceName = ContextNames.GLOBAL_CONTEXT_SERVICE_NAME            
      .append(BpmPlatform.APP_JNDI_NAME)
      .append(BpmPlatform.MODULE_JNDI_NAME)
      .append(processEngine.getName());
  
  final String jndiName = BpmPlatform.JNDI_NAME_PREFIX 
      + "/" + BpmPlatform.APP_JNDI_NAME 
      + "/" + BpmPlatform.MODULE_JNDI_NAME 
      + "/" +processEngine.getName();

  // bind process engine service
  bindingService = BindingUtil.createJndiBindings(context.getChildTarget(), processEngineServiceBindingServiceName, jndiName, managedReferenceFactory);

  // log info message
  LOGG.info("jndi binding for process engine " + processEngine.getName() + " is " + jndiName);
}
 
Example #2
Source File: ManagedProcessEngineFactoryBeanTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testProcessApplicationDeployment() {
  
  // initially, no process engine is registered:
  Assert.assertNull(BpmPlatform.getDefaultProcessEngine());
  Assert.assertEquals(0, BpmPlatform.getProcessEngineService().getProcessEngines().size());
  
  // start spring application context
  AbstractApplicationContext applicationContext = new ClassPathXmlApplicationContext("org/camunda/bpm/engine/spring/test/container/ManagedProcessEngineFactoryBean-context.xml");
  applicationContext.start();
  
  // assert that now the process engine is registered:
  Assert.assertNotNull(BpmPlatform.getDefaultProcessEngine());      
  
  // close the spring application context
  applicationContext.close();
  
  // after closing the application context, the process engine is gone
  Assert.assertNull(BpmPlatform.getDefaultProcessEngine());
  Assert.assertEquals(0, BpmPlatform.getProcessEngineService().getProcessEngines().size());
  
}
 
Example #3
Source File: SpringProcessApplicationTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testDeployProcessArchive() {

  // start a spring application context
  AbstractApplicationContext applicationContext = new ClassPathXmlApplicationContext("org/camunda/bpm/engine/spring/test/application/SpringProcessArchiveDeploymentTest-context.xml");
  applicationContext.start();

  // assert the process archive is deployed:
  ProcessEngine processEngine = BpmPlatform.getDefaultProcessEngine();
  Assert.assertNotNull(processEngine.getRepositoryService().createDeploymentQuery().deploymentName("pa").singleResult());

  applicationContext.close();

  // assert the process is undeployed
  Assert.assertNull(processEngine.getRepositoryService().createDeploymentQuery().deploymentName("pa").singleResult());

}
 
Example #4
Source File: SpringProcessApplicationTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testProcessApplicationDeployment() {

  // initially no applications are deployed:
  Assert.assertEquals(0, BpmPlatform.getProcessApplicationService().getProcessApplicationNames().size());

  // start a spring application context
  AbstractApplicationContext applicationContext = new ClassPathXmlApplicationContext("org/camunda/bpm/engine/spring/test/application/SpringProcessApplicationDeploymentTest-context.xml");
  applicationContext.start();

  // assert that there is a process application deployed with the name of the process application bean
  Assert.assertNotNull(BpmPlatform.getProcessApplicationService()
    .getProcessApplicationInfo("myProcessApplication"));

  // close the spring application context
  applicationContext.close();

  // after closing the application context, the process application is undeployed.
  Assert.assertNull(BpmPlatform.getProcessApplicationService()
    .getProcessApplicationInfo("myProcessApplication"));

}
 
Example #5
Source File: AbstractFoxPlatformIntegrationTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Before
public void setupBeforeTest() {
  processEngineService = BpmPlatform.getProcessEngineService();
  processEngine = processEngineService.getDefaultProcessEngine();
  processEngineConfiguration = ((ProcessEngineImpl)processEngine).getProcessEngineConfiguration();
  processEngineConfiguration.getJobExecutor().shutdown(); // make sure the job executor is down
  formService = processEngine.getFormService();
  historyService = processEngine.getHistoryService();
  identityService = processEngine.getIdentityService();
  managementService = processEngine.getManagementService();
  repositoryService = processEngine.getRepositoryService();
  runtimeService = processEngine.getRuntimeService();
  taskService = processEngine.getTaskService();
  caseService = processEngine.getCaseService();
  decisionService = processEngine.getDecisionService();
}
 
Example #6
Source File: TestWarDeploymentResumePreviousOff.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
@OperateOnDeployment(value=PA2)
public void testDeployProcessArchive() {
  Assert.assertNotNull(processEngine);
  RepositoryService repositoryService = processEngine.getRepositoryService();
  long count = repositoryService.createProcessDefinitionQuery()
    .processDefinitionKey("testDeployProcessArchive")
    .count();

  Assert.assertEquals(2, count);

  // validate registrations:
  ProcessApplicationService processApplicationService = BpmPlatform.getProcessApplicationService();
  Set<String> processApplicationNames = processApplicationService.getProcessApplicationNames();
  for (String paName : processApplicationNames) {
    ProcessApplicationInfo processApplicationInfo = processApplicationService.getProcessApplicationInfo(paName);
    List<ProcessApplicationDeploymentInfo> deploymentInfo = processApplicationInfo.getDeploymentInfo();
    if(deploymentInfo.size() == 2) {
      Assert.fail("Previous version of the deployment must not be resumed");
    }
  }

}
 
Example #7
Source File: MscRuntimeContainerDelegate.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void createJndiBindings() {

    final PlatformServiceReferenceFactory managedReferenceFactory = new PlatformServiceReferenceFactory(this);

    final ServiceName processEngineServiceBindingServiceName = ContextNames.GLOBAL_CONTEXT_SERVICE_NAME
      .append(BpmPlatform.APP_JNDI_NAME)
      .append(BpmPlatform.MODULE_JNDI_NAME)
      .append(BpmPlatform.PROCESS_ENGINE_SERVICE_NAME);

    // bind process engine service
    BindingUtil.createJndiBindings(childTarget, processEngineServiceBindingServiceName, BpmPlatform.PROCESS_ENGINE_SERVICE_JNDI_NAME, managedReferenceFactory);

    final ServiceName processApplicationServiceBindingServiceName = ContextNames.GLOBAL_CONTEXT_SERVICE_NAME
        .append(BpmPlatform.APP_JNDI_NAME)
        .append(BpmPlatform.MODULE_JNDI_NAME)
        .append(BpmPlatform.PROCESS_APPLICATION_SERVICE_NAME);

    // bind process application service
    BindingUtil.createJndiBindings(childTarget, processApplicationServiceBindingServiceName, BpmPlatform.PROCESS_APPLICATION_SERVICE_JNDI_NAME, managedReferenceFactory);

  }
 
Example #8
Source File: MscRuntimeContainerDelegate.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void createJndiBindings() {

    final PlatformServiceReferenceFactory managedReferenceFactory = new PlatformServiceReferenceFactory(this);

    final ServiceName processEngineServiceBindingServiceName = ContextNames.GLOBAL_CONTEXT_SERVICE_NAME
      .append(BpmPlatform.APP_JNDI_NAME)
      .append(BpmPlatform.MODULE_JNDI_NAME)
      .append(BpmPlatform.PROCESS_ENGINE_SERVICE_NAME);

    // bind process engine service
    BindingUtil.createJndiBindings(childTarget, processEngineServiceBindingServiceName, BpmPlatform.PROCESS_ENGINE_SERVICE_JNDI_NAME, managedReferenceFactory);

    final ServiceName processApplicationServiceBindingServiceName = ContextNames.GLOBAL_CONTEXT_SERVICE_NAME
        .append(BpmPlatform.APP_JNDI_NAME)
        .append(BpmPlatform.MODULE_JNDI_NAME)
        .append(BpmPlatform.PROCESS_APPLICATION_SERVICE_NAME);

    // bind process application service
    BindingUtil.createJndiBindings(childTarget, processApplicationServiceBindingServiceName, BpmPlatform.PROCESS_APPLICATION_SERVICE_JNDI_NAME, managedReferenceFactory);

  }
 
Example #9
Source File: MscManagedProcessEngine.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void createProcessEngineJndiBinding(StartContext context) {
  
  final ProcessEngineManagedReferenceFactory managedReferenceFactory = new ProcessEngineManagedReferenceFactory(processEngine);
  
  final ServiceName processEngineServiceBindingServiceName = ContextNames.GLOBAL_CONTEXT_SERVICE_NAME            
      .append(BpmPlatform.APP_JNDI_NAME)
      .append(BpmPlatform.MODULE_JNDI_NAME)
      .append(processEngine.getName());
  
  final String jndiName = BpmPlatform.JNDI_NAME_PREFIX 
      + "/" + BpmPlatform.APP_JNDI_NAME 
      + "/" + BpmPlatform.MODULE_JNDI_NAME 
      + "/" +processEngine.getName();

  // bind process engine service
  bindingService = BindingUtil.createJndiBindings(context.getChildTarget(), processEngineServiceBindingServiceName, jndiName, managedReferenceFactory);

  // log info message
  LOGG.info("jndi binding for process engine " + processEngine.getName() + " is " + jndiName);
}
 
Example #10
Source File: ApplicationContextPathUtil.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public static String getApplicationPathForDeployment(ProcessEngine engine, String deploymentId) {

    // get the name of the process application that made the deployment
    String processApplicationName = null;
    IdentityService identityService = engine.getIdentityService();
    Authentication currentAuthentication = identityService.getCurrentAuthentication();
    try {
      identityService.clearAuthentication();
      processApplicationName = engine.getManagementService().getProcessApplicationForDeployment(deploymentId);
    } finally {
      identityService.setAuthentication(currentAuthentication);
    }

    if (processApplicationName == null) {
      // no a process application deployment
      return null;
    } else {
      ProcessApplicationService processApplicationService = BpmPlatform.getProcessApplicationService();
      ProcessApplicationInfo processApplicationInfo = processApplicationService.getProcessApplicationInfo(processApplicationName);
      return processApplicationInfo.getProperties().get(ProcessApplicationInfo.PROP_SERVLET_CONTEXT_PATH);
    }
  }
 
Example #11
Source File: EmbeddedProcessApplicationTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void testDeployAppWithCustomEngine() {

    TestApplicationWithCustomEngine processApplication = new TestApplicationWithCustomEngine();
    processApplication.deploy();

    ProcessEngine processEngine = BpmPlatform.getProcessEngineService().getProcessEngine("embeddedEngine");
    assertNotNull(processEngine);
    assertEquals("embeddedEngine", processEngine.getName());

    ProcessEngineConfiguration configuration = ((ProcessEngineImpl) processEngine).getProcessEngineConfiguration();

    // assert engine properties specified
    assertTrue(configuration.isJobExecutorDeploymentAware());
    assertTrue(configuration.isJobExecutorPreferTimerJobs());
    assertTrue(configuration.isJobExecutorAcquireByDueDate());
    assertEquals(5, configuration.getJdbcMaxActiveConnections());

    processApplication.undeploy();

  }
 
Example #12
Source File: InvoiceProcessApplication.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Override
public void createDeployment(String processArchiveName, DeploymentBuilder deploymentBuilder) {
  ProcessEngine processEngine = BpmPlatform.getProcessEngineService().getProcessEngine("default");

  // Hack: deploy the first version of the invoice process once before the process application
  //   is deployed the first time
  if (processEngine != null) {

    RepositoryService repositoryService = processEngine.getRepositoryService();

    if (!isProcessDeployed(repositoryService, "invoice")) {
      ClassLoader classLoader = getProcessApplicationClassloader();

      repositoryService.createDeployment(this.getReference())
        .addInputStream("invoice.v1.bpmn", classLoader.getResourceAsStream("invoice.v1.bpmn"))
        .addInputStream("invoiceBusinessDecisions.dmn", classLoader.getResourceAsStream("invoiceBusinessDecisions.dmn"))
        .addInputStream("reviewInvoice.bpmn", classLoader.getResourceAsStream("reviewInvoice.bpmn"))
        .deploy();
    }
  }
}
 
Example #13
Source File: CdiProcessEngineTestCase.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Before
public void setUpCdiProcessEngineTestCase() throws Exception {

  if(BpmPlatform.getProcessEngineService().getDefaultProcessEngine() == null) {
    RuntimeContainerDelegate.INSTANCE.get().registerProcessEngine(processEngineRule.getProcessEngine());
  }

  beanManager = ProgrammaticBeanLookup.lookup(BeanManager.class);
  processEngine = processEngineRule.getProcessEngine();
  processEngineConfiguration = (ProcessEngineConfigurationImpl) processEngineRule.getProcessEngine().getProcessEngineConfiguration();
  formService = processEngine.getFormService();
  historyService = processEngine.getHistoryService();
  identityService = processEngine.getIdentityService();
  managementService = processEngine.getManagementService();
  repositoryService = processEngine.getRepositoryService();
  runtimeService = processEngine.getRuntimeService();
  taskService = processEngine.getTaskService();
  authorizationService = processEngine.getAuthorizationService();
  filterService = processEngine.getFilterService();
  externalTaskService = processEngine.getExternalTaskService();
  caseService = processEngine.getCaseService();
  decisionService = processEngine.getDecisionService();
}
 
Example #14
Source File: NamedProcessEngineServicesProducer.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Produces @ProcessEngineName("")
public ProcessEngine processEngine(InjectionPoint ip) {

  ProcessEngineName annotation = ip.getAnnotated().getAnnotation(ProcessEngineName.class);
  String processEngineName = annotation.value();
  if(processEngineName == null || processEngineName.length() == 0) {
   throw new ProcessEngineException("Cannot determine which process engine to inject: @ProcessEngineName must specify the name of a process engine.");
  }
  try {
    ProcessEngineService processEngineService = BpmPlatform.getProcessEngineService();
    return processEngineService.getProcessEngine(processEngineName);
  }catch (Exception e) {
    throw new ProcessEngineException("Cannot find process engine named '"+processEngineName+"' specified using @ProcessEngineName: "+e.getMessage(), e);
  }

}
 
Example #15
Source File: ProcessDefinitionFormWidget.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	propertiesStructureTable.addCommand(new EditODocumentCommand(propertiesStructureTable, getModeModel()));
	propertiesStructureTable.addCommand(new SaveODocumentCommand(propertiesStructureTable, getModeModel()){
		
		@Override
		protected void onInitialize() {
			super.onInitialize();
			setLabelModel(new ResourceModel("command.saveAndStart"));
		};
		
		@Override
		public void onClick(Optional<AjaxRequestTarget> targetOptional) {
			super.onClick(targetOptional);
			ODocument doc = formDocumentModel.getObject();
			Map<String, Object> variables = new HashMap<>();
			variables.put(formKey.getVariableName(), doc.getIdentity().toString());
			BpmPlatform.getDefaultProcessEngine().getRuntimeService()
				.startProcessInstanceById((String)ProcessDefinitionFormWidget.this.getModelObject().field("id"), variables);
			setResponsePage(new ODocumentPage(doc));
		};
	}.setForceCommit(true).setBootstrapType(BootstrapType.SUCCESS));
}
 
Example #16
Source File: TripBookinApplication.java    From trip-booking-saga-java with Apache License 2.0 5 votes vote down vote up
public static void main(String... args) throws Exception {
  SpringApplication.run(TripBookinApplication.class, args);

  // do default setup of platform (everything is only applied if not yet there)
  ProcessEngine engine = BpmPlatform.getDefaultProcessEngine();
  
  // start a Saga right away
  engine.getRuntimeService().startProcessInstanceByKey(
      "trip", 
      Variables.putValue("someVariableToPass", "someValue"));
  
  // Start H2 server to be able to connect to database from the outside
  Server.createTcpServer(new String[] { "-tcpPort", "8092", "-tcpAllowOthers" }).start();
}
 
Example #17
Source File: CompleteTaskCommand.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
@Override
public void onClick(Optional<AjaxRequestTarget> targetOptional) {
	super.onClick(targetOptional);
	ODocument doc = getModelObject();
	ProcessEngine processEngine = BpmPlatform.getDefaultProcessEngine();
	TaskService taskService = processEngine.getTaskService();
	String taskId = taskModel.getObject().field("id");
	String var = formKey.getVariableName();
	taskService.complete(taskId, CommonUtils.<String, Object>toMap(var, doc.getIdentity().toString()));
	setResponsePage(new ODocumentPage(doc));
	sendActionPerformed();
}
 
Example #18
Source File: IndependentJobExecutionTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
private ProcessApplicationInfo getProcessApplicationDeploymentInfo(String applicationName) {
  ProcessApplicationInfo processApplicationInfo = BpmPlatform.getProcessApplicationService().getProcessApplicationInfo(applicationName);
  if (processApplicationInfo == null) {
    processApplicationInfo = BpmPlatform.getProcessApplicationService().getProcessApplicationInfo("/" + applicationName);
  }
  return processApplicationInfo;

}
 
Example #19
Source File: JobPrioritizationFailureJavaSerializationTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Before
public void setEngines() {
  ProcessEngineService engineService = BpmPlatform.getProcessEngineService();
  engine1 = engineService.getProcessEngine("engine1");

  // unregister process application so that context switch cannot be performed
  unregisterProcessApplication();
}
 
Example #20
Source File: ProcessEngineServiceTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
@OperateOnDeployment("test1")
public void testNonExistingEngineRetrieval() {
  
  ProcessEngineService engineService = BpmPlatform.getProcessEngineService();
  ProcessEngine engine = engineService.getProcessEngine("aNonExistingEngineName");
  Assert.assertNull(engine);
}
 
Example #21
Source File: StartProcessSLSB.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public boolean doStartProcess() {

    BpmPlatform.getDefaultProcessEngine()
      .getRuntimeService()
      .startProcessInstanceByKey("callbackProcess");

    return true;
  }
 
Example #22
Source File: TestWarDeploymentEmptyProcessesXml.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testDeployProcessArchive() {
  Assert.assertNotNull(processEngine);
  RepositoryService repositoryService = processEngine.getRepositoryService();

  List<ProcessDefinition> processDefinitions = repositoryService.createProcessDefinitionQuery()
    .processDefinitionKey("testDeployProcessArchive")
    .list();

  Assert.assertEquals(1, processDefinitions.size());
  org.camunda.bpm.engine.repository.Deployment deployment = repositoryService.createDeploymentQuery()
    .deploymentId(processDefinitions.get(0).getDeploymentId())
    .singleResult();

  Set<String> registeredProcessApplications = BpmPlatform.getProcessApplicationService().getProcessApplicationNames();

  boolean containsProcessApplication = false;

  // the process application name is used as name for the db deployment
  for (String appName : registeredProcessApplications) {
    if (appName.equals(deployment.getName())) {
      containsProcessApplication = true;
    }
  }
  assertTrue(containsProcessApplication);


  // manually delete process definition here (to clean up)
  repositoryService.deleteDeployment(deployment.getId(), true);
}
 
Example #23
Source File: TestWarDeploymentResumePreviousOnDeploymentName.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
@OperateOnDeployment(value = PA2)
public void testDeployProcessArchive() {
  assertThat(processEngine, is(notNullValue()));
  RepositoryService repositoryService = processEngine.getRepositoryService();
  //since we have two processes deployed for PA2 we gotta check that both are present
  long count = repositoryService.createProcessDefinitionQuery().processDefinitionKey("testDeployProcessArchive").count();

  assertThat(count, is(1L));

  count = repositoryService.createProcessDefinitionQuery().processDefinitionKey("testProcess").count();
  
  assertThat(count, is(1L));
  
  // validate registrations:
  ProcessApplicationService processApplicationService = BpmPlatform.getProcessApplicationService();
  Set<String> processApplicationNames = processApplicationService.getProcessApplicationNames();
  // we have two PAs, one from the first deployment and one from the second
  // and only one (the second) is allowed to have two deployments
  boolean resumedRegistrationFound = false;
  for (String paName : processApplicationNames) {
    ProcessApplicationInfo processApplicationInfo = processApplicationService.getProcessApplicationInfo(paName);
    List<ProcessApplicationDeploymentInfo> deploymentInfo = processApplicationInfo.getDeploymentInfo();
    if (deploymentInfo.size() == 2) {
      if (resumedRegistrationFound) {
        fail("Cannot have two registrations");
      }
      resumedRegistrationFound = true;
    }
  }
  assertThat("Previous version of the deployment was not resumed", resumedRegistrationFound, is(true));
}
 
Example #24
Source File: TestWarDeploymentResumePrevious.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
@OperateOnDeployment(value=PA2)
public void testDeployProcessArchive() {
  Assert.assertNotNull(processEngine);
  RepositoryService repositoryService = processEngine.getRepositoryService();
  long count = repositoryService.createProcessDefinitionQuery()
    .processDefinitionKey("testDeployProcessArchive")
    .count();

  Assert.assertEquals(2, count);

  // validate registrations:
  ProcessApplicationService processApplicationService = BpmPlatform.getProcessApplicationService();
  Set<String> processApplicationNames = processApplicationService.getProcessApplicationNames();
  boolean resumedRegistrationFound = false;
  for (String paName : processApplicationNames) {
    ProcessApplicationInfo processApplicationInfo = processApplicationService.getProcessApplicationInfo(paName);
    List<ProcessApplicationDeploymentInfo> deploymentInfo = processApplicationInfo.getDeploymentInfo();
    if(deploymentInfo.size() == 2) {
      if(resumedRegistrationFound) {
        Assert.fail("Cannot have two registrations");
      }
      resumedRegistrationFound = true;
    }
  }
  Assert.assertTrue("Previous version of the deployment was not resumed", resumedRegistrationFound);

}
 
Example #25
Source File: TestWarDeploymentCustomPAName.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testProcessApplicationName() {
  Set<String> paNames = BpmPlatform.getProcessApplicationService().getProcessApplicationNames();

  Assert.assertEquals(1, paNames.size());
  Assert.assertTrue(paNames.contains(CustomNameServletPA.NAME));

}
 
Example #26
Source File: TestWarDeploymentResumePreviousOnProcessDefinitionKey.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
@OperateOnDeployment(value=PA2)
public void testDeployProcessArchive() {
  assertThat(processEngine, is(notNullValue()));
  RepositoryService repositoryService = processEngine.getRepositoryService();
  long count = repositoryService.createProcessDefinitionQuery()
    .processDefinitionKey("testDeployProcessArchive")
    .count();

  assertThat(count, is(2L));

  // validate registrations:
  ProcessApplicationService processApplicationService = BpmPlatform.getProcessApplicationService();
  Set<String> processApplicationNames = processApplicationService.getProcessApplicationNames();
  // we have two PAs, one from the first deployment and one from the second and only one (the second) is allowed to have two deployments
  boolean resumedRegistrationFound = false;
  for (String paName : processApplicationNames) {
    ProcessApplicationInfo processApplicationInfo = processApplicationService.getProcessApplicationInfo(paName);
    List<ProcessApplicationDeploymentInfo> deploymentInfo = processApplicationInfo.getDeploymentInfo();
    if(deploymentInfo.size() == 2) {
      if(resumedRegistrationFound) {
        fail("Cannot have two registrations");
      }
      resumedRegistrationFound = true;
    }
  }
  assertThat("Previous version of the deployment was not resumed", resumedRegistrationFound, is(true));
}
 
Example #27
Source File: TestWarDeploymentIsDeployChangedOnly.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
@OperateOnDeployment(value=PA2)
public void testDeployProcessArchive() {
  Assert.assertNotNull(processEngine);
  RepositoryService repositoryService = processEngine.getRepositoryService();
  long count = repositoryService.createProcessDefinitionQuery()
    .processDefinitionKey("testDeployProcessArchive")
    .count();

  Assert.assertEquals(1, count);

  // validate registrations:
  ProcessApplicationService processApplicationService = BpmPlatform.getProcessApplicationService();
  Set<String> processApplicationNames = processApplicationService.getProcessApplicationNames();
  boolean resumedRegistrationFound = false;
  for (String paName : processApplicationNames) {
    ProcessApplicationInfo processApplicationInfo = processApplicationService.getProcessApplicationInfo(paName);
    List<ProcessApplicationDeploymentInfo> deploymentInfo = processApplicationInfo.getDeploymentInfo();
    if(deploymentInfo.size() == 2) {
      if(resumedRegistrationFound) {
        Assert.fail("Cannot have two registrations");
      }
      resumedRegistrationFound = true;
    }
  }
  Assert.assertTrue("Previous version of the deployment was not resumed", resumedRegistrationFound);

}
 
Example #28
Source File: EnsureCleanDbPlugin.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("resource")
@Override
public void postProcessApplicationUndeploy(ProcessApplicationInterface processApplication) {
  // some tests deploy multiple PAs. => only clean DB after last PA is undeployed
  // if the deployment fails for example during parsing the deployment counter was not incremented
  // so we have to check if the counter is already zero otherwise we go into the negative values
  // best example is TestWarDeploymentWithBrokenBpmnXml in integration-test-engine test suite
  if(counter.get() == 0 || counter.decrementAndGet() == 0) {

    final ProcessEngine defaultProcessEngine = BpmPlatform.getDefaultProcessEngine();
    try {
      logger.log(Level.INFO, "=== Ensure Clean Database ===");
      ManagementServiceImpl managementService = (ManagementServiceImpl) defaultProcessEngine.getManagementService();
      PurgeReport report = managementService.purge();

      if (report.isEmpty()) {
        logger.log(Level.INFO, "Clean DB and cache.");
      } else {
        StringBuilder builder = new StringBuilder();

        DatabasePurgeReport databasePurgeReport = report.getDatabasePurgeReport();
        if (!databasePurgeReport.isEmpty()) {
          builder.append(DATABASE_NOT_CLEAN).append(databasePurgeReport.getPurgeReportAsString());
        }

        CachePurgeReport cachePurgeReport = report.getCachePurgeReport();
        if (!cachePurgeReport.isEmpty()) {
          builder.append(CACHE_IS_NOT_CLEAN).append(cachePurgeReport.getPurgeReportAsString());
        }
        logger.log(Level.INFO, builder.toString());
      }
    }
    catch(Throwable e) {
      logger.log(Level.SEVERE, "Could not clean DB:", e);
    }
  }

}
 
Example #29
Source File: DiscoverBpmPlatformPluginsStep.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected ClassLoader getPluginsClassloader() {

    ClassLoader pluginsClassLoader = ClassLoaderUtil.getContextClassloader();
    if(pluginsClassLoader == null) {
      // if context classloader is null, use classloader which loaded the camunda-engine jar.
      pluginsClassLoader = BpmPlatform.class.getClassLoader();
    }

    return pluginsClassLoader;
  }
 
Example #30
Source File: ProcessApplicationDeployerWithScanIntegrationTest.java    From camunda-bpm-platform-osgi with Apache License 2.0 5 votes vote down vote up
@Test(timeout = 20000L)
public void shouldBeAbleToDeploy() throws InterruptedException {
  String processApplicationName = "yo!";
  // It could take a second to register the process application
  Set<String> processApplicationNames = null;
  ProcessApplicationService processApplicationService = BpmPlatform.getProcessApplicationService();
  do {
    Thread.sleep(500L);
    processApplicationNames = processApplicationService.getProcessApplicationNames();
  } while (processApplicationNames.isEmpty());
  assertThat(processApplicationNames, hasItem(processApplicationName));
}