[jbpm-commits] JBoss JBPM SVN: r3108 - in projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts: gateway and 1 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Thu Nov 27 03:33:12 EST 2008


Author: thomas.diesler at jboss.com
Date: 2008-11-27 03:33:12 -0500 (Thu, 27 Nov 2008)
New Revision: 3108

Added:
   projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/gateway/
   projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/gateway/exclusive/
   projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/gateway/exclusive/ExclusiveGatewaySplitMarshallerTest.java
   projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/gateway/exclusive/ExclusiveGatewaySplitTest.java
Log:
WIP

Added: projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/gateway/exclusive/ExclusiveGatewaySplitMarshallerTest.java
===================================================================
--- projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/gateway/exclusive/ExclusiveGatewaySplitMarshallerTest.java	                        (rev 0)
+++ projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/gateway/exclusive/ExclusiveGatewaySplitMarshallerTest.java	2008-11-27 08:33:12 UTC (rev 3108)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.cts.gateway.exclusive;
+
+// $Id$
+
+import java.io.IOException;
+
+import org.jboss.bpm.api.model.ProcessDefinition;
+import org.jboss.bpm.api.service.ProcessDefinitionService;
+
+
+/**
+ * Exclusive data-based gateway that has conditional outgoing sequence flows. Only one of the gates is taken. It is an
+ * error if no gate is applicable.
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 06-Aug-2008
+ */
+public class ExclusiveGatewaySplitMarshallerTest extends ExclusiveGatewaySplitTest
+{
+  protected ProcessDefinition getProcessDefinition() throws IOException
+  {
+    // Marshall the process to a string
+    ProcessDefinition procDef = super.getProcessDefinition();
+    String procXML = marshallProcess(procDef);
+
+    //System.out.println(procXML);
+
+    // Recreate the ProcessDefinition from the marshalled ProcessDefinition
+    ProcessDefinitionService pdService = getProcessEngine().getService(ProcessDefinitionService.class);
+    return pdService.parseProcessDefinition(procXML);
+  }
+}


Property changes on: projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/gateway/exclusive/ExclusiveGatewaySplitMarshallerTest.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/gateway/exclusive/ExclusiveGatewaySplitTest.java
===================================================================
--- projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/gateway/exclusive/ExclusiveGatewaySplitTest.java	                        (rev 0)
+++ projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/gateway/exclusive/ExclusiveGatewaySplitTest.java	2008-11-27 08:33:12 UTC (rev 3108)
@@ -0,0 +1,113 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.cts.gateway.exclusive;
+
+// $Id$
+
+import java.io.IOException;
+
+import org.jboss.bpm.api.client.Token;
+import org.jboss.bpm.api.client.Token.TokenStatus;
+import org.jboss.bpm.api.model.Process;
+import org.jboss.bpm.api.model.ProcessDefinition;
+import org.jboss.bpm.api.model.Expression.ExpressionLanguage;
+import org.jboss.bpm.api.model.Gateway.GatewayType;
+import org.jboss.bpm.api.model.Process.ProcessStatus;
+import org.jboss.bpm.api.model.builder.GatewayBuilder;
+import org.jboss.bpm.api.model.builder.ProcessBuilder;
+import org.jboss.bpm.api.runtime.BasicAttachments;
+import org.jboss.bpm.api.service.ProcessBuilderService;
+import org.jboss.bpm.api.test.CTSTestCase;
+
+/**
+ * Exclusive data-based gateway that has conditional outgoing sequence flows. Only one of the gates is taken. It is an
+ * error if no gate is applicable.
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 06-Aug-2008
+ */
+public class ExclusiveGatewaySplitTest extends CTSTestCase
+{
+  public void testGateA() throws Exception
+  {
+    ProcessDefinition procDef = unregisterOnTearDown(getProcessDefinition());
+    Process proc = procDef.newInstance();
+
+    BasicAttachments att = new BasicAttachments();
+    att.addAttachment("foo", "5");
+
+    Token tok = proc.startProcess(att);
+
+    String nodeName = tok.getCurrentNode().getName();
+    assertEquals("EndA", nodeName);
+    
+    assertEquals(TokenStatus.Destroyed, tok.getTokenStatus());
+    assertEquals(ProcessStatus.Completed, proc.getProcessStatus());
+  }
+
+  public void testGateB() throws Exception
+  {
+    ProcessDefinition procDef = unregisterOnTearDown(getProcessDefinition());
+    Process proc = procDef.newInstance();
+
+    BasicAttachments att = new BasicAttachments();
+    att.addAttachment("foo", "15");
+    
+    Token tok = proc.startProcess(att);
+
+    String nodeName = tok.getCurrentNode().getName();
+    assertEquals("EndB", nodeName);
+    
+    assertEquals(TokenStatus.Destroyed, tok.getTokenStatus());
+    assertEquals(ProcessStatus.Completed, proc.getProcessStatus());
+  }
+
+  public void testInvalidGate() throws Exception
+  {
+    ProcessDefinition procDef = unregisterOnTearDown(getProcessDefinition());
+    Process proc = procDef.newInstance();
+
+    BasicAttachments att = new BasicAttachments();
+    att.addAttachment("foo", "10");
+    
+    try
+    {
+      proc.startProcess(att);
+      fail("No gate defined for foo==10");
+    }
+    catch (RuntimeException rte)
+    {
+      // expected
+    }
+  }
+
+  protected ProcessDefinition getProcessDefinition() throws IOException
+  {
+    ProcessBuilder procBuilder = ProcessBuilderService.locateProcessBuilder();
+    procBuilder.addProcess(getName()).addStartEvent("Start").addSequenceFlow("Split");
+    GatewayBuilder gatewayBuilder = procBuilder.addGateway("Split", GatewayType.Exclusive);
+    gatewayBuilder.addConditionalGate("EndA", ExpressionLanguage.MVEL, "foo < 10");
+    gatewayBuilder.addConditionalGate("EndB", ExpressionLanguage.MVEL, "foo > 10");
+    procBuilder.addEndEvent("EndA").addEndEvent("EndB");
+    return procBuilder.getProcessDefinition();
+  }
+}


Property changes on: projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/gateway/exclusive/ExclusiveGatewaySplitTest.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF




More information about the jbpm-commits mailing list