Author: rahul
Date: Mon Nov  6 17:36:54 2006
New Revision: 471963

URL: http://svn.apache.org/viewvc?view=rev&rev=471963
Log:
Add a test case that demonstrates adding a custom action with the same local 
name as one of the standard SCXML actions (in this test case, local name "send" 
is reused in another namespace), and its successful execution.

Added:
    
jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/custom-hello-world-03.xml
   (with props)
Modified:
    
jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/model/CustomActionTest.java

Added: 
jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/custom-hello-world-03.xml
URL: 
http://svn.apache.org/viewvc/jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/custom-hello-world-03.xml?view=auto&rev=471963
==============================================================================
--- 
jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/custom-hello-world-03.xml
 (added)
+++ 
jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/custom-hello-world-03.xml
 Mon Nov  6 17:36:54 2006
@@ -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="child (included) document" />
+        </onentry>
+
+    </state>
+
+</scxml>
+

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

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

Modified: 
jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/model/CustomActionTest.java
URL: 
http://svn.apache.org/viewvc/jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/model/CustomActionTest.java?view=diff&rev=471963&r1=471962&r2=471963
==============================================================================
--- 
jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/model/CustomActionTest.java
 (original)
+++ 
jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/model/CustomActionTest.java
 Mon Nov  6 17:36:54 2006
@@ -43,7 +43,7 @@
         junit.textui.TestRunner.main(testCaseName);
     }
 
-    private URL hello01, custom01, external01;
+    private URL hello01, custom01, external01, override01;
     private Digester digester;
     private SCXMLExecutor exec;
 
@@ -57,6 +57,8 @@
             getResource("org/apache/commons/scxml/custom-hello-world-01.xml");
         external01 = this.getClass().getClassLoader().
             getResource("org/apache/commons/scxml/external-hello-world.xml");
+        override01 = this.getClass().getClassLoader().
+            getResource("org/apache/commons/scxml/custom-hello-world-03.xml");
     }
 
     /**
@@ -189,10 +191,28 @@
             iterator().next()).getId());
     }
 
+    // Hello World example using custom <my:send> action
+    // (overriding SCXML local name "send")
+    public void testCustomActionOverrideLocalName() {
+        // (1) List of custom actions, use same local name as SCXML action
+        CustomAction ca =
+            new CustomAction("http://my.custom-actions.domain/CUSTOM";,
+                             "send", Hello.class);
+        List customActions = new ArrayList();
+        customActions.add(ca);
+        // (2) Parse the document with a custom digester.
+        SCXML scxml = SCXMLTestHelper.digest(override01, customActions);
+        // (3) Get a SCXMLExecutor
+        exec = SCXMLTestHelper.getExecutor(scxml);
+        // (4) Single, final state
+        assertEquals("custom", ((State) exec.getCurrentStatus().getStates().
+            iterator().next()).getId());
+    }
+
     // The custom action defined by Hello.class should be called
-    // to execute() exactly 4 times upto this point
+    // to execute() exactly 5 times upto this point
     public void testCustomActionCallbacks() {
-        assertEquals(4, Hello.callbacks);
+        assertEquals(5, Hello.callbacks);
     }
 
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to