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:43:51 UTC
svn commit: r600015 - in
/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml:
env/jexl/datamodel-04.xml model/DatamodelTest.java
Author: rahul
Date: Fri Nov 30 15:43:39 2007
New Revision: 600015
URL: http://svn.apache.org/viewvc?rev=600015&view=rev
Log:
Test case illustrating usage of data model to persist event data. No functional change.
Added:
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/env/jexl/datamodel-04.xml (with props)
Modified:
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/model/DatamodelTest.java
Added: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/env/jexl/datamodel-04.xml
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/env/jexl/datamodel-04.xml?rev=600015&view=auto
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/env/jexl/datamodel-04.xml (added)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/env/jexl/datamodel-04.xml Fri Nov 30 15:43:39 2007
@@ -0,0 +1,47 @@
+<?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.
+-->
+<!-- A fictitious state machine used by test cases.
+ Meant to illustrate the usage of SCXML <datamodel> element
+ to persist some _eventdata -->
+<scxml xmlns="http://www.w3.org/2005/07/scxml"
+ version="1.0"
+ initialstate="ten">
+
+ <!-- Root or document datamodel -->
+ <datamodel>
+ <data name="payload"/>
+ </datamodel>
+
+ <state id="ten">
+ <transition event="ten.done" target="twenty">
+ <assign name="payload" expr="_eventdata" />
+ </transition>
+ </state>
+
+ <state id="twenty">
+ <transition event="twenty.done" target="thirty" />
+ <onexit>
+ <log label="Persisted eventdata.one" expr="payload.one"/>
+ <log label="Persisted eventdata.two" expr="payload.two"/>
+ </onexit>
+ </state>
+
+ <state id="thirty" final="true"/>
+
+</scxml>
+
Propchange: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/env/jexl/datamodel-04.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/env/jexl/datamodel-04.xml
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/model/DatamodelTest.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/model/DatamodelTest.java?rev=600015&r1=600014&r2=600015&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/model/DatamodelTest.java (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/model/DatamodelTest.java Fri Nov 30 15:43:39 2007
@@ -17,6 +17,8 @@
package org.apache.commons.scxml.model;
import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
import java.util.Set;
import junit.framework.Test;
@@ -50,7 +52,7 @@
}
// Test data
- private URL datamodel01jexl, datamodel02jexl, datamodel01jsp, datamodel02jsp;
+ private URL datamodel01jexl, datamodel02jexl, datamodel04jexl, datamodel01jsp, datamodel02jsp;
private SCXMLExecutor exec01, exec02;
/**
@@ -61,6 +63,8 @@
getResource("org/apache/commons/scxml/env/jexl/datamodel-01.xml");
datamodel02jexl = this.getClass().getClassLoader().
getResource("org/apache/commons/scxml/env/jexl/datamodel-02.xml");
+ datamodel04jexl = this.getClass().getClassLoader().
+ getResource("org/apache/commons/scxml/env/jexl/datamodel-04.xml");
datamodel01jsp = this.getClass().getClassLoader().
getResource("org/apache/commons/scxml/env/jsp/datamodel-01.xml");
datamodel02jsp = this.getClass().getClassLoader().
@@ -108,6 +112,30 @@
assertNotNull(exec02);
assertFalse(exec01 == exec02);
runtest();
+ }
+
+ public void testDatamodel04Jexl() {
+ exec01 = SCXMLTestHelper.getExecutor(datamodel04jexl,
+ new JexlContext(), new JexlEvaluator());
+ assertNotNull(exec01);
+ Set currentStates = exec01.getCurrentStatus().getStates();
+ assertEquals(1, currentStates.size());
+ assertEquals("ten", ((State)currentStates.iterator().
+ next()).getId());
+ Map payload = new HashMap();
+ payload.put("one", "1");
+ payload.put("two", "2");
+ TriggerEvent te = new TriggerEvent("ten.done", TriggerEvent.SIGNAL_EVENT, payload);
+ SCXMLTestHelper.fireEvent(exec01, te);
+ currentStates = exec01.getCurrentStatus().getStates();
+ assertEquals(1, currentStates.size());
+ assertEquals("twenty", ((State)currentStates.iterator().
+ next()).getId());
+ SCXMLTestHelper.fireEvent(exec01, "twenty.done");
+ currentStates = exec01.getCurrentStatus().getStates();
+ assertEquals(1, currentStates.size());
+ assertEquals("thirty", ((State)currentStates.iterator().
+ next()).getId());
}
private void runtest() {