diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2012-09-08 23:26:39 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2012-09-08 23:26:39 (GMT) |
commit | aa6c3a1257a29cc5bcf8b94893732ee553f27582 (patch) | |
tree | 625adb1a353a17ffed2c7e0bac686d705aaec93f /test | |
download | uscxml-aa6c3a1257a29cc5bcf8b94893732ee553f27582.zip uscxml-aa6c3a1257a29cc5bcf8b94893732ee553f27582.tar.gz uscxml-aa6c3a1257a29cc5bcf8b94893732ee553f27582.tar.bz2 |
Initial upload
Still somewhat quirky to build but fairly feature complete
Diffstat (limited to 'test')
107 files changed, 6341 insertions, 0 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..297428c --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,29 @@ +add_executable(test-predicates src/test-predicates.cpp) +target_link_libraries(test-predicates uscxml) +add_test(test-predicates ${CMAKE_SOURCE_DIR}/test/src/test-predicates.scxml) +set_target_properties(test-predicates PROPERTIES FOLDER "Tests") + +add_executable(test-execution src/test-execution.cpp) +target_link_libraries(test-execution uscxml) +add_test(test-execution ${CMAKE_SOURCE_DIR}/test/src/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_SOURCE_DIR}/test/apache) +set_target_properties(test-apache-commons PROPERTIES FOLDER "Tests") + +add_executable(test-ecmascript-v8 src/test-ecmascript-v8.cpp) +target_link_libraries(test-ecmascript-v8 uscxml) +add_test(test-ecmascript-v8 test-ecmascript-v8) +set_target_properties(test-ecmascript-v8 PROPERTIES FOLDER "Tests") + +add_executable(test-communication src/test-communication.cpp) +target_link_libraries(test-communication uscxml) +add_test(test-communication test-communication) +set_target_properties(test-communication PROPERTIES FOLDER "Tests") + +add_executable(test-eventdelay src/test-eventdelay.cpp) +target_link_libraries(test-eventdelay uscxml) +add_test(test-eventdelay test-eventdelay) +set_target_properties(test-eventdelay PROPERTIES FOLDER "Tests") diff --git a/test/samples/apache/actions-initial-test.xml b/test/samples/apache/actions-initial-test.xml new file mode 100644 index 0000000..d2d3e48 --- /dev/null +++ b/test/samples/apache/actions-initial-test.xml @@ -0,0 +1,57 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + xmlns:cs="http://commons.apache.org/scxml" + version="1.0" + initial="actionsTest"> + + <state id="actionsTest"> + <initial> + <transition target="child1"> + <cs:var name="foo"/> + <cs:var name="delta" expr="${1+2+3}" /> + <cs:var name="eventsent"/> + <if cond="${delta le 3}"> + <assign name="foo" expr="bar" /> + <elseif cond="${delta eq 3}"/> + <assign name="foo" expr="fubar" /> + <else/> + <assign name="foo" expr="foobar" /> + </if> + <cs:var name="drink" expr="water" /> + <cs:var name="eat" expr="flies" /> + <send sendid="send12345" target="freddy" type="frog" + event="croak" namelist="drink eat" hints="h2o bzz" + delay="${1000+500}" /> + <cancel sendId="send12345"/> + <log expr="leaving" label="entry001" /> + <event name="event.test"/> + <!-- exit will be ignored, makes little sense in initial --> + <cs:exit expr="later" namelist="freddy" /> + </transition> + </initial> + + <transition event="event.test"> + <assign name="eventsent" expr="true"/> + </transition> + + <state id="child1"/> + + </state> + +</scxml>
\ No newline at end of file diff --git a/test/samples/apache/actions-parallel-test.xml b/test/samples/apache/actions-parallel-test.xml new file mode 100644 index 0000000..be9d25c --- /dev/null +++ b/test/samples/apache/actions-parallel-test.xml @@ -0,0 +1,55 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + xmlns:cs="http://commons.apache.org/scxml" + version="1.0" + initial="actionsTest"> + + <parallel id="actionsTest"> + <onentry> + <cs:var name="foo"/> + <cs:var name="delta" expr="${1+2+3}" /> + <cs:var name="eventsent"/> + <if cond="${delta le 3}"> + <assign name="foo" expr="bar" /> + <elseif cond="${delta eq 3}"/> + <assign name="foo" expr="fubar" /> + <else/> + <assign name="foo" expr="foobar" /> + </if> + <cs:var name="drink" expr="water" /> + <cs:var name="eat" expr="flies" /> + <send sendid="send12345" target="freddy" type="frog" + event="croak" namelist="drink eat" hints="h2o bzz" + delay="${1000+500}" /> + <cancel sendId="send12345"/> + <log expr="leaving" label="entry001" /> + <event name="event.test"/> + <cs:exit expr="later" namelist="freddy" /> + </onentry> + + <transition event="event.test"> + <assign name="eventsent" expr="true"/> + </transition> + + <!-- dummy regions --> + <state id="state01"/> + <state id="state02"/> + </parallel> + +</scxml>
\ No newline at end of file diff --git a/test/samples/apache/actions-state-test.xml b/test/samples/apache/actions-state-test.xml new file mode 100644 index 0000000..3374e21 --- /dev/null +++ b/test/samples/apache/actions-state-test.xml @@ -0,0 +1,52 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + xmlns:cs="http://commons.apache.org/scxml" + version="1.0" + initialstate="actionsTest"> + + <state id="actionsTest" final="true"> + <onentry> + <cs:var name="foo"/> + <cs:var name="delta" expr="${1+2+3}" /> + <cs:var name="eventsent"/> + <if cond="${delta le 3}"> + <assign name="foo" expr="bar" /> + <elseif cond="${delta eq 3}"/> + <assign name="foo" expr="fubar" /> + <else/> + <assign name="foo" expr="foobar" /> + </if> + <cs:var name="drink" expr="water" /> + <cs:var name="eat" expr="flies" /> + <send sendid="send12345" target="freddy" type="frog" + event="croak" namelist="drink eat" hints="h2o bzz" + delay="${1000+500}" /> + <cancel sendId="send12345"/> + <log expr="leaving" label="entry001" /> + <event name="event.test"/> + <cs:exit expr="later" namelist="freddy" /> + </onentry> + + <transition event="event.test"> + <assign name="eventsent" expr="true"/> + </transition> + + </state> + +</scxml>
\ No newline at end of file diff --git a/test/samples/apache/assign-test-01.xml b/test/samples/apache/assign-test-01.xml new file mode 100644 index 0000000..ed7e977 --- /dev/null +++ b/test/samples/apache/assign-test-01.xml @@ -0,0 +1,70 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<!-- Test "src" attribute of assign element --> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + xmlns:rad="http://foo/bar" + version="1.0" + initialstate="assign1"> + + <state id="assign1" final="true"> + + <datamodel> + <data id="foo"> + <root xmlns=""> + <foo/> + </root> + </data> + <data id="bar"> + <root xmlns=""> + <bar>5</bar> + </root> + </data> + </datamodel> + + <onentry> + <assign location="Data(foo,'root/foo')" src="assign-src.xml"/> + </onentry> + + <transition cond="Data(foo,'root/foo/a') + Data(bar,'root/bar') eq 15" + target="assign2" /> + + </state> + + <state id="assign2"> + + <datamodel> + <data id="jira51data1"> + <rad:timeout>10</rad:timeout> + </data> + <data id="jira51data2"> + <rad:short xmlns="">20</rad:short> + </data> + </datamodel> + + <onentry> + <assign location="Data(jira51data1,'rad:timeout')" expr="Data(jira51data2,'rad:short')"/> + </onentry> + + <transition cond="Data(jira51data1,'rad:timeout') eq 20" + target="assign3" /> + + </state> + + <state id="assign3" final="true"/> + +</scxml> diff --git a/test/samples/apache/assign-test-02.xml b/test/samples/apache/assign-test-02.xml new file mode 100644 index 0000000..38ab9b3 --- /dev/null +++ b/test/samples/apache/assign-test-02.xml @@ -0,0 +1,46 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<!-- Regress JIRA 89, incomplete child removal --> +<scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:rad="http://foo/bar" version="1.0" initialstate="assign1"> + <datamodel> + <data name="source"> + <rad:foo> + <rad:a>1</rad:a> + <rad:b>2</rad:b> + </rad:foo> + </data> + <data name="destination"> + <rad:bar> + <rad:a>3</rad:a> + <rad:b>4</rad:b> + </rad:bar> + </data> + </datamodel> + <!-- verify the destination contents --> + <state id="assign1" final="true"> + <transition cond="Data(destination,'rad:bar/rad:a') eq 3 and Data(destination,'rad:bar/rad:b') eq 4" target="assign2" /> + </state> + <!-- copy the new contents and verify --> + <state id="assign2"> + <onentry> + <assign location="Data(destination,'rad:bar')" expr="Data(source,'rad:foo')" /> + </onentry> + <transition cond="Data(destination,'rad:bar/rad:a') eq 1 and Data(destination,'rad:bar/rad:b') eq 2" target="assign3" /> + </state> + <state id="assign3" final="true" /> +</scxml> diff --git a/test/samples/apache/bar.xml b/test/samples/apache/bar.xml new file mode 100644 index 0000000..3901080 --- /dev/null +++ b/test/samples/apache/bar.xml @@ -0,0 +1,25 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initialstate="bar"> + + <state id="bar"/> + +</scxml> + diff --git a/test/samples/apache/custom-hello-world-01.xml b/test/samples/apache/custom-hello-world-01.xml new file mode 100644 index 0000000..5d8a348 --- /dev/null +++ b/test/samples/apache/custom-hello-world-01.xml @@ -0,0 +1,37 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<!-- Used for comparison with hello-world.xml by + CustomActionTest.java in model package --> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + xmlns:my="http://my.custom-actions.domain/CUSTOM1" + xmlns:foo="http://my.custom-actions.domain/CUSTOM2" + version="1.0" + initialstate="custom"> + + <state id="custom" final="true"> + + <onentry> + <my:hello name="world" /> + <!-- foo:bar also maps to Hello action --> + <foo:bar name="custom action" /> + </onentry> + + </state> + +</scxml> + diff --git a/test/samples/apache/custom-hello-world-02.xml b/test/samples/apache/custom-hello-world-02.xml new file mode 100644 index 0000000..7b27ccf --- /dev/null +++ b/test/samples/apache/custom-hello-world-02.xml @@ -0,0 +1,33 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<!-- Used for CustomActionTest.java in model package --> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + xmlns:my="http://my.custom-actions.domain/CUSTOM" + version="1.0" + initialstate="custom"> + + <state id="custom" final="true"> + + <onentry> + <my:hello name="child (included) document" /> + </onentry> + + </state> + +</scxml> + diff --git a/test/samples/apache/custom-hello-world-03.xml b/test/samples/apache/custom-hello-world-03.xml new file mode 100644 index 0000000..c8cfc5e --- /dev/null +++ b/test/samples/apache/custom-hello-world-03.xml @@ -0,0 +1,33 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<!-- Used for CustomActionTest.java in model package --> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + xmlns:my="http://my.custom-actions.domain/CUSTOM" + version="1.0" + initialstate="custom"> + + <state id="custom" final="true"> + + <onentry> + <my:send name="overridden local name" /> + </onentry> + + </state> + +</scxml> + diff --git a/test/samples/apache/custom-hello-world-04-el.xml b/test/samples/apache/custom-hello-world-04-el.xml new file mode 100644 index 0000000..0d5300b --- /dev/null +++ b/test/samples/apache/custom-hello-world-04-el.xml @@ -0,0 +1,44 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<!-- Used for CustomActionTest.java in model package --> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + xmlns:my="http://my.custom-actions.domain/CUSTOM" + version="1.0" initialstate="init"> + <datamodel> + <data id="helloName1" /> + </datamodel> + + <state id="init"> + <onentry> + <my:hello name="custom04" /> + </onentry> + + <transition event="helloevent" target="middle1"> + <assign name="helloName1" expr="${_eventdatamap.helloevent}" /> + </transition> + </state> + + <state id="middle1"> + <transition target="custom" cond="${helloName1 eq 'custom04'}" /> + </state> + + <state id="custom" final="true"/> + +</scxml> + + diff --git a/test/samples/apache/custom-hello-world-04-jexl.xml b/test/samples/apache/custom-hello-world-04-jexl.xml new file mode 100644 index 0000000..c44e9b3 --- /dev/null +++ b/test/samples/apache/custom-hello-world-04-jexl.xml @@ -0,0 +1,62 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<!-- Used for CustomActionTest.java in model package --> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + xmlns:my="http://my.custom-actions.domain/CUSTOM" + version="1.0" initialstate="init"> + <datamodel> + <data id="helloName1" /> + </datamodel> + + <state id="init"> + <onentry> + <my:hello name="custom04a" /> + </onentry> + + <transition event="helloevent" target="middle1"> + <assign name="helloName1" expr="_eventdatamap['helloevent']" /> + </transition> + </state> + + <state id="middle1"> + <transition target="custom1" cond="helloName1 eq 'custom04a'" /> + </state> + + <state id="custom1"> + <transition event="custom.next" target="custom2"/> + </state> + + <state id="custom2"> + <onentry> + <my:hello name="custom04b" /> + </onentry> + + <transition event="helloevent" target="custom3"> + <assign name="helloName1" expr="_eventdatamap.helloevent" /> + </transition> + </state> + + <state id="custom3"> + <transition target="end" cond="helloName1 eq 'custom04b'" /> + </state> + + <state id="end" final="true"/> + +</scxml> + + diff --git a/test/samples/apache/datamodel-01.xml b/test/samples/apache/datamodel-01.xml new file mode 100644 index 0000000..cc874fb --- /dev/null +++ b/test/samples/apache/datamodel-01.xml @@ -0,0 +1,107 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<!-- A fictitious state machine used by test cases. + Meant to illustrate the usage of SCXML <datamodel> element + and the Commons SCXML Data() function --> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initialstate="main"> + + <!-- Root or document datamodel --> + <datamodel> + <data id="docdata"> + <root xmlns=""> + <foo>foo</foo> + </root> + </data> + </datamodel> + + <state id="main"> + + <initial> + <transition target="ten"/> + </initial> + + <!-- datamodel scoped to state "main" --> + <datamodel> + <data id="mainvar" expr="${0}" /> + <data id="maindata"> + <root xmlns=""> + <foo> + <bar>bar</bar> + </foo> + </root> + </data> + </datamodel> + + <state id="ten"> + <onentry> + <!-- Assign Usage 1: name is previously defined + <var> or degenerate <data> (as in this case) --> + <assign name="mainvar" expr="${10}" /> + </onentry> + <!-- Commons SCXML defines a Data() function to use in conjunction + with the Commons EL expression language. The + first argument is the named XML data tree and the second is + the XPath expression to a node whose value is to be + examined --> + <transition event="ten.done" + cond="${mainvar eq 10 and Data(maindata,'root/foo/bar') eq 'bar'}" + target="twenty" /> + <onexit> + <!-- Assign Usage 2: location must point to an existing + node --> + <assign location="${Data(maindata,'root/foo/bar')}" expr="baz" /> + </onexit> + </state> + + <state id="twenty"> + <onentry> + <assign name="mainvar" expr="${20}" /> + </onentry> + <transition event="twenty.done" + cond="${Data(maindata,'root/foo/bar') eq 'baz' and mainvar eq 20}" + target="thirty" /> + <onexit> + <!-- Assign Usage 3: location points to an existing + node, and expr points to an existing node. + In this case, location adopts expr's child nodes. --> + <assign location="${Data(docdata,'root/foo')}" + expr="${Data(maindata,'root/foo')}" /> + <assign location="${Data(docdata,'root/foo/bar')}" + expr="${10}" /> + </onexit> + </state> + + <state id="thirty"> + <!-- Arithmetic operations are possible with results from + the Data() function. Note that data "docdata" + did not have a node at 'root/foo/bar' to begin with, + the XML tree was manipulated by the <assign> above --> + <transition event="thirty.done" + cond="${Data(docdata,'root/foo/bar') gt 5}" + target="forty" /> + </state> + + <state id="forty" final="true" /> + + </state> + +</scxml> + + diff --git a/test/samples/apache/datamodel-02.xml b/test/samples/apache/datamodel-02.xml new file mode 100644 index 0000000..b719b8b --- /dev/null +++ b/test/samples/apache/datamodel-02.xml @@ -0,0 +1,83 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<!-- A fictitious state machine used by test cases. Meant to illustrate + prefixed XPath expressions in the Commons SCXML Data() function --> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initialstate="ten"> + + <!-- Start with a prefixless XPath (see transition cond) --> + <state id="ten"> + + <datamodel> + <data id="data10"> + <root xmlns=""> + <foo>10</foo> + </root> + </data> + </datamodel> + + <transition event="ten.done" cond="${Data(data10,'root/foo') eq 10}" + target="twenty" /> + + </state> + + <!-- Already defined (and identical) prefixes --> + <state id="twenty" xmlns:ns1="http://namespace.test.domain/1" + xmlns:ns2="http://namespace.test.domain/2"> + + <datamodel> + <!-- Start with a prefixless XPath --> + <data id="data20"> + <ns1:root> + <ns2:foo>20</ns2:foo> + </ns1:root> + </data> + </datamodel> + + <transition event="twenty.done" cond="${Data(data20,'ns1:root/ns2:foo') eq 20}" + target="thirty" /> + + </state> + + <!-- Data without prefixes --> + <state id="thirty"> + + <datamodel> + <!-- Start with a prefixless XPath --> + <data id="data30"> + <root xmlns="http://namespace.test.domain/1"> + <foo xmlns="http://namespace.test.domain/2">30</foo> + </root> + </data> + </datamodel> + + <transition event="thirty.done" + xmlns:ns1="http://namespace.test.domain/1" + xmlns:ns2="http://namespace.test.domain/2" + xmlns:ns3="http://namespace.test.domain/3" + cond="${Data(data30,'ns1:root/ns2:foo') eq 30}" + target="forty" /> + + </state> + + <state id="forty" final="true" /> + +</scxml> + + diff --git a/test/samples/apache/datamodel-03.xml b/test/samples/apache/datamodel-03.xml new file mode 100644 index 0000000..f8a3310 --- /dev/null +++ b/test/samples/apache/datamodel-03.xml @@ -0,0 +1,259 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<!-- A fictitious state machine used by test cases. Meant to illustrate + prefixed XPath expressions in the Commons SCXML Data() function. + Used by org.apache.commons.scxml.NamespacePrefixedPathsTest + Also serves as testing the underlying functionality of the + underlying parsing technology (here, Digester 1.8) --> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + xmlns:cs="http://commons.apache.org/scxml" + version="1.0" + initialstate="ten"> + + <!-- Root data model --> + <datamodel> + + <!-- We'll use this for XPaths --> + <data id="rootdata" + xmlns:ns1="scheme://namespace.test.domain/1" + xmlns:ns2="scheme://namespace.test.domain/2" + xmlns:ns3="scheme://namespace.test.domain/3"> + <ns1:root> + <ns2:foo> + <ns3:bar>1</ns3:bar> + </ns2:foo> + </ns1:root> + </data> + + <!-- We'll use this for the JUnit test + NamespacePrefixedPathsTest.java (scxml package) --> + <data id="retval" /> + + </datamodel> + + <!-- State data model --> + <state id="ten"> + + <datamodel> + + <data id="data10" xmlns:ns4="scheme://namespace.test.domain/1"> + <root xmlns=""> + <ns4:foo> + <bar>10</bar> + </ns4:foo> + </root> + </data> + + </datamodel> + + <onentry> + <cs:var xmlns:pre1="scheme://namespace.test.domain/1" + xmlns:pre2="scheme://namespace.test.domain/2" + xmlns:pre3="scheme://namespace.test.domain/3" + name="tentest" + expr="${Data(rootdata,'pre1:root/pre2:foo/pre3:bar') + Data(data10,'root/pre1:foo/bar')}" /> + </onentry> + + <transition event="ten.done" + cond="${tentest eq 11}" + target="twenty" /> + + <onexit> + <assign name="retval" + expr="${tentest}" /> + </onexit> + + </state> + + <!-- Already defined (and different) prefixes --> + <state id="twenty" xmlns:ns1="scheme://namespace.test.domain/1" + xmlns:ns2="scheme://namespace.test.domain/2" + xmlns:ns3="scheme://namespace.test.domain/3"> + + <datamodel> + + <data id="data20"> + <ns1:root> + <ns2:foo>20</ns2:foo> + </ns1:root> + </data> + + </datamodel> + + <onentry> + <assign location="${Data(rootdata,'ns1:root/ns2:foo/ns3:bar')}" + expr="${2}" /> + </onentry> + + + <!-- Redefine namespace prefixes --> + <transition event="twenty.done" + xmlns:ns1="scheme://namespace.test.domain/1" + xmlns:ns2="scheme://namespace.test.domain/2" + cond="${Data(data20,'ns1:root/ns2:foo') eq 20 and Data(rootdata,'ns1:root/ns2:foo/ns3:bar') eq 2}" + target="thirty" /> + + <onexit> + + <!-- Redefine different prefixes bound to above namespaces --> + <if xmlns:pre1="scheme://namespace.test.domain/1" + xmlns:pre2="scheme://namespace.test.domain/2" + cond="${Data(data20,'pre1:root/pre2:foo') lt 20}"> + + <assign name="retval" expr="Less than 20" /> + + <elseif cond="${Data(data20,'pre1:root/pre2:foo') eq 20}" /> + + <assign name="retval" expr="Equal to 20" /> + + <else/> + + <assign name="retval" expr="Greater than 20" /> + + </if> + + </onexit> + + </state> + + <!-- XPath looking at attribute --> + <state id="thirty"> + + <datamodel> + + <data id="data30"> + <root xmlns="scheme://namespace.test.domain/1"> + <foo xmlns="scheme://namespace.test.domain/2" + xmlns:ns1="scheme://namespace.test.domain/3" + ns1:attfoo="30" attbar="300"/> + </root> + </data> + + </datamodel> + + <transition event="thirty.done" + xmlns:ns1="scheme://namespace.test.domain/1" + xmlns:ns2="scheme://namespace.test.domain/2" + xmlns:ns3="scheme://namespace.test.domain/3" + cond="${Data(data30,'ns1:root/ns2:foo/@ns3:attfoo') + Data(data30,'ns1:root/ns2:foo/@attbar') eq 330}" + target="forty" /> + + </state> + + <!-- Multiple data, already defined prefixes --> + <state id="forty" xmlns:ns1="scheme://namespace.test.domain/1" + xmlns:ns2="scheme://namespace.test.domain/2" + xmlns:ns3="scheme://namespace.test.domain/3" + xmlns:ns4="scheme://namespace.test.domain/4"> + + <datamodel> + + <data id="data40"> + <root xmlns=""> + <ns1:foo ns2:attfoo="40"/> + </root> + </data> + + <data id="data41"> + <ns3:root> + <ns4:foo>41</ns4:foo> + </ns3:root> + </data> + + </datamodel> + + <transition event="forty.done" + cond="${Data(data40,'root/ns1:foo/@ns2:attfoo') + Data(data41,'ns3:root/ns4:foo') eq 81}" + target="fifty" /> + + </state> + + <!-- Multiple data, prefixes on elements --> + <state id="fifty"> + + <datamodel> + + <data id="data50" xmlns:ns1="scheme://namespace.test.domain/1" + xmlns:ns2="scheme://namespace.test.domain/2" + xmlns:ns3="scheme://namespace.test.domain/3"> + <ns1:root> + <ns2:foo ns3:attfoo="50"/> + </ns1:root> + </data> + + <data id="data51" xmlns:ns3="scheme://namespace.test.domain/3" + xmlns:ns4="scheme://namespace.test.domain/4"> + <ns3:root> + <ns4:foo attfoo="51"/> + </ns3:root> + </data> + + </datamodel> + + <transition event="fifty.done" + xmlns:ns1="scheme://namespace.test.domain/1" + xmlns:ns2="scheme://namespace.test.domain/2" + xmlns:ns3="scheme://namespace.test.domain/3" + xmlns:ns4="scheme://namespace.test.domain/4" + cond="${Data(data50,'ns1:root/ns2:foo/@ns3:attfoo') + Data(rootdata,'ns1:root/ns2:foo/ns3:bar') eq 52}" + target="sixty" /> + + </state> + + <!-- Multiple data, prefixes on datamodel and transition elements --> + <state id="sixty"> + + <datamodel xmlns:ns1="scheme://namespace.test.domain/1" + xmlns:ns2="scheme://namespace.test.domain/2" + xmlns:ns3="scheme://namespace.test.domain/3" + xmlns:ns4="scheme://namespace.test.domain/4"> + + <data id="data60"> + <root xmlns=""> + <ns1:foo ns2:attfoo="60"/> + </root> + </data> + + <data id="data61"> + <ns3:root> + <ns4:foo attfoo="61"/> + </ns3:root> + </data> + + </datamodel> + + <transition event="sixty.done" + xmlns:pre1="scheme://namespace.test.domain/1" + xmlns:pre2="scheme://namespace.test.domain/2" + xmlns:pre3="scheme://namespace.test.domain/3" + xmlns:pre4="scheme://namespace.test.domain/4" + cond="${Data(data60,'root/pre1:foo/@pre2:attfoo') + Data(data61,'pre3:root/pre4:foo/@attfoo') eq 121}" + target="seventy"> + + <!-- should be 121 --> + <log expr="${Data(data60,'root/pre1:foo/@pre2:attfoo') + Data(data61,'pre3:root/pre4:foo/@attfoo')}"/> + + </transition> + + </state> + + <state id="seventy" final="true" /> + +</scxml> + + diff --git a/test/samples/apache/datamodel-04.xml b/test/samples/apache/datamodel-04.xml new file mode 100644 index 0000000..503a858 --- /dev/null +++ b/test/samples/apache/datamodel-04.xml @@ -0,0 +1,48 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<!-- A fictitious state machine used by test cases. + Meant to illustrate the usage of SCXML <datamodel> element + to persist some _eventdata --> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initialstate="ten"> + + <!-- Root or document datamodel --> + <datamodel> + <data id="payload"/> + </datamodel> + + <state id="ten"> + <transition event="ten.done" target="twenty"> + <assign name="payload" expr="_eventdata" /> + </transition> + </state> + + <state id="twenty"> + <transition event="twenty.done" target="thirty" /> + <onexit> + <log label="Persisted eventdata.one" expr="payload.one"/> + <log label="Persisted eventdata.two" expr="payload.two"/> + </onexit> + </state> + + <state id="thirty" final="true"/> + +</scxml> + + diff --git a/test/samples/apache/edit-profile-config.xml b/test/samples/apache/edit-profile-config.xml new file mode 100644 index 0000000..cdab498 --- /dev/null +++ b/test/samples/apache/edit-profile-config.xml @@ -0,0 +1,149 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + + $Id: edit-profile-config.xml 462838 2006-10-11 16:08:36Z rahul $ + +--> + +<!-- + + Dialog definitions for Shale Use Cases Example Web Application + written out as SCXML to demonstrate use of Commons SCXML as one + of Shale's Dialog Manager implementations. + + Related artifacts from <dialog name="Edit Profile">...</dialog> + in original dialogs definition file from Shale nightlies. + +--> + +<scxml xmlns="http://www.w3.org/2005/01/SCXML" version="1.0" + initialstate="edit"> + + <state id="edit"> + + <initial> + <transition> + <target next="setup"/> + </transition> + </initial> + + <!-- global transitions (within state "edit") --> + + <transition event="faces.outcome" + cond="${outcome eq 'cancel'}"> + <target next="cancel"/> + </transition> + + <transition event="faces.outcome" + cond="${outcome eq 'finish'}"> + <target next="finish"/> + </transition> + + <state id="setup"> + + <onentry> + <var name="setupOutcome" + expr="#{profile$edit.setup}" /> + </onentry> + + <transition cond="${setupOutcome eq 'success'}"> + <target next="page1"/> + </transition> + + </state> + + <state id="page1"> + + <transition event="faces.outcome" + cond="${outcome eq 'next'}"> + <target next="page2"/> + </transition> + + </state> + + <state id="page2"> + + <transition event="faces.outcome" + cond="${outcome eq 'previous'}"> + <target next="page1"/> + </transition> + + <transition event="faces.outcome" + cond="${outcome eq 'next'}"> + <target next="page3"/> + </transition> + + </state> + + <state id="page3"> + + <transition event="faces.outcome" + cond="${outcome eq 'previous'}"> + <target next="page2"/> + </transition> + + <transition event="faces.outcome" + cond="${outcome eq 'next'}"> + <target next="editExit"/> + </transition> + + </state> + + </state> + + <state id="cancel"> + + <onentry> + <var name="cancelOutcome" + expr="#{profile$edit.cancel}" /> + </onentry> + + <transition cond="${cancelOutcome eq 'success'}"> + <var name="outcome" + expr="cancel"/> + <target next="editExit"/> + </transition> + + </state> + + <state id="finish"> + + <onentry> + <var name="finishOutcome" + expr="#{profile$edit.finish}" /> + </onentry> + + <transition cond="${finishOutcome eq 'username'}"> + <target next="page1"/> + </transition> + + <transition cond="${finishOutcome eq 'password'}"> + <target next="page1"/> + </transition> + + <transition cond="${finishOutcome eq 'success'}"> + <var name="outcome" + expr="success"/> + <target next="editExit"/> + </transition> + + </state> + + <state id="editExit" + final="true" /> + +</scxml> diff --git a/test/samples/apache/eventdata-01.xml b/test/samples/apache/eventdata-01.xml new file mode 100644 index 0000000..c07d42d --- /dev/null +++ b/test/samples/apache/eventdata-01.xml @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + datamodel="ecmascript" + initialstate="state1"> + <state id="state1"> + <transition event="event.foo" cond="_event.data == 2" + target="state2"/> + <transition event="event.foo" cond="_event.data == 3" + target="state3"/> + <transition event="event.foo"> + <log expr="'event.name: ' + _event.name" /> + </transition> + </state> + <state id="state2" final="true"/> + <state id="state3"> + <transition event="event.bar" target="state4" + cond="_event.data == 4"/> + <transition event="event.bar" target="state5" + cond="_event.data == 5"/> + <transition event="event.bar" target="state6" + cond="_event.data == 6"/> + </state> + <state id="state4" final="true"/> + <state id="state5" final="true"/> + <state id="state6"> + <transition event="event.baz" target="state7" + cond="_event.data == 7"/> + </state> + <state id="state7" final="true"/> +</scxml> diff --git a/test/samples/apache/eventdata-02.xml b/test/samples/apache/eventdata-02.xml new file mode 100644 index 0000000..df130ae --- /dev/null +++ b/test/samples/apache/eventdata-02.xml @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + datamodel="ecmascript" + initialstate="state0"> + <state id="state0"> + <!-- Payload can be any object, such as a String ... --> + <transition event="connection.alerting" + cond="_event.data == 'line1'" target="state1"/> + <transition event="connection.alerting" + cond="_event.data == 'line2'" target="state2"/> + </state> + <state id="state1" final="true"/> + <state id="state2"> + <!-- ... or an arbitrary, user defined object. --> + <transition event="connection.alerting" + cond="_event.data.line == 3" target="state3"/> + <transition event="connection.alerting" + cond="_event.data.line == 4" target="state4"/> + </state> + <state id="state3" final="true"/> + <state id="state4" final="true"/> +</scxml> diff --git a/test/samples/apache/eventdata-03.xml b/test/samples/apache/eventdata-03.xml new file mode 100644 index 0000000..d4c4388 --- /dev/null +++ b/test/samples/apache/eventdata-03.xml @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + xmlns:cs="http://commons.apache.org/scxml" + version="1.0" + initialstate="ten"> + + <datamodel> + <data id="rootdata"> + <root xmlns=""> + <one>1</one> + <two>2</two> + </root> + </data> + </datamodel> + + <state id="ten"> + <transition event="event.foo" target="twenty"/> + </state> + + <state id="twenty"> + <onentry> + <cs:var name="one" expr="Data(rootdata,'root/one')"/> + <cs:var name="two" expr="Data(rootdata,'root/two')"/> + <send event="'event.bar'" namelist="one two"/> + </onentry> + <transition event="event.bar" + cond="_eventdatamap['event.bar'].one + _eventdatamap['event.bar'].two eq 3" + target="thirty"/> + </state> + + <state id="thirty" final="true"/> + +</scxml> diff --git a/test/samples/apache/eventdata-04.xml b/test/samples/apache/eventdata-04.xml new file mode 100644 index 0000000..541d2e9 --- /dev/null +++ b/test/samples/apache/eventdata-04.xml @@ -0,0 +1,57 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initialstate="start"> + + <parallel id="start"> + + <state id="simulatedUser"> + <datamodel> + <data name="one" expr="1" /> + <data name="two" expr="2" /> + </datamodel> + + <onentry> + <send event="'event.bar'" namelist="one two" delay="'100ms'"/> + </onentry> + <transition event="event.bar"> + <log label="'simulatedUser'" expr="_eventdatamap['event.bar'].one + ', ' + _eventdatamap['event.bar'].two"/> + </transition> + </state> + + <state id="counter"> + <initial> + <transition target="twenty"/> + </initial> + + <state id="twenty"> + <transition event="event.bar" + cond="_eventdatamap['event.bar'].one + _eventdatamap['event.bar'].two eq 3" + target="thirty"/> + <transition event="event.bar"> + <log label="'event.bar in twenty state'" expr="_eventdatamap['event.bar'].one + ', ' + _eventdatamap['event.bar'].two"/> + </transition> + </state> + + <state id="thirty" final="true"/> + </state> + + </parallel> + +</scxml> diff --git a/test/samples/apache/external-hello-world.xml b/test/samples/apache/external-hello-world.xml new file mode 100644 index 0000000..b6d1b9f --- /dev/null +++ b/test/samples/apache/external-hello-world.xml @@ -0,0 +1,33 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<!-- Used for testing custom actions in external document pulled in via + the src attributes by ExternalCustomActionTest.java in model package --> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + xmlns:my="http://my.custom-actions.domain/CUSTOM" + version="1.0" + initialstate="external-hello"> + + <state id="external-hello" final="true" src="custom-hello-world-02.xml"> + + <onentry> + <my:hello name="parent document" /> + </onentry> + + </state> + +</scxml> diff --git a/test/samples/apache/foo.xml b/test/samples/apache/foo.xml new file mode 100644 index 0000000..486d36e --- /dev/null +++ b/test/samples/apache/foo.xml @@ -0,0 +1,25 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initialstate="foo"> + + <state id="foo"/> + +</scxml> + diff --git a/test/samples/apache/hello-world.xml b/test/samples/apache/hello-world.xml new file mode 100644 index 0000000..7647899 --- /dev/null +++ b/test/samples/apache/hello-world.xml @@ -0,0 +1,31 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<!-- Used for comparison with custom-hello-world.xml by + CustomActionTest.java in model package --> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initialstate="hello"> + + <state id="hello" final="true"> + <onentry> + <log expr="'hello world'" /> + </onentry> + </state> + +</scxml> + diff --git a/test/samples/apache/history-deep-01.xml b/test/samples/apache/history-deep-01.xml new file mode 100644 index 0000000..209a974 --- /dev/null +++ b/test/samples/apache/history-deep-01.xml @@ -0,0 +1,75 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<!-- + This document is an example of using deep history +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" + initialstate="flow"> + + <state id="flow"> + <initial> + <transition target="phases"/> + </initial> + + <!-- deep history is specified by setting the type attribute + to "deep" --> + + <history id="hist" type="deep"> + + <!-- This is the transition to be followed if no + prior history is available --> + + <transition target="phases"/> + + </history> + + <state id="phases"> + + <initial> + <transition target="phase1"/> + </initial> + + <state id="phase1"> + <transition event="phase.done" target="phase2"/> + </state> + + <state id="phase2"> + <transition event="phase.done" target="phase3"/> + </state> + + <state id="phase3" final="true" /> + + </state> + + <transition event="flow.pause" target="interrupted"/> + + <transition event="flow.terminate" target="terminated"/> + + </state> + + <state id="interrupted"> + + <transition event="flow.resume" target="hist"/> + + <transition event="flow.terminate" target="terminated"/> + + </state> + + <state id="terminated" final="true"/> + +</scxml> diff --git a/test/samples/apache/history-default-01.xml b/test/samples/apache/history-default-01.xml new file mode 100644 index 0000000..cf2f70f --- /dev/null +++ b/test/samples/apache/history-default-01.xml @@ -0,0 +1,90 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<!-- + This document is an example of specifying default transitions for + history states (if the parent state has never been visited before) +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" + initialstate="state1"> + + <state id="state1"> + <initial> + <transition target="history1"/> + </initial> + + <!-- shallow history, explicit default transition --> + + <history id="history1"> + <transition next="state11"/> + </history> + + <state id="state11"> + <transition event="state.next" target="state2"/> + </state> + + </state> + + <state id="state2"> + <initial> + <transition target="history2"/> + </initial> + + <!-- deep history, explicit default transition --> + + <history id="history2" type="deep"> + <transition next="state211"/> + </history> + + <state id="state21"> + + <initial> + <transition target="state212"/> + </initial> + + <state id="state211"> + <transition event="state.next" target="history3"/> + </state> + + <state id="state212"> + <transition event="state.next" target="history3"/> + </state> + + </state> + + </state> + + <state id="state3"> + + <initial> + <transition target="state31"/> + </initial> + + <!-- shallow history, no default transition specified, + reuse initial as default transition --> + + <history id="history3"/> + + <state id="state31"> + <transition event="state.next" target="state4"/> + </state> + + </state> + + <state id="state4" final="true"/> + +</scxml> diff --git a/test/samples/apache/history-shallow-01.xml b/test/samples/apache/history-shallow-01.xml new file mode 100644 index 0000000..20b5bb5 --- /dev/null +++ b/test/samples/apache/history-shallow-01.xml @@ -0,0 +1,67 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<!-- + This document is an example of using shallow history +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" + initialstate="flow"> + + <state id="flow"> + <initial> + <transition target="phase1"/> + </initial> + + <!-- history defaults to shallow, optionally one can set + the type attribute to "shallow" for identical results --> + + <history id="hist"> + + <!-- This is the transition to be followed if no + prior history is available --> + + <transition target="phase1"/> + + </history> + + <state id="phase1"> + <transition event="phase.done" target="phase2"/> + </state> + + <state id="phase2"> + <transition event="phase.done" target="phase3"/> + </state> + + <state id="phase3" final="true"/> + + <transition event="flow.pause" target="interrupted"/> + + <transition event="flow.terminate" target="terminated"/> + + </state> + + <state id="interrupted"> + + <transition event="flow.resume" target="hist"/> + + <transition event="flow.terminate" target="terminated"/> + + </state> + + <state id="terminated" final="true"/> + +</scxml> diff --git a/test/samples/apache/invoked-01.xml b/test/samples/apache/invoked-01.xml new file mode 100644 index 0000000..a523995 --- /dev/null +++ b/test/samples/apache/invoked-01.xml @@ -0,0 +1,32 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initialstate="state1"> + + <state id="state1"> + <onentry> + <log expr="'foo is ' + foo + ' and bar is ' + bar" /> + </onentry> + <transition event="invoked.next" target="state2" /> + </state> + + <state id="state2" final="true" /> + +</scxml> + diff --git a/test/samples/apache/invoked-02.xml b/test/samples/apache/invoked-02.xml new file mode 100644 index 0000000..b1b471a --- /dev/null +++ b/test/samples/apache/invoked-02.xml @@ -0,0 +1,32 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initialstate="state1"> + + <state id="state1"> + <onentry> + <send event="'invoked.next'" /> + </onentry> + <transition event="invoked.next" target="state2" /> + </state> + + <state id="state2" final="true" /> + +</scxml> + diff --git a/test/samples/apache/invoked-03-01.xml b/test/samples/apache/invoked-03-01.xml new file mode 100644 index 0000000..3b73a66 --- /dev/null +++ b/test/samples/apache/invoked-03-01.xml @@ -0,0 +1,33 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<!-- Used by InvokeTest#testInvoke03Sample() --> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initialstate="s1"> + + <state id="s1"> + <onentry> + <log expr="' Inner invoke ...'"/> + </onentry> + <transition event="s1.next" target="s2"/> + </state> + + <state id="s2" final="true"/> + +</scxml> + diff --git a/test/samples/apache/invoked-03.xml b/test/samples/apache/invoked-03.xml new file mode 100644 index 0000000..91244e8 --- /dev/null +++ b/test/samples/apache/invoked-03.xml @@ -0,0 +1,37 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<!-- Used by InvokeTest#testInvoke03Sample() --> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initialstate="state1"> + + <state id="state1"> + <onentry> + <log expr="' Outer invoke ...'"/> + </onentry> + <invoke type="scxml" src="invoked-03-01.xml"/> + <transition event="state1.next" target="end1" /> + </state> + + <state id="end1" final="true"> + <onentry> + <log expr="' Inner invoke completed'"/> + </onentry> + </state> + +</scxml> diff --git a/test/samples/apache/invoker-01.xml b/test/samples/apache/invoker-01.xml new file mode 100644 index 0000000..5355896 --- /dev/null +++ b/test/samples/apache/invoker-01.xml @@ -0,0 +1,38 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initialstate="invoker"> + + <state id="invoker"> + <onentry> + <log expr="'Begin invoke test ...'" /> + </onentry> + <invoke type="scxml" src="invoked-01.xml"> + <param name="foo" expr="'foo'" /> + <param name="bar" expr="'bar'" /> + <finalize> + <log expr="'Finalizing ...'" /> + </finalize> + </invoke> + <transition event="invoker.invoke.done" target="end" /> + </state> + + <state id="end" final="true" /> + +</scxml> diff --git a/test/samples/apache/invoker-02.xml b/test/samples/apache/invoker-02.xml new file mode 100644 index 0000000..a6fb2cb --- /dev/null +++ b/test/samples/apache/invoker-02.xml @@ -0,0 +1,29 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initialstate="invoker"> + + <state id="invoker"> + <invoke type="scxml" src="invoked-02.xml"/> + <transition event="invoker.invoke.done" target="end" /> + </state> + + <state id="end" final="true" /> + +</scxml> diff --git a/test/samples/apache/invoker-03.xml b/test/samples/apache/invoker-03.xml new file mode 100644 index 0000000..be2d1fa --- /dev/null +++ b/test/samples/apache/invoker-03.xml @@ -0,0 +1,39 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<!-- Used by InvokeTest#testInvoke03Sample() --> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initialstate="invoker"> + + <state id="invoker"> + <onentry> + <log expr="'Invoker ...'"/> + </onentry> + <invoke type="scxml" src="invoked-03.xml"/> + <transition event="invoker.invoke.done" target="end"> + <log expr="' Outer invoke completed'"/> + </transition> + </state> + + <state id="end" final="true"> + <onentry> + <log expr="'Invoker completed'"/> + </onentry> + </state> + +</scxml> diff --git a/test/samples/apache/invoker-04.xml b/test/samples/apache/invoker-04.xml new file mode 100644 index 0000000..81c1bb8 --- /dev/null +++ b/test/samples/apache/invoker-04.xml @@ -0,0 +1,55 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<!-- A fictitious state machine used by test cases. + Meant to illustrate the usage of SCXML <param> element as part + of an invocation using a custom invoker --> + +<scxml xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initialstate="wait"> + + <datamodel> + <data id="foo"> + <bar>foo</bar> + </data> + </datamodel> + + <state id="wait"> + <transition event="test.trigger" target="first"/> + </state> + + <state id="first"> + <invoke src="FirstTestSrc" type="x-test"> + <param name="ding" expr="Data(foo,'node()')"/> + </invoke> + <transition event="test.trigger" target="second"/> + </state> + + <state id="second"> + <invoke src="SecondTestSrc" type="x-test"> + <param name="Data(foo,'node()')"/> + </invoke> + <transition event="test.trigger" target="third"/> + </state> + + <state id="third"> + <invoke src="ThirdTestSrc" type="x-test"> + <param name="Data(foo,'gibberish')"/> + </invoke> + </state> +</scxml>
\ No newline at end of file diff --git a/test/samples/apache/issue62-01-ext.xml b/test/samples/apache/issue62-01-ext.xml new file mode 100644 index 0000000..8c65a78 --- /dev/null +++ b/test/samples/apache/issue62-01-ext.xml @@ -0,0 +1,27 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" + initialstate="ext"> + + <state id="ext"> + <transition event="foo"> + <log expr="'Stay transition in issue 62 test'"/> + </transition> + </state> + +</scxml> diff --git a/test/samples/apache/issue62-01.xml b/test/samples/apache/issue62-01.xml new file mode 100644 index 0000000..3599e5e --- /dev/null +++ b/test/samples/apache/issue62-01.xml @@ -0,0 +1,29 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" + initialstate="s1"> + + <state id="s1"> + <initial> + <transition target="s1.1" /> + </initial> + <state id="s1.1" src="issue62-01-ext.xml#ext" /> + <state id="s1.2" src="issue62-01-ext.xml#ext" /> + </state> + +</scxml> diff --git a/test/samples/apache/issue62-02-ext.xml b/test/samples/apache/issue62-02-ext.xml new file mode 100644 index 0000000..98da5d6 --- /dev/null +++ b/test/samples/apache/issue62-02-ext.xml @@ -0,0 +1,39 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" + initialstate="e1"> + + <state id="e1"> + <initial> + <transition target="e1.1"/> + </initial> + <state id="e1.1"> + <initial> + <transition target="e1.1.1"/> + </initial> + <state id="e1.1.1"> + <transition event="bar" target="e1.1.2"/> + </state> + <state id="e1.1.2"> + <transition event="baz" target="e1.2"/> + </state> + </state> + <state id="e1.2" final="true"/> + </state> + +</scxml> diff --git a/test/samples/apache/issue62-02.xml b/test/samples/apache/issue62-02.xml new file mode 100644 index 0000000..8e52e42 --- /dev/null +++ b/test/samples/apache/issue62-02.xml @@ -0,0 +1,35 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" + initialstate="s1"> + + <state id="s1"> + <transition event="foo" target="s2" /> + </state> + + <state id="s2"> + <initial> + <transition target="s2.1"/> + </initial> + <state id="s2.1" src="issue62-02-ext.xml#e1" /> + <transition event="s2.1.done" target="s3"/> + </state> + + <state id="s3" final="true"/> + +</scxml> diff --git a/test/samples/apache/issue62-03-ext.xml b/test/samples/apache/issue62-03-ext.xml new file mode 100644 index 0000000..0168447 --- /dev/null +++ b/test/samples/apache/issue62-03-ext.xml @@ -0,0 +1,39 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" + initialstate="e1"> + + <state id="e1"> + <initial> + <transition target="e1.1"/> + </initial> + <state id="e1.1"> + <initial> + <transition target="e1.1.1"/> + </initial> + <state id="e1.1.1"> + <transition event="bar" target="e1.1.2"/> + </state> + <state id="e1.1.2"> + <transition event="baz" target="e1.2"/> + </state> + </state> + <final id="e1.2"/> + </state> + +</scxml> diff --git a/test/samples/apache/issue62-03.xml b/test/samples/apache/issue62-03.xml new file mode 100644 index 0000000..46b8991 --- /dev/null +++ b/test/samples/apache/issue62-03.xml @@ -0,0 +1,35 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" + initialstate="s1"> + + <state id="s1"> + <transition event="foo" target="s2" /> + </state> + + <state id="s2"> + <initial> + <transition target="s2.1"/> + </initial> + <state id="s2.1" src="issue62-03-ext.xml#e1" /> + <transition event="s2.1.done" target="s3"/> + </state> + + <final id="s3"/> + +</scxml> diff --git a/test/samples/apache/issue64-01.xml b/test/samples/apache/issue64-01.xml new file mode 100644 index 0000000..bb848fe --- /dev/null +++ b/test/samples/apache/issue64-01.xml @@ -0,0 +1,39 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<!-- Correct SCXML document --> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initialstate="tranbug"> + + <state id="tranbug"> + <datamodel> + <data id="dummy" expr="'somedata'"/> + </datamodel> + <onentry> + <log expr="'Begin transition bug test ...'" /> + </onentry> + <transition event="show.bug" target="end"> + <log expr="dummy" /> + <log expr="'*****' + dummy" /> + </transition> + </state> + <state id="end" final="true" /> + +</scxml> + + diff --git a/test/samples/apache/issue64-02.xml b/test/samples/apache/issue64-02.xml new file mode 100644 index 0000000..7e44d30 --- /dev/null +++ b/test/samples/apache/issue64-02.xml @@ -0,0 +1,55 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<!-- Bad SCXML document, many elements will be ignored with warnings from parser --> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + xmlns:my="http://my.foo.example/" + version="1.0" + initialstate="tranbug"> + + <datamodel> + <data id="foo"> + <alpha xmlns=""> + <beta/> + </alpha> + </data> + <misplaced/> + </datamodel> + + <state id="tranbug"> + <onentry> + <log expr="'Begin transition bug test ...'" /> + <foo/> + <my:bar/> + </onentry> + <transition event="show.bug" target="end"> + <!-- For example, FOLLOWING datamodel IS MISPLACED --> + <datamodel> + <data id="dummy" expr="'somedata'"/> + </datamodel> + <log expr="dummy" /> + <log expr="'*****' + dummy" /> + </transition> + </state> + + <my:baz/> + + <state id="end" final="true" /> + +</scxml> + + diff --git a/test/samples/apache/jsp-rootctx-test.xml b/test/samples/apache/jsp-rootctx-test.xml new file mode 100644 index 0000000..6a71579 --- /dev/null +++ b/test/samples/apache/jsp-rootctx-test.xml @@ -0,0 +1,31 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + xmlns:cs="http://commons.apache.org/scxml" + version="1.0" + initialstate="rootCtxTest"> + + <state id="rootCtxTest" final="true"> + <onentry> + <!-- 'foo' must exist in host JSP context --> + <assign name="foo" expr="${foo+1}" /> + <cs:var name="bar" expr="a brand new value" /> + </onentry> + </state> + +</scxml> diff --git a/test/samples/apache/log-on-config.xml b/test/samples/apache/log-on-config.xml new file mode 100644 index 0000000..b57780e --- /dev/null +++ b/test/samples/apache/log-on-config.xml @@ -0,0 +1,81 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + + $Id: log-on-config.xml 462838 2006-10-11 16:08:36Z rahul $ + +--> + +<!-- + + Dialog definitions for Shale Use Cases Example Web Application + written out as SCXML to demonstrate use of Commons SCXML as one + of Shale's Dialog Manager implementations. + + Related artifacts from <dialog name="Log On">...</dialog> + in original dialogs definition file from Shale nightlies. + +--> + +<scxml xmlns="http://www.w3.org/2005/01/SCXML" version="1.0" + initialstate="checkCookie"> + + + <state id="checkCookie"> + + <onentry> + <var name="cookieOutcome" + expr="#{profile$logon.check}" /> + </onentry> + + <transition cond="${cookieOutcome eq 'authenticated'}"> + <target next="exit"/> + </transition> + + <transition cond="${cookieOutcome eq 'unauthenticated'}"> + <target next="logon"/> + </transition> + + </state> + + <state id="logon"> + + <transition event="faces.outcome" + cond="${outcome eq 'authenticated'}"> + <target next="exit"/> + </transition> + + <transition event="faces.outcome" + cond="${outcome eq 'create'}"> + <target next="createProfile"/> + </transition> + + </state> + + <state id="createProfile" + src="edit-profile-config.xml" > + + <transition event="createProfile.done" + cond="${outcome eq 'success' or outcome eq 'cancel'}"> + <target next="exit"/> + </transition> + + </state> + + <state id="exit" + final="true" /> + +</scxml> diff --git a/test/samples/apache/microwave-01.xml b/test/samples/apache/microwave-01.xml new file mode 100644 index 0000000..86efa26 --- /dev/null +++ b/test/samples/apache/microwave-01.xml @@ -0,0 +1,78 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<!-- + This document uses JSP 2.0 EL as the expressions language. +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + xmlns:cs="http://commons.apache.org/scxml" + version="1.0" + initialstate="off"> + + <!-- trivial microwave oven example --> + <state id="off"> + <!-- off state --> + <transition event="turn_on" target="on"/> + </state> + + <state id="on"> + <initial> + <transition target="idle"/> + </initial> + + <!-- on/pause state --> + <onentry> + <!-- we assume the cook_time is passed in as a context parameter --> + <if cond="${empty cook_time}"> + <!-- default setting --> + <cs:var name="cook_time" expr="${5}"/> + </if> + <!-- again, door_closed should be a part of a global context --> + <if cond="${empty door_closed}"> + <!-- default setting --> + <cs:var name="door_closed" expr="${true}"/> + </if> + <!-- timer variable --> + <cs:var name="timer" expr="${0}"/> + </onentry> + + <transition event="turn_off" target="off"/> + + <transition cond="${timer ge cook_time}" target="off"/> + + <state id="idle"> + <!-- default immediate transition --> + <transition cond="${door_closed}" target="cooking"/> + + <!-- start cooking --> + <transition event="door_close" target="cooking"> + <assign name="door_closed" expr="${true}"/> + </transition> + </state> + + <state id="cooking"> + <transition event="door_open" target="idle"> + <assign name="door_closed" expr="${false}"/> + </transition> + <transition event="time" target="cooking"> + <assign name="timer" expr="${timer + 1}"/> + </transition> + </state> + + </state> + +</scxml> diff --git a/test/samples/apache/microwave-02-legacy.xml b/test/samples/apache/microwave-02-legacy.xml new file mode 100644 index 0000000..eaeb14a --- /dev/null +++ b/test/samples/apache/microwave-02-legacy.xml @@ -0,0 +1,87 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<!-- + This document uses JSP 2.0 EL as the expressions language. +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" + initialstate="microwave"> + + <!-- trivial microwave oven example --> + <!-- using parallel and In() predicate --> + + <state id="microwave"> + <parallel id="parts"> + <state id="oven"> + <initial> + <transition target="off"/> + </initial> + + <state id="off"> + <!-- off state --> + <transition event="turn_on" target="on"/> + </state> + + <state id="on"> + <initial> + <transition target="idle"/> + </initial> + + <!-- on/pause state --> + <onentry> + <!-- we assume the cook_time is passed in as a context parameter --> + <if cond="${empty cook_time}"> + <!-- default setting --> + <var name="cook_time" expr="${5}"/> + </if> + <!-- timer variable --> + <var name="timer" expr="${0}"/> + </onentry> + + <transition event="turn_off" target="off"/> + + <transition cond="${timer ge cook_time}" target="off"/> + + <state id="idle"> + <transition cond="${In('closed')}" target="cooking"/> + </state> + + <state id="cooking"> + <transition cond="${not In('closed')}" target="idle"/> + + <transition event="time" target="cooking"> + <assign name="timer" expr="${timer + 1}"/> + </transition> + </state> + </state> + </state> + + <state id="door"> + <initial> + <transition target="closed"/> + </initial> + <state id="closed"> + <transition event="door_open" target="open"/> + </state> + <state id="open"> + <transition event="door_close" target="closed"/> + </state> + </state> + </parallel> + </state> + +</scxml> diff --git a/test/samples/apache/microwave-02.xml b/test/samples/apache/microwave-02.xml new file mode 100644 index 0000000..c03fe05 --- /dev/null +++ b/test/samples/apache/microwave-02.xml @@ -0,0 +1,87 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<!-- + This document uses JSP 2.0 EL as the expressions language. +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + xmlns:cs="http://commons.apache.org/scxml" + version="1.0" + initialstate="microwave"> + + <!-- trivial microwave oven example --> + <!-- using parallel and In() predicate --> + + <parallel id="microwave"> + <state id="oven"> + <initial> + <transition target="off"/> + </initial> + + <state id="off"> + <!-- off state --> + <transition event="turn_on" target="on"/> + </state> + + <state id="on"> + <initial> + <transition target="idle"/> + </initial> + + <!-- on/pause state --> + <onentry> + <!-- we assume the cook_time is passed in as a context parameter --> + <if cond="${empty cook_time}"> + <!-- default setting --> + <cs:var name="cook_time" expr="${5}"/> + </if> + <!-- timer variable --> + <cs:var name="timer" expr="${0}"/> + </onentry> + + <transition event="turn_off" target="off"/> + + <transition cond="${timer ge cook_time}" target="off"/> + + <state id="idle"> + <transition cond="${In('closed')}" target="cooking"/> + </state> + + <state id="cooking"> + <transition cond="${not In('closed')}" target="idle"/> + + <transition event="time" target="cooking"> + <assign name="timer" expr="${timer + 1}"/> + </transition> + </state> + </state> + </state> + + <state id="door"> + <initial> + <transition target="closed"/> + </initial> + <state id="closed"> + <transition event="door_open" target="open"/> + </state> + <state id="open"> + <transition event="door_close" target="closed"/> + </state> + </state> + </parallel> + +</scxml> diff --git a/test/samples/apache/microwave-03.xml b/test/samples/apache/microwave-03.xml new file mode 100644 index 0000000..887b1a6 --- /dev/null +++ b/test/samples/apache/microwave-03.xml @@ -0,0 +1,79 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<!-- + This document uses Commons JEXL as the expressions language. + Needs SCXMLParser. +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + xmlns:cs="http://commons.apache.org/scxml" + version="1.0" + initialstate="off"> + + <!-- trivial microwave oven example --> + <state id="off"> + <!-- off state --> + <transition event="turn_on" target="on"/> + </state> + + <state id="on"> + <initial> + <transition target="idle"/> + </initial> + + <!-- on/pause state --> + <onentry> + <!-- we assume the cook_time is passed in as a context parameter --> + <if cond="empty(cook_time)"> + <!-- default setting --> + <cs:var name="cook_time" expr="5"/> + </if> + <!-- again, door_closed should be a part of a global context --> + <if cond="empty(door_closed)"> + <!-- default setting --> + <cs:var name="door_closed" expr="true"/> + </if> + <!-- timer variable --> + <cs:var name="timer" expr="0"/> + </onentry> + + <transition event="turn_off" target="off"/> + + <transition cond="timer ge cook_time" target="off"/> + + <state id="idle"> + <!-- default immediate transition --> + <transition cond="door_closed" target="cooking"/> + + <!-- start cooking --> + <transition event="door_close" target="cooking"> + <assign name="door_closed" expr="true"/> + </transition> + </state> + + <state id="cooking"> + <transition event="door_open" target="idle"> + <assign name="door_closed" expr="false"/> + </transition> + <transition event="time" target="cooking"> + <assign name="timer" expr="timer + 1"/> + </transition> + </state> + + </state> + +</scxml> diff --git a/test/samples/apache/microwave-04.xml b/test/samples/apache/microwave-04.xml new file mode 100644 index 0000000..96656dd --- /dev/null +++ b/test/samples/apache/microwave-04.xml @@ -0,0 +1,90 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<!-- + This document uses Commons JEXL as the expressions language. + Needs SCXMLParser. +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + xmlns:cs="http://commons.apache.org/scxml" + version="1.0" + initialstate="microwave"> + + <!-- trivial microwave oven example --> + <!-- using parallel and In() predicate --> + + <parallel id="microwave"> + + <state id="oven"> + <initial> + <transition target="off"/> + </initial> + + <state id="off"> + <!-- off state --> + <transition event="turn_on" target="on"/> + </state> + + <state id="on"> + <initial> + <transition target="idle"/> + </initial> + + <!-- on/pause state --> + <onentry> + <!-- we assume the cook_time is passed in as a context parameter --> + <if cond="empty(cook_time)"> + <!-- default setting, note namespace of this custom action --> + <cs:var name="cook_time" expr="5"/> + </if> + <!-- timer variable --> + <cs:var name="timer" expr="0"/> + </onentry> + + <transition event="turn_off" target="off"/> + + <transition cond="timer ge cook_time" target="off"/> + + <state id="idle"> + <transition cond="In('closed')" target="cooking"/> + </state> + + <state id="cooking"> + <transition cond="not In('closed')" target="idle"/> + + <transition event="time" target="cooking"> + <assign name="timer" expr="timer + 1"/> + </transition> + </state> + </state> + </state> + + <state id="door"> + <initial> + <transition target="closed"/> + </initial> + <state id="closed"> + <transition event="door_open" target="open"/> + </state> + <state id="open"> + <transition event="door_close" target="closed"/> + </state> + </state> + + </parallel> + +</scxml> diff --git a/test/samples/apache/microwave-05.xml b/test/samples/apache/microwave-05.xml new file mode 100644 index 0000000..06b9fc9 --- /dev/null +++ b/test/samples/apache/microwave-05.xml @@ -0,0 +1,98 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<!-- + This document uses Commons JEXL as the expressions language. + Needs SCXMLParser. +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + xmlns:cs="http://commons.apache.org/scxml" + version="1.0" + initialstate="microwave"> + + <!-- trivial microwave oven example --> + <!-- using parallel (part of composite state) and In() predicate --> + + <state id="microwave"> + + <initial> + <transition target="parts"/> + </initial> + + <parallel id="parts"> + + <state id="oven"> + <initial> + <transition target="off"/> + </initial> + + <state id="off"> + <!-- off state --> + <transition event="turn_on" target="on"/> + </state> + + <state id="on"> + <initial> + <transition target="idle"/> + </initial> + + <!-- on/pause state --> + <onentry> + <!-- we assume the cook_time is passed in as a context parameter --> + <if cond="empty(cook_time)"> + <!-- default setting, note namespace of this custom action --> + <cs:var name="cook_time" expr="5"/> + </if> + <!-- timer variable --> + <cs:var name="timer" expr="0"/> + </onentry> + + <transition event="turn_off" target="off"/> + + <transition cond="timer ge cook_time" target="off"/> + + <state id="idle"> + <transition cond="In('closed')" target="cooking"/> + </state> + + <state id="cooking"> + <transition cond="not In('closed')" target="idle"/> + + <transition event="time" target="cooking"> + <assign name="timer" expr="timer + 1"/> + </transition> + </state> + </state> + </state> + + <state id="door"> + <initial> + <transition target="closed"/> + </initial> + <state id="closed"> + <transition event="door_open" target="open"/> + </state> + <state id="open"> + <transition event="door_close" target="closed"/> + </state> + </state> + + </parallel> + + </state> + +</scxml> diff --git a/test/samples/apache/parallel-01.xml b/test/samples/apache/parallel-01.xml new file mode 100644 index 0000000..e822285 --- /dev/null +++ b/test/samples/apache/parallel-01.xml @@ -0,0 +1,70 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<!-- + Needs SCXMLParser +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initialstate="para"> + + <parallel id="para"> + + <state id="para1"> + + <initial> + <transition target="para11"/> + </initial> + + <state id="para11"> + <transition event="foo" target="para12"/> + </state> + + <state id="para12"> + <onexit> + <log expr="'Exiting para12'" /> + </onexit> + </state> + + </state> + + <state id="para2"> + + <initial> + <transition target="para21"/> + </initial> + + <state id="para21"> + <transition cond="In('para12')" target="para22"/> + </state> + + <state id="para22"> + <onexit> + <log expr="'Exiting para22'" /> + </onexit> + + <transition target="end"/> + </state> + + </state> + + </parallel> + + <state id="end" final="true" /> + +</scxml> + diff --git a/test/samples/apache/parallel-02.xml b/test/samples/apache/parallel-02.xml new file mode 100644 index 0000000..106fc86 --- /dev/null +++ b/test/samples/apache/parallel-02.xml @@ -0,0 +1,31 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<!-- + Needs SCXMLParser +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" initialstate="state0"> + + <parallel id="state0"> + <transition event="event1" target="state1" /> + <!-- dummy regions --> + <state id="state01"/> + <state id="state02"/> + </parallel> + <final id="state1"/> + +</scxml> diff --git a/test/samples/apache/parallel-03.xml b/test/samples/apache/parallel-03.xml new file mode 100644 index 0000000..d57196a --- /dev/null +++ b/test/samples/apache/parallel-03.xml @@ -0,0 +1,118 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<!-- + Needs SCXMLParser +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initial="para"> + + <datamodel> + <data id="root"> + <root xmlns=""> + <count>0</count> + </root> + </data> + </datamodel> + + <parallel id="para"> + + <onentry> + <assign location="Data(root, 'root/count')" expr="Data(root, 'root/count') + 1"/> + </onentry> + + <state id="para1"> + + <initial> + <transition target="para11"/> + </initial> + <onentry> + <assign location="Data(root, 'root/count')" expr="Data(root, 'root/count') + 1"/> + </onentry> + + <state id="para11"> + <onentry> + <assign location="Data(root, 'root/count')" expr="Data(root, 'root/count') + 1"/> + </onentry> + <transition event="foo" target="para12"/> + <onexit> + <assign location="Data(root, 'root/count')" expr="Data(root, 'root/count') + 1"/> + </onexit> + </state> + + <final id="para12"> + <onentry> + <assign location="Data(root, 'root/count')" expr="Data(root, 'root/count') + 1"/> + </onentry> + <onexit> + <assign location="Data(root, 'root/count')" expr="Data(root, 'root/count') + 1"/> + </onexit> + </final> + + <onexit> + <assign location="Data(root, 'root/count')" expr="Data(root, 'root/count') + 1"/> + </onexit> + + </state> + + <state id="para2"> + + <initial> + <transition target="para21"/> + </initial> + <onentry> + <assign location="Data(root, 'root/count')" expr="Data(root, 'root/count') + 1"/> + </onentry> + + <state id="para21"> + <onentry> + <assign location="Data(root, 'root/count')" expr="Data(root, 'root/count') + 1"/> + </onentry> + <transition event="bar" target="para22"/> + <onexit> + <assign location="Data(root, 'root/count')" expr="Data(root, 'root/count') + 1"/> + </onexit> + </state> + + <final id="para22"> + <onentry> + <assign location="Data(root, 'root/count')" expr="Data(root, 'root/count') + 1"/> + </onentry> + <onexit> + <assign location="Data(root, 'root/count')" expr="Data(root, 'root/count') + 1"/> + </onexit> + </final> + + <onexit> + <assign location="Data(root, 'root/count')" expr="Data(root, 'root/count') + 1"/> + </onexit> + + </state> + + <transition event="para.done" target="end"/> + + <onexit> + <assign location="Data(root, 'root/count')" expr="Data(root, 'root/count') + 1"/> + </onexit> + + </parallel> + + <state id="end" final="true" /> + +</scxml> + diff --git a/test/samples/apache/prefix-01.xml b/test/samples/apache/prefix-01.xml new file mode 100644 index 0000000..79cbe69 --- /dev/null +++ b/test/samples/apache/prefix-01.xml @@ -0,0 +1,29 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<scxml:scxml xmlns:scxml="http://www.w3.org/2005/07/scxml" + version="1.0" + initialstate="ten"> + + <scxml:state id="ten"> + <scxml:transition event="ten.done" target="twenty"/> + </scxml:state> + + <scxml:state id="twenty" final="true" /> + +</scxml:scxml> + diff --git a/test/samples/apache/scxml-initial-attr.xml b/test/samples/apache/scxml-initial-attr.xml new file mode 100644 index 0000000..0965653 --- /dev/null +++ b/test/samples/apache/scxml-initial-attr.xml @@ -0,0 +1,25 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<!-- Used for SrcTest.java in io package --> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initial="foo"> + + <final id="foo"/> + +</scxml> diff --git a/test/samples/apache/send-01.xml b/test/samples/apache/send-01.xml new file mode 100644 index 0000000..4f3cf40 --- /dev/null +++ b/test/samples/apache/send-01.xml @@ -0,0 +1,47 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initialstate="ten"> + + <state id="ten"> + <transition event="ten.done" target="twenty"> + <send sendid="send1" delay="'0'" + target="'http://localhost:8080/VXMLInterpreter'" type="'v3'" + xmlns:v3="http://foo.bar.com/vxml3" + xmlns:test="http://my.test.namespace"> + <v3:form id="Confirm"> + <v3:grammar type="application/srgs+xml" + src="/grammars/boolean.grxml"/> + <v3:block> + <v3:prompt>Say yes or no.</v3:prompt> + </v3:block> + </v3:form> + <test:foo id="foo1"> + <test:bar id="bar1" /> + </test:foo> + <test:foo id="foo2"> + <v3:prompt>This is just an example.</v3:prompt> + </test:foo> + </send> + </transition> + </state> + + <state id="twenty" final="true" /> + +</scxml> diff --git a/test/samples/apache/send-02.xml b/test/samples/apache/send-02.xml new file mode 100644 index 0000000..9685385 --- /dev/null +++ b/test/samples/apache/send-02.xml @@ -0,0 +1,89 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<!-- Various send usages that fire the events on the existing execution + engine. --> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initialstate="ten"> + + <!-- We are expected to just fall all the way through down to + the state "seventy", then hop over and end up in "ninety" --> + <state id="ten"> + <onentry> + <send event="'ten.' + 'done'" /> + </onentry> + <transition event="ten.done" target="twenty" /> + </state> + + <state id="twenty"> + <onentry> + <send event="'twenty.done'" type="'scxml'" /> + </onentry> + <transition event="twenty.done" target="thirty" /> + </state> + + <state id="thirty"> + <onentry> + <send event="'thirty.done'" type="' sCxML '" /> + </onentry> + <transition event="thirty.done" target="forty" /> + </state> + + <state id="forty"> + <onentry> + <send event="'forty.done'" type=" " target=" " /> + </onentry> + <transition event="forty.done" target="fifty" /> + </state> + + <state id="fifty"> + <onentry> + <send event="'fifty.done'" target="' '" /> + </onentry> + <transition event="fifty.done" target="sixty" /> + </state> + + <state id="sixty"> + <onentry> + <send event="'sixty.done'" type="'scxml'" target=" " /> + </onentry> + <transition event="sixty.done" target="seventy" /> + </state> + + <state id="seventy"> + <onentry> + <send event="'seventy.done'" type="'scxml'" target="'foo'" /> + </onentry> + + <!-- This transition should not be followed since + target "foo" is unavailable (any target other + than an empty target is unavailable, empty target + is current execution i.e. this state machine) --> + <transition event="seventy.done" target="eighty" /> + + <!-- Since "foo" it not available, the event + "error.send.targetunavailable" should be raised --> + <transition event="error.send.targetunavailable" target="ninety" /> + + </state> + + <state id="eighty" final="true" /> + + <state id="ninety" final="true" /> + +</scxml> diff --git a/test/samples/apache/src-test-1.xml b/test/samples/apache/src-test-1.xml new file mode 100644 index 0000000..74e6ce2 --- /dev/null +++ b/test/samples/apache/src-test-1.xml @@ -0,0 +1,31 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<!-- Used for SrcTest.java in io package --> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initialstate="srctest1"> + + <state id="srctest1" src="src-test-2.xml"> + <transition event="src.test" target="srctest3end"/> + <transition event="srctest1.done" target="srctest1end"/> + </state> + + <state id="srctest1end" final="true"/> + +</scxml> + diff --git a/test/samples/apache/src-test-2.xml b/test/samples/apache/src-test-2.xml new file mode 100644 index 0000000..16789ab --- /dev/null +++ b/test/samples/apache/src-test-2.xml @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<!-- Used for SrcTest.java in io package --> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initialstate="srctest2"> + + <state id="srctest2" src="src-test-3.xml"> + <transition event="srctest2.done" target="srctest2end"/> + </state> + + <state id="srctest2end" final="true"/> + +</scxml> + diff --git a/test/samples/apache/src-test-3.xml b/test/samples/apache/src-test-3.xml new file mode 100644 index 0000000..d675687 --- /dev/null +++ b/test/samples/apache/src-test-3.xml @@ -0,0 +1,28 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<!-- Used for SrcTest.java in io package --> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initialstate="srctest3"> + + <state id="srctest3"/> + + <state id="srctest3end" final="true"/> + +</scxml> + diff --git a/test/samples/apache/src-test-4.xml b/test/samples/apache/src-test-4.xml new file mode 100644 index 0000000..4fe18e5 --- /dev/null +++ b/test/samples/apache/src-test-4.xml @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<!-- Used for SrcTest.java in io package --> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initialstate="srctest1"> + + <state id="srctest1" src="bad-document-404.xml"> + <transition event="srctest1.done" target="srctest1end"/> + </state> + + <state id="srctest1end" final="true"/> + +</scxml> + diff --git a/test/samples/apache/src-test-5.xml b/test/samples/apache/src-test-5.xml new file mode 100644 index 0000000..a36e112 --- /dev/null +++ b/test/samples/apache/src-test-5.xml @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<!-- Used for SrcTest.java in io package --> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initialstate="srctest1"> + + <state id="srctest1" src="src-test-3.xml#badstateid404"> + <transition event="srctest1.done" target="srctest1end"/> + </state> + + <state id="srctest1end" final="true"/> + +</scxml> + diff --git a/test/samples/apache/state-01.xml b/test/samples/apache/state-01.xml new file mode 100644 index 0000000..22a9018 --- /dev/null +++ b/test/samples/apache/state-01.xml @@ -0,0 +1,24 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" initial="s1"> + + <state id="s1" initial="s11"> + <final id="s11"/> + </state> + +</scxml> diff --git a/test/samples/apache/stateless-01.xml b/test/samples/apache/stateless-01.xml new file mode 100644 index 0000000..1229b8f --- /dev/null +++ b/test/samples/apache/stateless-01.xml @@ -0,0 +1,50 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initialstate="main"> + + <state id="main"> + + <initial> + <transition target="ten"/> + </initial> + + <onentry> + <var name="instancevar" expr="${20}" /> + </onentry> + + <state id="ten"> + <transition event="ten.done" cond="${instancevar eq 20}" + target="twenty" /> + <onexit> + <assign name="instancevar" expr="${30}" /> + </onexit> + </state> + + <state id="twenty"> + <transition event="twenty.done" cond="${instancevar eq 30}" + target="thirty" /> + </state> + + <state id="thirty" final="true" /> + + </state> + +</scxml> + diff --git a/test/samples/apache/stateless-parallel-01.xml b/test/samples/apache/stateless-parallel-01.xml new file mode 100644 index 0000000..f2e9017 --- /dev/null +++ b/test/samples/apache/stateless-parallel-01.xml @@ -0,0 +1,54 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initialstate="main"> + + <state id="main"> + + <parallel id="main.parallel"> + + <state id="state1"> + <initial> + <transition target="state1.init"/> + </initial> + <state id="state1.init"> + <transition event="state1.event" target="state1.final" /> + </state> + <state id="state1.final" final="true" /> + </state> + + <state id="state2"> + <initial> + <transition target="state2.init"/> + </initial> + <state id="state2.init"> + <transition event="state2.event" target="state2.final" /> + </state> + <state id="state2.final" final="true" /> + </state> + + </parallel> + + <transition event="main.parallel.done" target="next" /> + + </state> + + <state id="next" final="true"/> + +</scxml> diff --git a/test/samples/apache/static-method.xml b/test/samples/apache/static-method.xml new file mode 100644 index 0000000..7ad034a --- /dev/null +++ b/test/samples/apache/static-method.xml @@ -0,0 +1,32 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<!-- Example of invoking a static method when using JEXL, for example: + (public static) java.lang.System#currentTimeMillis() +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initialstate="static"> + + <state id="static" final="true"> + <onentry> + <log expr="'Current time millis: ' + System.currentTimeMillis()" /> + </onentry> + </state> + +</scxml> + diff --git a/test/samples/apache/stopwatch.xml b/test/samples/apache/stopwatch.xml new file mode 100644 index 0000000..57572a1 --- /dev/null +++ b/test/samples/apache/stopwatch.xml @@ -0,0 +1,41 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initialstate="reset"> + + <state id="reset"> + <transition event="watch.start" target="running"/> + </state> + + <state id="running"> + <transition event="watch.split" target="paused"/> + <transition event="watch.stop" target="stopped"/> + </state> + + <state id="paused"> + <transition event="watch.unsplit" target="running"/> + <transition event="watch.stop" target="stopped"/> + </state> + + <state id="stopped"> + <transition event="watch.reset" target="reset"/> + </state> + +</scxml> + diff --git a/test/samples/apache/tie-breaker-01.xml b/test/samples/apache/tie-breaker-01.xml new file mode 100644 index 0000000..7cff894 --- /dev/null +++ b/test/samples/apache/tie-breaker-01.xml @@ -0,0 +1,35 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<!-- + Used by TieBreakerTest +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initialstate="ten"> + <state id="ten"> + <!-- twenty should win, document order --> + <transition event="ten.done" target="twenty" /> + <transition event="ten.done" target="thirty" /> + </state> + + <state id="twenty" final="true" /> + + <state id="thirty" final="true" /> + +</scxml> + diff --git a/test/samples/apache/tie-breaker-02.xml b/test/samples/apache/tie-breaker-02.xml new file mode 100644 index 0000000..62118dd --- /dev/null +++ b/test/samples/apache/tie-breaker-02.xml @@ -0,0 +1,45 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<!-- + Used by TieBreakerTest +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initialstate="ten"> + + <state id="ten"> + <initial> + <transition target="eleven"/> + </initial> + + <transition event="ten.done" target="twenty" /> + + <state id="eleven"> + <!-- thirty wins since eleven trumps + ten in the state heirarchy --> + <transition event="ten.done" target="thirty" /> + </state> + + </state> + + <state id="twenty" final="true" /> + + <state id="thirty" final="true" /> + +</scxml> + diff --git a/test/samples/apache/tie-breaker-03.xml b/test/samples/apache/tie-breaker-03.xml new file mode 100644 index 0000000..d850865 --- /dev/null +++ b/test/samples/apache/tie-breaker-03.xml @@ -0,0 +1,56 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<!-- + Used by TieBreakerTest +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initialstate="ten"> + + <state id="ten"> + <initial> + <transition target="eleven"/> + </initial> + + <transition event="ten.done" target="twenty" /> + + <transition event="ten.done" target="thirty" /> + + <state id="eleven"> + + <!-- forty wins due to document order and the fact + that since eleven trumps ten in the state + heirarchy --> + <transition event="ten.done" target="forty" /> + + <transition event="ten.done" target="fifty" /> + + </state> + + </state> + + <state id="twenty" final="true" /> + + <state id="thirty" final="true" /> + + <state id="forty" final="true" /> + + <state id="fifty" final="true" /> + +</scxml> + diff --git a/test/samples/apache/tie-breaker-04.xml b/test/samples/apache/tie-breaker-04.xml new file mode 100644 index 0000000..df87e63 --- /dev/null +++ b/test/samples/apache/tie-breaker-04.xml @@ -0,0 +1,36 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" initialstate="s1"> + + <state id="s1"> + <initial> + <transition target="s11"/> + </initial> + + <transition event="event_1"/> + + <transition event="event_2" target="s1"/> + + <state id="s11"> + <transition event="event_1"/> + <transition event="event_2" target="s11"/> + </state> + </state> + + <state id="s2" final="true" /> +</scxml> diff --git a/test/samples/apache/tie-breaker-05.xml b/test/samples/apache/tie-breaker-05.xml new file mode 100644 index 0000000..1fcbd35 --- /dev/null +++ b/test/samples/apache/tie-breaker-05.xml @@ -0,0 +1,64 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" initialstate="para"> + +<!-- + Testing dispute resolution in regions + {s11,s2111,s212} -event1-> {s12,s2112,s212} +--> + + <parallel id="para"> <!-- Outer parallel --> + + <state id="s1"> + <initial> + <transition target="s11"/> + </initial> + <state id="s11"> + <transition event="event1" target="s12"/> + <transition event="event1" target="s13"/> + </state> + <state id="s12"/> + <state id="s13"/> + </state> + + <state id="s2"> + <initial> + <transition target="para1"/> + </initial> + + <parallel id="para1"> <!-- Inner parallel --> + <state id="s211"> + <initial> + <transition target="s2111"/> + </initial> + <state id="s2111"> + <transition event="event1" target="s2112"/> + <transition event="event1" target="s2113"/> + </state> + <state id="s2112"/> + <state id="s2113"/> + </state> + <state id="s212"/> + </parallel> + + <state id="s22"/> + </state> + + </parallel> + +</scxml> diff --git a/test/samples/apache/tie-breaker-06.xml b/test/samples/apache/tie-breaker-06.xml new file mode 100644 index 0000000..a7f26ff --- /dev/null +++ b/test/samples/apache/tie-breaker-06.xml @@ -0,0 +1,40 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<!-- A fictitious state machine used by test cases. + <send>s in the same executable content block --> +<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" initialstate="main"> + + <state id="main"> + + <onentry> + <event name="internal_event1"/> + <event name="internal_event2"/> + </onentry> + + <transition event="internal_event1"> + <log label="Expected" + expr="'Transition for first event (internal_event1) followed'"/> + </transition> + <transition event="internal_event2"> + <log label="Unexpected" + expr="'Transition for second event (internal_event2) followed'"/> + </transition> + + </state> + +</scxml> diff --git a/test/samples/apache/transitions-01-legacy.xml b/test/samples/apache/transitions-01-legacy.xml new file mode 100644 index 0000000..f46bc74 --- /dev/null +++ b/test/samples/apache/transitions-01-legacy.xml @@ -0,0 +1,140 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initialstate="ten"> + + <!-- Start with a simple state --> + <state id="ten"> + <transition event="ten.done" target="twenty" /> + </state> + + <!-- Follow up with a composite state --> + <state id="twenty"> + + <initial> + <transition target="twenty_one"/> + </initial> + + <onentry> + <log expr="'In twenty'" /> + </onentry> + + <state id="twenty_one"> + <transition event="twenty_one.done" target="twenty_two"/> + </state> + + <state id="twenty_two"> + <transition event="twenty_two.done" target="thirty"/> + </state> + + </state> + + <!-- Finally, try an orthogonal state --> + <state id="thirty"> + + <parallel id="thirties_parallel"> + + <!-- The first (of three) regions in thirties_parallel --> + <state id="thirty_one"> + + <initial> + <transition target="thirty_one_child_one"/> + </initial> + <onentry> + <log expr="'Entering thirty_one'" /> + </onentry> + <transition event="thirty_one.done" target="forty"/> + + <state id="thirty_one_child_one"> + <onexit> + <log expr="'Exiting thirty_one_child_one'" /> + </onexit> + <transition event="thirty_one_child_one.done" + target="thirty_one_child_two"/> + </state> + + <state id="thirty_one_child_two"> + <onexit> + <log expr="'Exiting thirty_one_child_two'" /> + </onexit> + </state> + + </state> + + <!-- The second (of three) regions in thirties_parallel --> + <state id="thirty_two"> + + <initial> + <transition target="thirty_two_child_one"/> + </initial> + <onentry> + <log expr="'Entering thirty_two'" /> + </onentry> + + <state id="thirty_two_child_one"> + <onexit> + <log expr="'Exiting thirty_two_child_one'" /> + </onexit> + <transition event="thirty_two_child_one.done" + target="thirty_two_child_two"/> + </state> + + <state id="thirty_two_child_two"> + <onexit> + <log expr="'Exiting thirty_two_child_two'" /> + </onexit> + </state> + + </state> + + <!-- The third (of three) regions in thirties_parallel --> + <state id="thirty_three"> + + <initial> + <transition target="thirty_three_child_one"/> + </initial> + <onentry> + <log expr="'Entering thirty_three'" /> + </onentry> + + <state id="thirty_three_child_one"> + <onexit> + <log expr="'Exiting thirty_three_child_one'" /> + </onexit> + <transition event="thirty_three_child_one.done" + target="thirty_three_child_two"/> + </state> + + <state id="thirty_three_child_two"> + <onexit> + <log expr="'Exiting thirty_three_child_two'" /> + </onexit> + </state> + + </state> + + </parallel> + + </state> + + <!-- Declare victory --> + <state id="forty" final="true" /> + +</scxml> + diff --git a/test/samples/apache/transitions-01.xml b/test/samples/apache/transitions-01.xml new file mode 100644 index 0000000..ee5133f --- /dev/null +++ b/test/samples/apache/transitions-01.xml @@ -0,0 +1,136 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<scxml + version="1.0" + initial="ten"> + + <!-- Start with a simple state --> + <state id="ten"> + <transition event="ten.done" target="twenty" /> + </state> + + <!-- Follow up with a composite state --> + <state id="twenty"> + + <initial> + <transition target="twenty_one"/> + </initial> + + <onentry> + <log expr="'In twenty'" /> + </onentry> + + <state id="twenty_one"> + <transition event="twenty_one.done" target="twenty_two"/> + </state> + + <state id="twenty_two"> + <transition event="twenty_two.done" target="thirty"/> + </state> + + </state> + + <!-- Finally, try an orthogonal state --> + <parallel id="thirty"> + + <!-- The first (of three) regions in thirties_parallel --> + <state id="thirty_one"> + + <initial> + <transition target="thirty_one_child_one"/> + </initial> + <onentry> + <log expr="'Entering thirty_one'" /> + </onentry> + <transition event="thirty_one.done" target="forty"/> + + <state id="thirty_one_child_one"> + <onexit> + <log expr="'Exiting thirty_one_child_one'" /> + </onexit> + <transition event="thirty_one_child_one.done" + target="thirty_one_child_two"/> + </state> + + <state id="thirty_one_child_two"> + <onexit> + <log expr="'Exiting thirty_one_child_two'" /> + </onexit> + </state> + + </state> + + <!-- The second (of three) regions in thirties_parallel --> + <state id="thirty_two"> + + <initial> + <transition target="thirty_two_child_one"/> + </initial> + <onentry> + <log expr="'Entering thirty_two'" /> + </onentry> + + <state id="thirty_two_child_one"> + <onexit> + <log expr="'Exiting thirty_two_child_one'" /> + </onexit> + <transition event="thirty_two_child_one.done" + target="thirty_two_child_two"/> + </state> + + <state id="thirty_two_child_two"> + <onexit> + <log expr="'Exiting thirty_two_child_two'" /> + </onexit> + </state> + + </state> + + <!-- The third (of three) regions in thirties_parallel --> + <state id="thirty_three"> + + <initial> + <transition target="thirty_three_child_one"/> + </initial> + <onentry> + <log expr="'Entering thirty_three'" /> + </onentry> + + <state id="thirty_three_child_one"> + <onexit> + <log expr="'Exiting thirty_three_child_one'" /> + </onexit> + <transition event="thirty_three_child_one.done" + target="thirty_three_child_two"/> + </state> + + <state id="thirty_three_child_two"> + <onexit> + <log expr="'Exiting thirty_three_child_two'" /> + </onexit> + </state> + + </state> + + </parallel> + + <!-- Declare victory --> + <state id="forty" final="true" /> + +</scxml> + diff --git a/test/samples/apache/transitions-02.xml b/test/samples/apache/transitions-02.xml new file mode 100644 index 0000000..7c1dcf5 --- /dev/null +++ b/test/samples/apache/transitions-02.xml @@ -0,0 +1,53 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + xmlns:cs="http://commons.apache.org/scxml" + version="1.0" + initialstate="ten"> + + <state id="ten"> + + <onentry> + <cs:var name="foo" expr="1" /> + <log expr="'Foo is:' + foo" /> + </onentry> + + <!-- stay transition --> + <transition event="ten.stay"> + <assign name="foo" expr="foo + 1" /> + <log expr="'Foo is:' + foo" /> + </transition> + + <!-- self transition --> + <transition event="ten.self" target="ten"> + <assign name="foo" expr="foo + 1" /> + <log expr="'Foo is:' + foo" /> + </transition> + + <!-- "regular" transition --> + <transition event="ten.done" target="twenty"> + <assign name="foo" expr="foo + 1" /> + <log expr="'Foo is:' + foo" /> + </transition> + + </state> + + <state id="twenty" final="true" /> + +</scxml> + diff --git a/test/samples/apache/transitions-03.xml b/test/samples/apache/transitions-03.xml new file mode 100644 index 0000000..303d673 --- /dev/null +++ b/test/samples/apache/transitions-03.xml @@ -0,0 +1,88 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initialstate="ten"> + + <state id="ten"> + <transition event="ten.done" + target="twenty_one_2 twenty_two_2 twenty_three_2" /> + </state> + + <parallel id="twenty"> + + <state id="twenty_one"> + + <initial> + <transition target="twenty_one_1"/> + </initial> + + <state id="twenty_one_1"> + <transition event="foo" target="twenty_one_2"/> + </state> + + <state id="twenty_one_2"> + <onexit> + <log expr="'Exiting twenty_two_2'" /> + </onexit> + </state> + + </state> + + <state id="twenty_two"> + + <initial> + <transition target="twenty_two_1"/> + </initial> + + <state id="twenty_two_1"> + <transition event="foo" target="twenty_two_2"/> + </state> + + <state id="twenty_two_2"> + <onexit> + <log expr="'Exiting twenty_two_2'" /> + </onexit> + </state> + + </state> + + <state id="twenty_three"> + + <initial> + <transition target="twenty_three_1"/> + </initial> + + <state id="twenty_three_1"> + <transition event="foo" target="twenty_three_2"/> + </state> + + <state id="twenty_three_2"> + <onexit> + <log expr="'Exiting twenty_three_2'" /> + </onexit> + </state> + + </state> + + </parallel> + + <state id="thirty" final="true" /> + +</scxml> + diff --git a/test/samples/apache/transitions-04.xml b/test/samples/apache/transitions-04.xml new file mode 100644 index 0000000..547b702 --- /dev/null +++ b/test/samples/apache/transitions-04.xml @@ -0,0 +1,93 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<!-- + Needs SCXMLParser +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initialstate="ten"> + + <state id="ten"> + <transition event="ten.done" + target="twenty" /> + </state> + + <parallel id="twenty"> + + <state id="twenty_one"> + + <initial> + <transition target="twenty_one_1"/> + </initial> + + <transition event="bar" target="thirty"/> + + <state id="twenty_one_1"> + <transition event="foo" target="twenty_one_2"/> + </state> + + <state id="twenty_one_2"> + <onexit> + <log expr="'Exiting twenty_two_2'" /> + </onexit> + </state> + + </state> + + <state id="twenty_two"> + + <initial> + <transition target="twenty_two_1"/> + </initial> + + <state id="twenty_two_1"> + <transition event="foo" target="twenty_two_2"/> + </state> + + <state id="twenty_two_2"> + <onexit> + <log expr="'Exiting twenty_two_2'" /> + </onexit> + </state> + + </state> + + <state id="twenty_three"> + + <initial> + <transition target="twenty_three_1"/> + </initial> + + <state id="twenty_three_1"> + <transition event="foo" target="twenty_three_2"/> + </state> + + <state id="twenty_three_2"> + <onexit> + <log expr="'Exiting twenty_three_2'" /> + </onexit> + </state> + + </state> + + </parallel> + + <state id="thirty" final="true" /> + +</scxml> + diff --git a/test/samples/apache/transitions-05.xml b/test/samples/apache/transitions-05.xml new file mode 100644 index 0000000..7400359 --- /dev/null +++ b/test/samples/apache/transitions-05.xml @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" initial="init"> + <state id="init"> + <transition event="start" target="onetwo" /> + </state> + <parallel id="onetwo"> + <transition event="onetwo_three" target="three" /> + <state id="one"> + </state> + <state id="two"> + <transition event="two_four" target="four" /> + </state> + </parallel> + <state id="three"> + <transition event="three_one" target="one" /> + <transition event="three_four" target="four" /> + </state> + <state id="four"> + <transition event="four_onetwo" target="onetwo" /> + <transition event="four_three" target="three" /> + </state> +</scxml> diff --git a/test/samples/apache/travel-dialog.xml b/test/samples/apache/travel-dialog.xml new file mode 100644 index 0000000..08ebc99 --- /dev/null +++ b/test/samples/apache/travel-dialog.xml @@ -0,0 +1,54 @@ +<?xml version="1.0"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<scxml xmlns="http://www.w3.org/2005/01/SCXML" + version="1.0" + initialstate="tripType"> + + <state id="tripType"> + <transition event="tripType.done"> + <target next="departureCity"/> + </transition> + </state> + + <state id="departureCity"> + <transition event="departureCity.done"> + <target next="arrivalCity"/> + </transition> + </state> + + <state id="arrivalCity"> + <transition event="arrivalCity.done"> + <target next="departureDate"/> + </transition> + </state> + + <state id="departureDate"> + <transition event="departureDate.done" + cond="${tripType == 'round'}"> + <target next="arrivalDate"/> + </transition> + <transition event="departureDate.done" + cond="${tripType == '1way'}"> + <exit /> + </transition> + </state> + + <state id="arrivalDate" + final="true" /> + +</scxml> diff --git a/test/samples/apache/wildcard-01.xml b/test/samples/apache/wildcard-01.xml new file mode 100644 index 0000000..9f7ddc3 --- /dev/null +++ b/test/samples/apache/wildcard-01.xml @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + xmlns:cs="http://commons.apache.org/scxml" + version="1.0" + initialstate="state1"> + <state id="state1"> + <onentry> + <cs:var name="switch" expr="4" /> + </onentry> + <!-- We'll trigger 'foo.bar.baz' event, + and therefore, must end up in state4 --> + <transition event="*" cond="switch eq 2" target="state2"/> + <transition event="foo.*" cond="switch eq 3" target="state3"/> + <transition event="foo.bar.*" cond="switch eq 4" target="state4"/> + </state> + <state id="state2" final="true"/> + <state id="state3" final="true"/> + <state id="state4" final="true"/> +</scxml> diff --git a/test/samples/apache/wildcard-02.xml b/test/samples/apache/wildcard-02.xml new file mode 100644 index 0000000..d039f69 --- /dev/null +++ b/test/samples/apache/wildcard-02.xml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initialstate="state1"> + + <state id="state1"> + <onentry> + <event name="success.start"/> + </onentry> + <transition event="success.*" target="state2"/> + </state> + + <state id="state2"/> + +</scxml> + diff --git a/test/samples/apache/wizard-01.xml b/test/samples/apache/wizard-01.xml new file mode 100644 index 0000000..87492a6 --- /dev/null +++ b/test/samples/apache/wizard-01.xml @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initialstate="state1"> + <state id="state1"> + <transition event="event2" target="state2"/> + <transition event="event3" target="state3"/> + <transition event="event4" target="state4"/> + </state> + <state id="state2"> + <transition event="event1" target="state1"/> + <transition event="event3" target="state3"/> + <transition event="event4" target="state4"/> + </state> + <state id="state3"> + <transition event="event1" target="state1"/> + <transition event="event2" target="state2"/> + <transition event="event4" target="state4"/> + </state> + <state id="state4"> + <transition event="event1" target="state1"/> + <transition event="event2" target="state2"/> + <transition event="event3" target="state3"/> + </state> +</scxml> diff --git a/test/samples/apache/wizard-02.xml b/test/samples/apache/wizard-02.xml new file mode 100644 index 0000000..924b83f --- /dev/null +++ b/test/samples/apache/wizard-02.xml @@ -0,0 +1,65 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initialstate="state1"> + <state id="state1"> + <onentry> + <!-- Send without a type causes the + default to be chosen as "scxml". + This will cause the first transition + to state2 to be immediately followed. --> + <send event="'event2'" /> + </onentry> + <transition event="event2" target="state2"/> + <transition event="event3" target="state3"/> + <transition event="event4" target="state4"/> + </state> + <state id="state2"> + <onentry> + <var name="aValue" expr="2"/> + <!-- Send with a non-empty (and not "scxml") + type causes the callback on the + EventDispatcher implementation. See + testWizard02Sample() in WizardsTest + (org.apache.commons.scxml test package) --> + <send namelist="aValue" type="'foo'" /> + </onentry> + <transition event="event1" target="state1"/> + <transition event="event3" target="state3"/> + <transition event="event4" target="state4"/> + </state> + <state id="state3"> + <onentry> + <var name="aValue" expr="3"/> + <send namelist="aValue" type="'foo'" /> + </onentry> + <transition event="event1" target="state1"/> + <transition event="event2" target="state2"/> + <transition event="event4" target="state4"/> + </state> + <state id="state4"> + <onentry> + <var name="aValue" expr="4"/> + <send namelist="aValue" type="'foo'" /> + </onentry> + <transition event="event1" target="state1"/> + <transition event="event2" target="state2"/> + <transition event="event3" target="state3"/> + </state> +</scxml>
\ No newline at end of file diff --git a/test/samples/w3c/Blackjack.scxml b/test/samples/w3c/Blackjack.scxml new file mode 100644 index 0000000..4f55e53 --- /dev/null +++ b/test/samples/w3c/Blackjack.scxml @@ -0,0 +1,99 @@ +<?xml version="1.0"?> +<?access-control allow="*"?> +<scxml version="1.0" datamodel="ecmascript" initial="master"> <state id="master"> + <initial id="init1"> + <transition target="_home"/> + </initial> + <transition event="new_dealer" target="NewDealer"/> + <transition event="mumble" target="_home"/> <!-- bail out to caller --> + <transition event="silence" target="_home"/> <!-- bail out to caller --> + <state id="_home"> + <onenter> + <script> + _data = {}; + </script> + </onenter> + <invoke src="datamodel.v3#InitDataModel" type="vxml3"> + <finalize> + <script> + var n; + for (n in event) { + _data[n] = event[n]; + } + </script> + </finalize> + </invoke> + <transition event="success" target="Welcome"/> + </state> + + <state id="Welcome"> + <invoke src="dialog.vxml#Welcome" type="vxml3"> + <param name="skinpath" expr="skinpath"/> + </invoke> + <transition event="success" target="Intro2"/> + </state> + + <state id="Intro2"> + <invoke src="dialog.vxml#Intro2" type="vxml3"> + <param name="skinpath" expr="skinpath"/> + </invoke> + <transition event="success" target="EvalDeal"/> + </state> + + <state id="EvalDeal"> + <onenter> + <script>enterEvalDeal();</script> + </onenter> + <invoke src="dialog.vxml#EvalDeal" type="vxml3"> + <param name="skinpath" expr="skinpath"/> + <param name="playercard1" expr="playercard1"/> + <param name="playercard2" expr="playercard2"/> + <param name="playertotal" expr="blackjack.GetTotalOf('caller').toString()"/> + <param name="dealercardshowing" expr="dealercardshowing"/> + </invoke> + <transition event="success" target="AskHit"/> + </state> + + <state id="AskHit"> + <invoke src="dialog.vxml#AskHit" type="vxml3"> + <param name="skinpath" expr="skinpath"/> + <finalize> + <script>finalizeAskHit();</script> + </finalize> + </invoke> + <transition event="hit" target="PlayNewCard"/> + <transition event="stand" target="PlayDone"/> + </state> + + <state id="PlayNewCard"> + <invoke src="dialog.vxml#PlayNewCard" type="vxml3"> + <param name="skinpath" expr="skinpath"/> + <param name="playernewcard" expr="playernewcard"/> + <param name="playertotal" expr="blackjack.GetTotalOf('caller').toString()"/> + </invoke> + <transition event="success" cond="blackjack.GetTotalOf('caller') >= 21" target="PlayDone"/> + <transition event="success" target="AskHit"/> <!-- less than 21 --> + </state> + + <state id="PlayDone"> + <onenter> + <script>enterPlayDone();</script> + </onenter> + <invoke src="dialog.vxml#PlayDone" type="vxml3"> + <param name="skinpath" expr="skinpath"/> + <param name="gameresult" expr="blackjack.GetGameResult()"/> + <param name="dealertotal" expr="blackjack.GetTotalOf('dealer').toString()"/> + </invoke> + <transition event="playagain" target="Intro2"/> + <transition event="quit" target="_home"/> + </state> + + <state id="NewDealer"> + <onenter> + <script>enterNewDealer();</script> + </onenter> + <invoke src="dialog.vxml#Dummy" type="vxml3"/> + <transition event="success" target="Welcome"/> + </state> + </state> +</scxml> diff --git a/test/samples/w3c/Main.scxml b/test/samples/w3c/Main.scxml new file mode 100644 index 0000000..4c03631 --- /dev/null +++ b/test/samples/w3c/Main.scxml @@ -0,0 +1,204 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- A wrapper state that contains all other states in this file +- it represents the complete state machine --> +<scxml + xmlns:xi="http://www.w3.org/2001/XInclude" + version="1.0" + initial="Main" + datamodel="ecmascript"> + <state id="Main"> + <!-- its initial state is Test1 --> + <initial> + <transition target="Test1"/> + </initial> + + <!-- Really simple state showing the basic syntax. --> + <state id="Test1"> + <initial> + <transition target="Test1Sub1"/> + </initial> + <!-- Runs before we go into the substate --> + <onentry> + <log expr="'Inside Test1'"/> + </onentry> + + <!-- Here is our first substate --> + <state id="Test1Sub1"> + <onentry> + <log expr="'Inside Test1Sub1.'"/> + </onentry> + <onexit> + <log expr="'Leaving Test1Sub1'"/> + </onexit> + <!-- Go to Sub2 on Event1 --> + <transition event="Event1" target="Test1Sub2"/> + </state> + + <!-- Here is the second substate + It is final, so Test1 is done when we get here --> + <final id="Test1Sub2"/> + + <!-- We get this event when we reach Test1Sub2. --> + <transition event="Test1.done" target="Test2"/> + + <!-- We run this on the way out of Test1 --> + <onexit> + <log expr="'Leaving Test1...'"/> + </onexit> + </state> + + <state id="Test2"> + <initial> + <transition target="Test2Sub1"/> + </initial> + + <!-- This time we reference a state + defined in an external file. --> + <xi:include href="Test2Sub1.xml" parse="text"/> + + <final id="Test2Sub2"/> + + <!-- Test2Sub2 is defined as final, so this + event is generated when we reach it --> + <transition event="done.state.Test2" next="Test3"/> + </state> + + <state id="Test3"> + <initial> + <transition target="Test3Sub1"/> + </initial> + + <state id="Test3Sub1"> + <onentry> + <log expr="'Inside Test3Sub1...'"/> + <!-- Send our self an event in 5s --> + <send event="'Timer'" delay="'5s'"/> + </onentry> + <!-- Transition on to Test4. + This will exit both us and our parent. --> + <transition event="Timer" target="Test4"/> + <onexit> + <log expr="'Leaving Test3Sub1...'"/> + </onexit> + </state> + + <onexit> + <log expr="'Leaving Test3...'"/> + </onexit> + </state> + + <state id="Test4"> + <onentry> + <log expr="'Inside Test4...'"/> + </onentry> + <initial> + <transition target="Test4Sub1"/> + </initial> + + <state id="Test4Sub1"> + <onexit> + <log expr="'Leaving Test4Sub1...'"/> + </onexit> + <!-- This transition causes the state to exit immediately + after entering Test4Sub1. The transition has no event + or guard so it is always active --> + <transition target="Test5"/> + </state> + </state> + + <state id="Test5"> + <onentry> + <log expr="'Inside Test5...'"/> + </onentry> + <initial> + <transition target="Test5P"/> + </initial> + + <!-- Fire off parallel states. In a more realistic example + the parallel substates Test5PSub1 and Test5PSub2 would themselves + have substates and would do some real work before transitioning to final substates --> + <parallel id="Test5P"> + <state id="Test5PSub1" initial="Test5PSub1Final"> + <final id="Test5PSub1Final"/> + </state> + <state id="Test5PSub2" initial="Test5PSub2Final"> + <final id="Test5PSub2Final"/> + </state> + <onexit> + <log expr="'all parallel states done'"/> + </onexit> + </parallel> + + <!-- The parallel states immediately transition to final substates, + so this event is generated immediately. --> + <transition event="done.state.Test5P" target="Test6"/> + </state> + + <!-- + - This state shows invocation of an external component. + - We will use CCXML + VoiceXML actions as an example + - as it is a good smoke test to show how it all + - fits together. + - Note: In a real app you would likely + - split this over several states but we + - are trying to keep it simple here. + --> + <state id="Test6" + xmlns:ccxml="http://www.w3.org/2002/09/ccxml" + xmlns:v3="http://www.w3.org/2005/07/vxml3"> + <datamodel> + <data name="ccxmlid" expr="32459"/> + <date name="v3id" expr="17620"/> + <data name="dest" expr="'tel:+18315552020'"/> + <data name="src" expr="'helloworld2.vxml'"/> + <data name="id" expr="'HelloWorld'"/> + </datamodel> + + <onentry> + <!-- Use <send> a message to a CCXML Processor asking it to run createcall --> + <send target="ccxmlid" type="basichttp" event="ccxml:createcall" namelist="dest"/> + </onentry> + + <transition event="ccxml:connection.connected"> + <!-- Here as a platform-specific extension we use example V3 + Custom Action Elements instead of send. The implementation of this logic + would be platform-dependent. --> + <v3:form id="HelloWorld"> + <v3:block><v3:prompt>Hello World!</v3:prompt></v3:block> + </v3:form> + </transition> + + <transition event="v3:HelloWorld.done"> + <!-- Here we are using the low level <send> + element to run a v3 form. Note that the event "v3:HelloWorld.done" + is assumed either to be set/sent explicitly by the v3:form code or + implicitly by some process outside of the v3:form --> + <send target="v3id" type="basichttp" event="v3:formstart" namelist="src id"/> + </transition> + + <transition event="v3:HelloWorld2.done"> + <!-- we use _event.data to access data in the event we're processing. + Again we assume the v3:HelloWorld2.done is set/sent from outside + this document --> + <ccxml:disconnect connectionid="_event.data.connectionid"/> + </transition> + + <transition event="ccxml:connection.disconnected" target="Done"/> + + <transition event="send.failed" target="Done"> + <!-- If we get an error event we move to the Done state that + is a final state. --> + <log expr="'Sending to and External component failed'"/> + </transition> + + <onexit> + <log expr="'Finished with external component'"/> + </onexit> + </state> + + <!-- This final state is an immediate child of Main + - when we get here, Main.done is generated. --> + <final id="Done"/> + <!-- End of Main > --> + </state> +</scxml>
\ No newline at end of file diff --git a/test/samples/w3c/Test2Sub1.xml b/test/samples/w3c/Test2Sub1.xml new file mode 100644 index 0000000..6ab7b98 --- /dev/null +++ b/test/samples/w3c/Test2Sub1.xml @@ -0,0 +1,9 @@ +<!-- This is an example substate defined in +- an external file and included by Main.scxml. +--> +<state id="Test2Sub1"> +<onentry> + <log expr="'Inside Test2Sub1'"/> +</onentry> +<transition event="Event2" target="Test2Sub2"/> +</state> diff --git a/test/samples/w3c/TrafficReport.scxml b/test/samples/w3c/TrafficReport.scxml new file mode 100644 index 0000000..09e2e93 --- /dev/null +++ b/test/samples/w3c/TrafficReport.scxml @@ -0,0 +1,88 @@ +<?xml version="1.0"?> +<?access-control allow="*"?> +<!-- A comment! --> +<scxml version="1.0" initial="Intro" datamodel="ecmascript"> + <state id="Intro"> + <invoke src="dialog.vxml#Intro" type="vxml2"/> + <transition event="success" cond="sessionChrome.playAds" target="PlayAds"/> + <transition event="success" cond="!sessionChrome.playAds && ANIQuality" + target="ShouldGoBack"/> + <transition event="success" cond="!sessionChrome.playAds && !ANIQuality" + target="StartOver"/> + </state> + + <state id="PlayAds"> + <invoke src="dialog.vxml#PlayAds" type="vxml2"/> + <transition event="success" cond="ANIQuality" target="ShouldGoBack"/> + <transition event="success" cond="!ANIQuality" target="StartOver"/> + </state> + + <state id="StartOver"> + <onentry> + <script>enterStartOver();</script> + </onentry> + <invoke src="dialog.vxml#StartOver" type="vxml2"> + <param name="gotItFromANI" expr="gotItFromANI"/> + <finalize> + <script>finalizeStartOver();</script> + </finalize> + </invoke> + <transition event="success" target="ShouldGoBack"/> + <transition event="doOver" target="StartOver"/> + <transition event="restart" target="Intro"/> <!-- bail out to caller --> + </state> + + <state id="ShouldGoBack"> + <invoke src="dialog.vxml#ShouldGoBack" type="vxml2"> + <param name="cityState" expr="cityState"/> + <param name="gotItFromANI" expr="gotItFromANI"/> + <finalize> + <script>finalizeShouldGoBack();</script> + </finalize> + </invoke> + <transition event="highWay" target="HighwayReport"/> + <transition event="go_back" target="StartOver"/> + <transition event="doOver" target="ShouldGoBack"/> + <transition event="restart" target="Intro"/> + </state> + + <state id="HighwayReport"> + <invoke src="dialog.vxml#HighwayReport" type="vxml2"> + <param name="cityState" expr="cityState"/> + <param name="gotItFromANI" expr="gotItFromANI"/> + <param name="playHRPrompt" expr="playHRPrompt"/> + <param name="metroArea" expr="metroArea"/> + <finalize> + <script>finalizeHighwayReport();</script> + </finalize> + </invoke> + <transition event="highway" target="PlayHighway"/> + <transition event="go_back" target="StartOver"/> + <transition event="doOver" target="HighwayReport"/> + <transition event="fullreport" target="FullReport"/> + <transition event="restart" target="Intro"/> + </state> + + <state id="FullReport"> + <invoke src="dialog.vxml#FullReport" type="vxml2"> + <param name="cityState" expr="cityState"/> + <param name="metroArea" expr="metroArea"/> + <finalize> + <script>finalizeFullReport();</script> + </finalize> + </invoke> + <transition event="go_back" target="HighwayReport"/> + <transition event="new_city" target="StartOver"/> + </state> + + <state id="PlayHighway"> + <invoke src="dialog.vxml#PlayHighway" type="vxml2"> + <param name="cityState" expr="cityState"/> + <param name="curHighway" expr="curHighway"/> + <finalize> + <script>finalizePlayHighway();</script> + </finalize> + </invoke> + <transition event="go_back" target="HighwayReport"/> + </state> +</scxml> diff --git a/test/samples/w3c/calc.scxml b/test/samples/w3c/calc.scxml new file mode 100644 index 0000000..e759b45 --- /dev/null +++ b/test/samples/w3c/calc.scxml @@ -0,0 +1,158 @@ +<?xml version="1.0" ?> +<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" + initial="on" datamodel="ecmascript" name="calc"> + <datamodel> + <data id="long_expr" /> + <data id="short_expr" expr="0" /> + <data id="res" /> + </datamodel> + <state id="wrapper" initial="on"> + <state id="on" initial="ready"> + <onentry> + <send event="DISPLAY.UPDATE" /> + </onentry> + <state id="ready" initial="begin"> + <state id="begin"> + <transition event="OPER.MINUS" target="negated1" /> + <onentry> + <send event="DISPLAY.UPDATE" /> + </onentry> + </state> + <state id="result"> + </state> + <transition event="OPER" target="opEntered" /> + <transition event="DIGIT.0" target="zero1"> + <assign location="short_expr" expr="''" /> + </transition> + <transition event="DIGIT" target="int1"> + <assign location="short_expr" expr="''" /> + </transition> + <transition event="POINT" target="frac1"> + <assign location="short_expr" expr="''" /> + </transition> + </state> + <state id="negated1"> + <onentry> + <assign location="short_expr" expr="'-'" /> + <send event="DISPLAY.UPDATE" /> + </onentry> + <transition event="DIGIT.0" target="zero1" /> + <transition event="DIGIT" target="int1" /> + <transition event="POINT" target="frac1" /> + </state> + <state id="operand1"> + <state id="zero1"> + <transition event="DIGIT" cond="_event.name != 'DIGIT.0'" target="int1" /> + <transition event="POINT" target="frac1" /> + </state> + <state id="int1"> + <transition event="POINT" target="frac1" /> + <transition event="DIGIT"> + <assign location="short_expr" expr="short_expr+_event.name.substr(_event.name.lastIndexOf('.')+1)" /> + <send event="DISPLAY.UPDATE" /> + </transition> + <onentry> + <assign location="short_expr" expr="short_expr+_event.name.substr(_event.name.lastIndexOf('.')+1)" /> + <send event="DISPLAY.UPDATE" /> + </onentry> + </state> + <state id="frac1"> + <onentry> + <assign location="short_expr" expr="short_expr+'.'" /> + <send event="DISPLAY.UPDATE" /> + </onentry> + <transition event="DIGIT"> + <assign location="short_expr" expr="short_expr+_event.name.substr(_event.name.lastIndexOf('.')+1)" /> + <send event="DISPLAY.UPDATE" /> + </transition> + </state> + <transition event="OPER" target="opEntered" /> + </state> + <state id="opEntered"> + <transition event="OPER.MINUS" target="negated2" /> + <transition event="POINT" target="frac2" /> + <transition event="DIGIT.0" target="zero2" /> + <transition event="DIGIT" target="int2" /> + <onentry> + <raise event="CALC.SUB" /> + <send target="_internal" event="OP.INSERT"> + <param name="operator" expr="_event.name" /> + </send> + </onentry> + </state> + <state id="negated2"> + <onentry> + <assign location="short_expr" expr="'-'" /> + <send event="DISPLAY.UPDATE" /> + </onentry> + <transition event="DIGIT.0" target="zero2" /> + <transition event="DIGIT" target="int2" /> + <transition event="POINT" target="frac2" /> + </state> + <state id="operand2"> + <state id="zero2"> + <transition event="DIGIT" cond="_event.name != 'DIGIT.0'" target="int2" /> + <transition event="POINT" target="frac2" /> + </state> + <state id="int2"> + <transition event="DIGIT"> + <assign location="short_expr" expr="short_expr+_event.name.substr(_event.name.lastIndexOf('.')+1)" /> + <send event="DISPLAY.UPDATE" /> + </transition> + <onentry> + <assign location="short_expr" expr="short_expr+_event.name.substr(_event.name.lastIndexOf('.')+1)" /> + <send event="DISPLAY.UPDATE" /> + </onentry> + <transition event="POINT" target="frac2" /> + </state> + <state id="frac2"> + <onentry> + <assign location="short_expr" expr="short_expr +'.'" /> + <send event="DISPLAY.UPDATE" /> + </onentry> + <transition event="DIGIT"> + <assign location="short_expr" expr="short_expr +_event.name.substr(_event.name.lastIndexOf('.')+1)" /> + <send event="DISPLAY.UPDATE" /> + </transition> + </state> + <transition event="OPER" target="opEntered"> + <raise event="CALC.SUB" /> + <raise event="OP.INSERT" /> + </transition> + <transition event="EQUALS" target="result"> + <raise event="CALC.SUB" /> + <raise event="CALC.DO" /> + </transition> + </state> + <transition event="C" target="on" /> + </state> + <transition event="CALC.DO"> + <assign location="short_expr" expr="''+ res" /> + <assign location="long_expr" expr="''" /> + <assign location="res" expr="0" /> + </transition> + <transition event="CALC.SUB"> + <if cond="short_expr!=''"> + <assign location="long_expr" expr="long_expr+'('+short_expr+')'" /> + </if> + <assign location="res" expr="eval(long_expr)" /> + <assign location="short_expr" expr="''" /> + <send event="DISPLAY.UPDATE" /> + </transition> + <transition event="DISPLAY.UPDATE"> + <log level="0" label="'result'" expr=".short_expr==''?res:short_expr" /> + </transition> + <transition event="OP.INSERT"> + <log level="0" expr="_event.data[0]" /> + <if cond="_event.data[0] == 'OPER.PLUS'"> + <assign location="long_expr" expr="long_expr+'+'" /> + <elseif cond="_event.data[0]=='OPER.MINUS'" /> + <assign location="long_expr" expr="long_expr+'-'" /> + <elseif cond="_event.data[0]=='OPER.STAR'" /> + <assign location="long_expr" expr="long_expr+'*'" /> + <elseif cond="_event.data[0]=='OPER.DIV'" /> + <assign location="long_expr" expr="long_expr+'/'" /> + </if> + </transition> + </state> +</scxml> diff --git a/test/samples/w3c/edit-profile-config.scxml b/test/samples/w3c/edit-profile-config.scxml new file mode 100644 index 0000000..2f8753e --- /dev/null +++ b/test/samples/w3c/edit-profile-config.scxml @@ -0,0 +1,70 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Dialog definitions for Shale Use Cases Example Web Application + written out as SCXML to demonstrate use of Commons SCXML as one + of Shale's Dialog Manager implementations. + For details, see: http://shale.apache.org/shale-dialog-scxml/ +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:my="http://scxml.example.com/" + version="1.0" initial="edit" datamodel="el"> + + <state id="edit"> + <initial> + <transition target="setup"/> + </initial> + + <!-- global transitions (within state "edit") --> + <transition event="faces.outcome" cond="${outcome eq 'cancel'}" target="cancel"/> + <transition event="faces.outcome" cond="${outcome eq 'finish'}" target="finish"/> + + <state id="setup"> + <onentry> + <my:var name="setupOutcome" expr="#{profile$edit.setup}" /> + </onentry> + <transition cond="${setupOutcome eq 'success'}" target="page1"/> + </state> + + <state id="page1"> + <transition event="faces.outcome" cond="${outcome eq 'next'}" target="page2"/> + </state> + + <state id="page2"> + + <transition event="faces.outcome" cond="${outcome eq 'previous'}" target="page1"/> + <transition event="faces.outcome" cond="${outcome eq 'next'}" target="page3"/> + + </state> + + <state id="page3"> + <transition event="faces.outcome" cond="${outcome eq 'previous'}" target="page2"/> + <transition event="faces.outcome" cond="${outcome eq 'next'}" target="editExit"/> + </state> + + </state> + + <state id="cancel"> + + <onentry> + <my:var name="cancelOutcome" expr="#{profile$edit.cancel}" /> + </onentry> + <transition cond="${cancelOutcome eq 'success'}" target="editExit"> + <my:var name="outcome" expr="cancel"/> + </transition> + </state> + + <state id="finish"> + + <onentry> + <my:var name="finishOutcome" expr="#{profile$edit.finish}" /> + </onentry> + + <transition cond="${finishOutcome eq 'username'}" target="page1"/> + <transition cond="${finishOutcome eq 'password'}" target="page1"/> + <transition cond="${finishOutcome eq 'success'}" target="editExit"> + <my:var name="outcome" expr="success"/> + </transition> + </state> + + <final id="editExit"/> + +</scxml> diff --git a/test/samples/w3c/log-on-config.scxml b/test/samples/w3c/log-on-config.scxml new file mode 100644 index 0000000..01f45d6 --- /dev/null +++ b/test/samples/w3c/log-on-config.scxml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Dialog definitions for Shale Use Cases Example Web Application + written out as SCXML to demonstrate use of Commons SCXML as one + of Shale's Dialog Manager implementations. + For details, see: http://shale.apache.org/shale-dialog-scxml/ +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:my="http://scxml.example.com/" + version="1.0" initial="checkCookie" datamodel="el" > + + <state id="checkCookie"> + <onentry> + <my:var name="cookieOutcome" expr="#{profile$logon.check}" /> + </onentry> + <transition cond="${cookieOutcome eq 'authenticated'}" target="exit"/> + <transition cond="${cookieOutcome eq 'unauthenticated'}" target="logon"/> + + </state> + + <state id="logon"> + <transition event="faces.outcome" cond="${outcome eq 'authenticated'}" target="exit"/> + <transition event="faces.outcome" cond="${outcome eq 'create'}" target="createProfile"/> + </state> + + + <state id="createProfile" src="edit-profile-config.xml" > + <transition event="createProfile.done" cond="${outcome eq 'success' or outcome eq 'cancel'}" target="exit"/> + </state> + + <final id="exit"/> + +</scxml> diff --git a/test/samples/w3c/microwave-01.scxml b/test/samples/w3c/microwave-01.scxml new file mode 100644 index 0000000..71e2f98 --- /dev/null +++ b/test/samples/w3c/microwave-01.scxml @@ -0,0 +1,50 @@ +<?xml version="1.0"?> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + datamodel="ecmascript" + initial="off"> + + <!-- trivial 5 second microwave oven example --> + <datamodel> + <data id="cook_time" expr="5"/> + <data id="door_closed" expr="true"/> + <data id="timer" expr="0"/> + </datamodel> + + <state id="off"> + <!-- off state --> + <transition event="turn.on" target="on"/> + </state> + + <state id="on"> + <initial> + <transition target="idle"/> + </initial> + <!-- on/pause state --> + + <transition event="turn.off" target="off"/> + <transition cond="timer >= cook_time" target="off"/> + + <state id="idle"> + <!-- default immediate transition if door is shut --> + <transition cond="door_closed" target="cooking"/> + <transition event="door.close" target="cooking"> + <assign location="door_closed" expr="true"/> + <!-- start cooking --> + </transition> + </state> + + <state id="cooking"> + <transition event="door.open" target="idle"> + <assign location="door_closed" expr="false"/> + </transition> + + <!-- a 'time' event is seen once a second --> + <transition event="time"> + <assign location="timer" expr="timer + 1"/> + </transition> + </state> + + </state> + +</scxml> diff --git a/test/samples/w3c/microwave-02.scxml b/test/samples/w3c/microwave-02.scxml new file mode 100644 index 0000000..a96f1fd --- /dev/null +++ b/test/samples/w3c/microwave-02.scxml @@ -0,0 +1,63 @@ +<?xml version="1.0"?> +<scxml xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + datamodel="ecmascript" + initial="oven"> + + <!-- trivial 5 second microwave oven example --> + <!-- using parallel and In() predicate --> + <datamodel> + <data id="cook_time" expr="5"/> + <data id="door_closed" expr="true"/> + <data id="timer" expr="0"/> + </datamodel> + + <parallel id="oven"> + + <!-- this region tracks the microwave state and timer --> + <state id="engine"> + <transition target="off"/> + + <state id="off"> + <!-- off state --> + <transition event="turn.on" target="on"/> + </state> + + <state id="on"> + <transition target="idle"/> + <!-- on/pause state --> + + <transition event="turn.off" target="off"/> + <transition cond="timer >= cook_time" target="off"/> + + <state id="idle"> + <transition cond="In('closed')" target="cooking"/> + </state> + + <state id="cooking"> + <transition cond="In('open')" target="idle"/> + + <!-- a 'time' event is seen once a second --> + <transition event="time"> + <assign location="timer" expr="timer + 1"/> + </transition> + </state> + </state> + </state> + + <!-- this region tracks the microwave door state --> + <state id="door"> + <initial> + <transition target="closed"/> + </initial> + <state id="closed"> + <transition event="door.open" target="open"/> + </state> + <state id="open"> + <transition event="door.close" target="closed"/> + </state> + </state> + + </parallel> + +</scxml> diff --git a/test/samples/w3c/simple.xml b/test/samples/w3c/simple.xml new file mode 100644 index 0000000..d3badc8 --- /dev/null +++ b/test/samples/w3c/simple.xml @@ -0,0 +1,9 @@ +<scxml xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initial="Main" + datamodel="ecmascript"> + <state /> + <state /> + <state /> + <state /> +</scxml>
\ No newline at end of file diff --git a/test/schema/scxml-message.xsd b/test/schema/scxml-message.xsd new file mode 100644 index 0000000..de4b4b8 --- /dev/null +++ b/test/schema/scxml-message.xsd @@ -0,0 +1,122 @@ +<?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.xsd b/test/schema/scxml.xsd new file mode 100644 index 0000000..ebc0654 --- /dev/null +++ b/test/schema/scxml.xsd @@ -0,0 +1,176 @@ +<?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 driver for SCXML 1.0. + Please use this namespace for SCXML 1.0 elements: + + "http://www.w3.org/2005/07/scxml" + + </xsd:documentation> + <xsd:documentation source="scxml-copyright.xsd"/> + </xsd:annotation> + <xsd:annotation> + <xsd:documentation> + This is the XML Schema driver file for SCXML 1.0. + + This schema: + + sets the namespace for SCXML 1.0 + + imports external schemas (xml.xsd) + + imports SCXML common datatypes, attributes and content models + + imports modular schemas + + SCXML 1.0 includes: + + SCXML core constructs + + SCXML executable content + + SCXML data model and manipulation + + SCXML external communications + + This schema is permissive such that it accomodates all + datamodels, but validating documents may contain markup that + is ignored in certain datamodels. + </xsd:documentation> + </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 XML attributes are used by various modules. + </xsd:documentation> + </xsd:annotation> + </xsd:import> + + <xsd:include schemaLocation="scxml-attribs.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> + </xsd:annotation> + </xsd:include> + + <xsd:redefine 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. + </xsd:documentation> + </xsd:annotation> + </xsd:include> + + <xsd:redefine 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 + </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:schema> diff --git a/test/src/test-apache-commons.cpp b/test/src/test-apache-commons.cpp new file mode 100644 index 0000000..51c275d --- /dev/null +++ b/test/src/test-apache-commons.cpp @@ -0,0 +1,128 @@ +#include "uscxml/Interpreter.h" +#include <glog/logging.h> + +using namespace uscxml; +using namespace Arabica::DOM; +using namespace Arabica::XPath; + +static std::string path; + +bool testEvents1() { + LOG(INFO) << "---- testEvent1 "; + Interpreter* interpreter = new Interpreter(path + "/eventdata-01.xml"); + interpreter->start(); + interpreter->waitForStabilization(); + assert(interpreter->getConfiguration().size() == 1); + assert(Interpreter::isMember(interpreter->getState("state1"), interpreter->getConfiguration())); + + Event eventFoo; + eventFoo.name = "event.foo"; + eventFoo.atom = "3"; + interpreter->receive(eventFoo); + interpreter->waitForStabilization(); + assert(interpreter->getConfiguration().size() == 1); + assert(Interpreter::isMember(interpreter->getState("state3"), interpreter->getConfiguration())); + + Event eventBar; + eventBar.name = "event.bar"; + eventBar.atom = "6"; + interpreter->receive(eventBar); + interpreter->waitForStabilization(); + assert(interpreter->getConfiguration().size() == 1); + assert(Interpreter::isMember(interpreter->getState("state6"), interpreter->getConfiguration())); + + Event eventBaz; + eventBaz.name = "event.baz"; + eventBaz.atom = "7"; + interpreter->receive(eventBaz); + + delete interpreter; + return true; +} + +bool testEvents2() { + LOG(INFO) << "---- testEvent2 "; + Interpreter* interpreter = new Interpreter(path + "/eventdata-02.xml"); + interpreter->start(); + interpreter->waitForStabilization(); + assert(interpreter->getConfiguration().size() == 1); + assert(Interpreter::isMember(interpreter->getState("state0"), interpreter->getConfiguration())); + + Event eventConnAlert; + eventConnAlert.name = "connection.alerting"; + eventConnAlert.atom = "'line2'"; + interpreter->receive(eventConnAlert); + interpreter->waitForStabilization(); + assert(interpreter->getConfiguration().size() == 1); + assert(Interpreter::isMember(interpreter->getState("state2"), interpreter->getConfiguration())); + + Event eventConnAlert2; + eventConnAlert2.name = "connection.alerting"; + eventConnAlert2.compound["line"] = Data(std::string("4")); + interpreter->receive(eventConnAlert2); + + delete interpreter; + return true; +} + +//bool testEvents3() { +// LOG(INFO) << "---- testEvent3 "; +// Interpreter* Interpreter = new Interpreter(path + "/eventdata-03.xml"); +// interpreter->start(); +// interpreter->waitForStabilization(); +// Thread::sleepMs(200); +// assert(interpreter->getConfiguration().size() == 1); +// assert(Interpreter::isMember(interpreter->getState("state0"), interpreter->getConfiguration())); +// +// Event eventConnAlert; +// eventConnAlert.name = "connection.alerting"; +// eventConnAlert.atom = "'line2'"; +// interpreter->receive(eventConnAlert); +// Thread::sleepMs(200); +// assert(interpreter->getConfiguration().size() == 1); +// assert(Interpreter::isMember(interpreter->getState("state2"), interpreter->getConfiguration())); +// +// Event eventConnAlert2; +// eventConnAlert2.name = "connection.alerting"; +// eventConnAlert2.compound["line"] = Data(std::string("4")); +// interpreter->receive(eventConnAlert2); +// Thread::sleepMs(200); +// assert(interpreter->getConfiguration().size() == 1); +// assert(Interpreter::isMember(interpreter->getState("state4"), interpreter->getConfiguration())); +// +// delete Interpreter; +// return true; +//} + + +int main(int argc, char** argv) { + if (argc != 2) { + std::cerr << "Expected path to scxml file from apache commons distribution" << std::endl; + exit(EXIT_FAILURE); + } + + path = "file://"; + path += argv[1]; + + if (!testEvents1()) + return EXIT_FAILURE; + if (!testEvents2()) + return EXIT_FAILURE; +// if (!testEvents3()) +// return EXIT_FAILURE; + +// +// Interpreter* scxmlInterpreter = new Interpreter(path + "/tie-breaker-01.xml"); +// SCXMLRunner* scxmlRun = new SCXMLRunner(scxmlInterpreter); +// scxmlRun->start(); +// +// Thread::sleepMs(100); +// assert(Interpreter::isMember(scxmlinterpreter->getState("ten"), scxmlinterpreter->getConfiguration())); +// +// boost::shared_ptr<Event> event = boost::shared_ptr<Event>(new Event()); +// event->name = "ten.done"; +// scxmlinterpreter->receive(event); +// scxmlRun->join(); +// scxmlinterpreter->receive(event); + +}
\ No newline at end of file diff --git a/test/src/test-communication.cpp b/test/src/test-communication.cpp new file mode 100644 index 0000000..97584b8 --- /dev/null +++ b/test/src/test-communication.cpp @@ -0,0 +1,26 @@ +#include "uscxml/Interpreter.h" +#include <DOM/io/Stream.hpp> + +int main(int argc, char** argv) { + if (argc != 2) { + std::cerr << "Expected path to test-communication.scxml" << std::endl; + exit(EXIT_FAILURE); + } + + + using namespace uscxml; + std::list<Interpreter*> _interpreters; + +// Event e; +// e.compound["foo"] = Data("bar", Data::VERBATIM); +// e.compound["foo2"] = Data("bar2", Data::VERBATIM); +// std::cout << e.toDocument() << std::endl; + + for (int i = 0; i < 1; i++) { + _interpreters.push_back(new Interpreter(argv[1])); + _interpreters.back()->start(); + } + + tthread::this_thread::sleep_for(tthread::chrono::milliseconds(100000)); + +}
\ No newline at end of file diff --git a/test/src/test-communication.scxml b/test/src/test-communication.scxml new file mode 100644 index 0000000..cc3f577 --- /dev/null +++ b/test/src/test-communication.scxml @@ -0,0 +1,35 @@ +<scxml datamodel="ecmascript" initial="start" binding="late" name="foo"> + <state id="start"> + <datamodel> + <data id="foo" expr="'this is the foo data'" /> + <data id="bar" expr="'this is the bar data'" /> + </datamodel> + <onentry> + <log expr="'basichttp listening as ' + _ioprocessors['basichttp']" /> + <log expr="'Entered step1'" /> + <log expr="'Sending ourself an event'" /> + <send targetexpr="_ioprocessors['basichttp']" namelist="foo" type="basichttp" event="transitionToNext"> + <param name="bar" expr="'b' + 'ar'" /> + <content> +<![CDATA[ +This is some content you got there dude! +]]> + </content> + </send> + </onentry> + <transition event="transitionToNext" target="step1" /> + </state> + <state id="step1"> + <onentry> + <log expr="'Entered step1'" /> + <log expr="'Sending ourself a 2s delayed event'" /> + <send delay="2s" targetexpr="_ioprocessors['basichttp']" type="basichttp" event="transitionToNext" /> + </onentry> + <transition event="transitionToNext" target="final" /> + </state> + <final id="final"> + <onentry> + <log expr="'Finished!'" /> + </onentry> + </final> +</scxml>
\ No newline at end of file diff --git a/test/src/test-ecmascript-v8.cpp b/test/src/test-ecmascript-v8.cpp new file mode 100644 index 0000000..d0b69ba --- /dev/null +++ b/test/src/test-ecmascript-v8.cpp @@ -0,0 +1,44 @@ +#include "uscxml/Interpreter.h" +#include "uscxml/datamodel/ecmascript/v8/V8DataModel.h" + +int main(int argc, char** argv) { + if (argc != 2) { + std::cerr << "Expected path to test-ecmascript.scxml" << std::endl; + exit(EXIT_FAILURE); + } + + using namespace uscxml; + using namespace Arabica::DOM; + using namespace Arabica::XPath; + +// class SCXMLRunner : public Thread { +// public: +// SCXMLRunner(Runtime* runtime) : _runtime(runtime) {} +// void run() { +// _runtime->interpret(); +// } +// +// Runtime* _runtime; +// }; + +// boost::shared_ptr<V8DataModel> v8 = boost::static_pointer_cast<V8DataModel>(Factory::create("datamodel:ecmascript", Arabica::DOM::Node<std::string>())); +// v8->eval("var x = 4;"); +// assert(v8->evalAsBool("x == 4")); +// assert(!v8->evalAsBool("x == 5")); + + Interpreter* scxml = new Interpreter(argv[1]); + scxml->dump(); +// scxml->interpret(); + scxml->start(); + scxml->waitForStabilization(); + + Event event1; + event1.name = "event1"; + scxml->receive(event1); + scxml->waitForStabilization(); + tthread::this_thread::sleep_for(tthread::chrono::milliseconds(200)); + +// SCXMLRunner* scxmlRun = new SCXMLRunner(scxmlRuntime); +// scxmlRun->start(); + +}
\ No newline at end of file diff --git a/test/src/test-ecmascript.scxml b/test/src/test-ecmascript.scxml new file mode 100644 index 0000000..aa88f17 --- /dev/null +++ b/test/src/test-ecmascript.scxml @@ -0,0 +1,112 @@ +<scxml datamodel="ecmascript" initial="comparison" binding="late"> + <datamodel> + <data id="year" expr="2008" /> + <data id="CEO" expr="'Mr Big'" /> + <data id="profitable" /> + <data id="json"> + { + "id": 1, + "name": "Foo", + "price": 123, + "tags": [ "Bar", "Eek" ], + "stock": { + "warehouse": 300, + "retail": 20, + } + } + </data> + </datamodel> + <script> + var x = 4; + var a = ["a", "b", "c"]; + var b = [10,20,30]; + </script> + <script> + var y; + if (x > 10) { + y = 'true'; + } else { + y = 'false'; + } + </script> + <state id="comparison"> + <onentry> + <log expr="'-- Testing comparisons'" /> + <log expr="'x is ' + x + ', y is ' + y" /> + </onentry> + <transition cond="x >= 2" target="builtin"> + <log expr="'x is greater or equal to 2'" /> + </transition> + <transition cond="x < 2" target="builtin"> + <log expr="'x is smaller than 2'" /> + </transition> + </state> + <state id="builtin"> + <onentry> + <log expr="'-- Testing built ins'" /> + <if cond="In('builtin')"> + <log expr="'We are in state builtin'" /> + <else> + <log expr="'We are not in state builtin'" /> + </else> + </if> + </onentry> + <transition target="conditionals" /> + </state> + <state id="conditionals"> + <onentry> + <log expr="'-- Testing conditionals'" /> + <if cond="y == true"> + <log expr="'x is great and y is'" /> + <elseif cond="x > 3"> + <log expr="'x is somewhat great and y is not'" /> + </elseif> + <else> + <log expr="'x is great and y is not'" /> + </else> + </if> + </onentry> + <transition target="foreach" /> + </state> + <state id="foreach"> + <onentry> + <log expr="'-- Testing loops'" /> + <foreach array="a" item="itemA" index="indexA"> + <foreach array="b" item="itemB" index="indexB"> + <log expr="indexA + '.' + indexB + ' = ' + itemA + '.' + itemB" /> + </foreach> + </foreach> + </onentry> + <transition target="externalEvents" /> + </state> + <state id="externalEvents"> + <onentry> + <log expr="'-- External Events'" /> + </onentry> + <transition target="datamodels" event="event1" cond="_event.name == 'event1'" /> + </state> + <state id="datamodels"> + <datamodel> + <data id="bar" expr="'yeah, bar!'"/> + </datamodel> + <onentry> + <log expr="'-- DataModels'" /> + <log expr="'year = ' + year" /> + <log expr="'bar = ' + bar" /> + <log expr="'json.stock.warehouse = ' + json.stock.warehouse" /> + </onentry> + <transition target="syntaxerror" /> + </state> + <state id="syntaxerror"> + <onentry> + <log expr="'-- Syntax Error'" /> + <log expr="year = ' + year" /> + </onentry> + <transition event="error.execution" target="final" /> + </state> + <final id="final"> + <onentry> + <log expr="'Finished!'" /> + </onentry> + </final> +</scxml>
\ No newline at end of file diff --git a/test/src/test-eventdelay.cpp b/test/src/test-eventdelay.cpp new file mode 100644 index 0000000..6a28e44 --- /dev/null +++ b/test/src/test-eventdelay.cpp @@ -0,0 +1,39 @@ +#include "uscxml/concurrency/eventqueue/libevent/DelayedEventQueue.h" + +int eventCalled = 0; + +#include <sstream> + +static void callback(void* userData, const std::string eventId) { +// std::cout << eventId << ": " << (const char*)userData << std::endl; + std::cout << eventId << std::endl << std::flush; + eventCalled++; +} + +int main(int argc, char** argv) { + + using namespace uscxml; + DelayedEventQueue* eq = new DelayedEventQueue(); + + std::cout << "Starting" << std::endl; + eq->start(); + tthread::this_thread::sleep_for(tthread::chrono::milliseconds(10)); + +// eq->addEvent("foo", callback, 200, (void*)"event foo"); +// eq->addEvent("bar", callback, 400, (void*)"event bar"); +// eq->addEvent("bar", callback, 600, (void*)"event bar"); +// eq->cancelEvent("bar"); +// eq->addEvent("bar", callback, 300, (void*)"event bar"); +// eq->addEvent("baz", callback, 400, (void*)"event baz"); + + for (unsigned int i = 0; i <= 5000; i += 500) { +// eq->stop(); + std::stringstream ss; + ss << i; + eq->addEvent(ss.str(), callback, i, NULL); + std::cout << "Added " << i << std::endl; +// eq->start(); + } + tthread::this_thread::sleep_for(tthread::chrono::milliseconds(20000)); + +}
\ No newline at end of file diff --git a/test/src/test-execution.cpp b/test/src/test-execution.cpp new file mode 100644 index 0000000..e484eb4 --- /dev/null +++ b/test/src/test-execution.cpp @@ -0,0 +1,16 @@ +#include "uscxml/Interpreter.h" + +int main(int argc, char** argv) { + if (argc != 2) { + std::cerr << "Expected path to test-execution.scxml" << std::endl; + exit(EXIT_FAILURE); + } + + using namespace uscxml; + using namespace Arabica::DOM; + using namespace Arabica::XPath; + + Interpreter* interpreter = new Interpreter(argv[1]); + interpreter->dump(); + interpreter->interpret(); +}
\ No newline at end of file diff --git a/test/src/test-execution.scxml b/test/src/test-execution.scxml new file mode 100644 index 0000000..ada1a17 --- /dev/null +++ b/test/src/test-execution.scxml @@ -0,0 +1,56 @@ +<scxml initial="step2"> + <state id="start"> + <onentry> + <log expr="'Entered State: start'" /> + </onentry> + <transition target="step1"> + <log expr="'Transition start -> step1'" /> + </transition> + <onexit> + <log expr="'Exited State: start'" /> + </onexit> + </state> + <state id="step1"> + <onentry> + <log expr="'Entered State: step1'" /> + </onentry> + <transition target="step2"> + <log expr="'Transition step1 -> step2'" /> + </transition> + <onexit> + <log expr="'Exited State: step1'" /> + </onexit> + </state> + <parallel id="step2"> + <state id="parallel1"> + <onentry> + <log expr="'Entered State: parallel1'" /> + </onentry> + <transition target="step3"> + <log expr="'Transition parallel1 -> step3'" /> + </transition> + <onexit> + <log expr="'Exited State: parallel1'" /> + </onexit> + </state> + <state id="parallel2"> + <onentry> + <log expr="'Entered State: parallel2'" /> + </onentry> + <transition target="step3"> + <log expr="'Transition parallel2 -> step3'" /> + </transition> + <onexit> + <log expr="'Exited State: parallel2'" /> + </onexit> + </state> + </parallel> + <final id="step3"> + <onentry> + <log expr="'Entered Final State: step3'" /> + </onentry> + <onexit> + <log expr="'Exited Final State: step3'" /> + </onexit> + </final> +</scxml>
\ No newline at end of file diff --git a/test/src/test-predicates.cpp b/test/src/test-predicates.cpp new file mode 100644 index 0000000..73c37dc --- /dev/null +++ b/test/src/test-predicates.cpp @@ -0,0 +1,60 @@ +#define protected public +#include "uscxml/Interpreter.h" +#undef protected + +int main(int argc, char** argv) { + if (argc != 2) { + std::cerr << "Expected path to test-predicates.scxml" << std::endl; + exit(EXIT_FAILURE); + } + + using namespace uscxml; + using namespace Arabica::DOM; + using namespace Arabica::XPath; + + Interpreter* interpreter = new Interpreter(argv[1]); + + Node<std::string> atomicState = interpreter->getState("atomic"); + assert(Interpreter::isAtomic(atomicState)); + assert(!Interpreter::isParallel(atomicState)); + assert(!Interpreter::isCompound(atomicState)); + + Node<std::string> compoundState = interpreter->getState("compound"); + assert(!Interpreter::isAtomic(compoundState)); + assert(!Interpreter::isParallel(compoundState)); + assert(Interpreter::isCompound(compoundState)); + + Node<std::string> parallelState = interpreter->getState("parallel"); + assert(!Interpreter::isAtomic(parallelState)); + assert(Interpreter::isParallel(parallelState)); + assert(!Interpreter::isCompound(parallelState)); // parallel states are not compound! + + Node<std::string> initialState = interpreter->getInitialState(); + assert(initialState == atomicState); + + NodeSet<std::string> childs = interpreter->getChildStates(compoundState); + Node<std::string> compundChild1 = interpreter->getState("compundChild1"); + Node<std::string> compundChild2 = interpreter->getState("compundChild2"); + assert(childs.size() > 0); + assert(Interpreter::isMember(compundChild1, childs)); + assert(Interpreter::isMember(compundChild2, childs)); + assert(!Interpreter::isMember(compoundState, childs)); + + assert(Interpreter::isDescendant(compundChild1, compoundState)); + + std::string transEvents; + transEvents = "error"; + assert(Interpreter::nameMatch(transEvents, "error")); + assert(!Interpreter::nameMatch(transEvents, "foo")); + + transEvents = "error foo"; + assert(Interpreter::nameMatch(transEvents, "error")); + assert(Interpreter::nameMatch(transEvents, "error.send")); + assert(Interpreter::nameMatch(transEvents, "error.send.failed")); + assert(Interpreter::nameMatch(transEvents, "foo")); + assert(Interpreter::nameMatch(transEvents, "foo.bar")); + assert(!Interpreter::nameMatch(transEvents, "errors.my.custom")); + assert(!Interpreter::nameMatch(transEvents, "errorhandler.mistake")); + assert(!Interpreter::nameMatch(transEvents, "errOr.send")); + assert(!Interpreter::nameMatch(transEvents, "foobar")); +}
\ No newline at end of file diff --git a/test/src/test-predicates.scxml b/test/src/test-predicates.scxml new file mode 100644 index 0000000..98848a2 --- /dev/null +++ b/test/src/test-predicates.scxml @@ -0,0 +1,9 @@ +<scxml> + <state id="atomic" /> + <state id="compound"> + <state id="compundChild1" /> + <state id="compundChild2" /> + </state> + <parallel id="parallel"> + </parallel> +</scxml>
\ No newline at end of file |