Author: rahul
Date: Mon Aug  6 14:38:03 2007
New Revision: 563287

URL: http://svn.apache.org/viewvc?view=rev&rev=563287
Log:
SimpleSCXMLInvoker may miss transition to final state.
SCXML-49

Added:
    
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/invoked-02.xml
   (with props)
    
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/invoker-02.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?view=diff&rev=563287&r1=563286&r2=563287
==============================================================================
--- 
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
 Mon Aug  6 14:38:03 2007
@@ -111,6 +111,11 @@
         } catch (ModelException me) {
             throw new InvokerException(me.getMessage(), me.getCause());
         }
+        if (executor.getCurrentStatus().isFinal()) {
+            TriggerEvent te = new TriggerEvent(eventPrefix + invokeDone,
+                TriggerEvent.SIGNAL_EVENT);
+            new AsyncTrigger(parentSCInstance.getExecutor(), te);
+        }
     }
 
     /**

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?view=diff&rev=563287&r1=563286&r2=563287
==============================================================================
--- 
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
 Mon Aug  6 14:38:03 2007
@@ -54,7 +54,7 @@
     }
 
     // Test data
-    private URL invoke01;
+    private URL invoke01, invoke02;
     private SCXMLExecutor exec;
 
     /**
@@ -63,13 +63,15 @@
     public void setUp() {
         invoke01 = this.getClass().getClassLoader().
             getResource("org/apache/commons/scxml/invoke/invoker-01.xml");
+        invoke02 = this.getClass().getClassLoader().
+            getResource("org/apache/commons/scxml/invoke/invoker-02.xml");
     }
 
     /**
      * Tear down instance variables required by this test case.
      */
     public void tearDown() {
-        invoke01 = null;
+        invoke01 = invoke02 = null;
     }
 
     /**
@@ -90,6 +92,25 @@
             assertEquals(1, currentStates.size());
             assertEquals("invoker", ((State)currentStates.iterator().
                 next()).getId());
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        }
+    }
+
+    public void testInvoke02Sample() {
+        try {
+            SCXML scxml = SCXMLDigester.digest(invoke02,
+                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());
         } catch (Exception e) {
             e.printStackTrace();
             fail(e.getMessage());

Added: 
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/invoked-02.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/invoked-02.xml?view=auto&rev=563287
==============================================================================
--- 
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/invoked-02.xml
 (added)
+++ 
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/invoked-02.xml
 Mon Aug  6 14:38:03 2007
@@ -0,0 +1,32 @@
+<?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="state1">
+
+    <state id="state1">
+        <onentry>
+            <send event="invoked.next" />
+        </onentry>
+        <transition event="invoked.next" target="state2" />
+    </state>
+
+    <state id="state2" final="true" />
+
+</scxml>
+

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

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

Added: 
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/invoker-02.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/invoker-02.xml?view=auto&rev=563287
==============================================================================
--- 
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/invoker-02.xml
 (added)
+++ 
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/invoker-02.xml
 Mon Aug  6 14:38:03 2007
@@ -0,0 +1,30 @@
+<?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="invoker">
+
+    <state id="invoker">
+        <invoke targettype="scxml" src="invoked-02.xml"/>
+        <transition event="invoker.invoke.done" target="end" />
+    </state>
+
+    <state id="end" final="true" />
+
+</scxml>
+

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

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


Reply via email to