You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ra...@apache.org on 2007/12/01 00:47:01 UTC

svn commit: r600016 - in /commons/proper/scxml/trunk/src: main/java/org/apache/commons/scxml/invoke/ test/java/org/apache/commons/scxml/invoke/

Author: rahul
Date: Fri Nov 30 15:46:59 2007
New Revision: 600016

URL: http://svn.apache.org/viewvc?rev=600016&view=rev
Log:
Support nested invokes when using SimpleSCXMLInvoker.

Added:
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/invoked-03-01.xml   (with props)
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/invoked-03.xml   (with props)
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/invoker-03.xml   (with props)
Modified:
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/invoke/SimpleSCXMLInvoker.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/InvokeTest.java

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/invoke/SimpleSCXMLInvoker.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/invoke/SimpleSCXMLInvoker.java?rev=600016&r1=600015&r2=600016&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/invoke/SimpleSCXMLInvoker.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/invoke/SimpleSCXMLInvoker.java Fri Nov 30 15:46:59 2007
@@ -18,6 +18,7 @@
 
 import java.io.IOException;
 import java.io.Serializable;
+import java.net.URL;
 import java.util.Iterator;
 import java.util.Map;
 
@@ -86,8 +87,8 @@
     throws InvokerException {
         SCXML scxml = null;
         try {
-            scxml = SCXMLDigester.digest(source,
-                new SimpleErrorHandler(), null);
+            scxml = SCXMLDigester.digest(new URL(source),
+                new SimpleErrorHandler());
         } catch (ModelException me) {
             throw new InvokerException(me.getMessage(), me.getCause());
         } catch (IOException ioe) {
@@ -106,6 +107,7 @@
         executor.setRootContext(rootCtx);
         executor.setStateMachine(scxml);
         executor.addListener(scxml, new SimpleSCXMLListener());
+        executor.registerInvokerClass("scxml", this.getClass());
         try {
             executor.go();
         } catch (ModelException me) {

Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/InvokeTest.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/InvokeTest.java?rev=600016&r1=600015&r2=600016&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/InvokeTest.java (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/InvokeTest.java Fri Nov 30 15:46:59 2007
@@ -25,6 +25,7 @@
 import junit.textui.TestRunner;
 
 import org.apache.commons.scxml.SCXMLExecutor;
+import org.apache.commons.scxml.SCXMLTestHelper;
 import org.apache.commons.scxml.env.SimpleDispatcher;
 import org.apache.commons.scxml.env.SimpleErrorHandler;
 import org.apache.commons.scxml.env.SimpleErrorReporter;
@@ -54,7 +55,7 @@
     }
 
     // Test data
-    private URL invoke01, invoke02;
+    private URL invoke01, invoke02, invoke03;
     private SCXMLExecutor exec;
 
     /**
@@ -65,13 +66,15 @@
             getResource("org/apache/commons/scxml/invoke/invoker-01.xml");
         invoke02 = this.getClass().getClassLoader().
             getResource("org/apache/commons/scxml/invoke/invoker-02.xml");
+        invoke03 = this.getClass().getClassLoader().
+            getResource("org/apache/commons/scxml/invoke/invoker-03.xml");
     }
 
     /**
      * Tear down instance variables required by this test case.
      */
     public void tearDown() {
-        invoke01 = invoke02 = null;
+        invoke01 = invoke02 = invoke03 = null;
     }
 
     /**
@@ -111,6 +114,27 @@
             exec.go();
             Set currentStates = exec.getCurrentStatus().getStates();
             assertEquals(1, currentStates.size());
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        }
+    }
+
+    public void testInvoke03Sample() {
+        try {
+            SCXML scxml = SCXMLDigester.digest(invoke03,
+                new SimpleErrorHandler());
+            exec = new SCXMLExecutor(new JexlEvaluator(), new SimpleDispatcher(),
+                new SimpleErrorReporter());
+            assertNotNull(exec);
+            exec.setRootContext(new JexlContext());
+            exec.setStateMachine(scxml);
+            exec.registerInvokerClass("scxml", SimpleSCXMLInvoker.class);
+            exec.go();
+            Set currentStates = exec.getCurrentStatus().getStates();
+            assertEquals(1, currentStates.size());
+            SCXMLTestHelper.fireEvent(exec, "s1.next");
+            SCXMLTestHelper.fireEvent(exec, "state1.next");
         } catch (Exception e) {
             e.printStackTrace();
             fail(e.getMessage());

Added: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/invoked-03-01.xml
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/invoked-03-01.xml?rev=600016&view=auto
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/invoked-03-01.xml (added)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/invoked-03-01.xml Fri Nov 30 15:46:59 2007
@@ -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>
+

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

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

Added: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/invoked-03.xml
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/invoked-03.xml?rev=600016&view=auto
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/invoked-03.xml (added)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/invoked-03.xml Fri Nov 30 15:46:59 2007
@@ -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.
+-->
+<!-- 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 targettype="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>
+

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

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

Added: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/invoker-03.xml
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/invoker-03.xml?rev=600016&view=auto
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/invoker-03.xml (added)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/invoker-03.xml Fri Nov 30 15:46:59 2007
@@ -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.
+-->
+<!-- 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 targettype="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>
+

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

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