diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-01-25 01:41:49 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-01-25 01:41:49 (GMT) |
commit | 32921490d0d7dc0a2e0828e6f1051e74d27550cf (patch) | |
tree | fe0a816013ddfb2c4d8b2fa885a6b56c61e670f8 /test | |
parent | 3be96d1aa3024c1acc129e587f5d3165c9434e48 (diff) | |
download | uscxml-32921490d0d7dc0a2e0828e6f1051e74d27550cf.zip uscxml-32921490d0d7dc0a2e0828e6f1051e74d27550cf.tar.gz uscxml-32921490d0d7dc0a2e0828e6f1051e74d27550cf.tar.bz2 |
Started to resolve scxml-test-framework tests from SCION suite
Diffstat (limited to 'test')
-rw-r--r-- | test/CMakeLists.txt | 33 | ||||
-rwxr-xr-x | test/run-scxml-test-framework.sh | 166 | ||||
-rw-r--r-- | test/samples/uscxml/test-execution.scxml | 6 | ||||
-rw-r--r-- | test/schema/scxml-attribs.xsd | 57 | ||||
-rw-r--r-- | test/schema/scxml-contentmodels.xsd | 35 | ||||
-rw-r--r-- | test/schema/scxml-datatypes.xsd | 203 | ||||
-rw-r--r-- | test/schema/scxml-message.xsd | 122 | ||||
-rw-r--r-- | test/schema/scxml-module-core.xsd | 405 | ||||
-rw-r--r-- | test/schema/scxml-module-data.xsd | 151 | ||||
-rw-r--r-- | test/schema/scxml-module-external.xsd | 152 | ||||
-rw-r--r-- | test/schema/scxml.xsd | 138 | ||||
-rw-r--r-- | test/src/scxml-test-framework-client.cpp | 147 | ||||
-rw-r--r-- | test/src/test-url.cpp | 19 |
13 files changed, 1388 insertions, 246 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 5e5e697..88d10e9 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,3 +1,9 @@ +find_program(XMLLINT xmllint) +if (XMLLINT) + file(GLOB SCXML_FILES samples/uscxml/*.scxml) + +endif() + add_executable(test-predicates src/test-predicates.cpp) target_link_libraries(test-predicates uscxml) add_test(test-predicates ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-predicates ${CMAKE_SOURCE_DIR}/test/samples/uscxml/test-predicates.scxml) @@ -8,17 +14,17 @@ target_link_libraries(test-execution uscxml) add_test(test-execution ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-execution ${CMAKE_SOURCE_DIR}/test/samples/uscxml/test-execution.scxml) set_target_properties(test-execution PROPERTIES FOLDER "Tests") -add_executable(test-apache-commons src/test-apache-commons.cpp) -target_link_libraries(test-apache-commons uscxml) -add_test(test-apache-commons ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-apache-commons ${CMAKE_SOURCE_DIR}/test/samples/apache) -set_target_properties(test-apache-commons PROPERTIES FOLDER "Tests") +# add_executable(test-apache-commons src/test-apache-commons.cpp) +# target_link_libraries(test-apache-commons uscxml) +# add_test(test-apache-commons ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-apache-commons ${CMAKE_SOURCE_DIR}/test/samples/apache) +# set_target_properties(test-apache-commons PROPERTIES FOLDER "Tests") -if (V8_FOUND) - add_executable(test-ecmascript-v8 src/test-ecmascript-v8.cpp) - target_link_libraries(test-ecmascript-v8 uscxml) - add_test(test-ecmascript-v8 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-ecmascript-v8 ${CMAKE_SOURCE_DIR}/test/samples/uscxml/test-ecmascript.scxml) - set_target_properties(test-ecmascript-v8 PROPERTIES FOLDER "Tests") -endif() +# if (V8_FOUND) +# add_executable(test-ecmascript-v8 src/test-ecmascript-v8.cpp) +# target_link_libraries(test-ecmascript-v8 uscxml) +# add_test(test-ecmascript-v8 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-ecmascript-v8 ${CMAKE_SOURCE_DIR}/test/samples/uscxml/test-ecmascript.scxml) +# set_target_properties(test-ecmascript-v8 PROPERTIES FOLDER "Tests") +# endif() if (SWI_FOUND) add_executable(test-prolog-swi src/test-prolog-swi.cpp) @@ -59,3 +65,10 @@ add_executable(test-url src/test-url.cpp) target_link_libraries(test-url uscxml) add_test(test-url ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-url) set_target_properties(test-url PROPERTIES FOLDER "Tests") + +add_executable(scxml-test-framework-client + ${PROJECT_SOURCE_DIR}/contrib/src/jsmn/jsmn.c + src/scxml-test-framework-client.cpp) +target_link_libraries(scxml-test-framework-client uscxml) +set_target_properties(scxml-test-framework-client PROPERTIES FOLDER "Tests") + diff --git a/test/run-scxml-test-framework.sh b/test/run-scxml-test-framework.sh new file mode 100755 index 0000000..34f804d --- /dev/null +++ b/test/run-scxml-test-framework.sh @@ -0,0 +1,166 @@ +#!/bin/sh + +set -e + +ME=`basename $0` +DIR="$( cd "$( dirname "$0" )" && pwd )" + +if [ -z $1 ]; then + echo + echo "Expected filename of scxml-test-framework-client as first argument" + echo + exit; +fi +SCXML_TEST_FRAMEWORK_FULL="$( cd "$(dirname "$1")" && pwd)/$(basename $1)" +SCXML_TEST_FRAMEWORK_NAME=$(basename $1) + +if [[ ! -x "${SCXML_TEST_FRAMEWORK_FULL}" ]]; then + echo + echo "${SCXML_TEST_FRAMEWORK_FULL} not an executable file" + echo +fi + +TESTS="" +# TESTS="${TESTS} scxml-test-framework/test/actionSend/send1.scxml" # passed +# TESTS="${TESTS} scxml-test-framework/test/actionSend/send2.scxml" # passed +# TESTS="${TESTS} scxml-test-framework/test/actionSend/send3.scxml" # passed +# TESTS="${TESTS} scxml-test-framework/test/actionSend/send4.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/actionSend/send5.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/actionSend/send6.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/actionSend/send7.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/actionSend/send8.scxml" # failed + +# TESTS="${TESTS} scxml-test-framework/test/assign-current-small-step/test0.scxml" # passed +# TESTS="${TESTS} scxml-test-framework/test/assign-current-small-step/test1.scxml" # passed +# TESTS="${TESTS} scxml-test-framework/test/assign-current-small-step/test2.scxml" # passed +# TESTS="${TESTS} scxml-test-framework/test/assign-current-small-step/test3.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/assign-current-small-step/test4.scxml" # passed + +# TESTS="${TESTS} scxml-test-framework/test/assign-next-small-step/test0.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/assign-next-small-step/test1.scxml" # never terminates: getData not defined +# TESTS="${TESTS} scxml-test-framework/test/assign-next-small-step/test2.scxml" # never terminates: getData not defined +# TESTS="${TESTS} scxml-test-framework/test/assign-next-small-step/test3.scxml" # failed + +# TESTS="${TESTS} scxml-test-framework/test/atom3-basic-tests/m0.scxml" # passed +# TESTS="${TESTS} scxml-test-framework/test/atom3-basic-tests/m1.scxml" # passed +# TESTS="${TESTS} scxml-test-framework/test/atom3-basic-tests/m2.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/atom3-basic-tests/m3.scxml" # failed + +# TESTS="${TESTS} scxml-test-framework/test/basic/basic0.scxml" # passed +# TESTS="${TESTS} scxml-test-framework/test/basic/basic1.scxml" # passed +# TESTS="${TESTS} scxml-test-framework/test/basic/basic2.scxml" # passed + +# TESTS="${TESTS} scxml-test-framework/test/cond-js/test0.scxml" # passed +# TESTS="${TESTS} scxml-test-framework/test/cond-js/test1.scxml" # passed +# TESTS="${TESTS} scxml-test-framework/test/cond-js/test2.scxml" # passed +# TESTS="${TESTS} scxml-test-framework/test/cond-js/TestConditionalTransition.scxml" # failed + +# TESTS="${TESTS} scxml-test-framework/test/default-initial-state/initial1.scxml" # passed +# TESTS="${TESTS} scxml-test-framework/test/default-initial-state/initial2.scxml" # passed +# TESTS="${TESTS} scxml-test-framework/test/default-initial-state/initial3.scxml" # passed + +# TESTS="${TESTS} scxml-test-framework/test/delayedSend/send1.scxml" # segfault +# TESTS="${TESTS} scxml-test-framework/test/delayedSend/send2.scxml" # segfault +# TESTS="${TESTS} scxml-test-framework/test/delayedSend/send3.scxml" # segfault + +# TESTS="${TESTS} scxml-test-framework/test/documentOrder/documentOrder0.scxml" # passed + +# TESTS="${TESTS} scxml-test-framework/test/foreach/test1.scxml" # passed + +# TESTS="${TESTS} scxml-test-framework/test/hierarchy/hier0.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/hierarchy/hier1.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/hierarchy/hier2.scxml" # failed + +# TESTS="${TESTS} scxml-test-framework/test/hierarchy+documentOrder/test0.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/hierarchy+documentOrder/test1.scxml" # failed + +# TESTS="${TESTS} scxml-test-framework/test/history/history0.scxml" # segfault +# TESTS="${TESTS} scxml-test-framework/test/history/history1.scxml" # segfault +# TESTS="${TESTS} scxml-test-framework/test/history/history2.scxml" # segfault +# TESTS="${TESTS} scxml-test-framework/test/history/history3.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/history/history4.scxml" # segfault +# TESTS="${TESTS} scxml-test-framework/test/history/history5.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/history/history6.scxml" # segfault + +# TESTS="${TESTS} scxml-test-framework/test/if-else/test0.scxml" # failed + +# TESTS="${TESTS} scxml-test-framework/test/in/TestInPredicate.scxml" # failed + +# TESTS="${TESTS} scxml-test-framework/test/more-parallel/test0.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/more-parallel/test1.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/more-parallel/test2.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/more-parallel/test3.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/more-parallel/test4.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/more-parallel/test5.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/more-parallel/test6.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/more-parallel/test7.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/more-parallel/test8.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/more-parallel/test9.scxml" # failed + +# TESTS="${TESTS} scxml-test-framework/test/multiple-events-per-transition/test1.scxml" # passed + +# TESTS="${TESTS} scxml-test-framework/test/parallel/test0.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/parallel/test1.scxml" # exception +# TESTS="${TESTS} scxml-test-framework/test/parallel/test2.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/parallel/test3.scxml" # failed + +# TESTS="${TESTS} scxml-test-framework/test/parallel+interrupt/test0.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/parallel+interrupt/test1.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/parallel+interrupt/test10.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/parallel+interrupt/test11.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/parallel+interrupt/test12.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/parallel+interrupt/test13.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/parallel+interrupt/test14.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/parallel+interrupt/test15.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/parallel+interrupt/test16.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/parallel+interrupt/test17.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/parallel+interrupt/test18.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/parallel+interrupt/test19.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/parallel+interrupt/test2.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/parallel+interrupt/test20.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/parallel+interrupt/test21.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/parallel+interrupt/test22.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/parallel+interrupt/test23.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/parallel+interrupt/test24.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/parallel+interrupt/test25.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/parallel+interrupt/test26.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/parallel+interrupt/test27.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/parallel+interrupt/test28.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/parallel+interrupt/test29.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/parallel+interrupt/test3.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/parallel+interrupt/test30.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/parallel+interrupt/test31.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/parallel+interrupt/test4.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/parallel+interrupt/test5.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/parallel+interrupt/test6.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/parallel+interrupt/test7.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/parallel+interrupt/test8.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/parallel+interrupt/test9.scxml" # failed + +# TESTS="${TESTS} scxml-test-framework/test/script/test0.scxml" # getData not defined +# TESTS="${TESTS} scxml-test-framework/test/script/test1.scxml" # getData not defined +# TESTS="${TESTS} scxml-test-framework/test/script/test2.scxml" # getData not defined +# TESTS="${TESTS} scxml-test-framework/test/script-src/test0.scxml" # getData not defined +# TESTS="${TESTS} scxml-test-framework/test/script-src/test1.scxml" # getData not defined +# TESTS="${TESTS} scxml-test-framework/test/script-src/test2.scxml" # getData not defined +# TESTS="${TESTS} scxml-test-framework/test/script-src/test3.scxml" # getData not defined + +# TESTS="${TESTS} scxml-test-framework/test/scxml-prefix-event-name-matching/star0.scxml" # passed +# TESTS="${TESTS} scxml-test-framework/test/scxml-prefix-event-name-matching/test0.scxml" # passed +# TESTS="${TESTS} scxml-test-framework/test/scxml-prefix-event-name-matching/test1.scxml" # passed + +# TESTS="${TESTS} scxml-test-framework/test/send-data/send1.scxml" # segfault +# TESTS="${TESTS} scxml-test-framework/test/send-internal/test0.scxml" # failed + +# TESTS="${TESTS} scxml-test-framework/test/targetless-transition/test0.scxml" # passed +# TESTS="${TESTS} scxml-test-framework/test/targetless-transition/test1.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/targetless-transition/test2.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/targetless-transition/test3.scxml" # failed + + +trap 'killall ${SCXML_TEST_FRAMEWORK_NAME}' 0 +$SCXML_TEST_FRAMEWORK_FULL & +sleep 1 +cd $DIR + +node scxml-test-framework --test-server-url http://localhost:8080/test $TESTS diff --git a/test/samples/uscxml/test-execution.scxml b/test/samples/uscxml/test-execution.scxml index ada1a17..13373ba 100644 --- a/test/samples/uscxml/test-execution.scxml +++ b/test/samples/uscxml/test-execution.scxml @@ -1,4 +1,8 @@ -<scxml initial="step2"> +<?xml version="1.0" encoding="UTF-8"?> +<scxml + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initial="step2"> <state id="start"> <onentry> <log expr="'Entered State: start'" /> diff --git a/test/schema/scxml-attribs.xsd b/test/schema/scxml-attribs.xsd new file mode 100644 index 0000000..98aff4c --- /dev/null +++ b/test/schema/scxml-attribs.xsd @@ -0,0 +1,57 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" + targetNamespace="http://www.w3.org/2005/07/scxml" + xmlns="http://www.w3.org/2005/07/scxml" + elementFormDefault="qualified"> + <xsd:annotation> + <xsd:documentation> + This is the XML Schema common attributes for SCXML + </xsd:documentation> + <xsd:documentation source="scxml-copyright.xsd"/> + </xsd:annotation> + <xsd:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/xml.xsd"> + <xsd:annotation> + <xsd:documentation> + This import brings in the XML namespace attributes + The module itself does not provide the schemaLocation + and expects the driver schema to provide the + actual SchemaLocation. + </xsd:documentation> + </xsd:annotation> + </xsd:import> + <xsd:include schemaLocation="scxml-datatypes.xsd"> + <xsd:annotation> + <xsd:documentation> + This include brings in the SCXML datatypes. + </xsd:documentation> + </xsd:annotation> + </xsd:include> + + <xsd:attributeGroup name="Fetchtimeout.attrib"> + <xsd:annotation> + <xsd:documentation>Used in Cache.attribs</xsd:documentation> + </xsd:annotation> + <xsd:attribute name="fetchtimeout" type="Duration.datatype"/> + </xsd:attributeGroup> + <xsd:attributeGroup name="Maxage.attrib"> + <xsd:annotation> + <xsd:documentation>Used in Cache.attribs</xsd:documentation> + </xsd:annotation> + <xsd:attribute name="maxage" type="Integer.datatype"/> + </xsd:attributeGroup> + <xsd:attributeGroup name="Maxstale.attrib"> + <xsd:annotation> + <xsd:documentation>Used in Cache attribs</xsd:documentation> + </xsd:annotation> + <xsd:attribute name="maxstale" type="Integer.datatype"/> + </xsd:attributeGroup> + + <xsd:attributeGroup name="Cache.attribs"> + <xsd:annotation> + <xsd:documentation>Cache attributes to control caching behavior</xsd:documentation> + </xsd:annotation> + <xsd:attributeGroup ref="Fetchtimeout.attrib"/> + <xsd:attributeGroup ref="Maxage.attrib"/> + <xsd:attributeGroup ref="Maxstale.attrib"/> + </xsd:attributeGroup> +</xsd:schema> diff --git a/test/schema/scxml-contentmodels.xsd b/test/schema/scxml-contentmodels.xsd new file mode 100644 index 0000000..2850c3a --- /dev/null +++ b/test/schema/scxml-contentmodels.xsd @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" + targetNamespace="http://www.w3.org/2005/07/scxml" + xmlns="http://www.w3.org/2005/07/scxml" + elementFormDefault="qualified"> + <xsd:annotation> + <xsd:documentation> + XML Schema content models for SCXML + * scxml.extra.content + * content + * scxml.extra.attribs + Defines SCXML shared content models. + </xsd:documentation> + <xsd:documentation source="scxml-copyright.xsd"/> + </xsd:annotation> + + <xsd:attributeGroup name="scxml.extra.attribs"> + <xsd:annotation> + <xsd:documentation>group allowing attributes from other namespaces</xsd:documentation> + </xsd:annotation> + <xsd:anyAttribute namespace="##other" processContents="lax"/> + </xsd:attributeGroup> + + <xsd:group name="scxml.extra.content"> + <xsd:annotation> + <xsd:documentation> + group allowing elements from other namespaces + </xsd:documentation> + </xsd:annotation> + <xsd:sequence> + <xsd:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> + </xsd:group> + +</xsd:schema> diff --git a/test/schema/scxml-datatypes.xsd b/test/schema/scxml-datatypes.xsd new file mode 100644 index 0000000..7771084 --- /dev/null +++ b/test/schema/scxml-datatypes.xsd @@ -0,0 +1,203 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" + targetNamespace="http://www.w3.org/2005/07/scxml" + xmlns="http://www.w3.org/2005/07/scxml" + elementFormDefault="qualified"> + + <xsd:annotation> + <xsd:documentation> + XML Schema datatypes for SCXML + + Defines containers for the SCXML datatypes, many of these + imported from other specifications and standards. + + </xsd:documentation> + <xsd:documentation source="scxml-copyright.xsd"/> + </xsd:annotation> + + <xsd:simpleType name="Exmode.datatype"> + <xsd:annotation> + <xsd:documentation> + Describes the processor execution mode for this document, being + either "lax" or "strict". + </xsd:documentation> + </xsd:annotation> + <xsd:restriction base="xsd:NMTOKEN"> + <xsd:enumeration value="lax"/> + <xsd:enumeration value="strict"/> + </xsd:restriction> + </xsd:simpleType> + + <xsd:simpleType name="Binding.datatype"> + <xsd:annotation> + <xsd:documentation> + The binding type in use for the SCXML document. + </xsd:documentation> + </xsd:annotation> + <xsd:restriction base="xsd:NMTOKEN"> + <xsd:enumeration value="early"/> + <xsd:enumeration value="late"/> + </xsd:restriction> + </xsd:simpleType> + + + <xsd:simpleType name="HistoryType.datatype"> + <xsd:restriction base="xsd:string"> + <xsd:enumeration value="shallow"/> + <xsd:enumeration value="deep"/> + </xsd:restriction> + </xsd:simpleType> + + <xsd:simpleType name="TransitionType.datatype"> + <xsd:annotation> + <xsd:documentation> + The type of the transition i.e. internal or external. + </xsd:documentation> + </xsd:annotation> + <xsd:restriction base="xsd:NMTOKEN"> + <xsd:enumeration value="internal"/> + <xsd:enumeration value="external"/> + </xsd:restriction> + </xsd:simpleType> + + <xsd:simpleType name="Boolean.datatype"> + <xsd:annotation> + <xsd:documentation> + Boolean: true or false only + </xsd:documentation> + </xsd:annotation> + <xsd:restriction base="xsd:NMTOKENS"> + <xsd:enumeration value="true"/> + <xsd:enumeration value="false"/> + </xsd:restriction> + </xsd:simpleType> + + <xsd:simpleType name="AssignType.datatype"> + <xsd:annotation> + <xsd:documentation> + The assign type that allows for precise manipulation of the + datamodel location. Types are: + replacechildren (default), + firstchild, lastchild, + previoussibling, nextsibling, + replace, delete, + addattribute + </xsd:documentation> + </xsd:annotation> + <xsd:restriction base="xsd:NMTOKEN"> + <xsd:enumeration value="replacechildren"/> + <xsd:enumeration value="firstchild"/> + <xsd:enumeration value="lastchild"/> + <xsd:enumeration value="previoussibling"/> + <xsd:enumeration value="nextsibling"/> + <xsd:enumeration value="replace"/> + <xsd:enumeration value="delete"/> + <xsd:enumeration value="addattribute"/> + </xsd:restriction> + </xsd:simpleType> + + <xsd:simpleType name="URI.datatype"> + <xsd:annotation> + <xsd:documentation> + The xsd:anyURI type and thus URI references in SCXML + documents may contain a wide array of international + characters. Implementers should reference RFC 3987 and + the "Character Model for the World Wide Web 1.0: + Resource Identifiers" in order to provide appropriate + support for these characters in VoiceXML documents and + when processing values of this type or mapping them to + URIs. + </xsd:documentation> + </xsd:annotation> + <xsd:restriction base="xsd:anyURI"/> + </xsd:simpleType> + + <xsd:simpleType name="Integer.datatype"> + <xsd:annotation> + <xsd:documentation>Non-negative integer</xsd:documentation> + </xsd:annotation> + <xsd:restriction base="xsd:nonNegativeInteger"/> + </xsd:simpleType> + + <xsd:simpleType name="Duration.datatype"> + <xsd:annotation> + <xsd:documentation> + Duration allowing positive values ranging from milliseconds + to days. + </xsd:documentation> + </xsd:annotation> + <xsd:restriction base="xsd:string"> + <xsd:pattern value="\d*(\.\d+)?(ms|s|m|h|d)"/> + </xsd:restriction> + </xsd:simpleType> + + + <xsd:simpleType name="EventType.datatype"> + <xsd:annotation> + <xsd:documentation> + EventType is the name of an event. + Example legal values: + foo + foo.bar + foo.bar.baz + </xsd:documentation> + </xsd:annotation> + <xsd:restriction base="xsd:token"> + <xsd:pattern value="(\i|\d|\-)+(\.(\i|\d|\-)+)*"/> + </xsd:restriction> + </xsd:simpleType> + + <xsd:simpleType name="EventTypes.datatype"> + <xsd:annotation> + <xsd:documentation> + Custom datatype for the event attribute in SCXML based on xsd:token. + Example legal values: + * + foo + foo.bar + foo.* + foo.bar.* + foo bar baz + foo.bar bar.* baz.foo.* + </xsd:documentation> + </xsd:annotation> + <xsd:restriction base="xsd:token"> + <xsd:pattern value="\.?\*|(\i|\d|\-)+(\.(\i|\d|\-)+)*(\.\*)?(\s(\i|\d|\-)+(\.(\i|\d|\-)+)*(\.\*)?)*"/> + </xsd:restriction> + </xsd:simpleType> + + <!-- Defines the default CondLang datatype. --> + <xsd:simpleType name="CondLang.datatype"> + <xsd:annotation> + <xsd:documentation> + Conditional language is expression + which must evaluate to Boolean True or False. + The expression language must define In(stateID) + as a valid expression. + </xsd:documentation> + </xsd:annotation> + <xsd:restriction base="xsd:string"/> + </xsd:simpleType> + + <!-- Defines the default LocLang datatype. --> + <xsd:simpleType name="LocLang.datatype"> + <xsd:annotation> + <xsd:documentation> + Location language is expression + identifying a location in the datamodel. + </xsd:documentation> + </xsd:annotation> + <xsd:restriction base="xsd:string"/> + </xsd:simpleType> + + <!-- Defines the default ValueLang datatype. --> + <xsd:simpleType name="ValueLang.datatype"> + <xsd:annotation> + <xsd:documentation> + Value language is expression + return a value. + </xsd:documentation> + </xsd:annotation> + <xsd:restriction base="xsd:string"/> + </xsd:simpleType> +</xsd:schema> diff --git a/test/schema/scxml-message.xsd b/test/schema/scxml-message.xsd deleted file mode 100644 index de4b4b8..0000000 --- a/test/schema/scxml-message.xsd +++ /dev/null @@ -1,122 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - XML Schema for sending messages to SCXML processors. ---> -<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" - targetNamespace="http://www.w3.org/2005/07/scxml" - xmlns="http://www.w3.org/2005/07/scxml" - elementFormDefault="qualified"> - - <xsd:annotation> - <xsd:documentation xml:lang="en"> - XML Schema for sending messages to SCXML processors. - Version 1.0 - </xsd:documentation> - <xsd:documentation source="scxml-copyright.xsd" /> - </xsd:annotation> - - <xsd:attributeGroup name="scxmlmessage.extra.attribs"> - <xsd:annotation> - <xsd:documentation> - Group allowing attributes from other namespaces - </xsd:documentation> - </xsd:annotation> - <xsd:anyAttribute namespace="##other" processContents="lax" /> - </xsd:attributeGroup> - - <xsd:attributeGroup name="scxmlmessage.message.attlist"> - <xsd:attribute name="version" type="xsd:string" fixed="1.0" use="required" /> - <xsd:attribute name="source" type="xsd:anyURI" use="required" /> - <xsd:attribute name="target" type="xsd:anyURI" use="required" /> - <xsd:attribute name="sendid" type="xsd:string" use="optional"> - <xsd:annotation> - <xsd:documentation> - Non SCXML senders are not required to specify a sendid - </xsd:documentation> - </xsd:annotation> - </xsd:attribute> - <xsd:attribute name="name" type="xsd:string" use="optional"> - <xsd:annotation> - <xsd:documentation> - Defaults to "external.event" - </xsd:documentation> - </xsd:annotation> - </xsd:attribute> - <xsd:attribute name="sourcetype" type="xsd:string" use="optional"> - <xsd:annotation> - <xsd:documentation> - Defaults to "scxml" - </xsd:documentation> - </xsd:annotation> - </xsd:attribute> - <xsd:attributeGroup ref="scxmlmessage.extra.attribs" /> - </xsd:attributeGroup> - - <xsd:group name="scxmlmessage.message.content"> - <xsd:sequence> - <xsd:element ref="payload" minOccurs="1" maxOccurs="1" /> - </xsd:sequence> - </xsd:group> - - <xsd:complexType name="scxmlmessage.message.type"> - <xsd:group ref="scxmlmessage.message.content" /> - <xsd:attributeGroup ref="scxmlmessage.message.attlist" /> - </xsd:complexType> - - <xsd:element name="message" type="scxmlmessage.message.type" /> - - <xsd:attributeGroup name="scxmlmessage.payload.attlist"> - <xsd:attributeGroup ref="scxmlmessage.extra.attribs" /> - <xsd:attribute name="contenttype" type="xsd:string" use="optional"> - <xsd:annotation> - <xsd:documentation> - The mime type of the child content. - </xsd:documentation> - </xsd:annotation> - </xsd:attribute> - </xsd:attributeGroup> - - <xsd:group name="scxmlmessage.payload.content"> - <xsd:choice> - <xsd:sequence> - <xsd:element ref="property" minOccurs="0" - maxOccurs="unbounded" /> - </xsd:sequence> - <xsd:sequence> - <xsd:any namespace="##other" minOccurs="1" - maxOccurs="unbounded" processContents="lax" /> - </xsd:sequence> - </xsd:choice> - </xsd:group> - - <xsd:complexType name="scxmlmessage.payload.type"> - <xsd:group ref="scxmlmessage.payload.content" /> - <xsd:attributeGroup ref="scxmlmessage.payload.attlist" /> - </xsd:complexType> - - <xsd:element name="payload" type="scxmlmessage.payload.type" /> - - <xsd:attributeGroup name="scxmlmessage.property.attlist"> - <xsd:attribute name="name" type="xsd:string" use="required" /> - <xsd:attributeGroup ref="scxmlmessage.extra.attribs" /> - </xsd:attributeGroup> - - <xsd:group name="scxmlmessage.property.content"> - <xsd:sequence> - <xsd:element ref="hint" minOccurs="0" - maxOccurs="1" /> - <xsd:any namespace="##other" minOccurs="0" - maxOccurs="unbounded" processContents="skip" /> - </xsd:sequence> - </xsd:group> - - <xsd:complexType name="scxmlmessage.property.type" mixed="true"> - <xsd:group ref="scxmlmessage.property.content" /> - <xsd:attributeGroup ref="scxmlmessage.property.attlist" /> - </xsd:complexType> - - <xsd:element name="property" type="scxmlmessage.property.type" /> - - <xsd:element name="hint" type="xsd:string" /> - -</xsd:schema> diff --git a/test/schema/scxml-module-core.xsd b/test/schema/scxml-module-core.xsd new file mode 100644 index 0000000..5245bc9 --- /dev/null +++ b/test/schema/scxml-module-core.xsd @@ -0,0 +1,405 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" + targetNamespace="http://www.w3.org/2005/07/scxml" + xmlns="http://www.w3.org/2005/07/scxml" + elementFormDefault="qualified"> + <xsd:annotation> + <xsd:documentation> + This is the XML Schema core module for SCXML + * scxml + * state + * initial + * onexit + * onentry + * transition + * parallel + * final + * history + * donedata + * if + * elsif + * else + * foreach + * raise + * log + The core module defines these elements and the + attributes. + </xsd:documentation> + <xsd:documentation source="scxml-copyright.xsd"/> + </xsd:annotation> + + <xsd:include schemaLocation="scxml-datatypes.xsd"> + <xsd:annotation> + <xsd:documentation> + Includes common SCXML datatypes + </xsd:documentation> + </xsd:annotation> + </xsd:include> + + <xsd:include schemaLocation="scxml-attribs.xsd"> + <xsd:annotation> + <xsd:documentation> + Includes common SCXML attributes + </xsd:documentation> + </xsd:annotation> + </xsd:include> + + <xsd:include schemaLocation="scxml-contentmodels.xsd"> + <xsd:annotation> + <xsd:documentation> + This module defines Common content model extensions for SCXML + </xsd:documentation> + </xsd:annotation> + </xsd:include> + + + <!-- scxml --> + <xsd:attributeGroup name="scxml.scxml.attlist"> + <xsd:attribute name="initial" type="xsd:IDREFS"/> + <xsd:attribute name="name" type="xsd:NMTOKEN"/> + <xsd:attribute name="version" type="xsd:decimal" use="required" fixed="1.0"/> + <xsd:attribute name="datamodel" type="xsd:NMTOKEN" default="null" use="optional"/> + <xsd:attribute name="binding" type="Binding.datatype"/> + <xsd:attribute name="exmode" type="Exmode.datatype"/> + <xsd:attributeGroup ref="scxml.extra.attribs"/> + </xsd:attributeGroup> + <xsd:group name="scxml.scxml.mix"> + <xsd:choice> + <xsd:element ref="state" minOccurs="0" maxOccurs="unbounded"/> + <xsd:element ref="parallel" minOccurs="0" maxOccurs="unbounded"/> + <xsd:element ref="final" minOccurs="0" maxOccurs="unbounded"/> + <xsd:element ref="datamodel" minOccurs="0" maxOccurs="unbounded"/> + <xsd:element ref="script" minOccurs="0" maxOccurs="unbounded"/> + <xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/> + </xsd:choice> + </xsd:group> + <xsd:group name="scxml.scxml.content"> + <xsd:sequence> + <xsd:group ref="scxml.scxml.mix" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> + </xsd:group> + <xsd:complexType name="scxml.scxml.type"> + <xsd:group ref="scxml.scxml.content"/> + <xsd:attributeGroup ref="scxml.scxml.attlist"/> + </xsd:complexType> + <xsd:element name="scxml" type="scxml.scxml.type"/> + + <!-- state --> + <xsd:attributeGroup name="scxml.state.attlist"> + <xsd:attribute name="id" type="xsd:ID"/> + <xsd:attribute name="initial" type="xsd:IDREFS"/> + <xsd:attributeGroup ref="scxml.extra.attribs"/> + </xsd:attributeGroup> + <xsd:group name="scxml.state.mix"> + <xsd:choice> + <xsd:element ref="onentry" minOccurs="0" maxOccurs="unbounded"/> + <xsd:element ref="onexit" minOccurs="0" maxOccurs="unbounded"/> + <xsd:element ref="transition" minOccurs="0" maxOccurs="unbounded"/> + <xsd:element ref="initial" minOccurs="0" maxOccurs="1"/> + <xsd:element ref="state" minOccurs="0" maxOccurs="unbounded"/> + <xsd:element ref="parallel" minOccurs="0" maxOccurs="unbounded"/> + <xsd:element ref="final" minOccurs="0" maxOccurs="unbounded"/> + <xsd:element ref="history" minOccurs="0" maxOccurs="unbounded"/> + <xsd:element ref="datamodel" minOccurs="0" maxOccurs="1"/> + <xsd:element ref="invoke" minOccurs="0" maxOccurs="unbounded"/> + <xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/> + </xsd:choice> + </xsd:group> + <xsd:group name="scxml.state.content"> + <xsd:sequence> + <xsd:group ref="scxml.state.mix" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> + </xsd:group> + <xsd:complexType name="scxml.state.type"> + <xsd:sequence> + <xsd:group ref="scxml.state.content"/> + </xsd:sequence> + <xsd:attributeGroup ref="scxml.state.attlist"/> + </xsd:complexType> + <xsd:element name="state" type="scxml.state.type"/> + + <!-- initial --> + <xsd:attributeGroup name="scxml.initial.attlist"> + <xsd:attributeGroup ref="scxml.extra.attribs"/> + </xsd:attributeGroup> + <xsd:group name="scxml.initial.content"> + <xsd:sequence> + <xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/> + <xsd:element ref="transition" minOccurs="1" maxOccurs="1"/> + <xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> + </xsd:group> + <xsd:complexType name="scxml.initial.type"> + <xsd:group ref="scxml.initial.content"/> + <xsd:attributeGroup ref="scxml.initial.attlist"/> + </xsd:complexType> + <xsd:element name="initial" type="scxml.initial.type"/> + + <!-- onentry --> + <xsd:attributeGroup name="scxml.onentry.attlist"> + <xsd:attributeGroup ref="scxml.extra.attribs"/> + </xsd:attributeGroup> + <xsd:group name="scxml.onentry.content"> + <xsd:sequence> + <xsd:group ref="scxml.core.executablecontent" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> + </xsd:group> + <xsd:complexType name="scxml.onentry.type"> + <xsd:group ref="scxml.onentry.content"/> + <xsd:attributeGroup ref="scxml.onentry.attlist"/> + </xsd:complexType> + <xsd:element name="onentry" type="scxml.onentry.type"/> + + <!-- onexit --> + <xsd:attributeGroup name="scxml.onexit.attlist"> + <xsd:attributeGroup ref="scxml.extra.attribs"/> + </xsd:attributeGroup> + <xsd:group name="scxml.onexit.content"> + <xsd:sequence> + <xsd:group ref="scxml.core.executablecontent" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> + </xsd:group> + <xsd:complexType name="scxml.onexit.type"> + <xsd:group ref="scxml.onexit.content"/> + <xsd:attributeGroup ref="scxml.onexit.attlist"/> + </xsd:complexType> + <xsd:element name="onexit" type="scxml.onexit.type"/> + + <!-- transition --> + <xsd:attributeGroup name="scxml.transition.attlist"> + <xsd:attribute name="event" type="EventTypes.datatype"/> + <xsd:attribute name="cond" type="CondLang.datatype"/> + <xsd:attribute name="target" type="xsd:IDREFS"/> + <xsd:attribute name="type" type="TransitionType.datatype"/> + <xsd:attributeGroup ref="scxml.extra.attribs"/> + </xsd:attributeGroup> + <xsd:group name="scxml.transition.content"> + <xsd:sequence> + <xsd:group ref="scxml.core.executablecontent" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> + </xsd:group> + <xsd:complexType name="scxml.transition.type"> + <xsd:group ref="scxml.transition.content"/> + <xsd:attributeGroup ref="scxml.transition.attlist"/> + </xsd:complexType> + <xsd:element name="transition" type="scxml.transition.type"/> + + <!-- parallel --> + <xsd:attributeGroup name="scxml.parallel.attlist"> + <xsd:attribute name="id" type="xsd:ID"/> + <xsd:attributeGroup ref="scxml.extra.attribs"/> + </xsd:attributeGroup> + <xsd:group name="scxml.parallel.mix"> + <xsd:choice> + <xsd:element ref="onentry" minOccurs="0" maxOccurs="unbounded"/> + <xsd:element ref="onexit" minOccurs="0" maxOccurs="unbounded"/> + <xsd:element ref="transition" minOccurs="0" maxOccurs="unbounded"/> + <xsd:element ref="state" minOccurs="0" maxOccurs="unbounded"/> + <xsd:element ref="parallel" minOccurs="0" maxOccurs="unbounded"/> + <xsd:element ref="history" minOccurs="0" maxOccurs="unbounded"/> + <xsd:element ref="datamodel" minOccurs="0" maxOccurs="1"/> + <xsd:element ref="invoke" minOccurs="0" maxOccurs="unbounded"/> + <xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/> + </xsd:choice> + </xsd:group> + <xsd:group name="scxml.parallel.content"> + <xsd:sequence> + <xsd:group ref="scxml.parallel.mix" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> + </xsd:group> + <xsd:complexType name="scxml.parallel.type"> + <xsd:group ref="scxml.parallel.content"/> + <xsd:attributeGroup ref="scxml.parallel.attlist"/> + </xsd:complexType> + <xsd:element name="parallel" type="scxml.parallel.type"/> + + <!-- final --> + <xsd:attributeGroup name="scxml.final.attlist"> + <xsd:attribute name="id" type="xsd:ID"/> + <xsd:attributeGroup ref="scxml.extra.attribs"/> + </xsd:attributeGroup> + <xsd:group name="scxml.final.mix"> + <xsd:choice> + <xsd:element ref="onentry" minOccurs="0" maxOccurs="unbounded"/> + <xsd:element ref="onexit" minOccurs="0" maxOccurs="unbounded"/> + <xsd:element ref="donedata" minOccurs="0" maxOccurs="1"/> + <xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/> + </xsd:choice> + </xsd:group> + <xsd:group name="scxml.final.content"> + <xsd:sequence> + <xsd:group ref="scxml.final.mix" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> + </xsd:group> + <xsd:complexType name="scxml.final.type"> + <xsd:group ref="scxml.final.content"/> + <xsd:attributeGroup ref="scxml.final.attlist"/> + </xsd:complexType> + <xsd:element name="final" type="scxml.final.type"/> + + <!-- history --> + <xsd:attributeGroup name="scxml.history.attlist"> + <xsd:attribute name="id" type="xsd:ID"/> + <xsd:attribute name="type" type="HistoryType.datatype"/> + <xsd:attributeGroup ref="scxml.extra.attribs"/> + </xsd:attributeGroup> + <xsd:group name="scxml.history.content"> + <xsd:sequence> + <xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/> + <xsd:element ref="transition" minOccurs="1" maxOccurs="1"/> + <xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> + </xsd:group> + <xsd:complexType name="scxml.history.type"> + <xsd:group ref="scxml.history.content"/> + <xsd:attributeGroup ref="scxml.history.attlist"/> + </xsd:complexType> + <xsd:element name="history" type="scxml.history.type"/> + + + + <!-- donedata --> + <xsd:attributeGroup name="scxml.donedata.attlist"> + <xsd:attributeGroup ref="scxml.extra.attribs"/> + </xsd:attributeGroup> + <xsd:group name="scxml.donedata.content"> + <xsd:choice> + <xsd:element ref="content" minOccurs="0" maxOccurs="1"/> + <xsd:element ref="param" minOccurs="0" maxOccurs="unbounded"/> + </xsd:choice> + </xsd:group> + <xsd:complexType name="scxml.donedata.type"> + <xsd:group ref="scxml.donedata.content"/> + <xsd:attributeGroup ref="scxml.donedata.attlist"/> + </xsd:complexType> + <xsd:element name="donedata" type="scxml.donedata.type"/> + + <!-- if --> + <xsd:attributeGroup name="scxml.if.attlist"> + <xsd:attribute name="cond" type="CondLang.datatype" use="required"/> + <xsd:attributeGroup ref="scxml.extra.attribs"/> + </xsd:attributeGroup> + <xsd:group name="scxml.if.elseif.mix"> + <xsd:sequence> + <xsd:element ref="elseif" /> + <xsd:group ref="scxml.core.executablecontent" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> + </xsd:group> + <xsd:group name="scxml.if.else.mix"> + <xsd:sequence> + <xsd:element ref="else" /> + <xsd:group ref="scxml.core.executablecontent" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> + </xsd:group> + <xsd:group name="scxml.if.content"> + <xsd:sequence> + <xsd:group ref="scxml.core.executablecontent" minOccurs="0" maxOccurs="unbounded"/> + <xsd:group ref="scxml.if.elseif.mix" minOccurs="0" maxOccurs="1"/> + <xsd:group ref="scxml.if.else.mix" minOccurs="0" maxOccurs="1"/> + </xsd:sequence> + </xsd:group> + <xsd:complexType name="scxml.if.type"> + <xsd:group ref="scxml.if.content"/> + <xsd:attributeGroup ref="scxml.if.attlist"/> + </xsd:complexType> + <xsd:element name="if" type="scxml.if.type"/> + + <!-- elseif --> + <xsd:attributeGroup name="scxml.elseif.attlist"> + <xsd:attribute name="cond" type="CondLang.datatype" use="required"/> + <xsd:attributeGroup ref="scxml.extra.attribs"/> + </xsd:attributeGroup> + <xsd:group name="scxml.elseif.mix"> + <xsd:choice> + <!-- No content for this element --> + </xsd:choice> + </xsd:group> + <xsd:group name="scxml.elseif.content"> + <xsd:sequence> + <xsd:group ref="scxml.elseif.mix" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> + </xsd:group> + <xsd:complexType name="scxml.elseif.type"> + <xsd:group ref="scxml.elseif.content"/> + <xsd:attributeGroup ref="scxml.elseif.attlist"/> + </xsd:complexType> + <xsd:element name="elseif" type="scxml.elseif.type"/> + + <!-- else --> + <xsd:attributeGroup name="scxml.else.attlist"> + <xsd:attributeGroup ref="scxml.extra.attribs"/> + </xsd:attributeGroup> + <xsd:group name="scxml.else.mix"> + <xsd:choice> + <!-- No content for this element --> + </xsd:choice> + </xsd:group> + <xsd:group name="scxml.else.content"> + <xsd:sequence> + <xsd:group ref="scxml.else.mix" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> + </xsd:group> + <xsd:complexType name="scxml.else.type"> + <xsd:group ref="scxml.else.content"/> + <xsd:attributeGroup ref="scxml.else.attlist"/> + </xsd:complexType> + <xsd:element name="else" type="scxml.else.type"/> + + <!-- foreach --> + <xsd:attributeGroup name="scxml.foreach.attlist"> + <xsd:attribute name="array" type="ValueLang.datatype" use="required"/> + <xsd:attribute name="item" type="xsd:string" use="required"/> + <xsd:attribute name="index" type="xsd:string"/> + <xsd:attributeGroup ref="scxml.extra.attribs"/> + </xsd:attributeGroup> + <xsd:group name="scxml.foreach.content"> + <xsd:sequence> + <xsd:group ref="scxml.core.executablecontent" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> + </xsd:group> + <xsd:complexType name="scxml.foreach.type"> + <xsd:group ref="scxml.foreach.content"/> + <xsd:attributeGroup ref="scxml.foreach.attlist"/> + </xsd:complexType> + <xsd:element name="foreach" type="scxml.foreach.type"/> + + <!-- raise --> + <xsd:attributeGroup name="scxml.raise.attlist"> + <xsd:attribute name="event" type="xsd:NMTOKEN" use="required"/> + <xsd:attributeGroup ref="scxml.extra.attribs"/> + </xsd:attributeGroup> + <xsd:group name="scxml.raise.mix"> + <xsd:choice> + <!-- No content for this element --> + </xsd:choice> + </xsd:group> + <xsd:group name="scxml.raise.content"> + <xsd:sequence> + <xsd:group ref="scxml.raise.mix" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> + </xsd:group> + <xsd:complexType name="scxml.raise.type"> + <xsd:group ref="scxml.raise.content"/> + <xsd:attributeGroup ref="scxml.raise.attlist"/> + </xsd:complexType> + <xsd:element name="raise" type="scxml.raise.type"/> + + <!-- log --> + <xsd:attributeGroup name="scxml.log.attlist"> + <xsd:attribute name="label" type="xsd:string"/> + <xsd:attribute name="expr" type="ValueLang.datatype"/> + <xsd:attributeGroup ref="scxml.extra.attribs"/> + </xsd:attributeGroup> + <xsd:group name="scxml.log.content"> + <xsd:sequence> + <xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> + </xsd:group> + <xsd:complexType name="scxml.log.type"> + <xsd:group ref="scxml.log.content"/> + <xsd:attributeGroup ref="scxml.log.attlist"/> + </xsd:complexType> + <xsd:element name="log" type="scxml.log.type"/> + + +</xsd:schema> diff --git a/test/schema/scxml-module-data.xsd b/test/schema/scxml-module-data.xsd new file mode 100644 index 0000000..ec96e71 --- /dev/null +++ b/test/schema/scxml-module-data.xsd @@ -0,0 +1,151 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" + targetNamespace="http://www.w3.org/2005/07/scxml" + xmlns="http://www.w3.org/2005/07/scxml" + elementFormDefault="qualified"> + <xsd:annotation> + <xsd:documentation> + This is the XML Schema data module for SCXML + * datamodel + * data + * assign + * param + * script + * content + The data module defines these elements and their + attributes. + </xsd:documentation> + <xsd:documentation source="scxml-copyright.xsd"/> + </xsd:annotation> + + <xsd:include schemaLocation="scxml-datatypes.xsd"> + <xsd:annotation> + <xsd:documentation> + This module defines SCXML Attribute DataTypes + </xsd:documentation> + </xsd:annotation> + </xsd:include> + + <xsd:include schemaLocation="scxml-attribs.xsd"> + <xsd:annotation> + <xsd:documentation> + This module defines Common attributes for SCXML + </xsd:documentation> + </xsd:annotation> + </xsd:include> + + <xsd:include schemaLocation="scxml-contentmodels.xsd"> + <xsd:annotation> + <xsd:documentation> + This module defines Common content model extensions for SCXML + </xsd:documentation> + </xsd:annotation> + </xsd:include> + + <!-- datamodel --> + <xsd:attributeGroup name="scxml.datamodel.attlist"> + <xsd:attributeGroup ref="scxml.extra.attribs"/> + </xsd:attributeGroup> + <xsd:group name="scxml.datamodel.content"> + <xsd:sequence> + <xsd:element ref="data" minOccurs="0" maxOccurs="unbounded"/> + <xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> + </xsd:group> + <xsd:complexType name="scxml.datamodel.type"> + <xsd:group ref="scxml.datamodel.content"/> + <xsd:attributeGroup ref="scxml.datamodel.attlist"/> + </xsd:complexType> + <xsd:element name="datamodel" type="scxml.datamodel.type"/> + + <!-- data --> + <xsd:attributeGroup name="scxml.data.attlist"> + <xsd:attribute name="id" type="xsd:ID" use="required"/> + <xsd:attribute name="src" type="URI.datatype"/> + <xsd:attribute name="expr" type="ValueLang.datatype"/> + <xsd:attributeGroup ref="scxml.extra.attribs"/> + </xsd:attributeGroup> + <xsd:group name="scxml.data.content"> + <xsd:sequence> + <xsd:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> + </xsd:group> + <xsd:complexType name="scxml.data.type" mixed="true"> + <xsd:group ref="scxml.data.content"/> + <xsd:attributeGroup ref="scxml.data.attlist"/> + </xsd:complexType> + <xsd:element name="data" type="scxml.data.type"/> + + + + <!-- param --> + <xsd:attributeGroup name="scxml.param.attlist"> + <xsd:attribute name="name" type="xsd:NMTOKEN" use="required"/> + <xsd:attribute name="expr" type="ValueLang.datatype"/> + <xsd:attribute name="location" type="LocLang.datatype"/> + <xsd:attributeGroup ref="scxml.extra.attribs"/> + </xsd:attributeGroup> + <xsd:group name="scxml.param.content"> + <xsd:sequence> + <xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> + </xsd:group> + <xsd:complexType name="scxml.param.type"> + <xsd:group ref="scxml.param.content"/> + <xsd:attributeGroup ref="scxml.param.attlist"/> + </xsd:complexType> + <xsd:element name="param" type="scxml.param.type"/> + +<!-- assign --> + <xsd:attributeGroup name="scxml.assign.attlist"> + <xsd:attribute name="location" type="LocLang.datatype" use="required"/> + <xsd:attribute name="expr" type="ValueLang.datatype"/> + <xsd:attribute name="type" type="AssignType.datatype" default="replacechildren"/> + <xsd:attribute name="attr" type="xsd:NMTOKEN"/> + <xsd:attributeGroup ref="scxml.extra.attribs"/> + </xsd:attributeGroup> + <xsd:group name="scxml.assign.content"> + <xsd:sequence> + <xsd:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> + </xsd:group> + <xsd:complexType name="scxml.assign.type" mixed="true"> + <xsd:group ref="scxml.assign.content"/> + <xsd:attributeGroup ref="scxml.assign.attlist"/> + </xsd:complexType> + <xsd:element name="assign" type="scxml.assign.type"/> + + +<!-- script --> + <xsd:attributeGroup name="scxml.script.attlist"> + <xsd:attribute name="src" type="URI.datatype"/> + <xsd:attributeGroup ref="scxml.extra.attribs"/> + </xsd:attributeGroup> + <xsd:group name="scxml.script.content"> + <xsd:sequence> + <xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> + </xsd:group> + <xsd:complexType name="scxml.script.type" mixed="true"> + <xsd:group ref="scxml.script.content"/> + <xsd:attributeGroup ref="scxml.script.attlist"/> + </xsd:complexType> + <xsd:element name="script" type="scxml.script.type"/> + + <!-- content --> + <xsd:attributeGroup name="scxml.content.attlist"> + <xsd:attributeGroup ref="scxml.extra.attribs"/> + <xsd:attribute name="expr" type="ValueLang.datatype"/> + </xsd:attributeGroup> + <xsd:group name="scxml.content.content"> + <xsd:sequence> + <xsd:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> + </xsd:group> + <xsd:complexType name="scxml.content.type" mixed="true"> + <xsd:group ref="scxml.content.content"/> + <xsd:attributeGroup ref="scxml.content.attlist"/> + </xsd:complexType> + <xsd:element name="content" type="scxml.content.type"/> + +</xsd:schema> diff --git a/test/schema/scxml-module-external.xsd b/test/schema/scxml-module-external.xsd new file mode 100644 index 0000000..ae6ced3 --- /dev/null +++ b/test/schema/scxml-module-external.xsd @@ -0,0 +1,152 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" + targetNamespace="http://www.w3.org/2005/07/scxml" + xmlns="http://www.w3.org/2005/07/scxml" + elementFormDefault="qualified"> + <xsd:annotation> + <xsd:documentation> + This is the XML Schema external module for SCXML + * send + * cancel + * invoke + * finalize + The external module defines these elements and their + attributes. + </xsd:documentation> + <xsd:documentation source="scxml-copyright.xsd"/> + </xsd:annotation> + + <xsd:include schemaLocation="scxml-datatypes.xsd"> + <xsd:annotation> + <xsd:documentation> + This module defines SCXML Attribute DataTypes + </xsd:documentation> + </xsd:annotation> + </xsd:include> + + <xsd:include schemaLocation="scxml-attribs.xsd"> + <xsd:annotation> + <xsd:documentation> + This module defines Common attributes for SCXML + </xsd:documentation> + </xsd:annotation> + </xsd:include> + + <xsd:include schemaLocation="scxml-contentmodels.xsd"> + <xsd:annotation> + <xsd:documentation> + This module defines Common content model extensions for SCXML + </xsd:documentation> + </xsd:annotation> + </xsd:include> + +<!-- send --> + <xsd:attributeGroup name="scxml.send.attlist"> + <xsd:attribute name="event" type="EventType.datatype"/> + <xsd:attribute name="eventexpr" type="ValueLang.datatype"/> + <xsd:attribute name="target" type="URI.datatype"/> + <xsd:attribute name="targetexpr" type="ValueLang.datatype"/> + <xsd:attribute name="type" type="xsd:string" default="scxml"/> + <xsd:attribute name="typeexpr" type="ValueLang.datatype"/> + <xsd:attribute name="id" type="xsd:ID"/> + <xsd:attribute name="idlocation" type="LocLang.datatype"/> + <xsd:attribute name="delay" type="Duration.datatype" default="0s"/> + <xsd:attribute name="delayexpr" type="ValueLang.datatype"/> + <xsd:attribute name="namelist" type="xsd:string"/> + <xsd:attributeGroup ref="scxml.extra.attribs"/> + </xsd:attributeGroup> + <xsd:group name="scxml.send.mix"> + <xsd:choice> + <xsd:element ref="content" minOccurs="0" maxOccurs="1"/> + <xsd:element ref="param" minOccurs="0" maxOccurs="unbounded"/> + <xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/> + </xsd:choice> + </xsd:group> + <xsd:group name="scxml.send.content"> + <xsd:sequence> + <xsd:group ref="scxml.send.mix" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> + </xsd:group> + <xsd:complexType name="scxml.send.type"> + <xsd:group ref="scxml.send.content"/> + <xsd:attributeGroup ref="scxml.send.attlist"/> + </xsd:complexType> + <xsd:element name="send" type="scxml.send.type"/> + + <!-- cancel --> + <xsd:attributeGroup name="scxml.cancel.attlist"> + <xsd:attribute name="sendid" type="xsd:IDREF"/> + <xsd:attribute name="sendidexpr" type="ValueLang.datatype"/> + <xsd:attributeGroup ref="scxml.extra.attribs"/> + </xsd:attributeGroup> + <xsd:group name="scxml.cancel.mix"> + <xsd:sequence> + <xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> + </xsd:group> + <xsd:group name="scxml.cancel.content"> + <xsd:sequence> + <xsd:group ref="scxml.cancel.mix" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> + </xsd:group> + <xsd:complexType name="scxml.cancel.type"> + <xsd:group ref="scxml.cancel.content"/> + <xsd:attributeGroup ref="scxml.cancel.attlist"/> + </xsd:complexType> + <xsd:element name="cancel" type="scxml.cancel.type"/> + + + + <!-- invoke --> + <xsd:attributeGroup name="scxml.invoke.attlist"> + <xsd:attribute name="type" type="xsd:string" default="scxml"/> + <xsd:attribute name="typeexpr" type="ValueLang.datatype"/> + <xsd:attribute name="src" type="URI.datatype"/> + <xsd:attribute name="srcexpr" type="ValueLang.datatype"/> + <xsd:attribute name="id" type="xsd:ID"/> + <xsd:attribute name="idlocation" type="LocLang.datatype"/> + <xsd:attribute name="namelist" type="xsd:string"/> + <xsd:attribute name="autoforward" type="Boolean.datatype" use="optional" default="false"/> + <xsd:attributeGroup ref="scxml.extra.attribs"/> + </xsd:attributeGroup> + <xsd:group name="scxml.invoke.mix"> + <xsd:sequence> + <xsd:element ref="content" minOccurs="0" maxOccurs="1"/> + <xsd:element ref="param" minOccurs="0" maxOccurs="unbounded"/> + <xsd:element ref="finalize" minOccurs="0" maxOccurs="1"/> + <xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> + </xsd:group> + <xsd:group name="scxml.invoke.content"> + <xsd:sequence> + <xsd:group ref="scxml.invoke.mix" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> + </xsd:group> + <xsd:complexType name="scxml.invoke.type"> + <xsd:group ref="scxml.invoke.content"/> + <xsd:attributeGroup ref="scxml.invoke.attlist"/> + </xsd:complexType> + <xsd:element name="invoke" type="scxml.invoke.type"/> + + <!-- finalize --> + <xsd:attributeGroup name="scxml.finalize.attlist"> + <xsd:attributeGroup ref="scxml.extra.attribs"/> + </xsd:attributeGroup> + <xsd:group name="scxml.finalize.mix"> + <xsd:sequence> + <xsd:group ref="scxml.core.executablecontent"/> + </xsd:sequence> + </xsd:group> + <xsd:group name="scxml.finalize.content"> + <xsd:sequence> + <xsd:group ref="scxml.finalize.mix" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> + </xsd:group> + <xsd:complexType name="scxml.finalize.type"> + <xsd:group ref="scxml.finalize.content"/> + <xsd:attributeGroup ref="scxml.finalize.attlist"/> + </xsd:complexType> + <xsd:element name="finalize" type="scxml.finalize.type"/> + + +</xsd:schema> diff --git a/test/schema/scxml.xsd b/test/schema/scxml.xsd index ebc0654..000a909 100644 --- a/test/schema/scxml.xsd +++ b/test/schema/scxml.xsd @@ -45,132 +45,44 @@ </xsd:annotation> </xsd:import> - <xsd:include schemaLocation="scxml-attribs.xsd"> +<xsd:include schemaLocation="scxml-module-core.xsd"> <xsd:annotation> <xsd:documentation> - This includes brings in the common attributes for SCXML. - </xsd:documentation> - </xsd:annotation> - </xsd:include> - - <xsd:include schemaLocation="scxml-contentmodels.xsd"> - <xsd:annotation> - <xsd:documentation> - This includes the common content models. - </xsd:documentation> - </xsd:annotation> - </xsd:include> - - <xsd:include schemaLocation="scxml-datatypes.xsd"> - <xsd:annotation> - <xsd:documentation> - This includes brings in the common data types for SCXML. - </xsd:documentation> + This imports the core elements for SCXML. + </xsd:documentation> </xsd:annotation> </xsd:include> - - <xsd:redefine schemaLocation="scxml-module-data.xsd"> + + <xsd:include schemaLocation="scxml-module-data.xsd"> <xsd:annotation> <xsd:documentation> - This imports the data module for SCXML and redefines the following. - [1] Redefines assign attribute group to allow type and attr - </xsd:documentation> - </xsd:annotation> - <xsd:attributeGroup name="scxml.assign.attlist"> - <xsd:attributeGroup ref="scxml.assign.attlist"/> - <xsd:attribute name="type" type="AssignType.datatype" default="replacechildren"/> - <xsd:attribute name="attr" type="xsd:NMTOKEN"/> - </xsd:attributeGroup> - </xsd:redefine> - - <xsd:include schemaLocation="scxml-module-script.xsd"> - <xsd:annotation> - <xsd:documentation> - This includes the script module for SCXML. + This imports the data modelelements for SCXML. </xsd:documentation> </xsd:annotation> </xsd:include> - <xsd:redefine schemaLocation="scxml-module-external.xsd"> + <xsd:include schemaLocation="scxml-module-external.xsd"> <xsd:annotation> <xsd:documentation> - This imports the external module for SCXML and redefines the following. - [1] Redefines send and invoke mix group to allow - param - [2] Redefines finalize mix group to allow: - executable content + This imports the external communications elements for SCXML. </xsd:documentation> </xsd:annotation> - <xsd:group name="scxml.send.mix"> - <xsd:choice> - <xsd:group ref="scxml.send.mix"/> - <xsd:element ref="param" minOccurs="0" maxOccurs="unbounded"/> - </xsd:choice> - </xsd:group> - <xsd:group name="scxml.invoke.mix"> - <xsd:choice> - <xsd:group ref="scxml.invoke.mix"/> - <xsd:element ref="param" minOccurs="0" maxOccurs="unbounded"/> - </xsd:choice> - </xsd:group> - <xsd:group name="scxml.finalize.mix"> - <xsd:choice> - <xsd:group ref="scxml.finalize.mix"/> - <xsd:group ref="scxml.core.executablecontent"/> - </xsd:choice> - </xsd:group> - </xsd:redefine> - - <xsd:redefine schemaLocation="scxml-module-core.xsd"> - <xsd:annotation> - <xsd:documentation> - This imports the core module for SCXML and redefines the following. - [1] Redefines executable content to allow - send, assign, validate, cancel and script elements - [2] Redefines state and parallel mix group to allow - invoke and datamodel - [3] Redefines scxml group to allow - datamodel and script - </xsd:documentation> - </xsd:annotation> - <xsd:group name="scxml.core.executablecontent"> - <xsd:choice> - <xsd:group ref="scxml.core.executablecontent"/> - <xsd:element ref="send"/> - <xsd:element ref="assign"/> - <xsd:element ref="script"/> - <xsd:element ref="validate"/> - <xsd:element ref="cancel"/> - </xsd:choice> - </xsd:group> - <xsd:group name="scxml.scxml.mix"> - <xsd:choice> - <xsd:group ref="scxml.scxml.mix"/> - <xsd:element ref="datamodel" minOccurs="0" maxOccurs="unbounded"/> - <xsd:element ref="script" minOccurs="0" maxOccurs="unbounded"/> - </xsd:choice> - </xsd:group> - <xsd:group name="scxml.state.mix"> - <xsd:choice> - <xsd:group ref="scxml.state.mix"/> - <xsd:element ref="datamodel" minOccurs="0" maxOccurs="unbounded"/> - <xsd:element ref="invoke" minOccurs="0" maxOccurs="unbounded"/> - </xsd:choice> - </xsd:group> - <xsd:group name="scxml.parallel.mix"> - <xsd:choice> - <xsd:group ref="scxml.parallel.mix"/> - <xsd:element ref="datamodel" minOccurs="0" maxOccurs="unbounded"/> - <xsd:element ref="invoke" minOccurs="0" maxOccurs="unbounded"/> - </xsd:choice> - </xsd:group> - <xsd:group name="scxml.donedata.content"> - <xsd:choice> - <xsd:group ref="scxml.donedata.content"/> - <xsd:element ref="param" minOccurs="0" maxOccurs="unbounded"/> - </xsd:choice> - </xsd:group> - - </xsd:redefine> + </xsd:include> + +<!-- the various elements of executable content are defined in the relevant modules. +This gathers them up into a single type --> + <xsd:group name="scxml.core.executablecontent"> + <xsd:choice> + <xsd:group ref="scxml.extra.content" minOccurs="0" maxOccurs="unbounded"/> + <xsd:element ref="raise"/> + <xsd:element ref="if"/> + <xsd:element ref="foreach"/> + <xsd:element ref="send"/> + <xsd:element ref="script"/> + <xsd:element ref="assign"/> + <xsd:element ref="log"/> + <xsd:element ref="cancel"/> + </xsd:choice> + </xsd:group> </xsd:schema> diff --git a/test/src/scxml-test-framework-client.cpp b/test/src/scxml-test-framework-client.cpp new file mode 100644 index 0000000..8f26362 --- /dev/null +++ b/test/src/scxml-test-framework-client.cpp @@ -0,0 +1,147 @@ +#include "uscxml/Interpreter.h" +#include "uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.h" +#include <sstream> + +extern "C" { +#include "jsmn.h" // minimal json parser +} + +#include <event2/keyvalq_struct.h> +#include <event2/buffer.h> + +/** + POST /foo HTTP/1.1 + host: localhost:9000 + accept: application/json + content-type: application/json + content-length: 92 + Connection: keep-alive + + {"load":"http://localhost:9999/scxml-test-framework/test/targetless-transition/test3.scxml"} +*/ + +class TestIOProcessor : public uscxml::EventIOProcessor, public uscxml::InterpreterMonitor { +public: + + + static int lastToken; + static std::map<std::string, std::pair<uscxml::Interpreter*, evhttp_request*> > _interpreters; + + TestIOProcessor() {} + + virtual void onStableConfiguration(uscxml::Interpreter* interpreter) { + Arabica::XPath::NodeSet<std::string> configuration = interpreter->getConfiguration(); + + uscxml::Data reply; + reply.compound["sessionToken"] = uscxml::Data(interpreter->getName()); + std::string seperator; + for (size_t i = 0; i < configuration.size(); i++) { + reply.compound["nextConfiguration"].array.push_back(uscxml::Data(ATTR(configuration[i], "id"), uscxml::Data::VERBATIM)); + } + + std::cout << "---- reply:" << std::endl; + std::cout << reply << std::endl; + + std::stringstream replyString; + replyString << reply; + + struct evbuffer *databuf = evbuffer_new(); + evbuffer_add(databuf, replyString.str().c_str(), replyString.str().length()); + evhttp_send_reply(_interpreters[interpreter->getName()].second, 200, "OK", databuf); + evbuffer_free(databuf); + + } + + virtual void afterCompletion(uscxml::Interpreter* interpreter) { +// evhttp_request_free(_interpreterToRequest[interpreter]); + } + + virtual void httpRecvReq(struct evhttp_request *req) { + + std::cout << "---- received:" << std::endl; + + if (evhttp_request_get_command(req) != EVHTTP_REQ_POST) + return; + + evhttp_request_own(req); + + struct evkeyval *header; + struct evkeyvalq *headers; + headers = evhttp_request_get_input_headers(req); + + for (header = headers->tqh_first; header; + header = header->next.tqe_next) { + std::cout << header->key << ": " << header->value << std::endl; + } + + std::string content; + struct evbuffer *buf; + buf = evhttp_request_get_input_buffer(req); + while (evbuffer_get_length(buf)) { + int n; + char cbuf[128]; + n = evbuffer_remove(buf, cbuf, sizeof(buf)-1); + if (n > 0) { + content.append(cbuf, n); + } + } + + uscxml::Data jsonReq = uscxml::Data::fromJSON(content); + std::cout << jsonReq << std::endl; + + + // is this a load request? + if (jsonReq.compound.find("load") != jsonReq.compound.end()) { + std::string filename = jsonReq.compound["load"].atom; + std::cout << "Starting Interpreter with " << filename << std::endl; + uscxml::Interpreter* interpreter = uscxml::Interpreter::fromURI(filename); + if (interpreter) { + std::string token = uscxml::toStr(lastToken++); + assert(_interpreters.find(token) == _interpreters.end()); + interpreter->setName(token); + interpreter->addMonitor(this); + interpreter->start(); + _interpreters[token] = std::make_pair(interpreter, req); + } + return; + } + + if(jsonReq.compound.find("event") != jsonReq.compound.end()) { + assert(jsonReq.compound["event"].compound.find("sessionToken") != jsonReq.compound["event"].compound.end()); + std::string token = jsonReq.compound["event"].compound["sessionToken"].atom; + assert(_interpreters.find(token) != _interpreters.end()); + uscxml::Event event; + event.type = uscxml::Event::INTERNAL; + event.name = jsonReq.compound["event"].compound["name"].atom; + std::cout << "Sending event " << event << std::endl; +// evhttp_request_free(_interpreters[token].second); + _interpreters[token].second = req; + _interpreters[token].first->receive(event); + } + + } + + std::string getPath() { + return "test"; + } + + void setURL(const std::string& url) { + std::cout << "Listening at " << url << std::endl; + _url = url; + } +}; + +int TestIOProcessor::lastToken; +std::map<std::string, std::pair<uscxml::Interpreter*, evhttp_request*> > TestIOProcessor::_interpreters; + +int main(int argc, char** argv) { + TestIOProcessor* testServer = new TestIOProcessor(); + uscxml::EventIOServer::registerProcessor(testServer); + + while(true) + tthread::this_thread::sleep_for(tthread::chrono::milliseconds(20)); + +// uscxml::Interpreter* interpreter = uscxml::Interpreter::fromURI(argv[1]); +// interpreter->dump(); +// interpreter->interpret(); +}
\ No newline at end of file diff --git a/test/src/test-url.cpp b/test/src/test-url.cpp index 4e94455..e3ca1e3 100644 --- a/test/src/test-url.cpp +++ b/test/src/test-url.cpp @@ -1,4 +1,5 @@ #include "uscxml/URL.h" +#include "uscxml/Message.h" #include <assert.h> #include <boost/algorithm/string.hpp> #include <iostream> @@ -7,6 +8,24 @@ using namespace uscxml; using namespace boost; int main(int argc, char** argv) { + + { + Data data = Data::fromJSON("asdf"); + std::cout << data << std::endl; + } + { + Data data = Data::fromJSON("[ '1', '2', '3', '4' ]"); + std::cout << data << std::endl; + } + { + Data data = Data::fromJSON("{'foo1': 'bar2', 'foo3': { 'foo4': 'bar5' }, 'foo6': 'bar7', 'foo8': { 'foo9': 'foo10': { 'foo11': 'bar12' } } }"); + std::cout << data << std::endl; + } + { + Data data = Data::fromJSON("{\"firstName\": \"John\", \"lastName\": \"Smith\", \"age\": 25, \"address\": { \"streetAddress\": \"21 2nd Street\", \"city\": \"New York\",\"state\": \"NY\",\"postalCode\": 10021},\"phoneNumber\": [{\"type\": \"home\",\"number\": \"212 555-1234\"},{ \"type\": \"fax\",\"number\": \"646 555-4567\"}]}"); + std::cout << data << std::endl; + } + { URL url("http://www.heise.de/index.html"); std::cout << url.asString() << std::endl; |