You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ra...@apache.org on 2007/03/12 21:16:04 UTC

svn commit: r517367 - in /jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml: SCXMLExecutorTest.java transitions-03.xml

Author: rahul
Date: Mon Mar 12 13:16:03 2007
New Revision: 517367

URL: http://svn.apache.org/viewvc?view=rev&rev=517367
Log:
Add a test case for multiple transition targets (fails on v0.6, passes on trunk). Choose targets that are not respective initials in their region.

Added:
    jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/transitions-03.xml   (with props)
Modified:
    jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/SCXMLExecutorTest.java

Modified: jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/SCXMLExecutorTest.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/SCXMLExecutorTest.java?view=diff&rev=517367&r1=517366&r2=517367
==============================================================================
--- jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/SCXMLExecutorTest.java (original)
+++ jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/SCXMLExecutorTest.java Mon Mar 12 13:16:03 2007
@@ -17,6 +17,8 @@
 package org.apache.commons.scxml;
 
 import java.net.URL;
+import java.util.HashSet;
+import java.util.Iterator;
 import java.util.Set;
 
 import junit.framework.Test;
@@ -27,6 +29,7 @@
 import org.apache.commons.scxml.env.SimpleContext;
 import org.apache.commons.scxml.env.jsp.ELEvaluator;
 import org.apache.commons.scxml.model.State;
+import org.apache.commons.scxml.model.TransitionTarget;
 /**
  * Unit tests {@link org.apache.commons.scxml.SCXMLExecutor}.
  */
@@ -47,7 +50,8 @@
 
     // Test data
     private URL microwave01jsp, microwave02jsp, microwave01jexl,
-        microwave02jexl, transitions01, transitions02, prefix01, send01, send02;
+        microwave02jexl, transitions01, transitions02, transitions03,
+        prefix01, send01, send02;
     private SCXMLExecutor exec;
 
     /**
@@ -66,6 +70,8 @@
             getResource("org/apache/commons/scxml/transitions-01.xml");
         transitions02 = this.getClass().getClassLoader().
             getResource("org/apache/commons/scxml/transitions-02.xml");
+        transitions03 = this.getClass().getClassLoader().
+            getResource("org/apache/commons/scxml/transitions-03.xml");
         prefix01 = this.getClass().getClassLoader().
             getResource("org/apache/commons/scxml/prefix-01.xml");
         send01 = this.getClass().getClassLoader().
@@ -79,7 +85,8 @@
      */
     public void tearDown() {
         microwave01jsp = microwave02jsp = microwave01jexl = microwave02jexl =
-            transitions01 = transitions02 = prefix01 = send01 = send02 = null;
+            transitions01 = transitions02 = transitions03 = prefix01 =
+            send01 = send02 = null;
     }
 
     /**
@@ -165,6 +172,27 @@
         }
     }
 
+    public void testSCXMLExecutorTransitions03Sample() {
+        exec = SCXMLTestHelper.getExecutor(transitions03);
+        assertNotNull(exec);
+        try {
+            Set currentStates = SCXMLTestHelper.fireEvent(exec, "ten.done");
+            assertEquals(3, currentStates.size());
+            Set expected = new HashSet();
+            expected.add("twenty_one_2");
+            expected.add("twenty_two_2");
+            expected.add("twenty_three_2");
+            for (Iterator i = currentStates.iterator(); i.hasNext(); ) {
+                TransitionTarget tt = (TransitionTarget) i.next();
+                if (!expected.remove(tt.getId())) {
+                    fail("'" + tt.getId()
+                        + "' is not an expected current state ID");
+                }
+            }
+        } catch (Exception e) {
+            fail(e.getMessage());
+        }
+    }
     public void testSend01Sample() {
         exec = SCXMLTestHelper.getExecutor(send01);
         assertNotNull(exec);

Added: jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/transitions-03.xml
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/transitions-03.xml?view=auto&rev=517367
==============================================================================
--- jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/transitions-03.xml (added)
+++ jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/transitions-03.xml Mon Mar 12 13:16:03 2007
@@ -0,0 +1,92 @@
+<?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>
+
+    <state id="twenty">
+
+        <parallel id="twenties_parallel">
+
+            <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>
+
+    <state id="thirty" final="true" />
+
+</scxml>
+

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

Propchange: jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/transitions-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