Author: rahul
Date: Mon Aug 7 16:53:33 2006
New Revision: 429516
URL: http://svn.apache.org/viewvc?rev=429516&view=rev
Log:
Allow the target of a transition to be omitted.
Variant of patch by: Sitthichai Rernglertpricha <sitthichai_rernglertpricha AT
yahoo DOT com>
Also added a test case to ensure stay, self and regular transition behavior.
SCXML-14
Added:
jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/transitions-02.xml
Modified:
jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/io/ModelUpdater.java
jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/SCXMLExecutorTest.java
Modified:
jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/io/ModelUpdater.java
URL:
http://svn.apache.org/viewvc/jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/io/ModelUpdater.java?rev=429516&r1=429515&r2=429516&view=diff
==============================================================================
---
jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/io/ModelUpdater.java
(original)
+++
jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/io/ModelUpdater.java
Mon Aug 7 16:53:33 2006
@@ -224,6 +224,9 @@
private static void updateTransition(final Transition t,
final Map targets) throws ModelException {
String next = t.getNext();
+ if (next == null) { // stay transition
+ return;
+ }
TransitionTarget tt = t.getTarget();
if (tt == null) {
tt = (TransitionTarget) targets.get(next);
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?rev=429516&r1=429515&r2=429516&view=diff
==============================================================================
---
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 Aug 7 16:53:33 2006
@@ -46,7 +46,7 @@
// Test data
private URL microwave01jsp, microwave02jsp, microwave01jexl,
- microwave02jexl, transitions01, send02;
+ microwave02jexl, transitions01, transitions02, send02;
private SCXMLExecutor exec;
/**
@@ -63,6 +63,8 @@
getResource("org/apache/commons/scxml/env/jexl/microwave-02.xml");
transitions01 = this.getClass().getClassLoader().
getResource("org/apache/commons/scxml/transitions-01.xml");
+ transitions02 = this.getClass().getClassLoader().
+ getResource("org/apache/commons/scxml/transitions-02.xml");
send02 = this.getClass().getClassLoader().
getResource("org/apache/commons/scxml/send-02.xml");
}
@@ -72,7 +74,7 @@
*/
public void tearDown() {
microwave01jsp = microwave02jsp = microwave01jexl = microwave02jexl =
- transitions01 = send02 = null;
+ transitions01 = transitions02 = send02 = null;
}
/**
@@ -118,6 +120,27 @@
next()).getId());
currentStates = SCXMLTestHelper.fireEvent(exec, "twenty_two.done");
assertEquals(3, exec.getCurrentStatus().getStates().size());
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+ }
+
+ public void testSCXMLExecutorTransitions02Sample() {
+ exec = SCXMLTestHelper.getExecutor(transitions02);
+ assertNotNull(exec);
+ try {
+ Set currentStates = SCXMLTestHelper.fireEvent(exec, "ten.stay");
+ assertEquals(1, currentStates.size());
+ assertEquals("ten", ((State)currentStates.iterator().
+ next()).getId());
+ currentStates = SCXMLTestHelper.fireEvent(exec, "ten.self");
+ 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());
} catch (Exception e) {
fail(e.getMessage());
}
Added:
jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/transitions-02.xml
URL:
http://svn.apache.org/viewvc/jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/transitions-02.xml?rev=429516&view=auto
==============================================================================
---
jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/transitions-02.xml
(added)
+++
jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/transitions-02.xml
Mon Aug 7 16:53:33 2006
@@ -0,0 +1,51 @@
+<?xml version="1.0"?>
+<!--
+ Copyright 2006 The Apache Software Foundation
+
+ Licensed 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">
+
+ <onentry>
+ <var name="foo" expr="1" />
+ <log expr="'Foo is:' + foo" />
+ </onentry>
+
+ <!-- stay transition -->
+ <transition event="ten.stay">
+ <assign name="foo" expr="foo + 1" />
+ <log expr="'Foo is:' + foo" />
+ </transition>
+
+ <!-- self transition -->
+ <transition event="ten.self" target="ten">
+ <assign name="foo" expr="foo + 1" />
+ <log expr="'Foo is:' + foo" />
+ </transition>
+
+ <!-- "regular" transition -->
+ <transition event="ten.done" target="twenty">
+ <assign name="foo" expr="foo + 1" />
+ <log expr="'Foo is:' + foo" />
+ </transition>
+
+ </state>
+
+ <state id="twenty" final="true" />
+
+</scxml>
+
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]