Package org.activiti.engine

Examples of org.activiti.engine.ProcessEngine


        output.close();
    }

    @Test
    public void testEmptyListOfMachines() throws JAXBException, IOException, SAXException {
        ProcessEngine processEngine = new StandaloneInMemProcessEngineConfiguration().buildProcessEngine();
        try {
            RundeckServlet servlet = new RundeckServlet(processEngine);
            servlet.writeRundeckResourceModelXmlTo(writer);

            writer.flush();
            assertXMLEqual(output.toString(), "<project />");

        } finally {
            processEngine.close();
        }
    }
View Full Code Here


        outputStream.close();
    }

    @Test
    public void testNoProcessesRunning() throws Exception {
        final ProcessEngine processEngine = newProcessEngineMock(Collections.<ProcessInstance>emptyList());

        ListPoolsCommand command = new ListPoolsCommand(processEngine);
        command.setOut(out);

        CommandSession session = mock(CommandSession.class);
View Full Code Here

    public void testListProcess() throws Exception {
        final List<ProcessInstance> processes = ImmutableList.of(
            newProcessInstanceMock("p1", "k1"),
            newProcessInstanceMock("p2", "k2")
        );
        final ProcessEngine processEngine = newProcessEngineMock(processes);

        Pool pool = mock(Pool.class);
        setVariable(processEngine, "p1", CoreProcessVariables.POOL, pool);
        setVariable(processEngine, "p1", CoreProcessVariables.POOL_BUSINESS_KEY, "k1");
View Full Code Here

        when(runtimeService.getVariable(instanceId, key)).thenReturn(value);
    }

    private ProcessEngine newProcessEngineMock(List<ProcessInstance> instances) {
        ProcessEngine processEngine = mock(ProcessEngine.class);

        RuntimeService runtimeService = mock(RuntimeService.class);
        when(processEngine.getRuntimeService()).thenReturn(runtimeService);

        ProcessInstanceQuery allInstancesQuery = mock(ProcessInstanceQuery.class);
        when(allInstancesQuery.list()).thenReturn(instances);
        when(runtimeService.createProcessInstanceQuery()).thenReturn(allInstancesQuery);
View Full Code Here

        out.flush();
        assertThat(outputStream.toString()).containsIgnoringCase("please supply a business key");
    }

    private ProcessEngine newMockProcessEngine() {
        final ProcessEngine engine = mock(ProcessEngine.class);
        final List<ProcessInstance> processes = ImmutableList.of(
            newProcessInstanceMock("p1", BUSINESS_KEY, true),
            newProcessInstanceMock("p2", BUSINESS_KEY, false),
            newProcessInstanceMock("p3", BUSINESS_KEY, true)
        );

        final RuntimeService runtimeService = mock(RuntimeService.class);
        final ProcessInstanceQuery processInstanceQuery = mock(ProcessInstanceQuery.class);

        when(engine.getRuntimeService()).thenReturn(runtimeService);
        when(runtimeService.createProcessInstanceQuery()).thenReturn(processInstanceQuery);
        when(processInstanceQuery.variableValueEquals(CoreProcessVariables.POOL_BUSINESS_KEY, BUSINESS_KEY))
            .thenReturn(processInstanceQuery);
        when(processInstanceQuery.orderByProcessInstanceId()).thenReturn(processInstanceQuery);
        when(processInstanceQuery.desc()).thenReturn(processInstanceQuery);
View Full Code Here

  }
 
  public void startProcessWithJob() throws Exception {
    ProcessEngineConfiguration createStandaloneInMemProcessEngineConfiguration = StandaloneInMemProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration();
    createStandaloneInMemProcessEngineConfiguration.setJobExecutorActivate(true);
    ProcessEngine processEngine = createStandaloneInMemProcessEngineConfiguration.buildProcessEngine();
    RepositoryService repositoryService = processEngine.getRepositoryService();
    repositoryService.createDeployment().addInputStream("TimeBoundaryIntermediateEvent.bpmn20.xml",
        new FileInputStream(filename)).deploy();
    RuntimeService runtimeService = processEngine.getRuntimeService();
    Map<String, Object> variableMap = new HashMap<String, Object>();
    variableMap.put("name", "Activiti");
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("TimeBoundaryIntermediateEvent", variableMap);
    assertNotNull(processInstance.getId());
    System.out.println("id " + processInstance.getId() + " "
        + processInstance.getProcessDefinitionId());
   
    TaskService taskService = processEngine.getTaskService();
    Task task = taskService.createTaskQuery().singleResult();
    assertNotNull(task);
   
    HashMap<String, Object> properties = new HashMap<String, Object>();
    Calendar ca = Calendar.getInstance();
View Full Code Here

  public void afterDeploymentValidation(@Observes AfterDeploymentValidation event, BeanManager beanManager) {
    try {  
      logger.info("Initializing activiti-cdi.");     
      // initialize the process engine
      ProcessEngine processEngine = lookupProcessEngine(beanManager);     
      // deploy the processes if engine was set up correctly
      deployProcesses(processEngine);     
    } catch (Exception e) {
      // interpret engine initialization problems as definition errors
      event.addDeploymentProblem(e);
View Full Code Here

      public int compare(ProcessEngineLookup o1, ProcessEngineLookup o2) {      
        return (-1)*((Integer)o1.getPrecedence()).compareTo(o2.getPrecedence());
      }     
    });
   
    ProcessEngine processEngine = null;
   
    for (ProcessEngineLookup processEngineLookup : discoveredLookups) {
      processEngine = processEngineLookup.getProcessEngine();
      if(processEngine != null) {
        this.processEngineLookup = processEngineLookup;
View Full Code Here

    }
   
    static void deployToEngine(File wff) throws FileNotFoundException{
        LOGGER.info("deploying "+wff+" to workflow engine");
       
        ProcessEngine eng = JenkowEngine.getEngine();
        RuntimeService rtSvc = eng.getRuntimeService();
        RepositoryService repoSvc = eng.getRepositoryService();

        String wfn = wff+"20.xml"; // TODO 9: workaround for http://forums.activiti.org/en/viewtopic.php?f=8&t=3745&start=10
        DeploymentBuilder db = repoSvc.createDeployment().addInputStream(wfn,new FileInputStream(wff));

        // TODO 4: We should avoid redeploying here, if workflow file of a given version(?) is already deployed?
View Full Code Here

    JMXServiceURL url =
            new JMXServiceURL("service:jmx:rmi://" + hostName + ":10111/jndi/rmi://" + hostName + ":1099/jmxrmi/activiti");
  
   
    ProcessEngineConfiguration processEngineConfig = ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("activiti.cfg.xml");
    ProcessEngine processEngine = processEngineConfig.buildProcessEngine();
   
   
    // wait for jmx server to come up
    Thread.sleep(500);
    JMXConnector jmxc = JMXConnectorFactory.connect(url, null);
   
    MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();
   
   
    ObjectName deploymentsBeanName = new ObjectName("org.activiti.jmx.Mbeans:type=Deployments");
   
   
    Thread.sleep(500);
   
    // no process deployed yet
    List<List<String>> deployments = (List<List<String>>) mbsc.getAttribute(deploymentsBeanName, "Deployments");
    assertEquals(0, deployments.size());
   
   
    // deploy process remotely
   
    URL fileName = Thread.currentThread().getContextClassLoader().getResource( "org/activiti/management/jmx/trivialProcess.bpmn");
    mbsc.invoke(deploymentsBeanName, "deployProcessDefinition", new String[]{"trivialProcess.bpmn", fileName.getFile()}, new String[]{String.class.getName(), String.class.getName()});


    // one process is there now, test remote deployments
    deployments = (List<List<String>>) mbsc.getAttribute(deploymentsBeanName, "Deployments");
    assertNotNull(deployments);
    assertEquals(1, deployments.size());
    assertEquals(3, deployments.get(0).size());
    String firstDeploymentId = deployments.get(0).get(0);
   
   
    // test remote process definition
    List<List<String>> pdList = (List<List<String>>) mbsc.getAttribute(deploymentsBeanName, "ProcessDefinitions");
    assertNotNull(pdList);
    assertEquals(1, pdList.size());
    assertEquals(5, pdList.get(0).size());
    assertNotNull(pdList.get(0).get(0));
    assertEquals("My process", pdList.get(0).get(1));
    assertEquals("1", pdList.get(0).get(2))// version
    assertEquals("false", pdList.get(0).get(3))// not suspended
    assertEquals("This process to test JMX", pdList.get(0).get(4));
   
    // redeploy the same process
    mbsc.invoke(deploymentsBeanName, "deployProcessDefinition", new String[]{"trivialProcess.bpmn", fileName.getFile()}, new String[]{String.class.getName(), String.class.getName()});

  
    // now there should be two deployments
    deployments = (List<List<String>>) mbsc.getAttribute(deploymentsBeanName, "Deployments");
    assertNotNull(deployments);
    assertEquals(2, deployments.size());
    assertEquals(3, deployments.get(0).size());
    assertEquals(3, deployments.get(1).size());
   
    // there should be two process definitions, one with version equals to two
    pdList = (List<List<String>>) mbsc.getAttribute(deploymentsBeanName, "ProcessDefinitions");
    assertNotNull(pdList);
    assertEquals(2, pdList.size());
    assertEquals(5, pdList.get(0).size());
    assertEquals(5, pdList.get(1).size());
   
    // check there is one with version= = 1 and another one with version == 2, other attributed are the same
    String pidV2 = null;
    String pidV1 = null;
    if (pdList.get(0).get(2).equals("1") && pdList.get(1).get(2).equals("2")) {
      pidV2 = pdList.get(1).get(0);
      pidV1 = pdList.get(0).get(0);
    } else if  (pdList.get(1).get(2).equals("1") && pdList.get(0).get(2).equals("2")) {
      pidV2 = pdList.get(0).get(0);
      pidV1 = pdList.get(1).get(0);
     
    } else
      fail("there should one process definition with version == 1 and another one with version == 2. It is not the case");
   
    assertNotNull(pdList.get(0).get(0));
    assertNotNull(pdList.get(1).get(0));
    assertEquals("My process", pdList.get(0).get(1));
    assertEquals("My process", pdList.get(1).get(1));
    assertEquals("false", pdList.get(0).get(3))// not suspended
    assertEquals("false", pdList.get(1).get(3))// not suspended
    assertEquals("This process to test JMX", pdList.get(0).get(4));
    assertEquals("This process to test JMX", pdList.get(1).get(4));
   
    //suspend the one with version == 2   
    mbsc.invoke(deploymentsBeanName, "suspendProcessDefinitionById", new String[]{pidV2}, new String[]{String.class.getName()});
    RepositoryService repositoryService = processEngine.getRepositoryService();
   
    // test if it is realy suspended and not the other one
    assertTrue(repositoryService.getProcessDefinition(pidV2).isSuspended());
    assertFalse(repositoryService.getProcessDefinition(pidV1).isSuspended());
   
View Full Code Here

TOP

Related Classes of org.activiti.engine.ProcessEngine

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.