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 2006/04/03 22:35:44 UTC
svn commit: r391145 - in /jakarta/commons/sandbox/scxml/trunk/src:
main/java/org/apache/commons/scxml/semantics/
test/java/org/apache/commons/scxml/
test/java/org/apache/commons/scxml/env/jexl/
Author: rahul
Date: Mon Apr 3 13:35:43 2006
New Revision: 391145
URL: http://svn.apache.org/viewcvs?rev=391145&view=rev
Log:
Applying additions between Sep '05 and Jan '06 SCXML WDs related to events [part 2].
The wildcard event name "*" (a single asterisk) matches all event names.
Added a test case illustrating the usage.
Added:
jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/WildcardTest.java (with props)
jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/env/jexl/wildcard-01.xml (with props)
Modified:
jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/semantics/SCXMLSemanticsImpl.java
jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/SCXMLTestSuite.java
Modified: jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/semantics/SCXMLSemanticsImpl.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/semantics/SCXMLSemanticsImpl.java?rev=391145&r1=391144&r2=391145&view=diff
==============================================================================
--- jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/semantics/SCXMLSemanticsImpl.java (original)
+++ jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/semantics/SCXMLSemanticsImpl.java Mon Apr 3 13:35:43 2006
@@ -597,13 +597,14 @@
if (SCXMLHelper.isStringEmpty(transEvent)) {
return true;
} else {
- String transEventDot = transEvent + "."; //wildcard (prefix) event
- // support
+ String transEventDot = transEvent + "."; // prefix event support
Iterator i = eventOccurrences.iterator();
while (i.hasNext()) {
String evt = (String) i.next();
if (evt == null) {
continue; // Unnamed events
+ } else if (evt.equals("*")) {
+ return true; // Wildcard
} else if (evt.equals(transEvent)
|| evt.startsWith(transEventDot)) {
return true;
Modified: jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/SCXMLTestSuite.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/SCXMLTestSuite.java?rev=391145&r1=391144&r2=391145&view=diff
==============================================================================
--- jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/SCXMLTestSuite.java (original)
+++ jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/SCXMLTestSuite.java Mon Apr 3 13:35:43 2006
@@ -53,6 +53,7 @@
suite.addTest(SCXMLHelperTest.suite());
suite.addTest(StatusTest.suite());
suite.addTest(TriggerEventTest.suite());
+ suite.addTest(WildcardTest.suite());
suite.addTest(WizardsTest.suite());
return suite;
}
Added: jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/WildcardTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/WildcardTest.java?rev=391145&view=auto
==============================================================================
--- jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/WildcardTest.java (added)
+++ jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/WildcardTest.java Mon Apr 3 13:35:43 2006
@@ -0,0 +1,88 @@
+/*
+ * 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.
+ */
+package org.apache.commons.scxml;
+
+import java.net.URL;
+import java.util.Set;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+import org.apache.commons.scxml.model.State;
+/**
+ * Unit tests {@link org.apache.commons.scxml.SCXMLExecutor}.
+ * Testing wildcard event matching (*)
+ */
+public class WildcardTest extends TestCase {
+ /**
+ * Construct a new instance of SCXMLExecutorTest with
+ * the specified name
+ */
+ public WildcardTest(String name) {
+ super(name);
+ }
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(WildcardTest.class);
+ suite.setName("SCXML Executor Tests, wildcard event match");
+ return suite;
+ }
+
+ // Test data
+ private URL wildcard01;
+ private SCXMLExecutor exec;
+
+ /**
+ * Set up instance variables required by this test case.
+ */
+ public void setUp() {
+ wildcard01 = this.getClass().getClassLoader().
+ getResource("org/apache/commons/scxml/env/jexl/wildcard-01.xml");
+ }
+
+ /**
+ * Tear down instance variables required by this test case.
+ */
+ public void tearDown() {
+ wildcard01 = null;
+ }
+
+ /**
+ * Test the SCXML documents, usage of "_eventdata"
+ */
+ public void testWildcard01Sample() {
+ exec = SCXMLTestHelper.getExecutor(wildcard01);
+ assertNotNull(exec);
+ try {
+ Set currentStates = exec.getCurrentStatus().getStates();
+ assertEquals(1, currentStates.size());
+ assertEquals("state1", ((State)currentStates.iterator().
+ next()).getId());
+ currentStates = SCXMLTestHelper.fireEvent(exec, "*");
+ assertEquals(1, currentStates.size());
+ assertEquals("state4", ((State)currentStates.iterator().
+ next()).getId());
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+ }
+
+ public static void main(String args[]) {
+ TestRunner.run(suite());
+ }
+}
Propchange: jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/WildcardTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/WildcardTest.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/env/jexl/wildcard-01.xml
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/env/jexl/wildcard-01.xml?rev=391145&view=auto
==============================================================================
--- jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/env/jexl/wildcard-01.xml (added)
+++ jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/env/jexl/wildcard-01.xml Mon Apr 3 13:35:43 2006
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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="state1">
+ <state id="state1">
+ <onentry>
+ <var name="switch" expr="4" />
+ </onentry>
+ <!-- We'll match all the events using a wildcard (*),
+ and therefore, must end up in state4 -->
+ <transition event="foo.bar" cond="switch eq 2" target="state2"/>
+ <transition event="err.foo" cond="switch eq 3" target="state3"/>
+ <transition event="done.it" cond="switch eq 4" target="state4"/>
+ </state>
+ <state id="state2" final="true"/>
+ <state id="state3" final="true"/>
+ <state id="state4" final="true"/>
+</scxml>
Propchange: jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/env/jexl/wildcard-01.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/env/jexl/wildcard-01.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