Author: rahul
Date: Fri Jul 16 23:36:32 2010
New Revision: 964982

URL: http://svn.apache.org/viewvc?rev=964982&view=rev
Log:
Add an example of a guard condition operating over the XML payload of an event.

Modified:
    
commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/env/xpath/XPathExampleTest.java
    
commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/env/xpath/example-01.xml

Modified: 
commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/env/xpath/XPathExampleTest.java
URL: 
http://svn.apache.org/viewvc/commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/env/xpath/XPathExampleTest.java?rev=964982&r1=964981&r2=964982&view=diff
==============================================================================
--- 
commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/env/xpath/XPathExampleTest.java
 (original)
+++ 
commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/env/xpath/XPathExampleTest.java
 Fri Jul 16 23:36:32 2010
@@ -28,6 +28,7 @@ import org.apache.commons.scxml.Context;
 import org.apache.commons.scxml.Evaluator;
 import org.apache.commons.scxml.SCXMLExecutor;
 import org.apache.commons.scxml.SCXMLTestHelper;
+import org.apache.commons.scxml.TriggerEvent;
 import org.apache.commons.scxml.model.SCXML;
 import org.apache.commons.scxml.model.State;
 import org.apache.commons.scxml.model.TransitionTarget;
@@ -82,8 +83,15 @@ public class XPathExampleTest extends Te
         assertNotNull(exec);
         Set<TransitionTarget> currentStates = 
exec.getCurrentStatus().getStates();
         assertEquals(1, currentStates.size());
-        assertEquals("end", ((State)currentStates.iterator().
+        assertEquals("mid", ((State)currentStates.iterator().
             next()).getId());
+
+        String payload = "<test xmlns=''><status>complete</status></test>";
+        SCXMLTestHelper.assertPostTriggerState(exec,
+            new TriggerEvent("foo", TriggerEvent.SIGNAL_EVENT,
+                SCXMLTestHelper.stringToXMLDocument(payload)),
+            "end");
+
     }
 
 }

Modified: 
commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/env/xpath/example-01.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/env/xpath/example-01.xml?rev=964982&r1=964981&r2=964982&view=diff
==============================================================================
--- 
commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/env/xpath/example-01.xml
 (original)
+++ 
commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/env/xpath/example-01.xml
 Fri Jul 16 23:36:32 2010
@@ -41,15 +41,19 @@
                  expr="cs:Data('jungle','animals/lion/name')" />
         </onentry>
         <transition cond="cs:Data('jungle','animals/lion/age') = 12"
-                    target="end" />
+                    target="mid" />
     </state>
 
-    <final id="end">
+    <state id="mid">
         <onentry>
             <log label="Total age"
                 expr="cs:Data('jungle','animals/lion/age') +
                       cs:Data('jungle','animals/tiger/age')" />
         </onentry>
-    </final>
+        <transition event="foo" cond="$_eventdata/test/status = 'complete'"
+                    target="end" />
+    </state>
+
+    <final id="end"/>
 
 </scxml>


Reply via email to