You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by at...@apache.org on 2014/10/25 17:24:28 UTC
svn commit: r1634235 [1/3] - in
/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2: ./
env/ env/groovy/ env/javascript/ env/jexl/ env/xpath/ invoke/ io/ issues/
model/
Author: ate
Date: Sat Oct 25 15:24:25 2014
New Revision: 1634235
URL: http://svn.apache.org/r1634235
Log:
SCXML-212: Add support for SCXML datamodel type and default Evaluator instantiation
- leverage the new default SCXML datamodel type support in (almost) all test cases
- cleanup test case setup and wiring (a lot)
Modified:
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/EventDataTest.java
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/NamespacePrefixedXPathsTest.java
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/SCXMLExecutorTest.java
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/SCXMLTestHelper.java
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/TieBreakerTest.java
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/WildcardTest.java
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/WizardsTest.java
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/custom-hello-world-01.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/custom-hello-world-02.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/custom-hello-world-03.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/custom-hello-world-04-jexl.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/StopWatch.java
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/GroovyClosureTest.java
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/SerializableInitialBaseScriptTest.java
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/StaticMethodTest.java
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/groovy-closure.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/microwave-01.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/microwave-02.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/microwave-03.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/microwave-04.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/microwave-05.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/serializable-initial-base-script.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/static-method.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/javascript/JSEvaluatorTest.java
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/javascript/JSExampleTest.java
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/javascript/example-01.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/javascript/script-01.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/ForeachTest.java
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/StaticMethodTest.java
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/datamodel-01.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/datamodel-02.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/datamodel-03.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/datamodel-04.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/datamodel-05.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/eventdata-01.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/eventdata-02.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/eventdata-03.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/eventdata-04.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/foreach.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/microwave-01.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/microwave-02.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/microwave-03.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/microwave-04.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/microwave-05.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/script-01.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/stateless-01.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/static-method.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/wildcard-01.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/wildcard-02.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/wizard-01.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/wizard-02.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/xpath/XPathExampleTest.java
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/xpath/example-01.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/xpath/example-02.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/external-hello-world.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/hello-world.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/history-deep-01.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/history-default-01.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/history-parallel-01.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/history-shallow-01.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/invoke/InvokeParamNameTest.java
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/invoke/InvokeTest.java
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/invoke/invoked-01.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/invoke/invoked-02.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/invoke/invoked-03-01.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/invoke/invoked-03.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/invoke/invoker-01.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/invoke/invoker-02.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/invoke/invoker-03.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/invoke/invoker-04.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/io/SCXMLReaderTest.java
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/io/SCXMLRequiredAttributesTest.java
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/io/StateSrcTest.java
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/io/custom-action-body-test-1.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/io/scxml-initial-attr.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/io/scxml-invalid-transition-targets-test1.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/io/scxml-invalid-transition-targets-test2.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/io/scxml-valid-transition-targets-test.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/io/scxml-with-invalid-elems.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/io/src-test-1.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/io/src-test-2.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/io/src-test-3.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/io/src-test-4.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/io/src-test-5.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/issues/Issue112Test.java
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/issues/Issue62Test.java
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/issues/Issue64Test.java
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/issues/issue62-01-ext.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/issues/issue62-01.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/issues/issue62-02-ext.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/issues/issue62-02.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/issues/issue62-03-ext.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/issues/issue62-03.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/issues/issue64-01.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/issues/issue64-02.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/issues/queue-01.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/model/ActionsTest.java
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/model/AssignTest.java
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/model/CustomActionTest.java
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/model/DatamodelTest.java
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/model/HistoryTest.java
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/model/ParallelTest.java
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/model/ScriptTest.java
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/model/ScxmlInitialAttributeTest.java
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/model/StateTest.java
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/model/StatelessModelTest.java
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/model/actions-initial-test.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/model/actions-parallel-test.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/model/actions-state-test.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/model/assign-test-01.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/model/assign-test-02.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/model/parallel-01.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/model/parallel-02.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/model/parallel-03.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/model/state-01.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/model/stateless-parallel-01.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/prefix-01.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/send-01.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/send-02.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/tie-breaker-01.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/tie-breaker-02.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/tie-breaker-03.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/tie-breaker-04.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/tie-breaker-05.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/tie-breaker-06.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/transitions-01.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/transitions-02.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/transitions-03.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/transitions-04.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/transitions-05.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/transitions-06.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/transitions-event-variable.xml
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/transitions-with-cond-01.xml
Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/EventDataTest.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/EventDataTest.java?rev=1634235&r1=1634234&r2=1634235&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/EventDataTest.java (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/EventDataTest.java Sat Oct 25 15:24:25 2014
@@ -16,17 +16,13 @@
*/
package org.apache.commons.scxml2;
-import java.net.URL;
import java.util.Set;
import org.apache.commons.scxml2.env.SimpleScheduler;
import org.apache.commons.scxml2.env.Tracer;
-import org.apache.commons.scxml2.env.jexl.JexlEvaluator;
import org.apache.commons.scxml2.model.EnterableState;
import org.apache.commons.scxml2.model.SCXML;
-import org.junit.After;
import org.junit.Assert;
-import org.junit.Before;
import org.junit.Test;
/**
* Unit tests {@link org.apache.commons.scxml2.SCXMLExecutor}.
@@ -34,40 +30,13 @@ import org.junit.Test;
*/
public class EventDataTest {
- // Test data
- private URL eventdata01, eventdata02, eventdata03, eventdata04;
- private SCXMLExecutor exec;
-
- /**
- * Set up instance variables required by this test case.
- */
- @Before
- public void setUp() {
- eventdata01 = this.getClass().getClassLoader().
- getResource("org/apache/commons/scxml2/env/jexl/eventdata-01.xml");
- eventdata02 = this.getClass().getClassLoader().
- getResource("org/apache/commons/scxml2/env/jexl/eventdata-02.xml");
- eventdata03 = this.getClass().getClassLoader().
- getResource("org/apache/commons/scxml2/env/jexl/eventdata-03.xml");
- eventdata04 = this.getClass().getClassLoader().
- getResource("org/apache/commons/scxml2/env/jexl/eventdata-04.xml");
- }
-
- /**
- * Tear down instance variables required by this test case.
- */
- @After
- public void tearDown() {
- eventdata01 = eventdata02 = eventdata03 = eventdata04 = null;
- }
-
/**
* Test the SCXML documents, usage of "_event.data"
*/
@Test
public void testEventdata01Sample() throws Exception {
- exec = SCXMLTestHelper.getExecutor(eventdata01);
- Assert.assertNotNull(exec);
+ SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/env/jexl/eventdata-01.xml");
+ exec.go();
Set<EnterableState> currentStates = exec.getCurrentStatus().getStates();
Assert.assertEquals(1, currentStates.size());
Assert.assertEquals("state1", currentStates.iterator().next().getId());
@@ -91,8 +60,8 @@ public class EventDataTest {
@Test
public void testEventdata02Sample() throws Exception {
- exec = SCXMLTestHelper.getExecutor(eventdata02);
- Assert.assertNotNull(exec);
+ SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/env/jexl/eventdata-02.xml");
+ exec.go();
Set<EnterableState> currentStates = exec.getCurrentStatus().getStates();
Assert.assertEquals(1, currentStates.size());
Assert.assertEquals("state0", currentStates.iterator().next().getId());
@@ -111,8 +80,8 @@ public class EventDataTest {
@Test
public void testEventdata03Sample() throws Exception {
- exec = SCXMLTestHelper.getExecutor(eventdata03);
- Assert.assertNotNull(exec);
+ SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/env/jexl/eventdata-03.xml");
+ exec.go();
Set<EnterableState> currentStates = exec.getCurrentStatus().getStates();
Assert.assertEquals(1, currentStates.size());
Assert.assertEquals("ten", currentStates.iterator().next().getId());
@@ -125,10 +94,9 @@ public class EventDataTest {
@Test
public void testEventdata04Sample() throws Exception {
- SCXML scxml = SCXMLTestHelper.parse(eventdata04);
+ SCXML scxml = SCXMLTestHelper.parse("org/apache/commons/scxml2/env/jexl/eventdata-03.xml");
Tracer trc = new Tracer();
- exec = new SCXMLExecutor(new JexlEvaluator(), null, trc);
- Assert.assertNotNull(exec);
+ SCXMLExecutor exec = new SCXMLExecutor(null, null, trc);
exec.setEventdispatcher(new SimpleScheduler(exec));
exec.addListener(scxml, trc);
exec.setStateMachine(scxml);
Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/NamespacePrefixedXPathsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/NamespacePrefixedXPathsTest.java?rev=1634235&r1=1634234&r2=1634235&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/NamespacePrefixedXPathsTest.java (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/NamespacePrefixedXPathsTest.java Sat Oct 25 15:24:25 2014
@@ -16,13 +16,10 @@
*/
package org.apache.commons.scxml2;
-import java.net.URL;
import java.util.Set;
import org.apache.commons.scxml2.model.EnterableState;
-import org.junit.After;
import org.junit.Assert;
-import org.junit.Before;
import org.junit.Test;
/**
@@ -30,36 +27,15 @@ import org.junit.Test;
*/
public class NamespacePrefixedXPathsTest {
- // Test data
- private URL datamodel03jexl;
- private SCXMLExecutor exec01;
-
- /**
- * Set up instance variables required by this test case.
- */
- @Before
- public void setUp() throws Exception {
- datamodel03jexl = this.getClass().getClassLoader().
- getResource("org/apache/commons/scxml2/env/jexl/datamodel-03.xml");
- exec01 = SCXMLTestHelper.getExecutor(datamodel03jexl);
- }
-
- /**
- * Tear down instance variables required by this test case.
- */
- @After
- public void tearDown() {
- datamodel03jexl = null;
- exec01 = null;
- }
-
/**
* Test the XPath evaluation
*/
// JEXL
@Test
public void testNamespacePrefixedXPathsJexl() throws Exception {
- runtest(exec01);
+ SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/env/jexl/datamodel-03.xml");
+ exec.go();
+ runtest(exec);
}
// Same test, since same documents (different expression languages)
Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/SCXMLExecutorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/SCXMLExecutorTest.java?rev=1634235&r1=1634234&r2=1634235&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/SCXMLExecutorTest.java (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/SCXMLExecutorTest.java Sat Oct 25 15:24:25 2014
@@ -16,182 +16,97 @@
*/
package org.apache.commons.scxml2;
-import java.net.URL;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
-import org.apache.commons.scxml2.env.groovy.GroovyContext;
-import org.apache.commons.scxml2.env.groovy.GroovyEvaluator;
import org.apache.commons.scxml2.model.EnterableState;
-import org.apache.commons.scxml2.model.SCXML;
import org.apache.commons.scxml2.model.TransitionTarget;
-import org.junit.After;
import org.junit.Assert;
-import org.junit.Before;
import org.junit.Test;
/**
* Unit tests {@link org.apache.commons.scxml2.SCXMLExecutor}.
*/
public class SCXMLExecutorTest {
- // Test data
- private URL microwave01jexl, microwave02jexl, microwave03jexl, microwave04jexl, microwave05jexl,
- microwave01grv, microwave02grv, microwave03grv, microwave04grv, microwave05grv, transitions01,
- transitions02, transitions03, transitions04, transitions05, transitions06, prefix01, send01, send02,
- transitionsWithCond01, transitionsEventVar;
- private SCXMLExecutor exec;
-
- /**
- * Set up instance variables required by this test case.
- */
- @Before
- public void setUp() {
- microwave01jexl = this.getClass().getClassLoader().
- getResource("org/apache/commons/scxml2/env/jexl/microwave-01.xml");
- microwave02jexl = this.getClass().getClassLoader().
- getResource("org/apache/commons/scxml2/env/jexl/microwave-02.xml");
- microwave03jexl = this.getClass().getClassLoader().
- getResource("org/apache/commons/scxml2/env/jexl/microwave-03.xml");
- microwave04jexl = this.getClass().getClassLoader().
- getResource("org/apache/commons/scxml2/env/jexl/microwave-04.xml");
- microwave05jexl = this.getClass().getClassLoader().
- getResource("org/apache/commons/scxml2/env/jexl/microwave-05.xml");
- microwave01grv = this.getClass().getClassLoader().
- getResource("org/apache/commons/scxml2/env/groovy/microwave-01.xml");
- microwave02grv = this.getClass().getClassLoader().
- getResource("org/apache/commons/scxml2/env/groovy/microwave-02.xml");
- microwave03grv = this.getClass().getClassLoader().
- getResource("org/apache/commons/scxml2/env/groovy/microwave-03.xml");
- microwave04grv = this.getClass().getClassLoader().
- getResource("org/apache/commons/scxml2/env/groovy/microwave-04.xml");
- microwave05grv = this.getClass().getClassLoader().
- getResource("org/apache/commons/scxml2/env/groovy/microwave-05.xml");
- transitions01 = this.getClass().getClassLoader().
- getResource("org/apache/commons/scxml2/transitions-01.xml");
- transitions02 = this.getClass().getClassLoader().
- getResource("org/apache/commons/scxml2/transitions-02.xml");
- transitions03 = this.getClass().getClassLoader().
- getResource("org/apache/commons/scxml2/transitions-03.xml");
- transitions04 = this.getClass().getClassLoader().
- getResource("org/apache/commons/scxml2/transitions-04.xml");
- transitions05 = this.getClass().getClassLoader().
- getResource("org/apache/commons/scxml2/transitions-05.xml");
- transitions06 = this.getClass().getClassLoader().
- getResource("org/apache/commons/scxml2/transitions-06.xml");
- prefix01 = this.getClass().getClassLoader().
- getResource("org/apache/commons/scxml2/prefix-01.xml");
- send01 = this.getClass().getClassLoader().
- getResource("org/apache/commons/scxml2/send-01.xml");
- send02 = this.getClass().getClassLoader().
- getResource("org/apache/commons/scxml2/send-02.xml");
- transitionsWithCond01 = this.getClass().getClassLoader().
- getResource("org/apache/commons/scxml2/transitions-with-cond-01.xml");
- transitionsEventVar = this.getClass().getClassLoader().
- getResource("org/apache/commons/scxml2/transitions-event-variable.xml");
- }
-
- /**
- * Tear down instance variables required by this test case.
- */
- @After
- public void tearDown() {
- microwave01jexl = microwave02jexl =
- microwave04jexl = microwave05jexl = transitions01 = transitions02 = transitions03 =
- transitions04 = transitions05 = transitions06 = prefix01 = send01 = send02 =
- transitionsWithCond01 = transitionsEventVar = null;
- }
-
/**
* Test the implementation
*/
@Test
public void testSCXMLExecutorMicrowave01JexlSample() throws Exception {
- exec = SCXMLTestHelper.getExecutor(microwave01jexl);
- Assert.assertNotNull(exec);
- checkMicrowave01Sample();
+ SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/env/jexl/microwave-01.xml");
+ exec.go();
+ checkMicrowave01Sample(exec);
}
@Test
public void testSCXMLExecutorMicrowave02JexlSample() throws Exception {
- exec = SCXMLTestHelper.getExecutor(microwave02jexl);
- Assert.assertNotNull(exec);
- checkMicrowave02Sample();
+ SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/env/jexl/microwave-02.xml");
+ exec.go();
+ checkMicrowave02Sample(exec);
}
@Test
public void testSCXMLExecutorMicrowave03JexlSample() throws Exception {
- SCXML scxml = SCXMLTestHelper.parse(microwave03jexl);
- Assert.assertNotNull(scxml);
- exec = SCXMLTestHelper.getExecutor(scxml);
- Assert.assertNotNull(exec);
- checkMicrowave01Sample();
+ SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/env/jexl/microwave-03.xml");
+ exec.go();
+ checkMicrowave01Sample(exec);
}
@Test
public void testSCXMLExecutorMicrowave04JexlSample() throws Exception {
- SCXML scxml = SCXMLTestHelper.parse(microwave04jexl);
- Assert.assertNotNull(scxml);
- exec = SCXMLTestHelper.getExecutor(scxml);
- Assert.assertNotNull(exec);
- checkMicrowave02Sample();
+ SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/env/jexl/microwave-04.xml");
+ exec.go();
+ checkMicrowave02Sample(exec);
}
@Test
public void testSCXMLExecutorMicrowave05JexlSample() throws Exception {
- SCXML scxml = SCXMLTestHelper.parse(microwave05jexl);
- Assert.assertNotNull(scxml);
- exec = SCXMLTestHelper.getExecutor(scxml);
- Assert.assertNotNull(exec);
- checkMicrowave02Sample();
+ SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/env/jexl/microwave-05.xml");
+ exec.go();
+ checkMicrowave02Sample(exec);
}
@Test
public void testSCXMLExecutorMicrowave01grvSample() throws Exception {
- exec = SCXMLTestHelper.getExecutor(microwave01grv, new GroovyContext(), new GroovyEvaluator());
- Assert.assertNotNull(exec);
- checkMicrowave01Sample();
+ SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/env/groovy/microwave-01.xml");
+ exec.go();
+ checkMicrowave01Sample(exec);
}
@Test
public void testSCXMLExecutorMicrowave02grvSample() throws Exception {
- exec = SCXMLTestHelper.getExecutor(microwave02grv, new GroovyContext(), new GroovyEvaluator());
- Assert.assertNotNull(exec);
- checkMicrowave02Sample();
+ SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/env/groovy/microwave-02.xml");
+ exec.go();
+ checkMicrowave02Sample(exec);
}
@Test
public void testSCXMLExecutorMicrowave03grvSample() throws Exception {
- SCXML scxml = SCXMLTestHelper.parse(microwave03grv);
- Assert.assertNotNull(scxml);
- exec = SCXMLTestHelper.getExecutor(scxml, new GroovyContext(), new GroovyEvaluator());
- Assert.assertNotNull(exec);
- checkMicrowave01Sample();
+ SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/env/groovy/microwave-03.xml");
+ exec.go();
+ checkMicrowave01Sample(exec);
}
@Test
public void testSCXMLExecutorMicrowave04grvSample() throws Exception {
- SCXML scxml = SCXMLTestHelper.parse(microwave04grv);
- Assert.assertNotNull(scxml);
- exec = SCXMLTestHelper.getExecutor(scxml, new GroovyContext(), new GroovyEvaluator());
- Assert.assertNotNull(exec);
- checkMicrowave02Sample();
+ SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/env/groovy/microwave-04.xml");
+ exec.go();
+ checkMicrowave02Sample(exec);
}
@Test
public void testSCXMLExecutorMicrowave05grvSample() throws Exception {
- SCXML scxml = SCXMLTestHelper.parse(microwave05grv);
- Assert.assertNotNull(scxml);
- exec = SCXMLTestHelper.getExecutor(scxml, new GroovyContext(), new GroovyEvaluator());
- Assert.assertNotNull(exec);
- checkMicrowave02Sample();
+ SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/env/groovy/microwave-05.xml");
+ exec.go();
+ checkMicrowave02Sample(exec);
}
@Test
public void testSCXMLExecutorPrefix01Sample() throws Exception {
- exec = SCXMLTestHelper.getExecutor(prefix01);
- Assert.assertNotNull(exec);
+ SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/prefix-01.xml");
+ exec.go();
Set<EnterableState> currentStates = exec.getCurrentStatus().getStates();
Assert.assertEquals(1, currentStates.size());
Assert.assertEquals("ten", currentStates.iterator().next().getId());
@@ -202,8 +117,8 @@ public class SCXMLExecutorTest {
@Test
public void testSCXMLExecutorTransitions01Sample() throws Exception {
- exec = SCXMLTestHelper.getExecutor(transitions01);
- Assert.assertNotNull(exec);
+ SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/transitions-01.xml");
+ exec.go();
Set<EnterableState> currentStates = SCXMLTestHelper.fireEvent(exec, "done.state.ten");
Assert.assertEquals(1, currentStates.size());
Assert.assertEquals("twenty_one", currentStates.iterator().next().getId());
@@ -216,8 +131,8 @@ public class SCXMLExecutorTest {
@Test
public void testSCXMLExecutorTransitions02Sample() throws Exception {
- exec = SCXMLTestHelper.getExecutor(transitions02);
- Assert.assertNotNull(exec);
+ SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/transitions-02.xml");
+ exec.go();
Set<EnterableState> currentStates = SCXMLTestHelper.fireEvent(exec, "ten.stay");
Assert.assertEquals(1, currentStates.size());
Assert.assertEquals("ten", currentStates.iterator().next().getId());
@@ -232,8 +147,8 @@ public class SCXMLExecutorTest {
@Test
public void testSCXMLExecutorTransitions03Sample() throws Exception {
- exec = SCXMLTestHelper.getExecutor(transitions03);
- Assert.assertNotNull(exec);
+ SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/transitions-03.xml");
+ exec.go();
Set<EnterableState> currentStates = SCXMLTestHelper.fireEvent(exec, "done.state.ten");
Assert.assertEquals(3, currentStates.size());
Set<String> expected = new HashSet<String>();
@@ -250,10 +165,8 @@ public class SCXMLExecutorTest {
@Test
public void testSCXMLExecutorTransitions04Sample() throws Exception {
- SCXML scxml = SCXMLTestHelper.parse(transitions04);
- Assert.assertNotNull(scxml);
- exec = SCXMLTestHelper.getExecutor(scxml);
- Assert.assertNotNull(exec);
+ SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/transitions-04.xml");
+ exec.go();
Set<EnterableState> currentStates = SCXMLTestHelper.fireEvent(exec, "done.state.ten");
Assert.assertEquals(3, currentStates.size());
Set<String> expected = new HashSet<String>();
@@ -274,19 +187,15 @@ public class SCXMLExecutorTest {
@Test
public void testSCXMLExecutorTransitions05Sample() throws Exception {
- SCXML scxml = SCXMLTestHelper.parse(transitions05);
- Assert.assertNotNull(scxml);
- exec = SCXMLTestHelper.getExecutor(scxml);
- Assert.assertNotNull(exec);
+ SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/transitions-05.xml");
+ exec.go();
SCXMLTestHelper.assertPostTriggerState(exec, "foo", "end");
}
@Test
public void testSCXMLExecutorTransitions06Sample() throws Exception {
- SCXML scxml = SCXMLTestHelper.parse(transitions06);
- Assert.assertNotNull(scxml);
- exec = SCXMLTestHelper.getExecutor(scxml);
- Assert.assertNotNull(exec);
+ SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/transitions-06.xml");
+ exec.go();
SCXMLTestHelper.assertPostTriggerStates(exec, "start", new String[]{"one", "two"});
SCXMLTestHelper.assertPostTriggerState(exec, "onetwo_three", "three");
SCXMLTestHelper.assertPostTriggerStates(exec, "three_one", new String[]{"one", "two"});
@@ -295,8 +204,8 @@ public class SCXMLExecutorTest {
@Test
public void testSend01Sample() throws Exception {
- exec = SCXMLTestHelper.getExecutor(send01);
- Assert.assertNotNull(exec);
+ SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/send-01.xml");
+ exec.go();
Set<EnterableState> currentStates = exec.getCurrentStatus().getStates();
Assert.assertEquals(1, currentStates.size());
Assert.assertEquals("ten", currentStates.iterator().next().getId());
@@ -307,8 +216,8 @@ public class SCXMLExecutorTest {
@Test
public void testSend02TypeSCXMLSample() throws Exception {
- exec = SCXMLTestHelper.getExecutor(send02);
- Assert.assertNotNull(exec);
+ SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/send-02.xml");
+ exec.go();
Set<EnterableState> currentStates = exec.getCurrentStatus().getStates();
Assert.assertEquals(1, currentStates.size());
Assert.assertEquals("ninety", currentStates.iterator().next().getId());
@@ -317,11 +226,8 @@ public class SCXMLExecutorTest {
@Test
public void testSCXMLExecutorTransitionsWithCond01Sample() throws Exception {
- SCXML scxml = SCXMLTestHelper.parse(transitionsWithCond01);
- Assert.assertNotNull(scxml);
- exec = SCXMLTestHelper.getExecutor(scxml);
- Assert.assertNotNull(exec);
-
+ SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/transitions-with-cond-01.xml");
+ exec.go();
Map<String, Object> payload = new HashMap<String, Object>();
// with _event.data set to true, transition should happen as expected.
@@ -349,28 +255,23 @@ public class SCXMLExecutorTest {
@Test
public void testSCXMLExecutorSystemEventVariable() throws Exception {
- SCXML scxml = SCXMLTestHelper.parse(transitionsEventVar);
- Assert.assertNotNull(scxml);
- exec = SCXMLTestHelper.getExecutor(scxml);
- Assert.assertNotNull(exec);
-
+ SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/transitions-event-variable.xml");
+ exec.go();
Map<String, Object> payload = new HashMap<String, Object>();
payload.put("keyed", Boolean.TRUE);
SCXMLTestHelper.assertPostTriggerState(exec, "open", payload, "opened");
}
- private void checkMicrowave01Sample() throws Exception {
+ private void checkMicrowave01Sample(SCXMLExecutor exec) throws Exception {
Set<EnterableState> currentStates = SCXMLTestHelper.fireEvent(exec, "turn_on");
Assert.assertEquals(1, currentStates.size());
Assert.assertEquals("cooking", currentStates.iterator().next().getId());
}
- private void checkMicrowave02Sample() throws Exception {
+ private void checkMicrowave02Sample(SCXMLExecutor exec) throws Exception {
Set<EnterableState> currentStates = SCXMLTestHelper.fireEvent(exec, "turn_on");
Assert.assertEquals(2, currentStates.size());
String id = (currentStates.iterator().next()).getId();
Assert.assertTrue(id.equals("closed") || id.equals("cooking"));
}
-
}
-
Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/SCXMLTestHelper.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/SCXMLTestHelper.java?rev=1634235&r1=1634234&r2=1634235&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/SCXMLTestHelper.java (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/SCXMLTestHelper.java Sat Oct 25 15:24:25 2014
@@ -33,12 +33,10 @@ import javax.xml.parsers.DocumentBuilder
import org.apache.commons.scxml2.env.SimpleDispatcher;
import org.apache.commons.scxml2.env.Tracer;
-import org.apache.commons.scxml2.env.jexl.JexlEvaluator;
import org.apache.commons.scxml2.io.SCXMLReader;
import org.apache.commons.scxml2.io.SCXMLReader.Configuration;
import org.apache.commons.scxml2.model.CustomAction;
import org.apache.commons.scxml2.model.EnterableState;
-import org.apache.commons.scxml2.model.ModelException;
import org.apache.commons.scxml2.model.SCXML;
import org.apache.commons.scxml2.model.TransitionTarget;
import org.junit.Assert;
@@ -55,14 +53,13 @@ public class SCXMLTestHelper {
* "target" directory (so it can be removed via a clean build).
*/
public static final String SERIALIZATION_DIR = "target/serialization";
- public static final String SERIALIZATION_FILE_PREFIX =
- SERIALIZATION_DIR + "/scxml";
+ public static final String SERIALIZATION_FILE_PREFIX = SERIALIZATION_DIR + "/scxml";
public static final String SERIALIZATION_FILE_SUFFIX = ".ser";
// Generate a unique sequence number for the serialization files
private static int sequence=0;
- private synchronized static String getSequenceNumber(){
+ private synchronized static String getSequenceNumber() {
return Integer.toString(++sequence);
}
@@ -70,15 +67,24 @@ public class SCXMLTestHelper {
return SCXMLTestHelper.class.getClassLoader().getResource(name);
}
+ public static SCXML parse(final String scxmlResource) throws Exception {
+ Assert.assertNotNull(scxmlResource);
+ return parse(getResource(scxmlResource), null);
+ }
+
public static SCXML parse(final URL url) throws Exception {
return parse(url, null);
}
+ public static SCXML parse(final String scxmlResource, final List<CustomAction> customActions) throws Exception {
+ Assert.assertNotNull(scxmlResource);
+ return parse(getResource(scxmlResource), customActions);
+ }
+
public static SCXML parse(final URL url, final List<CustomAction> customActions) throws Exception {
Assert.assertNotNull(url);
- SCXML scxml = null;
Configuration configuration = new Configuration(null, null, customActions);
- scxml = SCXMLReader.read(url, configuration);
+ SCXML scxml = SCXMLReader.read(url, configuration);
Assert.assertNotNull(scxml);
SCXML roundtrip = testModelSerializability(scxml);
return roundtrip;
@@ -86,101 +92,42 @@ public class SCXMLTestHelper {
public static SCXML parse(final Reader scxmlReader, final List<CustomAction> customActions) throws Exception {
Assert.assertNotNull(scxmlReader);
- SCXML scxml = null;
Configuration configuration = new Configuration(null, null, customActions);
- scxml = SCXMLReader.read(scxmlReader, configuration);
+ SCXML scxml = SCXMLReader.read(scxmlReader, configuration);
Assert.assertNotNull(scxml);
SCXML roundtrip = testModelSerializability(scxml);
return roundtrip;
}
public static SCXMLExecutor getExecutor(final URL url) throws Exception {
- SCXML scxml = parse(url);
- Evaluator evaluator = new JexlEvaluator();
- return getExecutor(evaluator, scxml);
+ return getExecutor(parse(url), null);
}
- public static SCXMLExecutor getExecutor(final URL url,
- final Evaluator evaluator) throws Exception {
- SCXML scxml = parse(url);
- return getExecutor(evaluator, scxml);
+ public static SCXMLExecutor getExecutor(String scxmlResource) throws Exception {
+ return getExecutor(parse(scxmlResource), null);
}
public static SCXMLExecutor getExecutor(SCXML scxml) throws Exception {
return getExecutor(scxml, null);
}
- public static SCXMLExecutor getExecutor(SCXML scxml,
- SCXMLSemantics semantics) throws Exception {
- Evaluator evaluator = new JexlEvaluator();
- Context context = evaluator.newContext(null);
- EventDispatcher ed = new SimpleDispatcher();
- Tracer trc = new Tracer();
- return getExecutor(context, evaluator, scxml, ed, trc, semantics);
- }
-
- public static SCXMLExecutor getExecutor(Evaluator evaluator, SCXML scxml) throws Exception {
- EventDispatcher ed = new SimpleDispatcher();
- Tracer trc = new Tracer();
- Assert.assertNotNull("Null evaluator", evaluator);
- Context context = evaluator.newContext(null);
- return getExecutor(context, evaluator, scxml, ed, trc);
- }
-
- public static SCXMLExecutor getExecutor(final URL url, final Context ctx,
- final Evaluator evaluator) throws Exception {
- SCXML scxml = parse(url);
- EventDispatcher ed = new SimpleDispatcher();
- Tracer trc = new Tracer();
- return getExecutor(ctx, evaluator, scxml, ed, trc);
+ public static SCXMLExecutor getExecutor(final URL url, final Evaluator evaluator) throws Exception {
+ return getExecutor(parse(url), evaluator);
}
- public static SCXMLExecutor getExecutor(final SCXML scxml,
- final Context ctx, final Evaluator evaluator) throws Exception {
- EventDispatcher ed = new SimpleDispatcher();
+ public static SCXMLExecutor getExecutor(SCXML scxml, Evaluator evaluator) throws Exception {
Tracer trc = new Tracer();
- return getExecutor(ctx, evaluator, scxml, ed, trc);
- }
-
- public static SCXMLExecutor getExecutor(Context context,
- Evaluator evaluator, SCXML scxml, EventDispatcher ed, Tracer trc) throws Exception {
- return getExecutor(context, evaluator, scxml, ed, trc, null);
- }
-
- public static SCXMLExecutor getExecutor(Context context,
- Evaluator evaluator, SCXML scxml, EventDispatcher ed,
- Tracer trc, SCXMLSemantics semantics) throws Exception {
- Assert.assertNotNull(evaluator);
- Assert.assertNotNull(context);
- Assert.assertNotNull(scxml);
- Assert.assertNotNull(ed);
- Assert.assertNotNull(trc);
- SCXMLExecutor exec = null;
- if (semantics == null) {
- exec = new SCXMLExecutor(evaluator, ed, trc);
- } else {
- exec = new SCXMLExecutor(evaluator, ed, trc, semantics);
- }
- exec.addListener(scxml, trc);
- exec.setRootContext(context);
+ SCXMLExecutor exec = new SCXMLExecutor(evaluator, new SimpleDispatcher(), trc);
exec.setStateMachine(scxml);
- exec.go();
- Assert.assertNotNull(exec);
+ exec.addListener(scxml, trc);
return exec;
}
- public static TransitionTarget lookupTransitionTarget(SCXMLExecutor exec,
- String id) {
+ public static TransitionTarget lookupTransitionTarget(SCXMLExecutor exec, String id) {
return exec.getStateMachine().getTargets().get(id);
}
- public static Context lookupContext(SCXMLExecutor exec,
- EnterableState es) {
- return exec.getSCInstance().lookupContext(es);
- }
-
- public static Context lookupContext(SCXMLExecutor exec,
- String id) {
+ public static Context lookupContext(SCXMLExecutor exec, String id) {
TransitionTarget tt = lookupTransitionTarget(exec, id);
if (tt == null || !(tt instanceof EnterableState)) {
return null;
@@ -188,8 +135,7 @@ public class SCXMLTestHelper {
return exec.getSCInstance().lookupContext((EnterableState)tt);
}
- public static void assertState(SCXMLExecutor exec,
- String expectedStateId) throws Exception {
+ public static void assertState(SCXMLExecutor exec, String expectedStateId) throws Exception {
Set<EnterableState> currentStates = exec.getCurrentStatus().getStates();
Assert.assertEquals("Expected 1 simple (leaf) state with id '"
+ expectedStateId + "' but found " + currentStates.size() + " states instead.",
@@ -203,8 +149,7 @@ public class SCXMLTestHelper {
}
public static Set<EnterableState> fireEvent(SCXMLExecutor exec, String name, Object payload) throws Exception {
- TriggerEvent[] evts = {new TriggerEvent(name,
- TriggerEvent.SIGNAL_EVENT, payload)};
+ TriggerEvent[] evts = {new TriggerEvent(name, TriggerEvent.SIGNAL_EVENT, payload)};
exec.triggerEvents(evts);
return exec.getCurrentStatus().getStates();
}
@@ -332,58 +277,9 @@ public class SCXMLTestHelper {
}
/**
- * Get the active leaf state for this executor instance.
- * Assumes no usage of <parallel>.
- *
- * @param exec The {@link SCXMLExecutor} instance whose active state is
- * being queried.
- * @return The <code>id</code> of the active state.
- */
- public static String getCurrentState(SCXMLExecutor exec) {
- return exec.getCurrentStatus().getStates().iterator().next().getId();
- }
-
- /**
- * Set the active leaf state for this executor instance.
- * Assumes no usage of <parallel>.
- *
- * @param exec The {@link SCXMLExecutor} instance whose active state is
- * to be set.
- * @param id The <code>id</code> of the state to be made active.
- */
- public static void setCurrentState(SCXMLExecutor exec, final String id) {
- try {
- exec.reset();
- } catch (ModelException me) {
- throw new IllegalArgumentException("Provided SCXMLExecutor "
- + "instance cannot be reset.");
- }
- TransitionTarget active = exec.getStateMachine().getTargets().get(id);
- if (active == null) {
- throw new IllegalArgumentException("No target with id '" + id
- + "' present in state machine.");
- }
- Set<EnterableState> current = exec.getCurrentStatus().getStates();
- current.clear();
- current.add((EnterableState)active);
- }
-
- public static String removeCarriageReturns(final String original) {
- StringBuffer buf = new StringBuffer();
- for (int i = 0; i < original.length(); i++) {
- char c = original.charAt(i);
- if (c != '\r') {
- buf.append(c);
- }
- }
- return buf.toString();
- }
-
- /**
* Discourage instantiation.
*/
private SCXMLTestHelper() {
super();
}
-
}
Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/TieBreakerTest.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/TieBreakerTest.java?rev=1634235&r1=1634234&r2=1634235&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/TieBreakerTest.java (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/TieBreakerTest.java Sat Oct 25 15:24:25 2014
@@ -16,14 +16,11 @@
*/
package org.apache.commons.scxml2;
-import java.net.URL;
import java.util.Set;
import org.apache.commons.scxml2.model.EnterableState;
import org.apache.commons.scxml2.model.TransitionTarget;
-import org.junit.After;
import org.junit.Assert;
-import org.junit.Before;
import org.junit.Test;
/**
* Unit tests for testing conflict resolution amongst multiple transitions
@@ -39,46 +36,10 @@ import org.junit.Test;
*/
public class TieBreakerTest {
- // Test data
- private URL tiebreaker01, tiebreaker02, tiebreaker03, tiebreaker04,
- tiebreaker05, tiebreaker06;
- private SCXMLExecutor exec;
-
- /**
- * Set up instance variables required by this test case.
- */
- @Before
- public void setUp() {
- tiebreaker01 = this.getClass().getClassLoader().
- getResource("org/apache/commons/scxml2/tie-breaker-01.xml");
- tiebreaker02 = this.getClass().getClassLoader().
- getResource("org/apache/commons/scxml2/tie-breaker-02.xml");
- tiebreaker03 = this.getClass().getClassLoader().
- getResource("org/apache/commons/scxml2/tie-breaker-03.xml");
- tiebreaker04 = this.getClass().getClassLoader().
- getResource("org/apache/commons/scxml2/tie-breaker-04.xml");
- tiebreaker05 = this.getClass().getClassLoader().
- getResource("org/apache/commons/scxml2/tie-breaker-05.xml");
- tiebreaker06 = this.getClass().getClassLoader().
- getResource("org/apache/commons/scxml2/tie-breaker-06.xml");
- }
-
- /**
- * Tear down instance variables required by this test case.
- */
- @After
- public void tearDown() {
- tiebreaker01 = tiebreaker02 = tiebreaker03 = tiebreaker04 =
- tiebreaker05 = tiebreaker06 = null;
- }
-
- /**
- * Test the implementation
- */
@Test
public void testTieBreaker01() throws Exception {
- exec = SCXMLTestHelper.getExecutor(tiebreaker01);
- Assert.assertNotNull(exec);
+ SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/tie-breaker-01.xml");
+ exec.go();
Set<EnterableState> currentStates = exec.getCurrentStatus().getStates();
Assert.assertEquals(1, currentStates.size());
Assert.assertEquals("ten", currentStates.iterator().next().getId());
@@ -89,8 +50,8 @@ public class TieBreakerTest {
@Test
public void testTieBreaker02() throws Exception {
- exec = SCXMLTestHelper.getExecutor(tiebreaker02);
- Assert.assertNotNull(exec);
+ SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/tie-breaker-02.xml");
+ exec.go();
Set<EnterableState> currentStates = exec.getCurrentStatus().getStates();
Assert.assertEquals(1, currentStates.size());
Assert.assertEquals("eleven", currentStates.iterator().next().getId());
@@ -101,8 +62,8 @@ public class TieBreakerTest {
@Test
public void testTieBreaker03() throws Exception {
- exec = SCXMLTestHelper.getExecutor(tiebreaker03);
- Assert.assertNotNull(exec);
+ SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/tie-breaker-03.xml");
+ exec.go();
Set<EnterableState> currentStates = exec.getCurrentStatus().getStates();
Assert.assertEquals(1, currentStates.size());
Assert.assertEquals("eleven", currentStates.iterator().next().getId());
@@ -113,8 +74,8 @@ public class TieBreakerTest {
@Test
public void testTieBreaker04() throws Exception {
- exec = SCXMLTestHelper.getExecutor(tiebreaker04);
- Assert.assertNotNull(exec);
+ SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/tie-breaker-04.xml");
+ exec.go();
Set<EnterableState> currentStates = SCXMLTestHelper.fireEvent(exec, "event_2");
Assert.assertEquals(1, currentStates.size());
currentStates = SCXMLTestHelper.fireEvent(exec, "event_1");
@@ -123,8 +84,8 @@ public class TieBreakerTest {
@Test
public void testTieBreaker05() throws Exception {
- exec = SCXMLTestHelper.getExecutor(tiebreaker05);
- Assert.assertNotNull(exec);
+ SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/tie-breaker-05.xml");
+ exec.go();
Set<EnterableState> currentStates = exec.getCurrentStatus().getStates();
Assert.assertEquals(3, currentStates.size());
for (TransitionTarget tt : currentStates) {
@@ -143,10 +104,9 @@ public class TieBreakerTest {
@Test
public void testTieBreaker06() throws Exception {
- exec = SCXMLTestHelper.getExecutor(SCXMLTestHelper.parse(tiebreaker06));
- Assert.assertNotNull(exec);
+ SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/tie-breaker-06.xml");
+ exec.go();
Set<EnterableState> currentStates = exec.getCurrentStatus().getStates();
Assert.assertEquals(1, currentStates.size());
}
}
-
Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/WildcardTest.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/WildcardTest.java?rev=1634235&r1=1634234&r2=1634235&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/WildcardTest.java (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/WildcardTest.java Sat Oct 25 15:24:25 2014
@@ -16,13 +16,10 @@
*/
package org.apache.commons.scxml2;
-import java.net.URL;
import java.util.Set;
import org.apache.commons.scxml2.model.EnterableState;
-import org.junit.After;
import org.junit.Assert;
-import org.junit.Before;
import org.junit.Test;
/**
* Unit tests {@link org.apache.commons.scxml2.SCXMLExecutor}.
@@ -30,36 +27,13 @@ import org.junit.Test;
*/
public class WildcardTest {
- // Test data
- private URL wildcard01, wildcard02;
- private SCXMLExecutor exec;
-
- /**
- * Set up instance variables required by this test case.
- */
- @Before
- public void setUp() {
- wildcard01 = this.getClass().getClassLoader().
- getResource("org/apache/commons/scxml2/env/jexl/wildcard-01.xml");
- wildcard02 = this.getClass().getClassLoader().
- getResource("org/apache/commons/scxml2/env/jexl/wildcard-02.xml");
- }
-
- /**
- * Tear down instance variables required by this test case.
- */
- @After
- public void tearDown() {
- wildcard01 = wildcard02 = null;
- }
-
/**
* Test the SCXML documents, usage of "_event.data"
*/
@Test
public void testWildcard01Sample() throws Exception {
- exec = SCXMLTestHelper.getExecutor(wildcard01);
- Assert.assertNotNull(exec);
+ SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/env/jexl/wildcard-01.xml");
+ exec.go();
Set<EnterableState> currentStates = exec.getCurrentStatus().getStates();
Assert.assertEquals(1, currentStates.size());
Assert.assertEquals("state1", currentStates.iterator().next().getId());
@@ -71,8 +45,8 @@ public class WildcardTest {
@Test
public void testWildcard02Sample() throws Exception {
- exec = SCXMLTestHelper.getExecutor(SCXMLTestHelper.parse(wildcard02));
- Assert.assertNotNull(exec);
+ SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/env/jexl/wildcard-02.xml");
+ exec.go();
Set<EnterableState> currentStates = exec.getCurrentStatus().getStates();
Assert.assertEquals(1, currentStates.size());
Assert.assertEquals("state2", currentStates.iterator().next().getId());
Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/WizardsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/WizardsTest.java?rev=1634235&r1=1634234&r2=1634235&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/WizardsTest.java (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/WizardsTest.java Sat Oct 25 15:24:25 2014
@@ -17,20 +17,13 @@
package org.apache.commons.scxml2;
import java.io.Serializable;
-import java.net.URL;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import org.apache.commons.scxml2.env.Tracer;
-import org.apache.commons.scxml2.env.jexl.JexlContext;
-import org.apache.commons.scxml2.env.jexl.JexlEvaluator;
import org.apache.commons.scxml2.model.EnterableState;
-import org.apache.commons.scxml2.model.SCXML;
-import org.junit.After;
import org.junit.Assert;
-import org.junit.Before;
import org.junit.Test;
import org.w3c.dom.Node;
/**
@@ -38,35 +31,13 @@ import org.w3c.dom.Node;
*/
public class WizardsTest {
- // Test data
- private URL wizard01, wizard02;
- private SCXMLExecutor exec;
-
- /**
- * Set up instance variables required by this test case.
- */
- @Before
- public void setUp() {
- wizard01 = this.getClass().getClassLoader().
- getResource("org/apache/commons/scxml2/env/jexl/wizard-01.xml");
- wizard02 = this.getClass().getClassLoader().
- getResource("org/apache/commons/scxml2/env/jexl/wizard-02.xml");
- }
-
- /**
- * Tear down instance variables required by this test case.
- */
- @After
- public void tearDown() {
- wizard01 = wizard02 = null;
- }
-
/**
* Test the wizard style SCXML documents, and send usage
*/
@Test
public void testWizard01Sample() throws Exception {
- exec = SCXMLTestHelper.getExecutor(wizard01);
+ SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/env/jexl/wizard-01.xml");
+ exec.go();
Assert.assertNotNull(exec);
Set<EnterableState> currentStates = exec.getCurrentStatus().getStates();
Assert.assertEquals(1, currentStates.size());
@@ -89,11 +60,9 @@ public class WizardsTest {
@Test
public void testWizard02Sample() throws Exception {
- SCXML scxml = SCXMLTestHelper.parse(wizard02);
- exec = SCXMLTestHelper.getExecutor(new JexlContext(),
- new JexlEvaluator(), scxml, new TestEventDispatcher(),
- new Tracer());
- Assert.assertNotNull(exec);
+ SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/env/jexl/wizard-02.xml");
+ exec.setEventdispatcher(new TestEventDispatcher());
+ exec.go();
// If you change this, you must also change
// the TestEventDispatcher
Set<EnterableState> currentStates = exec.getCurrentStatus().getStates();
Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/custom-hello-world-01.xml
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/custom-hello-world-01.xml?rev=1634235&r1=1634234&r2=1634235&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/custom-hello-world-01.xml (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/custom-hello-world-01.xml Sat Oct 25 15:24:25 2014
@@ -21,6 +21,7 @@
xmlns:my="http://my.custom-actions.domain/CUSTOM1"
xmlns:foo="http://my.custom-actions.domain/CUSTOM2"
version="1.0"
+ datamodel="jexl"
initial="custom">
<final id="custom">
Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/custom-hello-world-02.xml
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/custom-hello-world-02.xml?rev=1634235&r1=1634234&r2=1634235&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/custom-hello-world-02.xml (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/custom-hello-world-02.xml Sat Oct 25 15:24:25 2014
@@ -19,6 +19,7 @@
<scxml xmlns="http://www.w3.org/2005/07/scxml"
xmlns:my="http://my.custom-actions.domain/CUSTOM"
version="1.0"
+ datamodel="jexl"
initial="custom">
<final id="custom">
Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/custom-hello-world-03.xml
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/custom-hello-world-03.xml?rev=1634235&r1=1634234&r2=1634235&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/custom-hello-world-03.xml (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/custom-hello-world-03.xml Sat Oct 25 15:24:25 2014
@@ -19,6 +19,7 @@
<scxml xmlns="http://www.w3.org/2005/07/scxml"
xmlns:my="http://my.custom-actions.domain/CUSTOM"
version="1.0"
+ datamodel="jexl"
initial="custom">
<final id="custom">
Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/custom-hello-world-04-jexl.xml
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/custom-hello-world-04-jexl.xml?rev=1634235&r1=1634234&r2=1634235&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/custom-hello-world-04-jexl.xml (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/custom-hello-world-04-jexl.xml Sat Oct 25 15:24:25 2014
@@ -18,7 +18,7 @@
<!-- Used for CustomActionTest.java in model package -->
<scxml xmlns="http://www.w3.org/2005/07/scxml"
xmlns:my="http://my.custom-actions.domain/CUSTOM"
- version="1.0" initial="init">
+ version="1.0" datamodel="jexl" initial="init">
<datamodel>
<data id="helloName1" />
</datamodel>
Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/StopWatch.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/StopWatch.java?rev=1634235&r1=1634234&r2=1634235&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/StopWatch.java (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/StopWatch.java Sat Oct 25 15:24:25 2014
@@ -20,7 +20,6 @@ import java.util.Timer;
import java.util.TimerTask;
import org.apache.commons.scxml2.model.ModelException;
-import org.apache.commons.scxml2.model.TransitionTarget;
/**
* A SCXML document driven stop watch.
Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/GroovyClosureTest.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/GroovyClosureTest.java?rev=1634235&r1=1634234&r2=1634235&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/GroovyClosureTest.java (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/GroovyClosureTest.java Sat Oct 25 15:24:25 2014
@@ -22,8 +22,6 @@ import java.util.Set;
import org.apache.commons.scxml2.SCXMLExecutor;
import org.apache.commons.scxml2.SCXMLTestHelper;
import org.apache.commons.scxml2.model.EnterableState;
-import org.apache.commons.scxml2.model.SCXML;
-import org.apache.commons.scxml2.model.State;
import org.junit.Assert;
import org.junit.Test;
@@ -32,14 +30,12 @@ public class GroovyClosureTest {
@Test
public void testGroovyClosure() throws Exception {
- URL groovyClosure = this.getClass().getClassLoader().getResource("org/apache/commons/scxml2/env/groovy/groovy-closure.xml");
- SCXML scxml = SCXMLTestHelper.parse(groovyClosure);
- Assert.assertNotNull(scxml);
- SCXMLExecutor exec = SCXMLTestHelper.getExecutor(scxml, new GroovyContext(), new GroovyEvaluator(true));
- Assert.assertNotNull(exec);
+ URL groovyClosure = SCXMLTestHelper.getResource("org/apache/commons/scxml2/env/groovy/groovy-closure.xml");
+ SCXMLExecutor exec = SCXMLTestHelper.getExecutor(groovyClosure, new GroovyEvaluator(true));
+ exec.go();
Set<EnterableState> currentStates = SCXMLTestHelper.fireEvent(exec, "turn_on");
Assert.assertEquals(2, currentStates.size());
- String id = ((State)currentStates.iterator().next()).getId();
+ String id = currentStates.iterator().next().getId();
Assert.assertTrue(id.equals("closed") || id.equals("cooking"));
}
}
Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/SerializableInitialBaseScriptTest.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/SerializableInitialBaseScriptTest.java?rev=1634235&r1=1634234&r2=1634235&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/SerializableInitialBaseScriptTest.java (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/SerializableInitialBaseScriptTest.java Sat Oct 25 15:24:25 2014
@@ -22,9 +22,7 @@ import java.util.Set;
import org.apache.commons.scxml2.SCXMLExecutor;
import org.apache.commons.scxml2.SCXMLTestHelper;
import org.apache.commons.scxml2.model.EnterableState;
-import org.junit.After;
import org.junit.Assert;
-import org.junit.Before;
import org.junit.Test;
/**
@@ -33,34 +31,14 @@ import org.junit.Test;
*/
public class SerializableInitialBaseScriptTest {
- // Test data
- private URL scxml;
- private SCXMLExecutor exec;
-
- /**
- * Set up instance variables required by this test case.
- */
- @Before
- public void setUp() {
- scxml = this.getClass().getClassLoader().
- getResource("org/apache/commons/scxml2/env/groovy/serializable-initial-base-script.xml");
- }
-
- /**
- * Tear down instance variables required by this test case.
- */
- @After
- public void tearDown() {
- scxml = null;
- }
-
/**
* Testing Groovy initial base script usage and validating serializable
*/
@Test
public void testSerializableInitialBaseScriptSample() throws Exception {
- exec = SCXMLTestHelper.getExecutor(scxml, new GroovyContext(), new GroovyEvaluator(true));
- Assert.assertNotNull(exec);
+ URL scxml = SCXMLTestHelper.getResource("org/apache/commons/scxml2/env/groovy/serializable-initial-base-script.xml");
+ SCXMLExecutor exec = SCXMLTestHelper.getExecutor(scxml, new GroovyEvaluator(true));
+ exec.go();
Set<EnterableState> currentStates = exec.getCurrentStatus().getStates();
Assert.assertEquals(1, currentStates.size());
Assert.assertEquals("state1", currentStates.iterator().next().getId());
Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/StaticMethodTest.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/StaticMethodTest.java?rev=1634235&r1=1634234&r2=1634235&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/StaticMethodTest.java (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/StaticMethodTest.java Sat Oct 25 15:24:25 2014
@@ -16,45 +16,21 @@
*/
package org.apache.commons.scxml2.env.groovy;
-import java.net.URL;
import java.util.Set;
-import org.apache.commons.scxml2.Context;
import org.apache.commons.scxml2.SCXMLExecutor;
import org.apache.commons.scxml2.SCXMLTestHelper;
import org.apache.commons.scxml2.model.EnterableState;
-import org.junit.After;
import org.junit.Assert;
-import org.junit.Before;
import org.junit.Test;
public class StaticMethodTest {
- private URL staticmethod;
-
- /**
- * Set up instance variables required by this test case.
- */
- @Before
- public void setUp() {
- staticmethod = this.getClass().getClassLoader().
- getResource("org/apache/commons/scxml2/env/groovy/static-method.xml");
- }
-
- /**
- * Tear down instance variables required by this test case.
- */
- @After
- public void tearDown() {
- staticmethod = null;
- }
-
@Test
public void testGroovyStaticMethodInvocation() throws Exception {
- Context jc = new GroovyContext();
- jc.set("System", System.class);
- SCXMLExecutor exec = SCXMLTestHelper.getExecutor(staticmethod,
- jc, new GroovyEvaluator());
+ SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/env/groovy/static-method.xml");
+ exec.getRootContext().set("System", System.class);
+ exec.go();
Set<EnterableState> currentStates = exec.getCurrentStatus().getStates();
Assert.assertEquals(1, currentStates.size());
Assert.assertEquals("static", currentStates.iterator().next().getId());
Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/groovy-closure.xml
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/groovy-closure.xml?rev=1634235&r1=1634234&r2=1634235&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/groovy-closure.xml (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/groovy-closure.xml Sat Oct 25 15:24:25 2014
@@ -21,6 +21,7 @@
<scxml xmlns="http://www.w3.org/2005/07/scxml"
xmlns:cs="http://commons.apache.org/scxml"
version="1.0"
+ datamodel="groovy"
initial="microwave">
<!-- Trivial microwave oven example using a Groovy closure defined within a script.
Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/microwave-01.xml
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/microwave-01.xml?rev=1634235&r1=1634234&r2=1634235&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/microwave-01.xml (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/microwave-01.xml Sat Oct 25 15:24:25 2014
@@ -21,6 +21,7 @@
<scxml xmlns="http://www.w3.org/2005/07/scxml"
xmlns:cs="http://commons.apache.org/scxml"
version="1.0"
+ datamodel="groovy"
initial="off">
<!-- trivial microwave oven example -->
Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/microwave-02.xml
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/microwave-02.xml?rev=1634235&r1=1634234&r2=1634235&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/microwave-02.xml (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/microwave-02.xml Sat Oct 25 15:24:25 2014
@@ -20,6 +20,7 @@
-->
<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0"
xmlns:cs="http://commons.apache.org/scxml"
+ datamodel="groovy"
initial="microwave">
<!-- trivial microwave oven example -->
Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/microwave-03.xml
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/microwave-03.xml?rev=1634235&r1=1634234&r2=1634235&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/microwave-03.xml (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/microwave-03.xml Sat Oct 25 15:24:25 2014
@@ -21,6 +21,7 @@
<scxml xmlns="http://www.w3.org/2005/07/scxml"
xmlns:cs="http://commons.apache.org/scxml"
version="1.0"
+ datamodel="groovy"
initial="off">
<!-- trivial microwave oven example -->
Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/microwave-04.xml
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/microwave-04.xml?rev=1634235&r1=1634234&r2=1634235&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/microwave-04.xml (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/microwave-04.xml Sat Oct 25 15:24:25 2014
@@ -21,6 +21,7 @@
<scxml xmlns="http://www.w3.org/2005/07/scxml"
xmlns:cs="http://commons.apache.org/scxml"
version="1.0"
+ datamodel="groovy"
initial="microwave">
<!-- trivial microwave oven example -->
Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/microwave-05.xml
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/microwave-05.xml?rev=1634235&r1=1634234&r2=1634235&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/microwave-05.xml (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/microwave-05.xml Sat Oct 25 15:24:25 2014
@@ -21,6 +21,7 @@
<scxml xmlns="http://www.w3.org/2005/07/scxml"
xmlns:cs="http://commons.apache.org/scxml"
version="1.0"
+ datamodel="groovy"
initial="microwave">
<!-- trivial microwave oven example -->
Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/serializable-initial-base-script.xml
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/serializable-initial-base-script.xml?rev=1634235&r1=1634234&r2=1634235&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/serializable-initial-base-script.xml (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/serializable-initial-base-script.xml Sat Oct 25 15:24:25 2014
@@ -21,6 +21,7 @@
<scxml xmlns="http://www.w3.org/2005/07/scxml"
xmlns:cs="http://commons.apache.org/scxml"
version="1.0"
+ datamodel="groovy"
initial="state1">
<script>
class Target implements Serializable {
Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/static-method.xml
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/static-method.xml?rev=1634235&r1=1634234&r2=1634235&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/static-method.xml (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/static-method.xml Sat Oct 25 15:24:25 2014
@@ -20,6 +20,7 @@
-->
<scxml xmlns="http://www.w3.org/2005/07/scxml"
version="1.0"
+ datamodel="groovy"
initial="static">
<final id="static">
Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/javascript/JSEvaluatorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/javascript/JSEvaluatorTest.java?rev=1634235&r1=1634234&r2=1634235&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/javascript/JSEvaluatorTest.java (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/javascript/JSEvaluatorTest.java Sat Oct 25 15:24:25 2014
@@ -23,8 +23,8 @@ import org.apache.commons.scxml2.Context
import org.apache.commons.scxml2.Evaluator;
import org.apache.commons.scxml2.SCXMLExecutor;
import org.apache.commons.scxml2.SCXMLExpressionException;
+import org.apache.commons.scxml2.SCXMLTestHelper;
import org.apache.commons.scxml2.io.SCXMLReader;
-import org.apache.commons.scxml2.model.SCXML;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -54,6 +54,7 @@ public class JSEvaluatorTest {
private static final String SCRIPT = "<?xml version='1.0'?>" +
"<scxml xmlns = 'http://www.w3.org/2005/07/scxml' " +
"xmlns:scxml = 'http://commons.apache.org/scxml' " +
+ "datamodel = 'ecmascript' " +
"initial = 'start' " +
"version = '1.0'>" +
"<datamodel>" +
@@ -99,7 +100,6 @@ public class JSEvaluatorTest {
// TEST VARIABLES
- private SCXML scxml;
private Context context;
private Evaluator evaluator;
private SCXMLExecutor fsm;
@@ -112,19 +112,10 @@ public class JSEvaluatorTest {
*/
@Before
public void setUp() throws Exception {
- StringReader reader = new StringReader(SCRIPT);
-
- scxml = SCXMLReader.read(reader);
- context = new JSContext();
- evaluator = new JSEvaluator();
- fsm = new SCXMLExecutor();
-
+ fsm = SCXMLTestHelper.getExecutor(SCXMLReader.read(new StringReader(SCRIPT)));
+ evaluator = fsm.getEvaluator();
+ context = fsm.getRootContext();
context.set(Context.NAMESPACES_KEY,null);
-
- fsm.setEvaluator (evaluator);
- fsm.setRootContext (context);
- fsm.setStateMachine(scxml);
- fsm.reset ();
}
// CLASS METHODS
Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/javascript/JSExampleTest.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/javascript/JSExampleTest.java?rev=1634235&r1=1634234&r2=1634235&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/javascript/JSExampleTest.java (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/javascript/JSExampleTest.java Sat Oct 25 15:24:25 2014
@@ -22,8 +22,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Set;
-import org.apache.commons.scxml2.Context;
-import org.apache.commons.scxml2.Evaluator;
import org.apache.commons.scxml2.SCXMLExecutor;
import org.apache.commons.scxml2.SCXMLExpressionException;
import org.apache.commons.scxml2.SCXMLTestHelper;
@@ -35,9 +33,7 @@ import org.apache.commons.scxml2.model.E
import org.apache.commons.scxml2.model.ModelException;
import org.apache.commons.scxml2.model.SCXML;
-import org.junit.After;
import org.junit.Assert;
-import org.junit.Before;
import org.junit.Test;
/**
@@ -46,41 +42,16 @@ import org.junit.Test;
*/
public class JSExampleTest {
- // Test data
- private URL example01;
- private SCXMLExecutor exec;
-
- /**
- * Set up instance variables required by this test case.
- */
- @Before
- public void setUp() {
- example01 = this.getClass().getClassLoader().
- getResource("org/apache/commons/scxml2/env/javascript/example-01.xml");
- }
-
- /**
- * Tear down instance variables required by this test case.
- */
- @After
- public void tearDown() {
- example01 = null;
- }
-
// TEST METHODS
@Test
public void testExample01Sample() throws Exception {
List<CustomAction> actions = new ArrayList<CustomAction>();
- actions.add(new CustomAction("http://my.custom-actions.domain",
- "eventdatamaptest", EventDataMapTest.class));
-
- SCXML scxml = SCXMLTestHelper.parse(example01,actions);
- Evaluator evaluator = new JSEvaluator();
- Context context = new JSContext();
- exec = SCXMLTestHelper.getExecutor(scxml, context, evaluator);
+ actions.add(new CustomAction("http://my.custom-actions.domain", "eventdatamaptest", EventDataMapTest.class));
- Assert.assertNotNull(exec);
+ SCXML scxml = SCXMLTestHelper.parse("org/apache/commons/scxml2/env/javascript/example-01.xml", actions);
+ SCXMLExecutor exec = SCXMLTestHelper.getExecutor(scxml);
+ exec.go();
Set<EnterableState> currentStates = exec.getCurrentStatus().getStates();
Assert.assertEquals(1, currentStates.size());
Assert.assertEquals("end", currentStates.iterator().next().getId());
Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/javascript/example-01.xml
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/javascript/example-01.xml?rev=1634235&r1=1634234&r2=1634235&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/javascript/example-01.xml (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/javascript/example-01.xml Sat Oct 25 15:24:25 2014
@@ -20,6 +20,7 @@
xmlns:scxml = 'http://commons.apache.org/scxml'
xmlns:my = 'http://my.custom-actions.domain'
initial = 'start'
+ datamodel = "ecmascript"
version = '1.0'>
<!-- DATA MODEL -->
Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/javascript/script-01.xml
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/javascript/script-01.xml?rev=1634235&r1=1634234&r2=1634235&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/javascript/script-01.xml (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/javascript/script-01.xml Sat Oct 25 15:24:25 2014
@@ -17,7 +17,8 @@
-->
<scxml xmlns="http://www.w3.org/2005/07/scxml"
version="1.0"
- initial="script">
+ initial="script"
+ datamodel="ecmascript">
<datamodel>
<data id="x" expr="1"/>
Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/ForeachTest.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/ForeachTest.java?rev=1634235&r1=1634234&r2=1634235&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/ForeachTest.java (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/ForeachTest.java Sat Oct 25 15:24:25 2014
@@ -16,11 +16,8 @@
*/
package org.apache.commons.scxml2.env.jexl;
-import java.net.URL;
-
import org.apache.commons.scxml2.SCXMLExecutor;
import org.apache.commons.scxml2.SCXMLTestHelper;
-import org.apache.commons.scxml2.model.SCXML;
import org.junit.Assert;
import org.junit.Test;
@@ -31,11 +28,8 @@ public class ForeachTest {
@Test
public void testForeach() throws Exception {
- URL document = this.getClass().getClassLoader().getResource("org/apache/commons/scxml2/env/jexl/foreach.xml");
- SCXML scxml = SCXMLTestHelper.parse(document);
- Assert.assertNotNull(scxml);
- SCXMLExecutor exec = SCXMLTestHelper.getExecutor(scxml, new JexlContext(), new JexlEvaluator());
- Assert.assertNotNull(exec);
+ SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/env/jexl/foreach.xml");
+ exec.go();
Assert.assertTrue(exec.getCurrentStatus().isFinal());
}
}
Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/StaticMethodTest.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/StaticMethodTest.java?rev=1634235&r1=1634234&r2=1634235&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/StaticMethodTest.java (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/StaticMethodTest.java Sat Oct 25 15:24:25 2014
@@ -16,46 +16,22 @@
*/
package org.apache.commons.scxml2.env.jexl;
-import java.net.URL;
import java.util.Set;
-import org.apache.commons.scxml2.Context;
import org.apache.commons.scxml2.SCXMLExecutor;
import org.apache.commons.scxml2.SCXMLTestHelper;
import org.apache.commons.scxml2.model.EnterableState;
-import org.junit.After;
import org.junit.Assert;
-import org.junit.Before;
import org.junit.Test;
public class StaticMethodTest {
- private URL staticmethod;
-
- /**
- * Set up instance variables required by this test case.
- */
- @Before
- public void setUp() {
- staticmethod = this.getClass().getClassLoader().
- getResource("org/apache/commons/scxml2/env/jexl/static-method.xml");
- }
-
- /**
- * Tear down instance variables required by this test case.
- */
- @After
- public void tearDown() {
- staticmethod = null;
- }
-
@Test
public void testJexlStaticMethodInvocation() throws Exception {
- Context jc = new JexlContext();
- jc.set("System", System.class);
- SCXMLExecutor exec = SCXMLTestHelper.getExecutor(staticmethod,
- jc, new JexlEvaluator());
+ SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/env/jexl/static-method.xml");
+ exec.getRootContext().set("System", System.class);
+ exec.go();
Set<EnterableState> currentStates = exec.getCurrentStatus().getStates();
Assert.assertEquals(1, currentStates.size());
Assert.assertEquals("static", currentStates.iterator().next().getId());
Modified: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/datamodel-01.xml
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/datamodel-01.xml?rev=1634235&r1=1634234&r2=1634235&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/datamodel-01.xml (original)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/datamodel-01.xml Sat Oct 25 15:24:25 2014
@@ -20,6 +20,7 @@
and the Commons SCXML Data() function -->
<scxml xmlns="http://www.w3.org/2005/07/scxml"
version="1.0"
+ datamodel="jexl"
initial="main">
<!-- Root or document datamodel -->