commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbe...@apache.org
Subject svn commit: r981101 - in /commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-143_external-communications-module: ./ src/javascript/scxml/cgf/backends/js/ src/javascript/scxml/cgf/util/external_communications/ src/javascript/scxml/cgf/util/xml/ src/xslt/...
Date Sat, 31 Jul 2010 22:34:26 GMT
Author: jbeard
Date: Sat Jul 31 22:34:25 2010
New Revision: 981101

URL: http://svn.apache.org/viewvc?rev=981101&view=rev
Log:
Test for send passes.

Modified:
    commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-143_external-communications-module/build.js
    commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-143_external-communications-module/src/javascript/scxml/cgf/backends/js/StatePatternStatechartGenerator.js
    commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-143_external-communications-module/src/javascript/scxml/cgf/util/external_communications/jquery.js
    commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-143_external-communications-module/src/javascript/scxml/cgf/util/xml/rhino.js
    commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-143_external-communications-module/src/xslt/backends/js/AbstractEnumeratedStatechartGenerator.xsl
    commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-143_external-communications-module/src/xslt/backends/js/AbstractStatechartGenerator.xsl
    commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-143_external-communications-module/src/xslt/ir-compiler/external_communications/genMessageTemplates.xsl
    commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-143_external-communications-module/test/send/TestSend.xml
    commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-143_external-communications-module/test/send/scripts/unitTest.js

Modified: commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-143_external-communications-module/build.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-143_external-communications-module/build.js?rev=981101&r1=981100&r2=981101&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-143_external-communications-module/build.js
(original)
+++ commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-143_external-communications-module/build.js
Sat Jul 31 22:34:25 2010
@@ -56,8 +56,8 @@ require.def("build",
 			//enums
 			//we keep backward links of these
 			var backends = {
-				"switch" : true,
-				"table" : true,
+				//"switch" : true,
+				//"table" : true,
 				"state" : true
 			}
 
@@ -73,6 +73,7 @@ require.def("build",
 
 			//paths to all of the SCXML files we want to compile
 			var scxmlTests = {
+				/*
 				KitchenSink_dataModule :"test/kitchen_sink/KitchenSink_dataModule.xml",
 				KitchenSink :"test/kitchen_sink/KitchenSink.xml",
 				KitchenSink_performance :"test/kitchen_sink/KitchenSink_performance.xml",
@@ -80,7 +81,9 @@ require.def("build",
 				ConditionalTransition :"test/conditional_transition/TestConditionalTransition.xml",
 				InPredicate :"test/in_predicate/TestInPredicate.xml",
 				EventSystemProperties :"test/event_system_properties/TestEventSystemProperties.xml",
-				PrefixEvents:"test/prefix_events/TestPrefixEvents.xml"
+				PrefixEvents:"test/prefix_events/TestPrefixEvents.xml",
+				*/
+				TestSend:"test/send/TestSend.xml"
 			}
 
 			//FIXME: this violates Don't Repeat Yourself; these paths are written here and in the
module
@@ -107,13 +110,16 @@ require.def("build",
 
 
 			var unitTestScripts = [
+					/*
 					"test/kitchen_sink/scripts/unitTest_dataModel",
 					"test/kitchen_sink/scripts/unitTest",
 					"test/kitchen_sink/scripts/unitTest_executableContent",
 					"test/conditional_transition/scripts/unitTest",
 					"test/in_predicate/scripts/unitTest",
 					"test/event_system_properties/scripts/unitTest",
-					"test/prefix_events/scripts/unitTest"
+					"test/prefix_events/scripts/unitTest",
+					*/
+					"test/send/scripts/unitTest"
 			]
 
 			//gets populated at run-time
@@ -707,7 +713,8 @@ require.def("build",
 
 											load(generatedScript.path);
 
-											unitTestModule.register(StatechartExecutionContext);
+											//pass in xmlUtil as well, in case he needs it (currently only testSend does)
+											unitTestModule.register(StatechartExecutionContext,xmlUtil);
 
 											delete StatechartExecutionContext;
 									});

Modified: commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-143_external-communications-module/src/javascript/scxml/cgf/backends/js/StatePatternStatechartGenerator.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-143_external-communications-module/src/javascript/scxml/cgf/backends/js/StatePatternStatechartGenerator.js?rev=981101&r1=981100&r2=981101&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-143_external-communications-module/src/javascript/scxml/cgf/backends/js/StatePatternStatechartGenerator.js
(original)
+++ commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-143_external-communications-module/src/javascript/scxml/cgf/backends/js/StatePatternStatechartGenerator.js
Sat Jul 31 22:34:25 2010
@@ -9,6 +9,8 @@ require.def(
 		"xml!src/xslt/ir-compiler/enumerateEvents.xsl",
 		"xml!src/xslt/ir-compiler/addEventRegularExpressions.xsl",
 		"xml!src/xslt/ir-compiler/expandStarEvent.xsl",
+		"xml!src/xslt/ir-compiler/external_communications/splitNamelist.xsl",
+		"xml!src/xslt/ir-compiler/external_communications/filterParams.xsl",
 		"xml!build/StatePatternStatechartGenerator_combined.xsl" //preprocessed stylesheet
 	],
 
@@ -19,6 +21,8 @@ require.def(
 		enumerateEvents,
 		addEventRegularExpressions,
 		expandStarEvent,
+		splitNamelist,
+		filterParams,
 		StatePatternStatechartGenerator
 	){
 
@@ -28,7 +32,9 @@ require.def(
 				copyEnumeratedEventTransitions,
 				enumerateEvents,
 				addEventRegularExpressions,
-				expandStarEvent]),
+				expandStarEvent,
+				splitNamelist,
+				filterParams]),
 			"code" : StatePatternStatechartGenerator
 		};
 

Modified: commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-143_external-communications-module/src/javascript/scxml/cgf/util/external_communications/jquery.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-143_external-communications-module/src/javascript/scxml/cgf/util/external_communications/jquery.js?rev=981101&r1=981100&r2=981101&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-143_external-communications-module/src/javascript/scxml/cgf/util/external_communications/jquery.js
(original)
+++ commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-143_external-communications-module/src/javascript/scxml/cgf/util/external_communications/jquery.js
Sat Jul 31 22:34:25 2010
@@ -6,7 +6,7 @@ function(common){
 	return {
 		get : function(url){
 			var toReturn;
-			$.ajax({
+			jQuery.ajax({
 				url:url,
 				success: function(result) {
 					toReturn = result;
@@ -15,7 +15,7 @@ function(common){
 			});
 			return toReturn;
 		},
-		post : function(url,messagedata,contentdata){
+		sendEvent : function(url,messagedata,contentdata){
 			var postDataString = null;
 			if(typeof contentdata == "string"){
 				//assume content
@@ -43,6 +43,9 @@ function(common){
 			});
 			return toReturn;
 			*/
+		},
+		post : function(url,data){
+			jQuery.post(url,data);
 		}
 	}
 })

Modified: commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-143_external-communications-module/src/javascript/scxml/cgf/util/xml/rhino.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-143_external-communications-module/src/javascript/scxml/cgf/util/xml/rhino.js?rev=981101&r1=981100&r2=981101&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-143_external-communications-module/src/javascript/scxml/cgf/util/xml/rhino.js
(original)
+++ commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-143_external-communications-module/src/javascript/scxml/cgf/util/xml/rhino.js
Sat Jul 31 22:34:25 2010
@@ -2,9 +2,14 @@ require.def("src/javascript/scxml/cgf/ut
 function(){
 
 	return {
-		parseFromString : function(){
-			//I think this would use DocumentBuilderFactory
-			new Error("No implementation for parseFromString.");
+		parseFromString : function(str){
+			var dbf = javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			var db = dbf.newDocumentBuilder();
+			var is = new org.xml.sax.InputSource();
+			is.setCharacterStream(new java.io.StringReader(str));
+
+			var doc = db.parse(is);
+			return doc;
 		},
 		serializeToString : (function(){
 			var ByteArrayOutputStream = java.io.ByteArrayOutputStream;

Modified: commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-143_external-communications-module/src/xslt/backends/js/AbstractEnumeratedStatechartGenerator.xsl
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-143_external-communications-module/src/xslt/backends/js/AbstractEnumeratedStatechartGenerator.xsl?rev=981101&r1=981100&r2=981101&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-143_external-communications-module/src/xslt/backends/js/AbstractEnumeratedStatechartGenerator.xsl
(original)
+++ commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-143_external-communications-module/src/xslt/backends/js/AbstractEnumeratedStatechartGenerator.xsl
Sat Jul 31 22:34:25 2010
@@ -62,9 +62,6 @@
 			var <value-of select="c:name"/> = <value-of select="c:id"/>;
 		</for-each>
 
-		//expose them as a convenient interface as part of the API
-		<call-template name="genTriggerExternalObject"/>
-
 		//needed for debugging
 		<call-template name="genTriggerIdToNameMap"/>
 
@@ -123,16 +120,6 @@
 			break;
 	</template>
 
-	<template name="genTriggerExternalObject"> 
-			this.TRIGGERS = { 
-				<for-each select="$enumeratedEventsEnum">
-					<value-of select="c:name"/> : <value-of select="c:name"/>
-					<if test="not(position() = last())"> , </if>
-				</for-each>
-			};
-	</template>
-
-
 	<template name="genTriggerIdToNameMap">
 		var TRIGGER_ID_TO_NAME_MAP = [
 			<for-each select="$enumeratedEventsEnum">

Modified: commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-143_external-communications-module/src/xslt/backends/js/AbstractStatechartGenerator.xsl
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-143_external-communications-module/src/xslt/backends/js/AbstractStatechartGenerator.xsl?rev=981101&r1=981100&r2=981101&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-143_external-communications-module/src/xslt/backends/js/AbstractStatechartGenerator.xsl
(original)
+++ commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-143_external-communications-module/src/xslt/backends/js/AbstractStatechartGenerator.xsl
Sat Jul 31 22:34:25 2010
@@ -19,8 +19,12 @@
 	xmlns:s="http://www.w3.org/2005/07/scxml"
 	xmlns:c="http://commons.apache.org/scxml-js"
 	version="1.0">
+
+	<import href="../../util/xml-to-string.xsl"/>
+
 	<output method="text"/>
 
+
 	<param name="log" select="true()"/>
 	<param name="noIndexOf" select="false()"/>
 	<param name="noMap" select="false()"/>
@@ -79,7 +83,11 @@
 		</choose>
 	</template>
 
-	<template match="/s:scxml">
+	<template match="/">
+		<apply-templates/>
+	</template>
+
+	<template match="s:scxml">
 
 		<if test="$noIndexOf">
 			<call-template name="genNoIndexOfArrayPrototypeExtension"/>
@@ -97,7 +105,7 @@
 			<call-template name="genNoSomeArrayPrototypeExtension"/>
 		</if>
 
-		function <value-of select="@name"/>StatechartExecutionContext(){
+		function <value-of select="@name"/>StatechartExecutionContext(commObject){
 
 				var self = this;	//used in the rare occasions we call public functions from inside this
class
 
@@ -137,6 +145,9 @@
 						<with-param name="states" select="$basicStates"/>
 				</call-template>
 
+				//trigger enum
+				<call-template name="genTriggerEnum"/>
+
 				//trigger methods for synchronous interaction
 				<for-each select="$allEventsEnum[not(c:name/text() = '*')]">
 					<call-template name="genExternalTriggerDispatcher">
@@ -171,7 +182,7 @@
 					= <value-of select="@expr"/>
 				</when>
 				<when test="@src">
-					= xhrGET(<value-of select="@src"/>)
+					= commObject.get(<value-of select="@src"/>)
 				</when>
 				<!-- if this inline content is JSON, we're good,  
 					otherwise, we need to parse the xml DOM at runtime 	
@@ -320,6 +331,17 @@
 
 	</template>
 
+	<template name="genTriggerEnum">	
+			this.TRIGGERS = { 
+				<for-each select="$enumeratedEventsEnum">
+					<value-of select="c:name"/> : 
+						<call-template name="genExternalTriggerDispatcherRunToCompletionEventValue">
+							<with-param name="eventName" select="c:name"/>
+						</call-template>
+					<if test="not(position() = last())"> , </if>
+				</for-each>
+			};
+	</template>
 
 	<template name="genStatesEnum">
 		<param name="states"/>
@@ -399,20 +421,214 @@
 
 	<!-- external communications module -->
 
+	<template name="genHandleSendEvent">
+		<choose>
+			<when test="@event">
+				<!-- handle event statically -->
+				innerEventQueue.push(
+					<call-template name="genExternalTriggerDispatcherRunToCompletionEventValue">
+						<with-param name="eventName" select="@event"/>
+					</call-template>,
+					null,
+					<value-of select="boolean($enumeratedEventsEnum[c:name/text() = @event])"/> );
+			</when>
+			<when test="@eventexpr">
+				<!-- handle event dynamically -->
+				<!-- adds event to inner queue dynamically -->
+				innerEventQueue.push(<value-of select="@eventexpr"/>,null,this.TRIGGERS[e]);
+			</when>	
+		</choose>
+	</template>
+
+	<template match="s:send">
+		<!-- TODO: switch based on whether send is internal.
+			the code so far is only for external -->
+
+		<variable name="eventParamValue">
+			<choose>
+				<when test="@event">
+					&quot;<value-of select="@event"/>&quot;
+				</when>
+				<when test="@eventexpr">
+					<value-of select="@eventexpr"/>
+				</when>
+				<otherwise>
+					<!-- TODO: move into constant variable -->
+					"external.event"
+				</otherwise>
+			</choose>
+		</variable>
+
+		<variable name="targetParamValue">
+			<choose>
+				<when test="@target">
+					&quot;<value-of select="@target"/>&quot;
+				</when>
+				<when test="@targetexpr">
+					<value-of select="@targetexpr"/>
+				</when>
+				<otherwise>
+					&quot;#_internal&quot;
+				</otherwise>
+			</choose>
+		</variable>
+
+		<variable name="typeParamValue">
+			<choose>
+				<when test="@type">
+					&quot;<value-of select="@type"/>&quot;
+				</when>
+				<when test="@typeexpr">
+					<value-of select="@typeexpr"/>
+				</when>
+				<otherwise>
+					"scxml"
+				</otherwise>
+			</choose>
+		</variable>
+
+		<variable name="idParamValue">
+			<choose>
+				<when test="@id">
+					&quot;<value-of select="@id"/>&quot;
+				</when>
+				<when test="@idlocation">
+					<value-of select="@idlocation"/>
+				</when>
+				<otherwise>
+					<!-- empty node-set? empty string?-->
+					""
+				</otherwise>
+			</choose>
+		</variable>
+
+		<variable name="delayParamValue">
+			<choose>
+				<when test="@delay">
+					&quot;<value-of select="@delay"/>&quot;
+				</when>
+				<when test="@delayexpr">
+					<value-of select="@delayexpr"/>
+				</when>
+				<otherwise>
+					<!-- empty node-set? empty string?-->
+					""
+				</otherwise>
+			</choose>
+		</variable>
+
+		<variable name="hintsParamValue">
+			<choose>
+				<when test="@hints">
+					&quot;<value-of select="@hints"/>&quot;
+				</when>
+				<when test="@hintsexpr">
+					<value-of select="@hintsexpr"/>
+				</when>
+				<otherwise>
+					<!-- empty node-set? empty string?-->
+					""
+				</otherwise>
+			</choose>
+		</variable>
+
+		<variable name="payload">
+			<choose>
+				<when test="s:content">
+					<!-- serialize to js-safe string -->
+					'<apply-templates select="s:content"/>'
+				</when>
+				<otherwise>
+					{
+					<for-each select="c:namelist/c:name | s:param">
+						<variable name="name">
+							<choose>
+								<when test="@name">
+									<value-of select="@name"/>
+								</when>
+								<otherwise>
+									<value-of select="."/>
+								</otherwise>
+							</choose>
+						</variable>
+						<value-of select="$name" /> : <value-of select="$name" />
+						<if test="@expr">
+							|| <value-of select="@expr"/>
+						</if>
+						<if test="not(position() = last())">
+						,
+						</if>
+					</for-each>
+					}
+				</otherwise>
+			</choose>
+		</variable>
+
+		<choose>
+			<!-- need to handle both static and dynamic cases, hence some reduplication of code...
-->
+			<when test="@target = '#_internal' 
+										or (not(@target) and not(@targetexpr))">
+				<!-- handle target statically -->
+				<call-template name="genHandleSendEvent"/>
+			</when>
+			<!-- TODO: handle session ids -->
+			<!--
+			<when test="@target = '#_scxml_'">
+			</when>
+			-->
+			<!-- TODO: handle invoke-->
+			<otherwise>
+				<!-- handle target dynamically -->
+				if(<value-of select="$targetParamValue"/> === '#_internal'){
+					<call-template name="genHandleSendEvent"/>
+				}
+				//TODO: handle session id's dyanmically
+				/*
+				if(<value-of select="$targetParamValue"/> === '#_scxml_number'){
+					//figure out what kind of an API we want to use for this
+					//accepts a map? sends across some event bus? dunno... architecture issue
+				}
+				*/
+				else{
+					//external event
+					commObject.sendEvent(
+						<value-of select="$targetParamValue"/>,
+						{
+							$event : <value-of select="$eventParamValue"/>,
+							$target : <value-of select="$targetParamValue"/>,
+							$type : <value-of select="$typeParamValue"/>,
+							$sendid : <value-of select="$idParamValue"/>,
+							$delay : <value-of select="$delayParamValue"/>,
+							$hints : <value-of select="$hintsParamValue"/>
+						},
+						<value-of select="$payload"/>
+					)
+				}
+			</otherwise>
+		</choose>
+	</template>
+
+	<template match="s:content">
+		<call-template name="escape-js-string">
+			<with-param name="text">
+				<for-each select="node()">
+					<call-template name="xml-to-string"/>
+				</for-each>
+			</with-param>
+		</call-template>
+	</template>
+
+	<!--
 	<template match="s:send">
 		<variable select="@event" name="eventName"/>
 
 		<choose>
 			<when test="@delay">
-				<!-- FIXME: this stuff needs to be fixed -->
-				<!--
 				window.setTimeout(function(){
 					self.GEN("<value-of select="@event"/>");
 				},<value-of select="number(@delay)*1000"/>);
-				-->
 			</when>
 			<otherwise>
-				<!--FIXME: hook up data part of this -->
 				innerEventQueue.push(
 						<call-template name="genExternalTriggerDispatcherRunToCompletionEventValue">
 							<with-param name="eventName" select="$eventName"/>
@@ -422,6 +638,7 @@
 			</otherwise>
 		</choose>
 	</template>
+	-->
 
 	<template match="s:cancel">
 	<!--TODO-->
@@ -579,7 +796,6 @@
 			isPreempted = false;
 		}
 
-
 		this.destroy = function(){
 			//right now, this only disables timer and sets global destroyed variable to prevent future
callbacks
 			window.clearTimeout(mainLoopCallback);
@@ -590,7 +806,7 @@
 
 		//this is for async communication
 		this.GEN = function(e,data){
-			outerEventQueue.push(e,data);
+			outerEventQueue.push(e,data,this.TRIGGERS[e]);
 		}
 
 		//this may or may not be something we want to expose, but for right now, we at least need
it for testing
@@ -914,6 +1130,5 @@
 	<template name="genTriggerDispatcherContext"/>
 	<template name="genExternalTriggerDispatcherRunToCompletionEventValue"/>
 
-
 </stylesheet>
 

Modified: commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-143_external-communications-module/src/xslt/ir-compiler/external_communications/genMessageTemplates.xsl
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-143_external-communications-module/src/xslt/ir-compiler/external_communications/genMessageTemplates.xsl?rev=981101&r1=981100&r2=981101&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-143_external-communications-module/src/xslt/ir-compiler/external_communications/genMessageTemplates.xsl
(original)
+++ commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-143_external-communications-module/src/xslt/ir-compiler/external_communications/genMessageTemplates.xsl
Sat Jul 31 22:34:25 2010
@@ -197,19 +197,42 @@
 			</xsl:choose>
 		</xsl:variable>
 
-		<xsl:text>send(</xsl:text>
-			<xsl:value-of select="$targetParamValue"/>,
-			{
-				$event : <xsl:value-of select="$eventParamValue"/>,
-				$target : <xsl:value-of select="$targetParamValue"/>,
-				$type : <xsl:value-of select="$typeParamValue"/>,
-				$sendid : <xsl:value-of select="$idParamValue"/>,
-				$delay : <xsl:value-of select="$delayParamValue"/>,
-				$hints : <xsl:value-of select="$hintsParamValue"/>
+		<xsl:choose>
+			<!-- need to handle both static and dynamic cases, hence some reduplication of code...
-->
+			<xsl:when test="@target = '#_internal'">
+				
+			</xsl:when>
+			<!-- TODO: handle session ids -->
+			<!--
+			<xsl:when test="@target = '#_scxml_'">
+			</xsl:when>
+			-->
+			<!-- TODO: handle invoke-->
+			<xsl:otherwise>
+				if(<xsl:value-of select="$eventParamValue"/> === '#_internal'){
+					innerEventQueue.push(
+						<call-template name="genExternalTriggerDispatcherRunToCompletionEventValue">
+							<with-param name="eventName" select="$eventParamValue"/>
+						</call-template>,
+						null,
+						<value-of select="boolean($enumeratedEventsEnum[c:name/text() = $eventName])"/>
);
+				}else{
+					send(
+						<xsl:value-of select="$targetParamValue"/>,
+						{
+							$event : <xsl:value-of select="$eventParamValue"/>,
+							$target : <xsl:value-of select="$targetParamValue"/>,
+							$type : <xsl:value-of select="$typeParamValue"/>,
+							$sendid : <xsl:value-of select="$idParamValue"/>,
+							$delay : <xsl:value-of select="$delayParamValue"/>,
+							$hints : <xsl:value-of select="$hintsParamValue"/>
 
-			},
-			<xsl:value-of select="$payload"/>
-		<xsl:text>)</xsl:text>
+						},
+						<xsl:value-of select="$payload"/>
+					)
+				}
+			</xsl:otherwise>
+		</xsl:choose>
 		<xsl:text>&#xA;&#xA;</xsl:text>
 	</xsl:template>
 

Modified: commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-143_external-communications-module/test/send/TestSend.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-143_external-communications-module/test/send/TestSend.xml?rev=981101&r1=981100&r2=981101&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-143_external-communications-module/test/send/TestSend.xml
(original)
+++ commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-143_external-communications-module/test/send/TestSend.xml
Sat Jul 31 22:34:25 2010
@@ -33,13 +33,13 @@
 	<!-- given event foo.bar, foo should be selected, and we should end in state b1-->
 	<state id="a">
 		<transition target="b" event="t1">
-			<send target="http://www.google.com"/>
+			<send target="a.com" event="my.event.one"/>
 		</transition>
 	</state>
 
 	<state id="b">
 		<transition target="c" event="t2">
-			<send target="http://www.google.com" namelist="foo bar"/>
+			<send target="b.com" namelist="foo bar"/>
 		</transition>
 	</state>
 
@@ -48,7 +48,7 @@
 			<!-- namelist foo should take priority over param foo,
 				default expression in bar should be ignored, as it's already defined in the data model,
 				and bat is not defined, so should here use the value 'default3' --> 
-			<send target="http://www.google.com" namelist="foo">
+			<send target="c.com" namelist="foo" event="my.event.two">
 				<param name="foo" expr="'default1'"/>
 				<param name="bar" expr="'default2'"/>
 				<param name="bat" expr="'default3'"/>
@@ -59,14 +59,8 @@
 	<state id="d">
 		<transition target="e" event="t4">
 			<!-- try with JSON data -->
-			<send target="http://www.google.com">
-				<content><![CDATA[
-					{
-						foo : 'foo',	
-						bar : 1,
-						woot : true
-					}
-				]]></content>
+			<send target="d.com">
+				<content><![CDATA[{ foo : 'foo',	bar : 1, woot : true }]]></content>
 			</send>
 		</transition>
 	</state>
@@ -74,24 +68,8 @@
 	<state id="e">
 		<transition target="f" event="t5">
 			<!-- try it with some arbirary XML content, here a bit of XSL -->
-			<send target="http://www.google.com">
-				<content>
-					<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
-						xmlns:s="http://www.w3.org/2005/07/scxml"
-						xmlns="http://www.w3.org/2005/07/scxml"
-						xmlns:c="http://commons.apache.org/scxml-js"
-						xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-						version="1.0">
-						<xsl:output method="text"/>
-
-						<xsl:template match="send">
-							<xsl:text>send(</xsl:text>
-								<xsl:apply-templates select="c:messageTemplate"/>,
-								<xsl:text>&apos;</xsl:text><xsl:value-of select="@target"/><xsl:text>&apos;</xsl:text>
-							<xsl:text>)</xsl:text>
-						</xsl:template>
-					</xsl:stylesheet>
-				</content>
+			<send target="e.com" event="my.event.three">
+				<content><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:s="http://www.w3.org/2005/07/scxml"
xmlns="http://www.w3.org/2005/07/scxml" xmlns:c="http://commons.apache.org/scxml-js" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="1.0"> <xsl:output method="text"/> <xsl:template match="send"> <xsl:text>send(</xsl:text>
<xsl:apply-templates select="c:messageTemplate"/>, <xsl:text>&apos;</xsl:text><xsl:value-of
select="@target"/><xsl:text>&apos;</xsl:text> <xsl:text>)</xsl:text>
</xsl:template> </xsl:stylesheet></content>
 			</send>
 		</transition>
 	</state>

Modified: commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-143_external-communications-module/test/send/scripts/unitTest.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-143_external-communications-module/test/send/scripts/unitTest.js?rev=981101&r1=981100&r2=981101&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-143_external-communications-module/test/send/scripts/unitTest.js
(original)
+++ commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-143_external-communications-module/test/send/scripts/unitTest.js
Sat Jul 31 22:34:25 2010
@@ -21,7 +21,7 @@ require.def( "test/send/scripts/unitTest
 
 	scxmlTest : "test/send/TestSend.xml",
 
-	register:function(scConstructor){
+	register:function(scConstructor,xmlUtil){
 
 		//TODO: can load this using RequireJS, so we don't need to use the dojo module system?
 		dojo.require("doh.runner");
@@ -34,11 +34,12 @@ require.def( "test/send/scripts/unitTest
 						//set up mock communications object
 						mockComm = {
 							_lastUrl : "",
-							_lastData : "",
-							send : funciton(url,data){
+							_lastMessageData : "",
+							_lastContentData : "",
+							sendEvent : function(url,messagedata,contentdata){
 								this._lastUrl = url;
-								this._lastData = data;
-								console.log("data ", data);
+								this._lastMessageData = messagedata;
+								this._lastContentData = contentdata;
 							}
 						};
 						sc = new scConstructor(mockComm)
@@ -48,47 +49,73 @@ require.def( "test/send/scripts/unitTest
 						var $ = function(conf){return conf.map(function(s){return s.toString()})};
 
 						var conf;
-						var googleUrl = "http://www.google.com";
 
 						conf = sc.getCurrentConfiguration();
 						console.log($(conf));
-						doh.assertEqual(setwiseEqual(sc._states.a,conf[0]));
+						doh.assertEqual(sc._states.a,conf[0]);
 
 						console.info("sending event t1")
 						sc.t1()
 						conf = sc.getCurrentConfiguration();
 						console.log($(conf));
-						doh.assertEqual(setwiseEqual(sc._states.b,conf[0]));
+						doh.assertEqual(sc._states.b,conf[0]);
 
-						doh.assertEqual(googleUrl,mockComm._lastUrl);
-						doh.assertEqual("",mockComm._lastData);
+						doh.assertEqual("a.com",mockComm._lastUrl);
+						doh.assertEqual("a.com",mockComm._lastMessageData.$target);
+						doh.assertEqual("my.event.one",mockComm._lastMessageData.$event);
 
 
 						console.info("sending event t2")
 						sc.t2()
 						conf = sc.getCurrentConfiguration();
 						console.log($(conf));
-						doh.assertEqual(setwiseEqual(sc._states.c,conf[0]));
+						doh.assertEqual(sc._states.c,conf[0]);
 
-						//TODO: figure out best way to test the mock data coming in
+						doh.assertEqual("b.com",mockComm._lastUrl);
+						doh.assertEqual("b.com",mockComm._lastMessageData.$target);
+						doh.assertEqual("external.event",mockComm._lastMessageData.$event);
+						doh.assertEqual("foo",mockComm._lastContentData.foo);
+						doh.assertEqual(1,mockComm._lastContentData.bar);
 
 						console.info("sending event t3")
 						sc.t3()
 						conf = sc.getCurrentConfiguration();
 						console.log($(conf));
-						doh.assertEqual(setwiseEqual(sc._states.d,conf[0]));
+						doh.assertEqual(sc._states.d,conf[0]);
+
+						doh.assertEqual("c.com",mockComm._lastUrl);
+						doh.assertEqual("c.com",mockComm._lastMessageData.$target);
+						doh.assertEqual("my.event.two",mockComm._lastMessageData.$event);
+						doh.assertEqual("foo",mockComm._lastContentData.foo);
+						doh.assertEqual(1,mockComm._lastContentData.bar);
+						doh.assertEqual("default3",mockComm._lastContentData.bat);
 
 						console.info("sending event t4")
 						sc.t4()
 						conf = sc.getCurrentConfiguration();
 						console.log($(conf));
-						doh.assertEqual(setwiseEqual(sc._states.e,conf[0]));
+						doh.assertEqual(sc._states.e,conf[0]);
+
+						doh.assertEqual("d.com",mockComm._lastUrl);
+						doh.assertEqual("d.com",mockComm._lastMessageData.$target);
+						doh.assertEqual("external.event",mockComm._lastMessageData.$event);
+						doh.assertEqual("{ foo : 'foo',	bar : 1, woot : true }",mockComm._lastContentData);
 
 						console.info("sending event t5")
 						sc.t5()
 						conf = sc.getCurrentConfiguration();
 						console.log($(conf));
-						doh.assertEqual(setwiseEqual(sc._states.f,conf[0]));
+						doh.assertEqual(sc._states.f,conf[0]);
+
+						//we compare the expected and actual xml documents by parsing and serializing them
+						//this should hopefully take care of any platform-specific xml strangeness (which is
why we don't compare to a string directly)
+						var expectedDoc = xmlUtil.parseFromString('<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"> <xsl:output method="text"/> <xsl:template match="send"> <xsl:text>send(</xsl:text>
<xsl:apply-templates select="c:messageTemplate"/>, <xsl:text>&apos;</xsl:text><xsl:value-of
select="@target"/><xsl:text>&apos;</xsl:text> <xsl:text>)</xsl:text>
</xsl:template> </xsl:stylesheet>')
+						var expectedSerializedDocString = xmlUtil.serializeToString(expectedDoc);
+
+						doh.assertEqual("e.com",mockComm._lastUrl);
+						doh.assertEqual("e.com",mockComm._lastMessageData.$target);
+						doh.assertEqual("my.event.three",mockComm._lastMessageData.$event);
+						doh.assertEqual(expectedSerializedDocString,xmlUtil.serializeToString(xmlUtil.parseFromString(mockComm._lastContentData)));
 
 					},
 					tearDown:function(){



Mime
View raw message