[jbpm-commits] JBoss JBPM SVN: r3628 - jbpm4/trunk/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/ejb.

do-not-reply at jboss.org do-not-reply at jboss.org
Sun Jan 11 00:15:48 EST 2009


Author: alex.guizar at jboss.com
Date: 2009-01-11 00:15:48 -0500 (Sun, 11 Jan 2009)
New Revision: 3628

Modified:
   jbpm4/trunk/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/ejb/CommandExecutorTest.java
   jbpm4/trunk/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/ejb/CommandReceiverTest.java
   jbpm4/trunk/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/ejb/EjbTimerSessionTest.java
   jbpm4/trunk/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/ejb/TimerTest.java
Log:
minor edits to enterprise tests

Modified: jbpm4/trunk/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/ejb/CommandExecutorTest.java
===================================================================
--- jbpm4/trunk/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/ejb/CommandExecutorTest.java	2009-01-09 20:15:34 UTC (rev 3627)
+++ jbpm4/trunk/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/ejb/CommandExecutorTest.java	2009-01-11 05:15:48 UTC (rev 3628)
@@ -48,12 +48,14 @@
 
   private LocalCommandExecutor commandExecutor;
 
-  private static final Log log = Log.getLog(CommandExecutorTest.class.getName());
+  private static final Log log = Log
+      .getLog(CommandExecutorTest.class.getName());
 
   private static LocalCommandExecutorHome commandExecutorHome;
 
   public static Test suite() {
-    return new IntegrationTestSetup(CommandExecutorTest.class, "jbpm-enterprise-test.ear");
+    return new IntegrationTestSetup(CommandExecutorTest.class,
+        "jbpm-enterprise-test.ear");
   }
 
   @Override
@@ -62,8 +64,10 @@
       // retrieve managed objects
       InitialContext initialContext = new InitialContext();
       try {
-        commandExecutorHome = (LocalCommandExecutorHome) initialContext.lookup("java:comp/env/ejb/LocalCommandExecutor");
-      } finally {
+        commandExecutorHome = (LocalCommandExecutorHome) initialContext
+            .lookup("java:comp/env/ejb/LocalCommandExecutor");
+      }
+      finally {
         initialContext.close();
       }
     }
@@ -76,15 +80,23 @@
   }
 
   /**
+   * <p>
    * This scenario tests a command that completes with no incident.
+   * </p>
    * <h3>Preconditions</h3>
+   * <p>
    * The TEST_PHRASE table does not contain any row with the specified text.
+   * </p>
    * <h3>Behavior</h3>
+   * <p>
    * The {@link InsertCommentCmd} command creates a row with the specified text.
+   * </p>
    * <h3>Postconditions</h3>
+   * <p>
    * A new row with the specified text exists in the table. The
-   * {@link RemoveCommentCmd} command removes the row, and the return value confirms
-   * it was there.
+   * {@link RemoveCommentCmd} command removes the row, and the return value
+   * confirms it was there.
+   * </p>
    */
   public void testHappyCommand() throws CreateException {
     String text = "been there, done that";
@@ -94,18 +106,26 @@
   }
 
   /**
+   * <p>
    * This scenario tests a command that throws a checked exception inside the
    * {@link InsertCommentCmd#execute(org.jbpm.env.Environment) execute} method.
+   * </p>
    * <h3>Preconditions</h3>
+   * <p>
    * The TEST_PHRASE table does not contain any row with the specified text.
+   * </p>
    * <h3>Behavior</h3>
-   * The {@link InsertCommentCmd} command creates a row with the specified text. The
-   * command is configured to throw a checked exception before completing.
+   * <p>
+   * The {@link InsertCommentCmd} command creates a row with the specified text.
+   * The command is configured to throw a checked exception before completing.
+   * </p>
    * <h3>Postconditions</h3>
+   * <p>
    * The command executor throws an {@link EJBException} and rolls back the
    * managed transaction. No row with the specified text exists in the database.
    * The {@link RemoveCommentCmd} command return value confirms the row was not
    * there.
+   * </p>
    */
   public void testNoisyCommand() throws CreateException {
     String text = "houston, we have a problem";
@@ -113,7 +133,8 @@
     try {
       commandExecutor.execute(new InsertCommentCmd(text, /* fail? */true));
       fail("expected: " + EJBException.class.getSimpleName());
-    } catch (EJBException e) {
+    }
+    catch (EJBException e) {
       log.info("noisy command threw exception", e);
       // verify phrase was NOT inserted
       assertFalse(commandExecutor.execute(new RemoveCommentCmd(text)));

Modified: jbpm4/trunk/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/ejb/CommandReceiverTest.java
===================================================================
--- jbpm4/trunk/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/ejb/CommandReceiverTest.java	2009-01-09 20:15:34 UTC (rev 3627)
+++ jbpm4/trunk/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/ejb/CommandReceiverTest.java	2009-01-11 05:15:48 UTC (rev 3628)
@@ -91,14 +91,25 @@
   }
 
   /**
-   * This scenario tests a command message that completes with no incident. <h3>
-   * Preconditions</h3> The TEST_PHRASE table does not contain any row with the
-   * specified text. <h3>Behavior</h3> The {@link InsertCommentCmd} command
-   * message creates a row with the specified text. Once the command completes,
-   * the command receiver sends the result to the reply queue. <h3>
-   * Postconditions</h3> A new row with the specified text exists in the table.
-   * The {@link RemoveCommentCmd} command message removes the row. The result
-   * sent to the reply queue confirms the row was there.
+   * <p>
+   * This scenario tests a command message that completes with no incident.
+   * </p>
+   * <h3>Preconditions</h3>
+   * <p>
+   * The TEST_PHRASE table does not contain any row with the specified text.
+   * </p>
+   * <h3>Behavior</h3>
+   * <p>
+   * The {@link InsertCommentCmd} command message creates a row with the
+   * specified text. Once the command completes, the command receiver sends the
+   * result to the reply queue.
+   * </p>
+   * <h3>Postconditions</h3>
+   * <p>
+   * A new row with the specified text exists in the table. The
+   * {@link RemoveCommentCmd} command message removes the row. The result sent
+   * to the reply queue confirms the row was there.
+   * </p>
    */
   public void testHappyMessage() throws JMSException {
     final String text = "been there, done that";
@@ -139,18 +150,29 @@
   }
 
   /**
+   * <p>
    * This scenario tests a command message that throws a checked exception
    * inside the {@link InsertCommentCmd#execute(org.jbpm.env.Environment)
-   * execute} method. <h3>Preconditions</h3> The TEST_PHRASE table does not
-   * contain any row with the specified text. <h3>Behavior</h3> The
-   * {@link InsertCommentCmd} command message creates a row with the specified
-   * text. The command is configured to throw a checked exception before
-   * completing. The exception prevents the command receiver from sending the
-   * result to the reply queue. <h3>Postconditions</h3> The command receiver
-   * rolls back the managed transaction and puts the insertion message back in
-   * the command queue. No row with the specified exists in the database. The
-   * {@link RemoveCommentCmd} command result sent to the reply queue confirms
-   * the row was not there.
+   * execute} method.
+   * </p>
+   * <h3>Preconditions</h3>
+   * <p>
+   * The TEST_PHRASE table does not contain any row with the specified text.
+   * </p>
+   * <h3>Behavior</h3>
+   * <p>
+   * The {@link InsertCommentCmd} command message creates a row with the
+   * specified text. The command is configured to throw a checked exception
+   * before completing. The exception prevents the command receiver from sending
+   * the result to the reply queue.
+   * </p>
+   * <h3>Postconditions</h3>
+   * <p>
+   * The command receiver rolls back the managed transaction and puts the
+   * insertion message back in the command queue. No row with the specified
+   * exists in the database. The {@link RemoveCommentCmd} command result sent to
+   * the reply queue confirms the row was not there.
+   * </p>
    */
   public void testNoisyMessage() throws JMSException {
     final String text = "houston, we have a problem";

Modified: jbpm4/trunk/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/ejb/EjbTimerSessionTest.java
===================================================================
--- jbpm4/trunk/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/ejb/EjbTimerSessionTest.java	2009-01-09 20:15:34 UTC (rev 3627)
+++ jbpm4/trunk/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/ejb/EjbTimerSessionTest.java	2009-01-11 05:15:48 UTC (rev 3628)
@@ -59,6 +59,7 @@
 
   private String processDefinitionId;
 
+  private Date dueDate;
   private static final int TIMEOUT = 2000;
 
   public static Test suite() {
@@ -80,11 +81,16 @@
     }
     // create local bean
     commandExecutor = commandExecutorHome.create();
-    // deploy process
+    // define process
+    dueDate = new Date(System.currentTimeMillis() + TIMEOUT);
     ClientProcessDefinition processDefinition = ProcessFactory.build(getName())
-        .node().initial().timer(TIMEOUT + " milliseconds", null).event(
-            "timeout").listener(new ObjectDescriptor(HappyActivity.class))
+        .node()
+          .initial()
+          .timer(dueDate, null)
+            .event("timeout")
+              .listener(new ObjectDescriptor(HappyActivity.class))
         .done();
+    // deploy process
     List<ProcessDefinition> processDefinitions = commandExecutor
         .execute(new DeployCmd(new DeploymentImpl(processDefinition)));
     assertEquals(1, processDefinitions.size());
@@ -96,17 +102,27 @@
   }
 
   /**
+   * <p>
    * This scenario schedules a non-repeating timer whose referenced activity
-   * completes with no incident. <h3>Preconditions</h3> The activity has not
-   * executed. <h3>Behavior</h3> The {@link ScheduleTimerCmd} command activates
-   * a timer. After that, the test waits for the activity to execute. Upon
-   * timeout, the {@linkplain HappyActivity activity} notifies the test of its
-   * execution. <h3>Postconditions</h3> The activity executes on or after the
-   * timer's due date.
+   * completes with no incident.
+   * </p>
+   * <h3>Preconditions</h3>
+   * <p>
+   * The activity has not executed.
+   * </p>
+   * <h3>Behavior</h3>
+   * <p>
+   * The {@link ScheduleTimerCmd} command activates a timer. After that, the
+   * test waits for the activity to execute. Upon timeout, the
+   * {@linkplain HappyActivity activity} notifies the test of its execution.
+   * </p>
+   * <h3>Postconditions</h3>
+   * <p>
+   * The activity executes on or after the timer's due date.
+   * </p>
    */
   public void testSchedule() throws CreateException {
     // start an execution
-    Date dueDate = new Date(System.currentTimeMillis() + TIMEOUT);
     commandExecutor.execute(new StartExecutionCmd(processDefinitionId, null,
         null));
 
@@ -116,12 +132,23 @@
   }
 
   /**
+   * <p>
    * This scenario schedules a non-repeating timer and immediately cancels it.
-   * <h3>Preconditions</h3> The activity has not executed. <h3>Behavior</h3> The
-   * {@link ScheduleTimerCmd} command activates a timer, which is immediately
-   * disabled by the {@link CancelTimerCmd} command. After that, the test waits
-   * past the timer's due date. <h3>Postconditions</h3> The activity does not
-   * execute, ever.
+   * </p>
+   * <h3>Preconditions</h3>
+   * <p>
+   * The activity has not executed.
+   * </p>
+   * <h3>Behavior</h3>
+   * <p>
+   * The {@link ScheduleTimerCmd} command activates a timer, which is
+   * immediately disabled by the {@link CancelTimerCmd} command. After that, the
+   * test waits past the timer's due date.
+   * </p>
+   * <h3>Postconditions</h3>
+   * <p>
+   * The activity does not execute, ever.
+   * </p>
    */
   public void testCancel() throws CreateException {
     // start an execution

Modified: jbpm4/trunk/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/ejb/TimerTest.java
===================================================================
--- jbpm4/trunk/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/ejb/TimerTest.java	2009-01-09 20:15:34 UTC (rev 3627)
+++ jbpm4/trunk/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/ejb/TimerTest.java	2009-01-11 05:15:48 UTC (rev 3628)
@@ -31,6 +31,7 @@
 import junit.framework.Test;
 
 import org.apache.cactus.ServletTestCase;
+import org.jbpm.client.ClientProcessDefinition;
 import org.jbpm.cmd.Command;
 import org.jbpm.enterprise.internal.custom.HappyActivity;
 import org.jbpm.enterprise.internal.custom.NoisyActivity;
@@ -41,7 +42,6 @@
 import org.jbpm.enterprise.internal.ejb.TimerEB;
 import org.jbpm.env.Environment;
 import org.jbpm.log.Log;
-import org.jbpm.model.OpenProcessDefinition;
 import org.jbpm.pvm.internal.cmd.DeployCmd;
 import org.jbpm.pvm.internal.cmd.GetVariablesCmd;
 import org.jbpm.pvm.internal.cmd.StartExecutionCmd;
@@ -54,15 +54,16 @@
 import org.jbpm.test.enterprise.IntegrationTestSetup;
 
 /**
- * Server-side test for the {@linkplain TimerEB timerImpl bean}. The local
- * interface is used.
+ * Server-side test for the {@linkplain TimerEB timer bean}. The local interface
+ * is used.
  * 
  * @author Alejandro Guizar
  */
 public class TimerTest extends ServletTestCase {
 
-  private OpenProcessDefinition processDefinition;
+  private ClientProcessDefinition processDefinition;
   private ObjectDescriptor activityDescriptor = new ObjectDescriptor();
+  private Date dueDate;
 
   private LocalCommandExecutor commandExecutor;
 
@@ -95,9 +96,14 @@
     // create local bean
     commandExecutor = commandExecutorHome.create();
     // define process
-    processDefinition = ProcessFactory.build(getName()).node().initial().timer(
-        TIMEOUT + " milliseconds", null).event("timeout").listener(
-        activityDescriptor).done();
+    dueDate = new Date(System.currentTimeMillis() + TIMEOUT);
+    processDefinition = ProcessFactory.build(getName())
+        .node()
+          .initial()
+          .timer(dueDate, null)
+            .event("timeout")
+              .listener(activityDescriptor)
+        .done();
   }
 
   protected void tearDown() throws Exception {
@@ -105,13 +111,25 @@
   }
 
   /**
-   * This scenario tests a non-repeating timerImpl whose referenced activity
-   * completes with no incident. <h3>Preconditions</h3> The activity has not
-   * executed. <h3>Behavior</h3> The {@link CreateTimerCmd} command subscribes a
-   * timerImpl bean to the EJB timerImpl service. After that, the test waits for
-   * the activity to execute. Upon timeout, the {@linkplain HappyActivity
-   * activity} notifies the test of its execution. <h3>Postconditions</h3> The
-   * activity executes on or after the timerImpl's due date.
+   * <p>
+   * This scenario tests a non-repeating timer whose referenced activity
+   * completes with no incident.
+   * </p>
+   * <h3>Preconditions</h3>
+   * <p>
+   * The activity has not executed.
+   * </p>
+   * <h3>Behavior</h3>
+   * <p>
+   * The {@link CreateTimerCmd} command subscribes a timer bean to the EJB
+   * timer service. After that, the test waits for the activity to execute.
+   * Upon timeout, the {@linkplain HappyActivity activity} notifies the test of
+   * its execution.
+   * </p>
+   * <h3>Postconditions</h3>
+   * <p>
+   * The activity executes on or after the timer's due date.
+   * </p>
    */
   public void testHappyTimer() throws CreateException {
     activityDescriptor.setClassName(HappyActivity.class.getName());
@@ -121,27 +139,37 @@
     ExecutionImpl execution = (ExecutionImpl) commandExecutor
         .execute(new StartExecutionCmd(processDefinition.getId(), null, null));
 
-    Date dueDate = new Date(System.currentTimeMillis() + TIMEOUT);
-    TimerImpl timerImpl = new TimerImpl();
-    timerImpl.setEventName("timeout");
-    timerImpl.setDueDate(dueDate);
-    timerImpl.setExecution(execution);
-    commandExecutor.execute(new CreateTimerCmd(timerImpl));
+    TimerImpl timer = new TimerImpl();
+    timer.setEventName("timeout");
+    timer.setDueDate(dueDate);
+    timer.setExecution(execution);
+    commandExecutor.execute(new CreateTimerCmd(timer));
 
     Date executionDate = HappyActivity.waitFor();
     assertTrue(dueDate.compareTo(executionDate) <= 0);
   }
 
   /**
-   * This scenario tests a non-repeating timerImpl whose referenced activity
-   * throws a checked exception. <h3>Preconditions</h3> The activity has not
-   * executed. <h3>Behavior</h3> The {@link CreateTimerCmd} command subscribes a
-   * timerImpl bean to the EJB timerImpl service. After that, the test waits for
-   * the activity to execute. Upon timeout, the {@linkplain NoisyActivity
-   * activity} notifies the test of its execution, sets a variable and throws a
-   * checked exception. <h3>Postconditions</h3> The activity executes on or
-   * after the timerImpl's due date. The EJB timerImpl service rolls back the
-   * managed transaction. The variable is unset.
+   * <p>
+   * This scenario tests a non-repeating timer whose referenced activity throws
+   * a checked exception.
+   * </p>
+   * <h3>Preconditions</h3>
+   * <p>
+   * The activity has not executed.
+   * </p>
+   * <h3>Behavior</h3>
+   * <p>
+   * The {@link CreateTimerCmd} command subscribes a timer bean to the EJB timer
+   * service. After that, the test waits for the activity to execute. Upon
+   * timeout, the {@linkplain NoisyActivity activity} notifies the test of its
+   * execution, sets a variable and throws a checked exception.
+   * </p>
+   * <h3>Postconditions</h3>
+   * <p>
+   * The activity executes on or after the timer's due date. The EJB timer
+   * service rolls back the managed transaction. The variable is unset.
+   * </p>
    */
   public void testNoisyTimer() throws CreateException {
     activityDescriptor.setClassName(NoisyActivity.class.getName());
@@ -151,12 +179,11 @@
     ExecutionImpl execution = (ExecutionImpl) commandExecutor
         .execute(new StartExecutionCmd(processDefinition.getId(), null, null));
 
-    Date dueDate = new Date(System.currentTimeMillis() + TIMEOUT);
-    TimerImpl timerImpl = new TimerImpl();
-    timerImpl.setEventName("timeout");
-    timerImpl.setDueDate(dueDate);
-    timerImpl.setExecution(execution);
-    commandExecutor.execute(new CreateTimerCmd(timerImpl));
+    TimerImpl timer = new TimerImpl();
+    timer.setEventName("timeout");
+    timer.setDueDate(dueDate);
+    timer.setExecution(execution);
+    commandExecutor.execute(new CreateTimerCmd(timer));
 
     Date executionDate = NoisyActivity.waitFor();
     assertTrue(dueDate.compareTo(executionDate) <= 0);
@@ -169,16 +196,29 @@
   }
 
   /**
-   * This scenario tests a repeating timerImpl whose referenced activity
-   * completes with no incident. <h3>Preconditions</h3> The activity has not
-   * executed. <h3>Behavior</h3> The {@link CreateTimerCmd} command subscribes a
-   * timerImpl bean to the EJB timerImpl service. After that, the test waits for
-   * the first execution of the activity, and then for the subsequent <em>n</em>
-   * executions of the activity. Upon each timeout, the
-   * {@linkplain HappyActivity activity} notifies the test of its execution. <h3>
-   * Postconditions</h3> The first execution of the activity occurs on or after
-   * the timerImpl's due date. The subsequent <em>n</em> executions of the
-   * activity occur on or after the timerImpl's repeat interval.
+   * <p>
+   * This scenario tests a repeating timer whose referenced activity completes
+   * with no incident.
+   * </p>
+   * <h3>Preconditions</h3>
+   * <p>
+   * The activity has not executed.
+   * </p>
+   * <h3>Behavior</h3>
+   * <p>
+   * The {@link CreateTimerCmd} command subscribes a timer bean to the EJB timer
+   * service. After that, the test waits for the first execution of the
+   * activity, and then for the subsequent <em>n</em> executions of the
+   * activity. Upon each timeout, the {@linkplain HappyActivity activity}
+   * notifies the test of its execution.
+   * </p>
+   * <h3>
+   * Postconditions</h3>
+   * <p>
+   * The first execution of the activity occurs on or after the timer's due
+   * date. The subsequent <em>n</em> executions of the activity occur on or
+   * after the timer's repeat interval.
+   * </p>
    */
   public void testCyclicTimer() throws CreateException {
     activityDescriptor.setClassName(HappyActivity.class.getName());
@@ -188,13 +228,12 @@
     ExecutionImpl execution = (ExecutionImpl) commandExecutor
         .execute(new StartExecutionCmd(processDefinition.getId(), null, null));
 
-    Date dueDate = new Date(System.currentTimeMillis() + TIMEOUT);
-    TimerImpl timerImpl = new TimerImpl();
-    timerImpl.setEventName("timeout");
-    timerImpl.setDueDate(dueDate);
-    timerImpl.setRepeat(REPEAT + " milliseconds");
-    timerImpl.setExecution(execution);
-    commandExecutor.execute(new CreateTimerCmd(timerImpl));
+    TimerImpl timer = new TimerImpl();
+    timer.setEventName("timeout");
+    timer.setDueDate(dueDate);
+    timer.setRepeat(REPEAT + " milliseconds");
+    timer.setExecution(execution);
+    commandExecutor.execute(new CreateTimerCmd(timer));
 
     try {
       Date executionTime = HappyActivity.waitFor();
@@ -208,34 +247,34 @@
       }
     }
     finally {
-      commandExecutor.execute(new CancelTimerCmd(timerImpl.getDbid()));
+      commandExecutor.execute(new CancelTimerCmd(timer.getDbid()));
     }
   }
 
   static class CreateTimerCmd implements Command<Void> {
 
-    private final TimerImpl timerImpl;
+    private final TimerImpl timer;
 
     private static final long serialVersionUID = 1L;
 
-    CreateTimerCmd(TimerImpl timerImpl) {
-      this.timerImpl = timerImpl;
+    CreateTimerCmd(TimerImpl timer) {
+      this.timer = timer;
     }
 
     public Void execute(Environment environment) throws Exception {
       DbSession dbSession = environment.get(DbSession.class);
-      dbSession.save(timerImpl);
+      dbSession.save(timer);
       dbSession.flush();
 
-      long timerDbid = timerImpl.getDbid();
-      log.info("scheduling " + timerImpl + " #" + timerDbid);
+      long timerDbid = timer.getDbid();
+      log.info("scheduling " + timer + " #" + timerDbid);
       LocalTimer timerBean = timerHome.findByPrimaryKey(timerDbid);
       timerBean.schedule();
       return null;
     }
 
     public String toString() {
-      return CreateTimerCmd.class.getSimpleName() + '(' + timerImpl + ')';
+      return CreateTimerCmd.class.getSimpleName() + '(' + timer + ')';
     }
   }
 




More information about the jbpm-commits mailing list