[jbpm-commits] JBoss JBPM SVN: r3346 - in jbpm4/trunk/modules/examples/src/test: java/org/jbpm/examples/end/processinstance and 11 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Thu Dec 11 11:58:57 EST 2008


Author: tom.baeyens at jboss.com
Date: 2008-12-11 11:58:56 -0500 (Thu, 11 Dec 2008)
New Revision: 3346

Added:
   jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/end/multiple/EndMultipleTest.java
   jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/end/processinstance/EndProcessInstanceTest.java
   jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/end/state/EndStateTest.java
   jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/exclusive/expression/ExclusiveExpressionTest.java
   jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/exclusive/handler/ContentEvaluation.java
   jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/exclusive/handler/ExclusiveHandlerTest.java
   jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/end/
   jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/end/multiple/
   jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/end/multiple/process.jpdl.xml
   jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/end/processinstance/
   jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/end/processinstance/process.jpdl.xml
   jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/end/state/
   jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/end/state/process.jpdl.xml
   jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/exclusive/expression/
   jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/exclusive/expression/process.jpdl.xml
   jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/exclusive/handler/
   jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/exclusive/handler/process.jpdl.xml
Log:


Added: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/end/multiple/EndMultipleTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/end/multiple/EndMultipleTest.java	                        (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/end/multiple/EndMultipleTest.java	2008-12-11 16:58:56 UTC (rev 3346)
@@ -0,0 +1,62 @@
+/*
+ * 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.examples.end.multiple;
+
+import org.jbpm.Execution;
+import org.jbpm.test.DbTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class EndMultipleTest extends DbTestCase {
+
+  public void testEndMultipleOk() {
+    deployJpdlResource("org/jbpm/examples/end/multiple/process.jpdl.xml");
+    
+    Execution execution = executionService.startExecutionByKey("EndMultiple");
+    String executionId = execution.getId();
+    execution = executionService.signalExecutionById(executionId, "200");
+    assertTrue(execution.isEnded());
+    assertEquals("ok", execution.getNodeName());
+  }
+
+  public void testEndMultipleBadRequest() {
+    deployJpdlResource("org/jbpm/examples/end/multiple/process.jpdl.xml");
+    
+    Execution execution = executionService.startExecutionByKey("EndMultiple");
+    String executionId = execution.getId();
+    execution = executionService.signalExecutionById(executionId, "400");
+    assertTrue(execution.isEnded());
+    assertEquals("bad request", execution.getNodeName());
+  }
+
+  public void testEndMultipleInternalServerError() {
+    deployJpdlResource("org/jbpm/examples/end/multiple/process.jpdl.xml");
+    
+    Execution execution = executionService.startExecutionByKey("EndMultiple");
+    String executionId = execution.getId();
+    execution = executionService.signalExecutionById(executionId, "500");
+    assertTrue(execution.isEnded());
+    assertEquals("internal server error", execution.getNodeName());
+  }
+}

Added: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/end/processinstance/EndProcessInstanceTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/end/processinstance/EndProcessInstanceTest.java	                        (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/end/processinstance/EndProcessInstanceTest.java	2008-12-11 16:58:56 UTC (rev 3346)
@@ -0,0 +1,62 @@
+/*
+ * 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.examples.end.processinstance;
+
+import org.jbpm.Execution;
+import org.jbpm.test.DbTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class EndProcessInstanceTest extends DbTestCase {
+
+  public void testEndOk() {
+    deployJpdlResource("org/jbpm/examples/end/multiple/process.jpdl.xml");
+    
+    Execution execution = executionService.startExecutionByKey("EndMultiple");
+    String executionId = execution.getId();
+    
+    execution = executionService.signalExecutionById(executionId, "200");
+    assertEquals("ok", execution.getNodeName());
+  }
+
+  public void testEndBadRequest() {
+    deployJpdlResource("org/jbpm/examples/end/multiple/process.jpdl.xml");
+    
+    Execution execution = executionService.startExecutionByKey("EndMultiple");
+    String executionId = execution.getId();
+    
+    execution = executionService.signalExecutionById(executionId, "400");
+    assertEquals("bad request", execution.getNodeName());
+  }
+
+  public void testEndInternalServerError() {
+    deployJpdlResource("org/jbpm/examples/end/multiple/process.jpdl.xml");
+    
+    Execution execution = executionService.startExecutionByKey("EndMultiple");
+    String executionId = execution.getId();
+    
+    execution = executionService.signalExecutionById(executionId, "500");
+    assertEquals("internal server error", execution.getNodeName());
+  }
+}

Added: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/end/state/EndStateTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/end/state/EndStateTest.java	                        (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/end/state/EndStateTest.java	2008-12-11 16:58:56 UTC (rev 3346)
@@ -0,0 +1,62 @@
+/*
+ * 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.examples.end.state;
+
+import org.jbpm.Execution;
+import org.jbpm.test.DbTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class EndStateTest extends DbTestCase {
+
+  public void testEndStateCompleted() {
+    deployJpdlResource("org/jbpm/examples/end/state/process.jpdl.xml");
+    
+    Execution execution = executionService.startExecutionByKey("EndState");
+    String executionId = execution.getId();
+    execution = executionService.signalExecutionById(executionId, "200");
+    assertEquals("completed", execution.getState());
+    assertEquals("ok", execution.getNodeName());
+  }
+
+  public void testEndStateErrorBadRequest() {
+    deployJpdlResource("org/jbpm/examples/end/state/process.jpdl.xml");
+    
+    Execution execution = executionService.startExecutionByKey("EndState");
+    String executionId = execution.getId();
+    execution = executionService.signalExecutionById(executionId, "400");
+    assertEquals("error", execution.getState());
+    assertEquals("bad request", execution.getNodeName());
+  }
+
+  public void testEndStateErrorInternalServerError() {
+    deployJpdlResource("org/jbpm/examples/end/state/process.jpdl.xml");
+    
+    Execution execution = executionService.startExecutionByKey("EndState");
+    String executionId = execution.getId();
+    execution = executionService.signalExecutionById(executionId, "500");
+    assertEquals("error", execution.getState());
+    assertEquals("internal server error", execution.getNodeName());
+  }
+}

Added: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/exclusive/expression/ExclusiveExpressionTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/exclusive/expression/ExclusiveExpressionTest.java	                        (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/exclusive/expression/ExclusiveExpressionTest.java	2008-12-11 16:58:56 UTC (rev 3346)
@@ -0,0 +1,63 @@
+/*
+ * 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.examples.exclusive.expression;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jbpm.Execution;
+import org.jbpm.test.DbTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ExclusiveExpressionTest extends DbTestCase {
+
+  public void testExclusiveExpressionGood() {
+    deployJpdlResource("org/jbpm/examples/exclusive/expression/process.jpdl.xml");
+    
+    Map<String, Object> variables = new HashMap<String, Object>();
+    variables.put("content", "good");
+    Execution execution = executionService.startExecutionByKey("ExclusiveExpression", variables);
+    assertEquals("submit document", execution.getNodeName());
+  }
+
+  public void testExclusiveExpressionBad() {
+    deployJpdlResource("org/jbpm/examples/exclusive/expression/process.jpdl.xml");
+    
+    Map<String, Object> variables = new HashMap<String, Object>();
+    variables.put("content", "bad");
+    Execution execution = executionService.startExecutionByKey("ExclusiveExpression", variables);
+    assertEquals("try again", execution.getNodeName());
+  }
+
+  public void testExclusiveExpressionUgly() {
+    deployJpdlResource("org/jbpm/examples/exclusive/expression/process.jpdl.xml");
+    
+    Map<String, Object> variables = new HashMap<String, Object>();
+    variables.put("content", "ugly");
+    Execution execution = executionService.startExecutionByKey("ExclusiveExpression", variables);
+    assertEquals("give up", execution.getNodeName());
+  }
+
+}

Added: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/exclusive/handler/ContentEvaluation.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/exclusive/handler/ContentEvaluation.java	                        (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/exclusive/handler/ContentEvaluation.java	2008-12-11 16:58:56 UTC (rev 3346)
@@ -0,0 +1,39 @@
+/*
+ * 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.examples.exclusive.handler;
+
+import org.jbpm.jpdl.ExclusiveHandler;
+import org.jbpm.model.OpenExecution;
+
+public class ContentEvaluation implements ExclusiveHandler {
+
+  public String select(OpenExecution execution) {
+    String content = (String) execution.getVariable("content");
+    if (content.equals("you're great")) {
+      return "good";
+    }
+    if (content.equals("you gotta improve")) {
+      return "bad";
+    }
+    return "ugly";
+  }
+}
\ No newline at end of file

Added: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/exclusive/handler/ExclusiveHandlerTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/exclusive/handler/ExclusiveHandlerTest.java	                        (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/exclusive/handler/ExclusiveHandlerTest.java	2008-12-11 16:58:56 UTC (rev 3346)
@@ -0,0 +1,62 @@
+/*
+ * 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.examples.exclusive.handler;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jbpm.Execution;
+import org.jbpm.test.DbTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ExclusiveHandlerTest extends DbTestCase {
+  
+  public void testExclusiveHandlerGreat() {
+    deployJpdlResource("org/jbpm/examples/exclusive/handler/process.jpdl.xml");
+
+    Map<String, Object> variables = new HashMap<String, Object>();
+    variables.put("content", "you're great");
+    Execution execution = executionService.startExecutionByKey("ExclusiveHandler", variables);
+    assertEquals("submit document", execution.getNodeName());
+  }
+
+  public void testExclusiveHandlerImprove() {
+    deployJpdlResource("org/jbpm/examples/exclusive/handler/process.jpdl.xml");
+
+    Map<String, Object> variables = new HashMap<String, Object>();
+    variables.put("content", "you gotta improve");
+    Execution execution = executionService.startExecutionByKey("ExclusiveHandler", variables);
+    assertEquals("try again", execution.getNodeName());
+  }
+
+  public void testExclusiveHandlerSuck() {
+    deployJpdlResource("org/jbpm/examples/exclusive/handler/process.jpdl.xml");
+
+    Map<String, Object> variables = new HashMap<String, Object>();
+    variables.put("content", "you suck");
+    Execution execution = executionService.startExecutionByKey("ExclusiveHandler", variables);
+    assertEquals("give up", execution.getNodeName());
+  }
+}

Added: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/end/multiple/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/end/multiple/process.jpdl.xml	                        (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/end/multiple/process.jpdl.xml	2008-12-11 16:58:56 UTC (rev 3346)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="EndMultiple" xmlns="http://jbpm.org/4/jpdl">
+
+  <start>
+    <flow to="get return code" />
+  </start>
+
+  <state name="get return code">
+    <flow name="200" to="ok" />
+    <flow name="400" to="bad request" />
+    <flow name="500" to="internal server error" />
+  </state>
+
+  <end name="ok" />
+  <end name="bad request" />
+  <end name="internal server error" />
+
+</process>

Added: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/end/processinstance/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/end/processinstance/process.jpdl.xml	                        (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/end/processinstance/process.jpdl.xml	2008-12-11 16:58:56 UTC (rev 3346)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="EndProcessInstance" xmlns="http://jbpm.org/4/jpdl">
+
+  <start>
+    <flow to="end" />
+  </start>
+
+  <end name="end" />
+
+</process>

Added: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/end/state/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/end/state/process.jpdl.xml	                        (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/end/state/process.jpdl.xml	2008-12-11 16:58:56 UTC (rev 3346)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="EndState" xmlns="http://jbpm.org/4/jpdl">
+
+  <start>
+    <flow to="get return code" />
+  </start>
+
+  <state name="get return code">
+    <flow name="200" to="ok" />
+    <flow name="400" to="bad request" />
+    <flow name="500" to="internal server error" />
+  </state>
+
+  <end name="ok" state="completed" />
+  <end name="bad request" state="error" />
+  <end name="internal server error" state="error" />
+
+</process>

Added: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/exclusive/expression/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/exclusive/expression/process.jpdl.xml	                        (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/exclusive/expression/process.jpdl.xml	2008-12-11 16:58:56 UTC (rev 3346)
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="ExclusiveExpression">
+
+  <start>
+    <flow to="evaluate document" />
+  </start>
+
+  <exclusive name="evaluate document" expr="#{content}">
+    <flow name="good" to="submit document" />
+    <flow name="bad" to="try again" />
+    <flow name="ugly" to="give up" />
+  </exclusive>
+
+  <state name="submit document" />
+
+  <state name="try again" />
+
+  <state name="give up" />
+
+</process>

Added: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/exclusive/handler/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/exclusive/handler/process.jpdl.xml	                        (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/exclusive/handler/process.jpdl.xml	2008-12-11 16:58:56 UTC (rev 3346)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="ExclusiveHandler">
+
+  <start>
+    <flow to="evaluate document" />
+  </start>
+
+  <exclusive name="evaluate document">
+    <handler class="org.jbpm.examples.exclusive.handler.ContentEvaluation" />
+    <flow name="good" to="submit document" />
+    <flow name="bad" to="try again" />
+    <flow name="ugly" to="give up" />
+  </exclusive>
+
+  <state name="submit document" />
+
+  <state name="try again" />
+
+  <state name="give up" />
+
+</process>




More information about the jbpm-commits mailing list