Ejemplo n.º 1
0
  public void testScript() throws IOException {
    // deploy test script definition
    ClassPathResource processDef = new ClassPathResource("jbpmresources/test_script.xml");
    assertFalse(
        workflowComponent.isDefinitionDeployed(
            processDef.getInputStream(), MimetypeMap.MIMETYPE_XML));
    WorkflowDeployment deployment =
        workflowComponent.deployDefinition(processDef.getInputStream(), MimetypeMap.MIMETYPE_XML);
    assertNotNull(deployment);

    WorkflowDefinition workflowDef = deployment.getDefinition();
    Map<QName, Serializable> parameters = new HashMap<QName, Serializable>();
    parameters.put(QName.createQName(NamespaceService.DEFAULT_URI, "testNode"), rootNodeRef);
    parameters.put(
        QName.createQName(NamespaceService.BPM_MODEL_1_0_URI, "package"),
        packageComponent.createPackage(null));
    WorkflowPath path = workflowComponent.startWorkflow(workflowDef.getId(), parameters);
    assertNotNull(path);
    List<WorkflowTask> tasks1 = workflowComponent.getTasksForWorkflowPath(path.getId());
    assertNotNull(tasks1);
    assertEquals(1, tasks1.size());
    assertEquals(WorkflowTaskState.IN_PROGRESS, tasks1.get(0).getState());
    WorkflowTask updatedTask = taskComponent.endTask(tasks1.get(0).getId(), null);
    assertNotNull(updatedTask);
  }
Ejemplo n.º 2
0
  @SuppressWarnings("deprecation")
  @Override
  protected void onSetUpInTransaction() throws Exception {
    super.onSetUpInTransaction();

    personService = (PersonService) applicationContext.getBean("PersonService");
    person1 = createPerson(USER1);
    person2 = createPerson(USER2);
    person3 = createPerson(USER3);

    BPMEngineRegistry registry =
        (BPMEngineRegistry) applicationContext.getBean("bpm_engineRegistry");
    workflowComponent = registry.getWorkflowComponent(JBPMEngine.ENGINE_ID);
    taskComponent = registry.getTaskComponent(JBPMEngine.ENGINE_ID);
    packageComponent = (WorkflowPackageComponent) applicationContext.getBean("workflowPackageImpl");

    // deploy test process messages
    I18NUtil.registerResourceBundle("jbpmresources/test-messages");

    // deploy test process definition
    ClassPathResource processDef =
        new ClassPathResource("jbpmresources/test_processdefinition.xml");
    assertFalse(
        workflowComponent.isDefinitionDeployed(
            processDef.getInputStream(), MimetypeMap.MIMETYPE_XML));
    WorkflowDeployment deployment =
        workflowComponent.deployDefinition(processDef.getInputStream(), MimetypeMap.MIMETYPE_XML);
    testWorkflowDef = deployment.definition;
    assertNotNull(testWorkflowDef);
    assertEquals("jbpm$test", testWorkflowDef.name);
    assertEquals("1", testWorkflowDef.version);
    assertTrue(
        workflowComponent.isDefinitionDeployed(
            processDef.getInputStream(), MimetypeMap.MIMETYPE_XML));

    authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName());
  }