Package org.openbp.server.context

Examples of org.openbp.server.context.TokenContext


    startValue = 99;
    inputParams.put("NumValue", new Integer(startValue));

    // Create the process context and start the process
    TokenContext token = testCase.createToken();
    token.setDebuggerId("Deb1");
    token.createProcessVariable("externalValue", true);
    token.setProcessVariableValue("externalValue", new Integer(199));
    processFacade.startToken(token, STARTREF, inputParams);

    Object tokenId = token.getId();

    // Note: This might also be done by some worker thread; for the test case, we do it right here.
    processFacade.executePendingContextsInThisThread();

    return tokenId;
View Full Code Here


  }

  @Transactional(propagation = Propagation.REQUIRED)
  public void doCheckStart(TestCaseBase testCase, final Object tokenId)
  {
    TokenContext token = processFacade.getTokenById(tokenId);

    // The first workflow node made us stop here
    testCase.assertCurrentNode(token, "Workflow");
  }
View Full Code Here

  }

  @Transactional(propagation = Propagation.REQUIRED)
  public void doWorkflowTask(TestCaseBase testCase, final Object tokenId)
  {
    TokenContext token = processFacade.getTokenById(tokenId);

    // Check the process variables of the token context
    Object p = token.getProcessVariableValue("globalObject");
    assertTrue(p instanceof PersistedComplexParam);
    PersistedComplexParam rcp = (PersistedComplexParam) p;
    int nRet = rcp.getResult();
    assertEquals(startValue + 1, nRet);

    // The any workflow tasks that are associated with our process.
    WorkflowTaskCriteria criteria = new WorkflowTaskCriteria();
    criteria.setTokenContext(token);
    Iterator it = processFacade.getworkflowTasks(criteria);
    assertTrue(it.hasNext());
    WorkflowTask task = (WorkflowTask) it.next();

    TokenContext taskToken = task.getTokenContext();

    // Check the process variables of the token context
    Object p2 = taskToken.getProcessVariableValue("globalObject");
    assertTrue(p2 instanceof PersistedComplexParam);
    PersistedComplexParam rcp2 = (PersistedComplexParam) p2;
    int nRet2 = rcp2.getResult();
    assertEquals(startValue + 1, nRet2);
View Full Code Here

  }

  @Transactional(propagation = Propagation.REQUIRED)
  public void doFinish(TestCaseBase testCase, final Object tokenId)
  {
    TokenContext token = processFacade.getTokenById(tokenId);

    // Note: This should be done by some worker thread; for the test case, we do it right here.
    processFacade.executePendingContextsInThisThread();

    // Token should be at the end of the workflow
View Full Code Here

  @Transactional(propagation = Propagation.REQUIRED)
  public void doCheckFinish(TestCaseBase testCase, final Object tokenId)
  {
    // Token should have been removed from the database
    TokenContext token = processFacade.getTokenById(tokenId);
    assertNull(token);
  }
View Full Code Here

  public int checkNumberOfContexts(String stepName, int expected)
  {
    int n = 0;
    for (Iterator it = CollectionUtil.iterator(processFacade.getTokens(null, 0)); it.hasNext();)
    {
      TokenContext token = (TokenContext) it.next();
      if (token.getCurrentSocket() == null)
      {
        errOut("Test context check " + stepName + ": Socket of context " + token + " is null.");
      }
      ++n;
    }
View Full Code Here

    // Start 3 processes that consist of a signal wait activity only
    // and make them wait for the signal id "Sync".
    ArrayList contextList = new ArrayList();
    for (int i = 0; i < NUM_THREADS; ++i)
    {
      TokenContext tc = startSimpleSignalWaitProcess("Sync" + i, 0);
      contextList.add(tc);
    }

    // Thread pool capacity is 2, so the executor should pick exactly 2 processes for execution.
    int n = getProcessFacade().executePendingContextsInDifferentThread();
View Full Code Here

    // Start 3 processes that consist of a signal wait activity only
    // and make them wait for the signal id "Sync".
    final ArrayList contextList = new ArrayList();
    for (int i = 0; i < NUM_THREADS; ++i)
    {
      TokenContext tc = startSimpleSignalWaitProcess("Signal" + i, 0);
      contextList.add(tc);
    }

    // In 3 seconds, we will send the signal to the processes
    new Thread()
View Full Code Here

    startSimpleSignalSetProcess("Sync2", "Sig 2", 1);
    startSimpleSignalSetProcess("Sync3", "Sig 3", 3);

    Iterator it = getProcessServer().getTokenContextService().getExecutableContexts(10);

    TokenContext tc;

    tc = (TokenContext) it.next();
    getProcessFacade().executeContextInThisThread(tc);
    assertEquals(TestCaseSyncMgr.getInstance().getSignal(tc, "Sync2"), "Sig 2");
View Full Code Here

    String localHost = new DefaultSystemNameProvider().getSystemName();
    TokenContextService tokenContextService = getProcessServer().getTokenContextService();

    // Create all kinds of contexts and simulate several states

    TokenContext tc1 = startSimpleSignalSetProcess("TestSignal1", "Done", 0);
    tc1.setLifecycleState(LifecycleState.SELECTED);
    tc1.setLifecycleRequest(LifecycleRequest.NONE);
    tc1.setNodeId(localHost);
    tokenContextService.saveContext(tc1);

    TokenContext tc2 = startSimpleSignalSetProcess("TestSignal2", "Done", 0);
    tc2.setLifecycleState(LifecycleState.SELECTED);
    tc2.setLifecycleRequest(LifecycleRequest.NONE);
    tc2.setNodeId("DifferentHost");
    tokenContextService.saveContext(tc2);

    TokenContext tc3 = startSimpleSignalSetProcess("TestSignal3", "Done", 0);
    tc3.setLifecycleState(LifecycleState.RUNNING);
    tc3.setLifecycleRequest(LifecycleRequest.NONE);
    tc3.setNodeId(localHost);
    tokenContextService.saveContext(tc3);

    TokenContext tc4 = startSimpleSignalSetProcess("TestSignal4", "Done", 0);
    tc4.setLifecycleState(LifecycleState.ERROR);
    tc4.setLifecycleRequest(LifecycleRequest.NONE);
    tc4.setNodeId(localHost);
    tokenContextService.saveContext(tc4);

    TokenContext tc5 = startSimpleSignalSetProcess("TestSignal5", "Done", 0);
    tokenContextService.saveContext(tc5);

    getProcessServer().getEngine().commit();

    // Execute those that can be executed
View Full Code Here

TOP

Related Classes of org.openbp.server.context.TokenContext

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.