Author: rahul
Date: Sat Mar 24 10:53:54 2007
New Revision: 522070
URL: http://svn.apache.org/viewvc?view=rev&rev=522070
Log:
o Add some test cases which fail using the old parser, but will pass with the
new parser.
- Not hooked in yet, so tests won't execute
- The entire test directory structure should be reorganized (perhaps Java and
XML files should be separated out, SCXML documents should be filed per WD
version etc.). Perhaps one day I might have an urge to clean the tests up a bit.
o One line of whitespace added to SCXMLTestHelper (useful to have that between
methods)
Added:
jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/env/jexl/microwave-03.xml
(with props)
jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/env/jexl/microwave-04.xml
(with props)
jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/io/SCXMLParserTest.java
(with props)
jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/transitions-04.xml
(with props)
Modified:
jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/SCXMLTestHelper.java
Modified:
jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/SCXMLTestHelper.java
URL:
http://svn.apache.org/viewvc/jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/SCXMLTestHelper.java?view=diff&rev=522070&r1=522069&r2=522070
==============================================================================
---
jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/SCXMLTestHelper.java
(original)
+++
jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/SCXMLTestHelper.java
Sat Mar 24 10:53:54 2007
@@ -112,6 +112,7 @@
SCXML roundtrip = testModelSerializability(scxml);
return roundtrip;
}
+
public static SCXMLExecutor getExecutor(final URL url) {
SCXML scxml = digest(url);
Evaluator evaluator = new JexlEvaluator();
Added:
jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/env/jexl/microwave-03.xml
URL:
http://svn.apache.org/viewvc/jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/env/jexl/microwave-03.xml?view=auto&rev=522070
==============================================================================
---
jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/env/jexl/microwave-03.xml
(added)
+++
jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/env/jexl/microwave-03.xml
Sat Mar 24 10:53:54 2007
@@ -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://jakarta.apache.org/commons/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>
Propchange:
jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/env/jexl/microwave-03.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/env/jexl/microwave-03.xml
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added:
jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/env/jexl/microwave-04.xml
URL:
http://svn.apache.org/viewvc/jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/env/jexl/microwave-04.xml?view=auto&rev=522070
==============================================================================
---
jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/env/jexl/microwave-04.xml
(added)
+++
jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/env/jexl/microwave-04.xml
Sat Mar 24 10:53:54 2007
@@ -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://jakarta.apache.org/commons/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>
Propchange:
jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/env/jexl/microwave-04.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/env/jexl/microwave-04.xml
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added:
jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/io/SCXMLParserTest.java
URL:
http://svn.apache.org/viewvc/jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/io/SCXMLParserTest.java?view=auto&rev=522070
==============================================================================
---
jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/io/SCXMLParserTest.java
(added)
+++
jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/io/SCXMLParserTest.java
Sat Mar 24 10:53:54 2007
@@ -0,0 +1,97 @@
+/*
+ * 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.
+ */
+package org.apache.commons.scxml.io;
+
+import java.net.URL;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+import org.apache.commons.scxml.SCXMLTestHelper;
+import org.apache.commons.scxml.model.SCXML;
+/**
+ * Unit tests [EMAIL PROTECTED] org.apache.commons.scxml.SCXMLParser}.
+ */
+public class SCXMLParserTest extends TestCase {
+ /**
+ * Construct a new instance of SCXMLDigesterTest with
+ * the specified name
+ */
+ public SCXMLParserTest(String name) {
+ super(name);
+ }
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(SCXMLParserTest.class);
+ suite.setName("SCXML Parser Tests");
+ return suite;
+ }
+
+ // Test data
+ private URL microwave03, microwave04;
+ private SCXML scxml;
+ private String scxmlAsString;
+
+ /**
+ * Set up instance variables required by this test case.
+ */
+ public void setUp() {
+ microwave03 = this.getClass().getClassLoader().
+ getResource("org/apache/commons/scxml/env/jexl/microwave-03.xml");
+ microwave04 = this.getClass().getClassLoader().
+ getResource("org/apache/commons/scxml/env/jexl/microwave-04.xml");
+ }
+
+ /**
+ * Tear down instance variables required by this test case.
+ */
+ public void tearDown() {
+ microwave03 = microwave04 = null;
+ scxml = null;
+ scxmlAsString = null;
+ }
+
+ /**
+ * Test the implementation
+ */
+ public void testSCXMLParserMicrowave03Sample() {
+ scxml = SCXMLTestHelper.parse(microwave03);
+ assertNotNull(scxml);
+ scxmlAsString = serialize(scxml);
+ assertNotNull(scxmlAsString);
+ }
+
+ public void testSCXMLParserMicrowave04Sample() {
+ scxml = SCXMLTestHelper.parse(microwave04);
+ assertNotNull(scxml);
+ scxmlAsString = serialize(scxml);
+ assertNotNull(scxmlAsString);
+ }
+
+ private String serialize(final SCXML scxml) {
+ scxmlAsString = SCXMLSerializer.serialize(scxml);
+ assertNotNull(scxmlAsString);
+ return scxmlAsString;
+ }
+
+ public static void main(String args[]) {
+ TestRunner.run(suite());
+ }
+}
+
Propchange:
jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/io/SCXMLParserTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/io/SCXMLParserTest.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added:
jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/transitions-04.xml
URL:
http://svn.apache.org/viewvc/jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/transitions-04.xml?view=auto&rev=522070
==============================================================================
---
jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/transitions-04.xml
(added)
+++
jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/transitions-04.xml
Sat Mar 24 10:53:54 2007
@@ -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>
+
Propchange:
jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/transitions-04.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/transitions-04.xml
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]