Author: tho...@jb...
Date: 2008-07-04 07:20:17 -0400 (Fri, 04 Jul 2008)
New Revision: 1515
Added:
api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/activity/BasicActivity.java
api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/context/
api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/context/ContextActivity.java
api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/context/ContextValue.java
api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/context/ExecutionContextTest.java
Removed:
api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/activity/MyActivity.java
Modified:
api/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/Activity.java
api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/activity/BasicActivityTest.java
Log:
[JBPM-1255] Execution Context Variables
Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/Activity.java
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/Activity.java 2008-07-04 10:50:40 UTC (rev 1514)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/Activity.java 2008-07-04 11:20:17 UTC (rev 1515)
@@ -40,6 +40,7 @@
{
/**
* Execute business logic associated with a Node
+ * @param node The node this activity is associated with
* @param ctx The execution context
*/
void execute(Node node, Context ctx);
Copied: api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/activity/BasicActivity.java (from rev 1509, api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/activity/MyActivity.java)
===================================================================
--- api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/activity/BasicActivity.java (rev 0)
+++ api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/activity/BasicActivity.java 2008-07-04 11:20:17 UTC (rev 1515)
@@ -0,0 +1,37 @@
+/*
+ * 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.jboss.bpm.samples.activity;
+
+// $Id$
+
+import org.jboss.bpm.Context;
+import org.jboss.bpm.def.Node;
+import org.jboss.bpm.runtime.Activity;
+
+public class BasicActivity implements Activity
+{
+ public void execute(Node node, Context ctx)
+ {
+ String name = node.getName();
+ ctx.addAttachment(String.class, "Activity on: " + name);
+ }
+}
Modified: api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/activity/BasicActivityTest.java
===================================================================
--- api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/activity/BasicActivityTest.java 2008-07-04 10:50:40 UTC (rev 1514)
+++ api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/activity/BasicActivityTest.java 2008-07-04 11:20:17 UTC (rev 1515)
@@ -43,7 +43,7 @@
" </start-state>" +
" <state name='stateA'>" +
" <event type='node-enter'>" +
- " <action class='org.jboss.bpm.samples.activity.MyActivity' />" +
+ " <action class='org.jboss.bpm.samples.activity.BasicActivity' />" +
" </event>" +
" <transition to='end'/>" +
" </state>" +
Deleted: api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/activity/MyActivity.java
===================================================================
--- api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/activity/MyActivity.java 2008-07-04 10:50:40 UTC (rev 1514)
+++ api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/activity/MyActivity.java 2008-07-04 11:20:17 UTC (rev 1515)
@@ -1,37 +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.jboss.bpm.samples.activity;
-
-// $Id$
-
-import org.jboss.bpm.Context;
-import org.jboss.bpm.def.Node;
-import org.jboss.bpm.runtime.Activity;
-
-public class MyActivity implements Activity
-{
- public void execute(Node node, Context ctx)
- {
- String name = node.getName();
- ctx.addAttachment(String.class, "Activity on: " + name);
- }
-}
Added: api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/context/ContextActivity.java
===================================================================
--- api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/context/ContextActivity.java (rev 0)
+++ api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/context/ContextActivity.java 2008-07-04 11:20:17 UTC (rev 1515)
@@ -0,0 +1,38 @@
+/*
+ * 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.jboss.bpm.samples.context;
+
+// $Id$
+
+import org.jboss.bpm.Context;
+import org.jboss.bpm.def.Node;
+import org.jboss.bpm.runtime.Activity;
+
+public class ContextActivity implements Activity
+{
+ public void execute(Node node, Context ctx)
+ {
+ String name = node.getName();
+ ctx.addAttachment(String.class, "ActivityMessage", "Activity on '" + name + "' has: " + ctx.getAttachments());
+ ctx.addAttachment(ContextValue.class, "ActivityAttachment", new ContextValue("bar"));
+ }
+}
Property changes on: api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/context/ContextActivity.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/context/ContextValue.java
===================================================================
--- api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/context/ContextValue.java (rev 0)
+++ api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/context/ContextValue.java 2008-07-04 11:20:17 UTC (rev 1515)
@@ -0,0 +1,37 @@
+/*
+ * 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.jboss.bpm.samples.context;
+
+// $Id$
+
+class ContextValue
+{
+ private String msg;
+ public ContextValue(String msg)
+ {
+ this.msg = msg;
+ }
+ public String getMsg()
+ {
+ return msg;
+ }
+}
\ No newline at end of file
Property changes on: api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/context/ContextValue.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/context/ExecutionContextTest.java
===================================================================
--- api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/context/ExecutionContextTest.java (rev 0)
+++ api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/context/ExecutionContextTest.java 2008-07-04 11:20:17 UTC (rev 1515)
@@ -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.jboss.bpm.samples.context;
+
+// $Id$
+
+import org.jboss.bpm.client.Execution;
+import org.jboss.bpm.client.ProcessDefinitionManager;
+import org.jboss.bpm.def.ProcessDefinition;
+import org.jboss.bpm.test.DefaultEngineTestCase;
+
+/**
+ * Test that the execution context
+ *
+ * @author tho...@jb...
+ * @since 03-Jul-2008
+ */
+public class ExecutionContextTest extends DefaultEngineTestCase
+{
+ String jpdl =
+ "<process-definition>" +
+ " <start-state>" +
+ " <transition to='stateA' />" +
+ " </start-state>" +
+ " <state name='stateA'>" +
+ " <event type='node-enter'>" +
+ " <action class='org.jboss.bpm.samples.context.ContextActivity' />" +
+ " </event>" +
+ " <transition to='end'/>" +
+ " </state>" +
+ " <end-state name='end' />" +
+ "</process-definition>";
+
+ /**
+ * Test that the execution context variables
+ */
+ public void testTransientValues() throws Exception
+ {
+ // Create an Execution through the ProcessDefinition
+ ProcessDefinitionManager pdm = ProcessDefinitionManager.locateProcessDefinitionManager();
+ ProcessDefinition pd = pdm.createProcessDefinition(jpdl);
+ Execution ex = pd.createExecution();
+
+ // Set a context variable
+ ex.getContext().addAttachment(ContextValue.class, new ContextValue("foo"));
+
+ // Signal the execution
+ ex.signal();
+
+ // Verify context variables
+ String msg = ex.getContext().getAttachment(String.class, "ActivityMessage");
+ assertEquals("Activity on 'stateA' has: [[org.jboss.bpm.samples.context.ContextValue,null]]", msg);
+
+ // Validate original attachement
+ ContextValue att1 = ex.getContext().getAttachment(ContextValue.class);
+ assertEquals("foo", att1.getMsg());
+
+ // Validate activity attachement
+ ContextValue att2 = ex.getContext().getAttachment(ContextValue.class, "ActivityAttachment");
+ assertEquals("bar", att2.getMsg());
+ }
+}
Property changes on: api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/context/ExecutionContextTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
|