Author: tom.baeyens(a)jboss.com
Date: 2008-12-29 07:27:04 -0500 (Mon, 29 Dec 2008)
New Revision: 3581
Added:
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/eventlistener/
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/eventlistener/DisplaySource.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/eventlistener/EventListenerTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/eventlistener/EventPropagationTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/eventlistener/PrintLn.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/execution/
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/execution/AutomaticCreditRating.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/execution/BasicProcessExecutionTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/execution/Decision.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/execution/ExternalDecisionTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/execution/InternalDecisionTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/variables/
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/variables/CustomTypeVariableTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/variables/VariablesTest.java
jbpm4/trunk/modules/pvm/src/test/resources/org/jbpm/pvm/variables/
jbpm4/trunk/modules/pvm/src/test/resources/org/jbpm/pvm/variables/custom.types.jbpm.cfg.xml
Removed:
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/example06/
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/example07/
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/example08/
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/langext/
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/type/
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/samples/ExamplesConfiguration.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/samples/activities/
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/samples/ex01/
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/samples/ex02/
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/samples/ex03/
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/samples/ex04/
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/samples/ex05/
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/samples/ex06/
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/samples/ex07/
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/samples/ex08/
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/samples/ex09/
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/samples/ex13/
jbpm4/trunk/modules/pvm/src/test/resources/org/jbpm/pvm/internal/db/langext/
jbpm4/trunk/modules/pvm/src/test/resources/org/jbpm/pvm/internal/db/type/
Modified:
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/expr/GroovyExpressionTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/expr/JuelExpressionTest.java
Log:
pvm test suite cleanup
Copied:
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/eventlistener/DisplaySource.java (from
rev 3579,
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/example08/DisplaySource.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/eventlistener/DisplaySource.java
(rev 0)
+++
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/eventlistener/DisplaySource.java 2008-12-29
12:27:04 UTC (rev 3581)
@@ -0,0 +1,34 @@
+/*
+ * 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.pvm.eventlistener;
+
+import org.jbpm.listener.EventListener;
+import org.jbpm.listener.EventListenerExecution;
+
+public class DisplaySource implements EventListener {
+
+ private static final long serialVersionUID = 1L;
+
+ public void notify(EventListenerExecution execution) {
+ System.out.println("leaving "+execution.getEventSource());
+ }
+}
Property changes on:
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/eventlistener/DisplaySource.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/eventlistener/EventListenerTest.java
(from rev 3579,
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/example07/EventListenerTest.java)
===================================================================
---
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/eventlistener/EventListenerTest.java
(rev 0)
+++
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/eventlistener/EventListenerTest.java 2008-12-29
12:27:04 UTC (rev 3581)
@@ -0,0 +1,70 @@
+/*
+ * 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.pvm.eventlistener;
+
+import javax.enterprise.deploy.spi.exceptions.ClientExecuteException;
+
+import org.jbpm.client.ClientExecution;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.model.Event;
+import org.jbpm.pvm.display.Display;
+import org.jbpm.pvm.display.TestConsole;
+import org.jbpm.pvm.executionmode.object.AutomaticActivity;
+import org.jbpm.pvm.executionmode.object.WaitState;
+import org.jbpm.pvm.model.ProcessFactory;
+import org.jbpm.test.JbpmTestCase;
+
+
+public class EventListenerTest extends JbpmTestCase {
+
+ TestConsole testConsole;
+
+ public void setUp() {
+ testConsole = TestConsole.install();
+ }
+
+ public void tearDown() {
+ TestConsole.uninstall();
+ testConsole = null;
+ }
+
+ public void testEventListener() {
+ ClientProcessDefinition processDefinition = ProcessFactory.build()
+ .node("a").initial().behaviour(new AutomaticActivity())
+ .event(Event.NODE_END)
+ .listener(new PrintLn("leaving a"))
+ .listener(new PrintLn("second message while leaving a"))
+ .transition().to("b")
+ .listener(new PrintLn("taking transition"))
+ .node("b").behaviour(new WaitState())
+ .event(Event.NODE_BEGIN)
+ .listener(new PrintLn("entering b"))
+ .done();
+
+ ClientExecution execution = processDefinition.startProcessInstance();
+
+ assertEquals("leaving a", testConsole.getLine(0));
+ assertEquals("second message while leaving a", testConsole.getLine(1));
+ assertEquals("taking transition", testConsole.getLine(2));
+ assertEquals("entering b", testConsole.getLine(3));
+ }
+}
Property changes on:
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/eventlistener/EventListenerTest.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/eventlistener/EventPropagationTest.java
(from rev 3579,
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/example08/EventPropagationTest.java)
===================================================================
---
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/eventlistener/EventPropagationTest.java
(rev 0)
+++
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/eventlistener/EventPropagationTest.java 2008-12-29
12:27:04 UTC (rev 3581)
@@ -0,0 +1,107 @@
+/*
+ * 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.pvm.eventlistener;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.client.ClientExecution;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.model.Event;
+import org.jbpm.pvm.display.TestConsole;
+import org.jbpm.pvm.executionmode.object.WaitState;
+import org.jbpm.pvm.model.ProcessFactory;
+import org.jbpm.test.JbpmTestCase;
+
+
+public class EventPropagationTest extends JbpmTestCase {
+
+ TestConsole testConsole;
+
+ public void setUp() {
+ testConsole = TestConsole.install();
+ }
+
+ public void tearDown() {
+ TestConsole.uninstall();
+ testConsole = null;
+ }
+
+ public void testEventPropagation() {
+ ClientProcessDefinition processDefinition =
ProcessFactory.build("propagate")
+ .compositeNode("composite")
+ .event(Event.NODE_END)
+ .listener(new DisplaySource())
+ .node("a").initial().behaviour(new WaitState())
+ .transition().to("b")
+ .node("b").behaviour(new WaitState())
+ .transition().to("c")
+ .compositeEnd()
+ .node("c").behaviour(new WaitState())
+ .done();
+
+ ClientExecution execution = processDefinition.startProcessInstance();
+
+ List<String> expectedLines = new ArrayList<String>();
+ assertEquals(expectedLines, testConsole.lines);
+
+ execution.signal();
+
+ expectedLines.add("leaving node(a)");
+ assertEquals(expectedLines, testConsole.lines);
+
+ execution.signal();
+
+ expectedLines.add("leaving node(b)");
+ expectedLines.add("leaving node(composite)");
+ assertEquals(expectedLines, testConsole.lines);
+ }
+
+ public void testEventPropagationDisabled() {
+ ClientProcessDefinition processDefinition =
ProcessFactory.build("propagate")
+ .compositeNode("composite")
+ .event(Event.NODE_END)
+ .listener(new DisplaySource())
+ .propagationDisabled()
+ .node("a").initial().behaviour(new WaitState())
+ .transition().to("b")
+ .node("b").behaviour(new WaitState())
+ .transition().to("c")
+ .compositeEnd()
+ .node("c").behaviour(new WaitState())
+ .done();
+
+ ClientExecution execution = processDefinition.startProcessInstance();
+
+ List<String> expectedLines = new ArrayList<String>();
+ assertEquals(expectedLines, testConsole.lines);
+
+ execution.signal();
+
+ assertEquals(expectedLines, testConsole.lines);
+
+ execution.signal();
+
+ expectedLines.add("leaving node(composite)");
+ assertEquals(expectedLines, testConsole.lines);
+ }
+}
Property changes on:
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/eventlistener/EventPropagationTest.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/eventlistener/PrintLn.java
(from rev 3579,
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/example07/PrintLn.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/eventlistener/PrintLn.java
(rev 0)
+++
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/eventlistener/PrintLn.java 2008-12-29
12:27:04 UTC (rev 3581)
@@ -0,0 +1,41 @@
+/*
+ * 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.pvm.eventlistener;
+
+import org.jbpm.listener.EventListener;
+import org.jbpm.listener.EventListenerExecution;
+
+
+public class PrintLn implements EventListener {
+
+ private static final long serialVersionUID = 1L;
+
+ String message;
+
+ public PrintLn(String message) {
+ this.message = message;
+ }
+
+ public void notify(EventListenerExecution execution) throws Exception {
+ System.out.println(message);
+ }
+}
Property changes on:
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/eventlistener/PrintLn.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/execution/AutomaticCreditRating.java
(from rev 3579,
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/samples/ex05/AutomaticCreditRating.java)
===================================================================
---
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/execution/AutomaticCreditRating.java
(rev 0)
+++
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/execution/AutomaticCreditRating.java 2008-12-29
12:27:04 UTC (rev 3581)
@@ -0,0 +1,49 @@
+/*
+ * 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.pvm.execution;
+
+import org.jbpm.activity.Activity;
+import org.jbpm.activity.ActivityExecution;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class AutomaticCreditRating implements Activity {
+
+ private static final long serialVersionUID = 1L;
+
+ public void execute(ActivityExecution execution) {
+ int creditRate = (Integer) execution.getVariable("creditRate");
+
+ if (creditRate > 5) {
+ execution.take("good");
+
+ } else if (creditRate < -5) {
+ execution.take("bad");
+
+ } else {
+ execution.take("average");
+ }
+ }
+
+}
Property changes on:
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/execution/AutomaticCreditRating.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Copied:
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/execution/BasicProcessExecutionTest.java
(from rev 3579,
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/example06/BasicProcessExecutionTest.java)
===================================================================
---
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/execution/BasicProcessExecutionTest.java
(rev 0)
+++
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/execution/BasicProcessExecutionTest.java 2008-12-29
12:27:04 UTC (rev 3581)
@@ -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.pvm.execution;
+
+import org.jbpm.client.ClientExecution;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.pvm.display.Display;
+import org.jbpm.pvm.externalactivity.WaitState;
+import org.jbpm.pvm.model.ProcessFactory;
+import org.jbpm.test.JbpmTestCase;
+
+
+public class BasicProcessExecutionTest extends JbpmTestCase {
+
+ public void testBasicProcessExecution() {
+ ClientProcessDefinition processDefinition = ProcessFactory.build("loan")
+ .node("submit loan request").initial().behaviour(new Display("loan
request submitted"))
+ .transition().to("evaluate")
+ .node("evaluate").behaviour(new WaitState())
+ .transition("approve").to("wire money")
+ .transition("reject").to("end")
+ .node("wire money").behaviour(new Display("wire the money"))
+ .transition().to("archive")
+ .node("archive").behaviour(new WaitState())
+ .transition().to("end")
+ .node("end").behaviour(new WaitState())
+ .done();
+
+ ClientExecution execution = processDefinition.startProcessInstance();
+
+
+
+ }
+}
Property changes on:
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/execution/BasicProcessExecutionTest.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/execution/Decision.java (from
rev 3579, jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/samples/ex04/Decision.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/execution/Decision.java
(rev 0)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/execution/Decision.java 2008-12-29
12:27:04 UTC (rev 3581)
@@ -0,0 +1,44 @@
+/*
+ * 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.pvm.execution;
+
+import java.util.Map;
+
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.activity.ExternalActivity;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class Decision implements ExternalActivity {
+
+ private static final long serialVersionUID = 1L;
+
+ public void execute(ActivityExecution execution) throws Exception {
+ execution.waitForSignal();
+ }
+
+ public void signal(ActivityExecution execution, String signalName, Map<String,
Object> parameters) throws Exception {
+ execution.take(signalName);
+ }
+}
Property changes on:
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/execution/Decision.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Copied:
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/execution/ExternalDecisionTest.java
(from rev 3579,
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/samples/ex04/ExternalDecisionTest.java)
===================================================================
---
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/execution/ExternalDecisionTest.java
(rev 0)
+++
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/execution/ExternalDecisionTest.java 2008-12-29
12:27:04 UTC (rev 3581)
@@ -0,0 +1,78 @@
+/*
+ * 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.pvm.execution;
+
+import junit.framework.TestCase;
+
+import org.jbpm.client.ClientExecution;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.pvm.executionmode.embedded.AutomaticActivity;
+import org.jbpm.pvm.externalactivity.WaitState;
+import org.jbpm.pvm.model.ProcessFactory;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ExternalDecisionTest extends TestCase {
+
+ public static ClientProcessDefinition createCreditProcess() {
+ return ProcessFactory.build()
+ .node("initial").initial().behaviour(new AutomaticActivity())
+ .transition().to("creditRate?")
+ .node("creditRate?").behaviour(new Decision())
+ .transition("good").to("priority delivery")
+ .transition("average").to("bulk delivery")
+ .transition("bad").to("payment upfront")
+ .node("priority delivery").behaviour(new WaitState())
+ .node("bulk delivery").behaviour(new WaitState())
+ .node("payment upfront").behaviour(new WaitState())
+ .done();
+ }
+
+ public void testGoodRating() {
+ ClientProcessDefinition processDefinition = createCreditProcess();
+
+ ClientExecution execution = processDefinition.startProcessInstance();
+ execution.signal("good");
+
+ assertEquals("priority delivery", execution.getNode().getName());
+ }
+
+ public void testAverageRating() {
+ ClientProcessDefinition processDefinition = createCreditProcess();
+
+ ClientExecution execution = processDefinition.startProcessInstance();
+ execution.signal("average");
+
+ assertEquals("bulk delivery", execution.getNode().getName());
+ }
+
+ public void testBadRating() {
+ ClientProcessDefinition processDefinition = createCreditProcess();
+
+ ClientExecution execution = processDefinition.startProcessInstance();
+ execution.signal("bad");
+
+ assertEquals("payment upfront", execution.getNode().getName());
+ }
+}
Property changes on:
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/execution/ExternalDecisionTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Copied:
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/execution/InternalDecisionTest.java
(from rev 3579,
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/samples/ex05/InternalDecisionTest.java)
===================================================================
---
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/execution/InternalDecisionTest.java
(rev 0)
+++
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/execution/InternalDecisionTest.java 2008-12-29
12:27:04 UTC (rev 3581)
@@ -0,0 +1,81 @@
+/*
+ * 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.pvm.execution;
+
+import junit.framework.TestCase;
+
+import org.jbpm.client.ClientExecution;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.pvm.externalactivity.WaitState;
+import org.jbpm.pvm.model.ProcessFactory;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class InternalDecisionTest extends TestCase {
+
+ public static ClientProcessDefinition createCreditProcess() {
+ return ProcessFactory.build()
+ .node("get credit rate").initial().behaviour(WaitState.class)
+ .transition().to("creditRate?")
+ .node("creditRate?").behaviour(AutomaticCreditRating.class)
+ .transition("good").to("priority delivery")
+ .transition("average").to("bulk delivery")
+ .transition("bad").to("payment upfront")
+ .node("priority delivery").behaviour(WaitState.class)
+ .node("bulk delivery").behaviour(WaitState.class)
+ .node("payment upfront").behaviour(WaitState.class)
+ .done();
+ }
+
+ public void testGoodRating() {
+ ClientProcessDefinition processDefinition = createCreditProcess();
+
+ ClientExecution execution = processDefinition.startProcessInstance();
+ execution.setVariable("creditRate", 7);
+ execution.signal();
+
+ assertEquals("priority delivery", execution.getNode().getName());
+ }
+
+ public void testAverageRating() {
+ ClientProcessDefinition processDefinition = createCreditProcess();
+
+ ClientExecution execution = processDefinition.startProcessInstance();
+ execution.setVariable("creditRate", 2);
+ execution.signal();
+
+ assertEquals("bulk delivery", execution.getNode().getName());
+ }
+
+ public void testBadRating() {
+ ClientProcessDefinition processDefinition = createCreditProcess();
+
+ ClientExecution execution = processDefinition.startProcessInstance();
+ execution.setVariable("creditRate", -9);
+ execution.signal();
+
+ assertEquals("payment upfront", execution.getNode().getName());
+ }
+
+}
Property changes on:
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/execution/InternalDecisionTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Modified:
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/expr/GroovyExpressionTest.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/expr/GroovyExpressionTest.java 2008-12-29
12:00:36 UTC (rev 3580)
+++
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/expr/GroovyExpressionTest.java 2008-12-29
12:27:04 UTC (rev 3581)
@@ -25,9 +25,9 @@
import org.jbpm.client.ClientExecution;
import org.jbpm.env.Environment;
import org.jbpm.env.EnvironmentFactory;
+import org.jbpm.pvm.externalactivity.WaitState;
import org.jbpm.pvm.internal.script.ScriptManager;
import org.jbpm.pvm.model.ProcessFactory;
-import org.jbpm.pvm.samples.activities.WaitState;
import org.jbpm.test.JbpmTestCase;
Modified:
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/expr/JuelExpressionTest.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/expr/JuelExpressionTest.java 2008-12-29
12:00:36 UTC (rev 3580)
+++
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/expr/JuelExpressionTest.java 2008-12-29
12:27:04 UTC (rev 3581)
@@ -25,9 +25,9 @@
import org.jbpm.client.ClientExecution;
import org.jbpm.env.Environment;
import org.jbpm.env.EnvironmentFactory;
+import org.jbpm.pvm.externalactivity.WaitState;
import org.jbpm.pvm.internal.script.ScriptManager;
import org.jbpm.pvm.model.ProcessFactory;
-import org.jbpm.pvm.samples.activities.WaitState;
import org.jbpm.test.JbpmTestCase;
Deleted:
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/samples/ExamplesConfiguration.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/samples/ExamplesConfiguration.java 2008-12-29
12:00:36 UTC (rev 3580)
+++
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/samples/ExamplesConfiguration.java 2008-12-29
12:27:04 UTC (rev 3581)
@@ -1,73 +0,0 @@
-/*
- * 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.pvm.samples;
-
-import org.jbpm.Configuration;
-import org.jbpm.ExecutionService;
-import org.jbpm.ManagementService;
-import org.jbpm.ProcessService;
-import org.jbpm.cfg.JbpmConfiguration;
-import org.jbpm.env.EnvironmentFactory;
-
-
-/**
- * @author Tom Baeyens
- */
-public abstract class ExamplesConfiguration {
-
- static boolean isInitialized;
- static ProcessService processService;
- static ExecutionService executionService;
- static ManagementService managementService;
- static EnvironmentFactory environmentFactory;
-
- public static ProcessService getProcessService() {
- initialize();
- return processService;
- }
-
- public static ExecutionService getExecutionService() {
- initialize();
- return executionService;
- }
-
- public static ManagementService getManagementService() {
- initialize();
- return managementService;
- }
-
- public static EnvironmentFactory getEnvironmentFactory() {
- initialize();
- return environmentFactory;
- }
-
- private synchronized static void initialize() {
- if (!isInitialized) {
- isInitialized = true;
- environmentFactory = (EnvironmentFactory) new
Configuration().setResource("environment.cfg.xml").buildProcessEngine();
- processService = environmentFactory.get(ProcessService.class);
- executionService = environmentFactory.get(ExecutionService.class);
- managementService = environmentFactory.get(ManagementService.class);
- }
- }
-
-}
Copied:
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/variables/CustomTypeVariableTest.java
(from rev 3579,
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/type/VariableCustomTypeTest.java)
===================================================================
---
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/variables/CustomTypeVariableTest.java
(rev 0)
+++
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/variables/CustomTypeVariableTest.java 2008-12-29
12:27:04 UTC (rev 3581)
@@ -0,0 +1,93 @@
+/*
+ * 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.pvm.variables;
+
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+import java.util.Map;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.activity.ExternalActivity;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.type.Variable;
+import org.jbpm.pvm.internal.type.variable.DateVariable;
+import org.jbpm.pvm.model.ProcessFactory;
+import org.jbpm.test.EnvironmentDbTestCase;
+import org.jbpm.test.EnvironmentFactoryTestSetup;
+
+/**
+ * @author Guillaume Porcher
+ */
+public class CustomTypeVariableTest extends EnvironmentDbTestCase {
+
+ private static final String ENVIRONMENT_CFG_XML =
"org/jbpm/pvm/variables/custom.types.jbpm.cfg.xml";
+
+ public CustomTypeVariableTest() {
+ super(ENVIRONMENT_CFG_XML);
+ }
+
+ public static class WaitState implements ExternalActivity {
+
+ private static final long serialVersionUID = 1L;
+
+ public void execute(ActivityExecution execution) {
+ execution.waitForSignal();
+ }
+
+ public void signal(ActivityExecution execution, String signalName, Map<String,
Object> parameters) {
+ execution.take(signalName);
+ }
+ }
+
+ public void testDateVariable() {
+ ClientProcessDefinition clientProcessDefinition =
ProcessFactory.build().node().initial().behaviour(WaitState.class).done();
+
+ getDbSession().save(clientProcessDefinition);
+
+ ExecutionImpl execution = (ExecutionImpl)
clientProcessDefinition.startProcessInstance();
+
+ execution = reload(execution, ExecutionImpl.class);
+
+ Calendar calendar = new GregorianCalendar();
+ calendar.set(Calendar.YEAR, 2007);
+ calendar.set(Calendar.MONTH, 10); // (10 == november)
+ calendar.set(Calendar.DAY_OF_MONTH, 22);
+ calendar.set(Calendar.HOUR_OF_DAY, 15);
+ calendar.set(Calendar.MINUTE, 28);
+ calendar.set(Calendar.SECOND, 57);
+ calendar.set(Calendar.MILLISECOND, 374);
+
+ execution.setVariable("v", calendar.getTime());
+
+ execution = reload(execution, ExecutionImpl.class);
+
+ Variable variable = execution.getVariableObject("v");
+ assertEquals(DateVariable.class, variable.getClass());
+
+ assertEquals(calendar.getTime(), execution.getVariable("v"));
+ }
+
+}
Property changes on:
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/variables/CustomTypeVariableTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:mergeinfo
+
Copied: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/variables/VariablesTest.java
(from rev 3579,
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/samples/ex03/VariablesTest.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/variables/VariablesTest.java
(rev 0)
+++
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/variables/VariablesTest.java 2008-12-29
12:27:04 UTC (rev 3581)
@@ -0,0 +1,69 @@
+/*
+ * 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.pvm.variables;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.client.ClientProcessInstance;
+import org.jbpm.pvm.externalactivity.WaitState;
+import org.jbpm.pvm.model.ProcessFactory;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class VariablesTest extends TestCase {
+
+ public void testVariables() {
+ ClientProcessDefinition processDefinition =
ProcessFactory.build("expenses")
+ .node("evaluate").initial().behaviour(WaitState.class)
+ .transition().to("pay back")
+ .node("pay back").behaviour(WaitState.class)
+ .done();
+
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("reason", "business trip");
+ variables.put("total amount", "$1500");
+
+ ClientProcessInstance execution = processDefinition.createProcessInstance();
+ execution.setVariables(variables);
+ execution.start();
+
+ assertEquals("business trip", execution.getVariable("reason"));
+ assertEquals("$1500", execution.getVariable("total amount"));
+
+ execution.setVariable("total amount", "$1400");
+ execution.setVariable("approver", "me");
+ execution.setVariable("cost center", 87364);
+
+ execution.signal();
+
+ assertEquals("business trip", execution.getVariable("reason"));
+ assertEquals("$1400", execution.getVariable("total amount"));
+ assertEquals("me", execution.getVariable("approver"));
+ assertEquals(new Integer(87364), execution.getVariable("cost center"));
+ }
+}
Property changes on:
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/variables/VariablesTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Copied:
jbpm4/trunk/modules/pvm/src/test/resources/org/jbpm/pvm/variables/custom.types.jbpm.cfg.xml
(from rev 3579,
jbpm4/trunk/modules/pvm/src/test/resources/org/jbpm/pvm/internal/db/type/environmentCustomTypes.cfg.xml)
===================================================================
---
jbpm4/trunk/modules/pvm/src/test/resources/org/jbpm/pvm/variables/custom.types.jbpm.cfg.xml
(rev 0)
+++
jbpm4/trunk/modules/pvm/src/test/resources/org/jbpm/pvm/variables/custom.types.jbpm.cfg.xml 2008-12-29
12:27:04 UTC (rev 3581)
@@ -0,0 +1,31 @@
+<jbpm-configuration>
+
+ <process-engine>
+
+ <hibernate-configuration>
+ <properties resource="hibernate.properties" />
+ <mapping resource="jbpm.pvm.typedefs.hbm.xml" />
+ <mapping resource="jbpm.pvm.wire.hbm.xml" />
+ <mapping resource="jbpm.pvm.definition.hbm.xml" />
+ <mapping resource="jbpm.pvm.execution.hbm.xml" />
+ <mapping resource="jbpm.pvm.variable.hbm.xml" />
+ <mapping resource="jbpm.pvm.job.hbm.xml" />
+ <cache-configuration resource="jbpm.pvm.cache.xml"
+ usage="nonstrict-read-write" />
+ </hibernate-configuration>
+
+ <hibernate-session-factory />
+ <variable-types>
+ <type name="date" class="java.util.Date"
variable-class="org.jbpm.pvm.internal.type.variable.DateVariable" />
+ </variable-types>
+ </process-engine>
+
+ <environment>
+
+ <transaction />
+ <hibernate-session />
+ <pvm-db-session />
+
+ </environment>
+
+</jbpm-configuration>
Property changes on:
jbpm4/trunk/modules/pvm/src/test/resources/org/jbpm/pvm/variables/custom.types.jbpm.cfg.xml
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:mergeinfo
+