[jbpm-commits] JBoss JBPM SVN: r3358 - in projects/gwt-console/trunk/server/src: test/java/org/jboss/bpm/console/server and 1 other directory.

do-not-reply at jboss.org do-not-reply at jboss.org
Fri Dec 12 06:25:39 EST 2008


Author: heiko.braun at jboss.com
Date: 2008-12-12 06:25:39 -0500 (Fri, 12 Dec 2008)
New Revision: 3358

Modified:
   projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/JBPM3CommandDelegate.java
   projects/gwt-console/trunk/server/src/test/java/org/jboss/bpm/console/server/ProcessManagementTest.java
   projects/gwt-console/trunk/server/src/test/java/org/jboss/bpm/console/server/TaskManagementTest.java
Log:
Spec compliance: Starting new instances will issue a default signal

Modified: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/JBPM3CommandDelegate.java
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/JBPM3CommandDelegate.java	2008-12-12 11:24:54 UTC (rev 3357)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/integration/jbpm3/JBPM3CommandDelegate.java	2008-12-12 11:25:39 UTC (rev 3358)
@@ -53,176 +53,179 @@
  */
 class JBPM3CommandDelegate
 {
-  private LocalCommandService facade;
-  private static final String DEFAULT_JNDI_NAME = "java:ejb/CommandServiceBean";
+   private LocalCommandService facade;
+   private static final String DEFAULT_JNDI_NAME = "java:ejb/CommandServiceBean";
 
-  /*
+   /*
    * Lookup with particluar JNDI name.
    * @param jndiName
    */
-  public JBPM3CommandDelegate(String jndiName)
-  {
-    ejbLookup(jndiName);
-  }
+   public JBPM3CommandDelegate(String jndiName)
+   {
+      ejbLookup(jndiName);
+   }
 
-  /*
+   /*
    * Lookup using default JNDI name.
    * @see #DEFAULT_JNDI_NAME
    */
 
-  public JBPM3CommandDelegate()
-  {
-    ejbLookup(DEFAULT_JNDI_NAME);
-  }
+   public JBPM3CommandDelegate()
+   {
+      ejbLookup(DEFAULT_JNDI_NAME);
+   }
 
-  private void ejbLookup(String jndiName)
-  {
-    try
-    {
-      LocalCommandServiceHome home = (LocalCommandServiceHome)ServiceLocator.getEjbLocalHome(jndiName);
-      this.facade = home.create();
-    }
-    catch (CreateException e)
-    {
-      throw new RuntimeException("Failed to create LocalCommandService", e);
-    }
-  }
+   private void ejbLookup(String jndiName)
+   {
+      try
+      {
+         LocalCommandServiceHome home = (LocalCommandServiceHome)ServiceLocator.getEjbLocalHome(jndiName);
+         this.facade = home.create();
+      }
+      catch (CreateException e)
+      {
+         throw new RuntimeException("Failed to create LocalCommandService", e);
+      }
+   }
 
-  public List<ProcessDefinition> getActualDefinitions()
-  {
-    List<ProcessDefinition> defs = (List<ProcessDefinition>)facade.execute(new GetProcessDefinitionsCommand(false));
-    return defs;
-  }
+   public List<ProcessDefinition> getActualDefinitions()
+   {
+      List<ProcessDefinition> defs = (List<ProcessDefinition>)facade.execute(new GetProcessDefinitionsCommand(false));
+      return defs;
+   }
 
-  public ProcessDefinition getActualDefinition(String name)
-  {
-    ProcessDefinition def = (ProcessDefinition)facade.execute(new GetProcessDefinitionCommand(name));
-    return def;
-  }
+   public ProcessDefinition getActualDefinition(String name)
+   {
+      ProcessDefinition def = (ProcessDefinition)facade.execute(new GetProcessDefinitionCommand(name));
+      return def;
+   }
 
-  public ProcessDefinition getActualDefinition(long processId)
-  {
-    List<ProcessDefinition> defs = getActualDefinitions();
+   public ProcessDefinition getActualDefinition(long processId)
+   {
+      List<ProcessDefinition> defs = getActualDefinitions();
 
-    ProcessDefinition match = null;
-    for (ProcessDefinition p0 : defs)
-    {
-      if (processId == p0.getId())
+      ProcessDefinition match = null;
+      for (ProcessDefinition p0 : defs)
       {
-        match = p0;
-        break;
+         if (processId == p0.getId())
+         {
+            match = p0;
+            break;
+         }
       }
-    }
 
-    if (null == match)
-      throw new IllegalArgumentException("No process definition with ID " + processId);
+      if (null == match)
+         throw new IllegalArgumentException("No process definition with ID " + processId);
 
-    return match;
-  }
+      return match;
+   }
 
-  public void removeActualDefinition(long processId)
-  {
-    ProcessDefinition def = getActualDefinition(processId);
-    facade.execute(new DeleteProcessDefinitionCommand(processId));
-  }
+   public void removeActualDefinition(long processId)
+   {
+      ProcessDefinition def = getActualDefinition(processId);
+      facade.execute(new DeleteProcessDefinitionCommand(processId));
+   }
 
-  public org.jbpm.graph.exe.ProcessInstance getActualInstance(long instanceId)
-  {
-    ProcessInstance instance = (ProcessInstance)facade.execute(new GetProcessInstanceCommand(instanceId));
-    return instance;
-  }
+   public org.jbpm.graph.exe.ProcessInstance getActualInstance(long instanceId)
+   {
+      ProcessInstance instance = (ProcessInstance)facade.execute(new GetProcessInstanceCommand(instanceId));
+      return instance;
+   }
 
-  public List<ProcessInstance> getActualInstances(long processId)
-  {
-    ProcessDefinition p0 = getActualDefinition(processId);
-    GetProcessInstancesCommand command = new GetProcessInstancesCommand();
-    command.setProcessId(processId);
+   public List<ProcessInstance> getActualInstances(long processId)
+   {
+      ProcessDefinition p0 = getActualDefinition(processId);
+      GetProcessInstancesCommand command = new GetProcessInstancesCommand();
+      command.setProcessId(processId);
 
-    List<ProcessInstance> instances = (List<ProcessInstance>)facade.execute(command);
+      List<ProcessInstance> instances = (List<ProcessInstance>)facade.execute(command);
 
-    return instances;
-  }
+      return instances;
+   }
 
-  public ProcessInstance startNewInstance(long processId)
-  {
-    NewProcessInstanceCommand command = new NewProcessInstanceCommand();
-    command.setProcessId(processId);
-    ProcessInstance instance = (ProcessInstance)facade.execute(command);
-    return instance;
-  }
+   public ProcessInstance startNewInstance(long processId)
+   {
+      NewProcessInstanceCommand command = new NewProcessInstanceCommand();
+      command.setProcessId(processId);
+      ProcessInstance instance = (ProcessInstance)facade.execute(command);
 
-  public ProcessDefinition deploy(byte[] data)
-  {
-    ProcessDefinition p0 = (ProcessDefinition)facade.execute(new DeployProcessCommand(data));
-    return p0;
-  }
+      // default signal to behave spec compliant
+      instance.signal();
+      return instance;
+   }
 
-  public List<TaskInstance> getActualTasksForActor(String actorName)
-  {
+   public ProcessDefinition deploy(byte[] data)
+   {
+      ProcessDefinition p0 = (ProcessDefinition)facade.execute(new DeployProcessCommand(data));
+      return p0;
+   }
 
-    List<String> groupNames = getGroupsForActor(actorName);
+   public List<TaskInstance> getActualTasksForActor(String actorName)
+   {
 
-    String[] actors = new String[groupNames.size() + 1];
-    int i = 0;
-    for (String s : groupNames)
-    {
-      actors[i] = s;
-      i++;
-    }
+      List<String> groupNames = getGroupsForActor(actorName);
 
-    actors[i] = actorName; // all groups & the username
+      String[] actors = new String[groupNames.size() + 1];
+      int i = 0;
+      for (String s : groupNames)
+      {
+         actors[i] = s;
+         i++;
+      }
 
-    List<TaskInstance> tasks = new ArrayList<TaskInstance>();
-    GetTaskListCommand command = new GetTaskListCommand(actors);
-    tasks.addAll((List<TaskInstance>)facade.execute(command));
-    return tasks;
-  }
+      actors[i] = actorName; // all groups & the username
 
-  public List<String> getGroupsForActor(String actorName)
-  {
-    List<String> groupNames = (List<String>)facade.execute(new GetGroupMembershipCommand(actorName));
-    return groupNames;
-  }
+      List<TaskInstance> tasks = new ArrayList<TaskInstance>();
+      GetTaskListCommand command = new GetTaskListCommand(actors);
+      tasks.addAll((List<TaskInstance>)facade.execute(command));
+      return tasks;
+   }
 
-  public List<String> getActorsForGroup(String groupName)
-  {
-    List<String> actorIds = (List<String>)facade.execute(new GetUsersForGroupCommand(groupName));
-    return actorIds;
-  }
+   public List<String> getGroupsForActor(String actorName)
+   {
+      List<String> groupNames = (List<String>)facade.execute(new GetGroupMembershipCommand(actorName));
+      return groupNames;
+   }
 
-  public TaskInstance getTaskById(long taskId)
-  {
-    // include variables, but no logs
-    return (TaskInstance)facade.execute(new GetTaskInstanceCommand(taskId, true, false));
-  }
+   public List<String> getActorsForGroup(String groupName)
+   {
+      List<String> actorIds = (List<String>)facade.execute(new GetUsersForGroupCommand(groupName));
+      return actorIds;
+   }
 
-  public void assignTask(long taskId, String actorId)
-  {
-    if (actorId != null)
-    {
-      StartWorkOnTaskCommand command = new StartWorkOnTaskCommand(taskId, true);
-      command.setActorId(actorId);
+   public TaskInstance getTaskById(long taskId)
+   {
+      // include variables, but no logs
+      return (TaskInstance)facade.execute(new GetTaskInstanceCommand(taskId, true, false));
+   }
+
+   public void assignTask(long taskId, String actorId)
+   {
+      if (actorId != null)
+      {
+         StartWorkOnTaskCommand command = new StartWorkOnTaskCommand(taskId, true);
+         command.setActorId(actorId);
+         facade.execute(command);
+      }
+      else
+      {
+         CancelWorkOnTaskCommand command = new CancelWorkOnTaskCommand(taskId);
+         facade.execute(command);
+      }
+   }
+
+   public void signalToken(long tokenId, String signalName)
+   {
+      SignalCommand command = new SignalCommand(tokenId, signalName);
       facade.execute(command);
-    }
-    else
-    {
-      CancelWorkOnTaskCommand command = new CancelWorkOnTaskCommand(taskId);
-      facade.execute(command);
-    }
-  }
+   }
 
-  public void signalToken(long tokenId, String signalName)
-  {
-    SignalCommand command = new SignalCommand(tokenId, signalName);
-    facade.execute(command);
-  }
+   public void endTask(long taskId, String signalName)
+   {
+      TaskInstanceEndCommand command = new TaskInstanceEndCommand();
+      command.setTaskInstanceId(taskId);
+      command.setTransitionName(signalName);
 
-  public void endTask(long taskId, String signalName)
-  {
-    TaskInstanceEndCommand command = new TaskInstanceEndCommand();
-    command.setTaskInstanceId(taskId);
-    command.setTransitionName(signalName);
-
-    facade.execute(command);
-  }
+      facade.execute(command);
+   }
 }

Modified: projects/gwt-console/trunk/server/src/test/java/org/jboss/bpm/console/server/ProcessManagementTest.java
===================================================================
--- projects/gwt-console/trunk/server/src/test/java/org/jboss/bpm/console/server/ProcessManagementTest.java	2008-12-12 11:24:54 UTC (rev 3357)
+++ projects/gwt-console/trunk/server/src/test/java/org/jboss/bpm/console/server/ProcessManagementTest.java	2008-12-12 11:25:39 UTC (rev 3358)
@@ -28,13 +28,13 @@
 
 /**
  * Tests process management functionality.
- * 
+ *
  * @author Heiko.Braun <heiko.braun at jboss.com>
  */
 public class ProcessManagementTest extends BaseTC
 {
-  /*
-   * Checks the following reqiorements:<br> 
+   /*
+   * Checks the following requirements:<br> 
    * <ul> 
    * <li> Process deployment 
    * <li> Create instance 
@@ -42,62 +42,84 @@
    * <li> End an instance 
    * </ul>
    */
-  public void testProcessDefinitionList() throws Exception
-  {
-    String response = HTTP.get(SERVER_URL + "/process/definitions", DEFAULT_CREDENTIALS);
+   public void testProcessDefinitionList() throws Exception
+   {
+      String response = HTTP.get(SERVER_URL + "/process/definitions", DEFAULT_CREDENTIALS);
 
-    ProcessDefinitionRefWrapper dto = unmarshallProcessDefinitionList(response);
+      ProcessDefinitionRefWrapper dto = unmarshallProcessDefinitionList(response);
 
-    ProcessDefinitionRef match = null;
-    for (ProcessDefinitionRef def : dto.getDefinitions())
-    {
-      if (def.equals(testDeploymentRef))
-        match = def;
-    }
+      ProcessDefinitionRef match = null;
+      for (ProcessDefinitionRef def : dto.getDefinitions())
+      {
+         if (def.equals(testDeploymentRef))
+            match = def;
+      }
 
-    assertNotNull(match);
+      assertNotNull(match);
 
-  }
+   }
 
-  /*
+   /*
    * Test instance creation, suspend, resume and deletion.
    */
-  public void testInstanceOperations() throws Exception
-  {
-    ProcessInstanceRef newInstanceRef = createNewProcessInstance();
+   public void testInstanceOperations() throws Exception
+   {
+      ProcessInstanceRef newInstanceRef = createNewProcessInstance();
 
-    // ------- Suspend it
+      // ------- Suspend it
 
-    newInstanceRef.setState(ProcessInstanceRef.STATE.SUSPENDED);
-    HTTP.post(SERVER_URL + "/process/instances/" + newInstanceRef.getInstanceId() + "/state/" + newInstanceRef.getState(), EMPTY, DEFAULT_CREDENTIALS);
+      newInstanceRef.setState(ProcessInstanceRef.STATE.SUSPENDED);
+      HTTP.post(SERVER_URL + "/process/instances/" + newInstanceRef.getInstanceId() + "/state/" + newInstanceRef.getState(), EMPTY, DEFAULT_CREDENTIALS);
 
-    // ------- Verify
+      // ------- Verify
 
-    ProcessInstanceRefWrapper instanceList = getInstanceList(testDeploymentRef);
-    assertFalse(instanceList.getInstances().isEmpty());
-    assertTrue(instanceList.getTotalCount() == 1);
+      ProcessInstanceRefWrapper instanceList = getInstanceList(testDeploymentRef);
+      assertFalse(instanceList.getInstances().isEmpty());
+      assertTrue(instanceList.getTotalCount() == 1);
 
-    ProcessInstanceRef match = null;
-    for (ProcessInstanceRef ref : instanceList.getInstances())
-    {
-      if (ref.equals(newInstanceRef))
+      ProcessInstanceRef match = null;
+      for (ProcessInstanceRef ref : instanceList.getInstances())
       {
-        match = ref;
-        break;
+         if (ref.equals(newInstanceRef))
+         {
+            match = ref;
+            break;
+         }
       }
-    }
 
-    assertNotNull(match);
-    assertEquals(ProcessInstanceRef.STATE.SUSPENDED, match.getState());
+      assertNotNull(match);
+      assertEquals(ProcessInstanceRef.STATE.SUSPENDED, match.getState());
 
-    // end and verify
-    newInstanceRef.setState(ProcessInstanceRef.STATE.ENDED);
-    HTTP.post(SERVER_URL + "/process/instances/" + newInstanceRef.getInstanceId() + "/state/" + newInstanceRef.getState(), EMPTY, DEFAULT_CREDENTIALS);
+      // end and verify
+      newInstanceRef.setState(ProcessInstanceRef.STATE.ENDED);
+      HTTP.post(SERVER_URL + "/process/instances/" + newInstanceRef.getInstanceId() + "/state/" + newInstanceRef.getState(), EMPTY, DEFAULT_CREDENTIALS);
 
-    // refresh instance list
-    instanceList = getInstanceList(testDeploymentRef);
-    assertTrue(instanceList.getInstances().isEmpty());
+      // refresh instance list
+      instanceList = getInstanceList(testDeploymentRef);
+      assertTrue(instanceList.getInstances().isEmpty());
 
-  }
+   }
 
+   public void testSignaling() throws Exception
+   {
+      /*
+      // signal it to move to task node
+      String url = "/jbpm3/tokens/"+newInstanceRef.getRootToken().getId()+"/transition/default";
+      HTTP.post(
+            SERVER_URL + url, EMPTY, DEFAULT_CREDENTIALS
+      );
+
+      // refresh instance ref
+      newInstanceRef = getInstance(testDeploymentRef, newInstanceId);
+      assertNotNull(newInstanceRef);
+
+      // same token?
+      assertTrue(previousTokenId == newInstanceRef.getRootToken().getId());
+
+      // did it really move?
+      assertFalse( previousNodeName.equals( newInstanceRef.getRootToken().getCurrentNodeName()));
+       
+      */
+
+   }
 }

Modified: projects/gwt-console/trunk/server/src/test/java/org/jboss/bpm/console/server/TaskManagementTest.java
===================================================================
--- projects/gwt-console/trunk/server/src/test/java/org/jboss/bpm/console/server/TaskManagementTest.java	2008-12-12 11:24:54 UTC (rev 3357)
+++ projects/gwt-console/trunk/server/src/test/java/org/jboss/bpm/console/server/TaskManagementTest.java	2008-12-12 11:25:39 UTC (rev 3358)
@@ -48,28 +48,8 @@
    public void testTaskOperations() throws Exception
    {
       ProcessInstanceRef newInstanceRef = createNewProcessInstance();
-      long newInstanceId = newInstanceRef.getInstanceId();
-      String previousNodeName = newInstanceRef.getRootToken().getCurrentNodeName();
-      long previousTokenId = newInstanceRef.getRootToken().getId();
-
       assertEquals(newInstanceRef.getState(), ProcessInstanceRef.STATE.RUNNING);
 
-      // signal it to move to task node
-      String url = "/jbpm3/tokens/"+newInstanceRef.getRootToken().getId()+"/transition/default";
-      HTTP.post(
-            SERVER_URL + url, EMPTY, DEFAULT_CREDENTIALS
-      );
-
-      // refresh instance ref
-      newInstanceRef = getInstance(testDeploymentRef, newInstanceId);
-      assertNotNull(newInstanceRef);
-
-      // same token?
-      assertTrue(previousTokenId == newInstanceRef.getRootToken().getId());
-
-      // did it really move?
-      assertFalse( previousNodeName.equals( newInstanceRef.getRootToken().getCurrentNodeName()));
-
       // has a task been created?
       String taskListResponse = HTTP.get(
             SERVER_URL + "/tasks/actor/admin", DEFAULT_CREDENTIALS // 'user' is the actual actorname




More information about the jbpm-commits mailing list