commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ra...@apache.org
Subject svn commit: r515801 - in /jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml: SCXMLTestSuite.java TieBreakerTest.java tie-breaker-01.xml tie-breaker-02.xml tie-breaker-03.xml
Date Wed, 07 Mar 2007 22:09:03 GMT
Author: rahul
Date: Wed Mar  7 14:09:03 2007
New Revision: 515801

URL: http://svn.apache.org/viewvc?view=rev&rev=515801
Log:
Upto v0.6, non-deterministic behavior leads to an error condition. Based on the February 2007
WD, such non-determinism should now be resolved based on document order and heirarchy of states
within the state machine. Adding a suite of "tie breaker" tests that fail on v0.6, but need
to pass on v0.7. Since none of that work is done yet, the tests are commented out.

Added:
    jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/TieBreakerTest.java
  (with props)
    jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/tie-breaker-01.xml
  (with props)
    jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/tie-breaker-02.xml
  (with props)
    jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/tie-breaker-03.xml
  (with props)
Modified:
    jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/SCXMLTestSuite.java

Modified: jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/SCXMLTestSuite.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/SCXMLTestSuite.java?view=diff&rev=515801&r1=515800&r2=515801
==============================================================================
--- jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/SCXMLTestSuite.java
(original)
+++ jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/SCXMLTestSuite.java
Wed Mar  7 14:09:03 2007
@@ -54,6 +54,7 @@
         suite.addTest(SCXMLExecutorTest.suite());
         suite.addTest(SCXMLHelperTest.suite());
         suite.addTest(StatusTest.suite());
+        suite.addTest(TieBreakerTest.suite());
         suite.addTest(TriggerEventTest.suite());
         suite.addTest(WildcardTest.suite());
         suite.addTest(WizardsTest.suite());

Added: jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/TieBreakerTest.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/TieBreakerTest.java?view=auto&rev=515801
==============================================================================
--- jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/TieBreakerTest.java
(added)
+++ jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/TieBreakerTest.java
Wed Mar  7 14:09:03 2007
@@ -0,0 +1,125 @@
+/*
+ * 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;
+
+import java.net.URL;
+import java.util.Set;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+import org.apache.commons.scxml.model.State;
+/**
+ * Unit tests for testing conflict resolution amongst multiple transitions
+ * within the {@link org.apache.commons.scxml.SCXMLExecutor}'s default
+ * semantics.
+ *
+ * Upto v0.6, non-deterministic behavior leads to an error condition. Based
+ * on the February 2007 WD, such non-determinism should now be resolved
+ * based on document order and heirarchy of states within the state machine.
+ * This class tests various such cases where more than one candidate
+ * transition exists at a particular point, and tie-breaking rules are used
+ * to make progress, rather than resulting in error conditions.
+ */
+public class TieBreakerTest extends TestCase {
+    /**
+     * Construct a new instance of SCXMLExecutorTest with
+     * the specified name
+     */
+    public TieBreakerTest(String name) {
+        super(name);
+    }
+
+    public static Test suite() {
+        TestSuite suite = new TestSuite(TieBreakerTest.class);
+        suite.setName("SCXML Executor Tie-Breaker Tests");
+        return suite;
+    }
+
+    // Test data
+    private URL tiebreaker01, tiebreaker02, tiebreaker03;
+    private SCXMLExecutor exec;
+
+    /**
+     * Set up instance variables required by this test case.
+     */
+    public void setUp() {
+        tiebreaker01 = this.getClass().getClassLoader().
+            getResource("org/apache/commons/scxml/tie-breaker-01.xml");
+        tiebreaker02 = this.getClass().getClassLoader().
+            getResource("org/apache/commons/scxml/tie-breaker-02.xml");
+        tiebreaker03 = this.getClass().getClassLoader().
+            getResource("org/apache/commons/scxml/tie-breaker-03.xml");
+    }
+
+    /**
+     * Tear down instance variables required by this test case.
+     */
+    public void tearDown() {
+        tiebreaker01 = tiebreaker02 = tiebreaker03 = null;
+    }
+
+    /**
+     * Test the implementation
+     */
+    /* TODO - These tests must pass before v0.7
+    public void testTieBreaker01() {
+        exec = SCXMLTestHelper.getExecutor(tiebreaker01);
+        assertNotNull(exec);
+        Set currentStates = exec.getCurrentStatus().getStates();
+        assertEquals(1, currentStates.size());
+        assertEquals("ten", ((State)currentStates.iterator().
+            next()).getId());
+        currentStates = SCXMLTestHelper.fireEvent(exec, "ten.done");
+        assertEquals(1, currentStates.size());
+        assertEquals("twenty", ((State)currentStates.iterator().
+            next()).getId());
+    }
+
+    public void testTieBreaker02() {
+        exec = SCXMLTestHelper.getExecutor(tiebreaker02);
+        assertNotNull(exec);
+        Set currentStates = exec.getCurrentStatus().getStates();
+        assertEquals(1, currentStates.size());
+        assertEquals("eleven", ((State)currentStates.iterator().
+            next()).getId());
+        currentStates = SCXMLTestHelper.fireEvent(exec, "ten.done");
+        assertEquals(1, currentStates.size());
+        assertEquals("thirty", ((State)currentStates.iterator().
+            next()).getId());
+    }
+
+    public void testTieBreaker03() {
+        exec = SCXMLTestHelper.getExecutor(tiebreaker03);
+        assertNotNull(exec);
+        Set currentStates = exec.getCurrentStatus().getStates();
+        assertEquals(1, currentStates.size());
+        assertEquals("eleven", ((State)currentStates.iterator().
+            next()).getId());
+        currentStates = SCXMLTestHelper.fireEvent(exec, "ten.done");
+        assertEquals(1, currentStates.size());
+        assertEquals("forty", ((State)currentStates.iterator().
+            next()).getId());
+    }*/
+
+    public static void main(String args[]) {
+        TestRunner.run(suite());
+    }
+}
+

Propchange: jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/TieBreakerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/TieBreakerTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/tie-breaker-01.xml
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/tie-breaker-01.xml?view=auto&rev=515801
==============================================================================
--- jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/tie-breaker-01.xml
(added)
+++ jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/tie-breaker-01.xml
Wed Mar  7 14:09:03 2007
@@ -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.
+-->
+<!--
+  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>
+

Propchange: jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/tie-breaker-01.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/tie-breaker-01.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/tie-breaker-02.xml
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/tie-breaker-02.xml?view=auto&rev=515801
==============================================================================
--- jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/tie-breaker-02.xml
(added)
+++ jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/tie-breaker-02.xml
Wed Mar  7 14:09:03 2007
@@ -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>
+

Propchange: jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/tie-breaker-02.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/tie-breaker-02.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/tie-breaker-03.xml
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/tie-breaker-03.xml?view=auto&rev=515801
==============================================================================
--- jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/tie-breaker-03.xml
(added)
+++ jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/tie-breaker-03.xml
Wed Mar  7 14:09:03 2007
@@ -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>
+

Propchange: jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/tie-breaker-03.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/tie-breaker-03.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message