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 2005/08/24 05:52:10 UTC
svn commit: r239518 - in /jakarta/commons/sandbox/scxml/trunk: ./
src/test/java/org/apache/commons/scxml/
src/test/java/org/apache/commons/scxml/env/
src/test/java/org/apache/commons/scxml/model/
Author: rahul
Date: Tue Aug 23 20:52:02 2005
New Revision: 239518
URL: http://svn.apache.org/viewcvs?rev=239518&view=rev
Log:
Some more tests, clover reports 62.3% coverage for Commons SCXML.
Added:
jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/SCXMLTestHelper.java (with props)
jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/env/MockJspContext.java (with props)
jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/env/RootContextTest.java (with props)
jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/env/jsp-rootctx-test.xml (with props)
jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/model/ActionsTest.java (with props)
jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/model/actions-test.xml (with props)
jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/transitions-01.xml (with props)
Modified:
jakarta/commons/sandbox/scxml/trunk/project.xml
jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/SCXMLDigesterTest.java
jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/SCXMLExecutorTest.java
jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/SCXMLTestSuite.java
jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/env/EnvTestSuite.java
jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/model/ModelTestSuite.java
Modified: jakarta/commons/sandbox/scxml/trunk/project.xml
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/trunk/project.xml?rev=239518&r1=239517&r2=239518&view=diff
==============================================================================
--- jakarta/commons/sandbox/scxml/trunk/project.xml (original)
+++ jakarta/commons/sandbox/scxml/trunk/project.xml Tue Aug 23 20:52:02 2005
@@ -109,17 +109,19 @@
<unitTestSourceDirectory>src/test/java</unitTestSourceDirectory>
<unitTest>
<includes>
- <include>org/apache/commons/scxml/AllSCXMLTestSuite.java</include>
+ <include>org/apache/commons/scxml/env/EnvTestSuite.java</include>
+ <include>org/apache/commons/scxml/model/ModelTestSuite.java</include>
+ <include>org/apache/commons/scxml/SCXMLTestSuite.java</include>
</includes>
+ <resources>
+ <resource>
+ <directory>${pom.build.unitTestSourceDirectory}</directory>
+ <includes>
+ <include>**/*.xml</include>
+ </includes>
+ </resource>
+ </resources>
</unitTest>
- <resources>
- <resource>
- <directory>${pom.build.unitTestSourceDirectory}</directory>
- <includes>
- <include>**/*.xml</include>
- </includes>
- </resource>
- </resources>
</build>
<reports>
Modified: jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/SCXMLDigesterTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/SCXMLDigesterTest.java?rev=239518&r1=239517&r2=239518&view=diff
==============================================================================
--- jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/SCXMLDigesterTest.java (original)
+++ jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/SCXMLDigesterTest.java Tue Aug 23 20:52:02 2005
@@ -22,8 +22,6 @@
import junit.framework.TestSuite;
import junit.textui.TestRunner;
-import org.apache.commons.scxml.env.ELEvaluator;
-import org.apache.commons.scxml.env.ELContext;
import org.apache.commons.scxml.model.SCXML;
/**
* Unit tests {@link org.apache.commons.scxml.SCXMLDigester}.
@@ -44,9 +42,7 @@
}
// Test data
- private URL microwave01, microwave02;
- private Evaluator evaluator;
- private Context ctx;
+ private URL microwave01, microwave02, transitions01;
private SCXML scxml;
private String scxmlAsString;
@@ -58,15 +54,15 @@
getResource("org/apache/commons/scxml/microwave-01.xml");
microwave02 = this.getClass().getClassLoader().
getResource("org/apache/commons/scxml/microwave-02.xml");
+ transitions01 = this.getClass().getClassLoader().
+ getResource("org/apache/commons/scxml/transitions-01.xml");
}
/**
* Tear down instance variables required by this test case.
*/
public void tearDown() {
- microwave01 = microwave02 = null;
- evaluator = null;
- ctx = null;
+ microwave01 = microwave02 = transitions01 = null;
scxml = null;
scxmlAsString = null;
}
@@ -74,25 +70,19 @@
/**
* Test the implementation
*/
- public void testSCXMLDigester() {
- scxml = digest(microwave01);
+ public void testSCXMLDigesterMicrowave01Sample() {
+ scxml = SCXMLTestHelper.digest(microwave01);
scxmlAsString = serialize(scxml);
- scxml = digest(microwave02);
+ }
+
+ public void testSCXMLDigesterMicrowave02Sample() {
+ scxml = SCXMLTestHelper.digest(microwave02);
scxmlAsString = serialize(scxml);
}
- private SCXML digest(final URL url) {
- assertNotNull(url);
- evaluator = new ELEvaluator();
- ctx = new ELContext();
- try {
- scxml = SCXMLDigester.digest(url,
- null, ctx, evaluator);
- } catch (Exception e) {
- fail();
- }
- assertNotNull(scxml);
- return scxml;
+ public void testSCXMLDigesterTransitions01Sample() {
+ scxml = SCXMLTestHelper.digest(transitions01);
+ scxmlAsString = serialize(scxml);
}
private String serialize(final SCXML scxml) {
Modified: jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/SCXMLExecutorTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/SCXMLExecutorTest.java?rev=239518&r1=239517&r2=239518&view=diff
==============================================================================
--- jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/SCXMLExecutorTest.java (original)
+++ jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/SCXMLExecutorTest.java Tue Aug 23 20:52:02 2005
@@ -16,17 +16,14 @@
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.env.ELEvaluator;
-import org.apache.commons.scxml.env.ELContext;
-import org.apache.commons.scxml.env.SimpleDispatcher;
-import org.apache.commons.scxml.env.Tracer;
-import org.apache.commons.scxml.model.SCXML;
+import org.apache.commons.scxml.model.State;
/**
* Unit tests {@link org.apache.commons.scxml.SCXMLExecutor}.
*/
@@ -46,13 +43,8 @@
}
// Test data
- private URL microwave01, microwave02;
- private Evaluator evaluator;
- private Context ctx;
- private SCXML scxml;
+ private URL microwave01, microwave02, transitions01;
private SCXMLExecutor exec;
- private EventDispatcher ed;
- private Tracer trc;
/**
* Set up instance variables required by this test case.
@@ -62,54 +54,58 @@
getResource("org/apache/commons/scxml/microwave-01.xml");
microwave02 = this.getClass().getClassLoader().
getResource("org/apache/commons/scxml/microwave-02.xml");
+ transitions01 = this.getClass().getClassLoader().
+ getResource("org/apache/commons/scxml/transitions-01.xml");
}
/**
* Tear down instance variables required by this test case.
*/
public void tearDown() {
- microwave01 = microwave02 = null;
- evaluator = null;
- ctx = null;
- scxml = null;
- exec = null;
- ed = null;
- trc = null;
+ microwave01 = microwave02 = transitions01 = null;
}
/**
* Test the implementation
*/
- public void testSCXMLExecutor() {
- exec = getExecutor(microwave01);
+ public void testSCXMLExecutorMicrowave01Sample() {
+ exec = SCXMLTestHelper.getExecutor(microwave01);
assertNotNull(exec);
- exec = getExecutor(microwave02);
+ }
+
+ public void testSCXMLExecutorMicrowave02Sample() {
+ exec = SCXMLTestHelper.getExecutor(microwave02);
assertNotNull(exec);
}
- private SCXMLExecutor getExecutor(final URL url) {
- assertNotNull(url);
- evaluator = new ELEvaluator();
- ctx = new ELContext();
+ public void testSCXMLExecutorTransitions01Sample() {
+ exec = SCXMLTestHelper.getExecutor(transitions01);
+ assertNotNull(exec);
try {
- scxml = SCXMLDigester.digest(url,
- null, ctx, evaluator);
+ Set currentStates = fireEvent("ten.done");
+ assertTrue(currentStates.size() == 1);
+ assertEquals("twenty_one", ((State)currentStates.iterator().
+ next()).getId());
+ currentStates = fireEvent("twenty_one.done");
+ assertTrue(currentStates.size() == 1);
+ assertEquals("twenty_two", ((State)currentStates.iterator().
+ next()).getId());
+ currentStates = fireEvent("twenty_two.done");
+ assertTrue(exec.getCurrentStatus().getStates().size() == 3);
} catch (Exception e) {
- fail();
+ fail(e.getMessage());
}
- assertNotNull(scxml);
- ed = new SimpleDispatcher();
- trc = new Tracer();
+ }
+
+ private Set fireEvent(String name) {
+ TriggerEvent[] evts = {new TriggerEvent(name,
+ TriggerEvent.SIGNAL_EVENT, null)};
try {
- exec = new SCXMLExecutor(evaluator, ed, trc);
- scxml.addListener(trc);
- exec.setSuperStep(true);
- exec.setStateMachine(scxml);
+ exec.triggerEvents(evts);
} catch (Exception e) {
- fail();
+ fail(e.getMessage());
}
- assertNotNull(exec);
- return exec;
+ return exec.getCurrentStatus().getStates();
}
public static void main(String args[]) {
Added: jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/SCXMLTestHelper.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/SCXMLTestHelper.java?rev=239518&view=auto
==============================================================================
--- jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/SCXMLTestHelper.java (added)
+++ jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/SCXMLTestHelper.java Tue Aug 23 20:52:02 2005
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2005 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 junit.framework.Assert;
+
+import org.apache.commons.scxml.env.ELEvaluator;
+import org.apache.commons.scxml.env.ELContext;
+import org.apache.commons.scxml.env.SimpleDispatcher;
+import org.apache.commons.scxml.env.Tracer;
+import org.apache.commons.scxml.model.SCXML;
+
+import org.xml.sax.ErrorHandler;
+/**
+ * Helper methods for running SCXML unit tests.
+ */
+public class SCXMLTestHelper {
+
+ public static SCXML digest(final URL url) {
+ Evaluator evaluator = new ELEvaluator();
+ Context ctx = new ELContext();
+ return digest(url, null, ctx, evaluator);
+ }
+
+ public static SCXML digest(final URL url, final Context ctx,
+ final Evaluator evaluator) {
+ return digest(url, null, ctx, evaluator);
+ }
+
+ public static SCXML digest(final URL url, final ErrorHandler errHandler,
+ final Context ctx, final Evaluator evaluator) {
+ Assert.assertNotNull(url);
+ Assert.assertNotNull(ctx);
+ // SAX ErrorHandler may be null
+ Assert.assertNotNull(evaluator);
+ SCXML scxml = null;
+ try {
+ scxml = SCXMLDigester.digest(url, errHandler, ctx, evaluator);
+ } catch (Exception e) {
+ Assert.fail(e.getMessage());
+ }
+ Assert.assertNotNull(scxml);
+ return scxml;
+ }
+
+ public static SCXMLExecutor getExecutor(final URL url) {
+ Evaluator evaluator = new ELEvaluator();
+ Context ctx = new ELContext();
+ SCXML scxml = digest(url, null, ctx, evaluator);
+ return getExecutor(evaluator, scxml);
+ }
+
+ public static SCXMLExecutor getExecutor(final URL url, final Context ctx,
+ final Evaluator evaluator) {
+ SCXML scxml = digest(url, null, ctx, evaluator);
+ return getExecutor(evaluator, scxml);
+ }
+
+ public static SCXMLExecutor getExecutor(final URL url,
+ final ErrorHandler errHandler,final Context ctx,
+ final Evaluator evaluator) {
+ SCXML scxml = digest(url, errHandler, ctx, evaluator);
+ return getExecutor(evaluator, scxml);
+ }
+
+ public static SCXMLExecutor getExecutor(Evaluator evaluator, SCXML scxml) {
+ EventDispatcher ed = new SimpleDispatcher();
+ Tracer trc = new Tracer();
+ return getExecutor(evaluator, scxml, ed, trc);
+ }
+
+ public static SCXMLExecutor getExecutor(Evaluator evaluator, SCXML scxml,
+ EventDispatcher ed, Tracer trc) {
+ Assert.assertNotNull(evaluator);
+ Assert.assertNotNull(scxml);
+ Assert.assertNotNull(ed);
+ Assert.assertNotNull(trc);
+ SCXMLExecutor exec = null;
+ try {
+ exec = new SCXMLExecutor(evaluator, ed, trc);
+ scxml.addListener(trc);
+ exec.setSuperStep(true);
+ exec.setStateMachine(scxml);
+ } catch (Exception e) {
+ Assert.fail(e.getMessage());
+ }
+ Assert.assertNotNull(exec);
+ return exec;
+ }
+
+ /**
+ * Discourage instantiation.
+ */
+ private SCXMLTestHelper() {
+ super();
+ }
+
+}
+
Propchange: jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/SCXMLTestHelper.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/SCXMLTestHelper.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
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=239518&r1=239517&r2=239518&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 Tue Aug 23 20:52:02 2005
@@ -46,9 +46,9 @@
public static Test suite() {
TestSuite suite = new TestSuite();
suite.setName("Commons-SCXML Tests");
- suite.addTest(TriggerEventTest.suite());
suite.addTest(SCXMLDigesterTest.suite());
suite.addTest(SCXMLExecutorTest.suite());
+ suite.addTest(TriggerEventTest.suite());
return suite;
}
}
Modified: jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/env/EnvTestSuite.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/env/EnvTestSuite.java?rev=239518&r1=239517&r2=239518&view=diff
==============================================================================
--- jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/env/EnvTestSuite.java (original)
+++ jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/env/EnvTestSuite.java Tue Aug 23 20:52:02 2005
@@ -47,6 +47,8 @@
public static Test suite() {
TestSuite suite = new TestSuite();
suite.setName("Commons-SCXML-env Tests");
+ suite.addTest(RootContextTest.suite());
return suite;
}
}
+
Added: jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/env/MockJspContext.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/env/MockJspContext.java?rev=239518&view=auto
==============================================================================
--- jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/env/MockJspContext.java (added)
+++ jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/env/MockJspContext.java Tue Aug 23 20:52:02 2005
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2005 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.env;
+
+import java.net.URL;
+
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+import javax.servlet.jsp.el.ExpressionEvaluator;
+import javax.servlet.jsp.el.VariableResolver;
+import javax.servlet.jsp.JspContext;
+import javax.servlet.jsp.JspWriter;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * A placeholder for a JspContext, to run tests against.
+ */
+public class MockJspContext extends JspContext
+ implements VariableResolver {
+ private Map vars;
+ public MockJspContext() {
+ super();
+ vars = new HashMap();
+ }
+ public void setAttribute(String name, Object value) {
+ vars.put(name, value);
+ }
+ public void setAttribute(String name, Object value, int scope) {
+ setAttribute(name, value);
+ }
+ public Object getAttribute(String name) {
+ return vars.get(name);
+ }
+ public Object getAttribute(String name, int scope) {
+ return getAttribute(name);
+ }
+ public void removeAttribute(String name) {
+ vars.remove(name);
+ }
+ public void removeAttribute(String name, int scope) {
+ removeAttribute(name);
+ }
+ public Object findAttribute(String name) {
+ return getAttribute(name);
+ }
+ public VariableResolver getVariableResolver() {
+ return this;
+ }
+ public Object resolveVariable(String name) {
+ return getAttribute(name);
+ }
+ public ExpressionEvaluator getExpressionEvaluator() {
+ return null;
+ }
+ public int getAttributesScope(String name) {
+ return 1;
+ }
+ public Enumeration getAttributeNamesInScope(int scope) {
+ return null;
+ }
+ public JspWriter getOut() {
+ return null;
+ }
+}
+
Propchange: jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/env/MockJspContext.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/env/MockJspContext.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/env/RootContextTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/env/RootContextTest.java?rev=239518&view=auto
==============================================================================
--- jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/env/RootContextTest.java (added)
+++ jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/env/RootContextTest.java Tue Aug 23 20:52:02 2005
@@ -0,0 +1,106 @@
+/*
+ * Copyright 2005 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.env;
+
+import java.net.URL;
+
+import java.util.HashMap;
+import java.util.Map;
+import javax.servlet.jsp.JspContext;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+import org.apache.commons.scxml.env.ELEvaluator;
+import org.apache.commons.scxml.SCXMLExecutor;
+import org.apache.commons.scxml.SCXMLTestHelper;
+
+/**
+ * Unit tests {@link org.apache.commons.scxml.env.RootContext}.
+ */
+public class RootContextTest extends TestCase {
+ /**
+ * Construct a new instance of ActionsTest with
+ * the specified name
+ */
+ public RootContextTest(String name) {
+ super(name);
+ }
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(RootContextTest.class);
+ suite.setName("SCXML Env RootContext (wraps JSP Context) Tests");
+ return suite;
+ }
+
+ // Test data
+ private URL rootCtxSample;
+ private ELEvaluator evaluator;
+ private JspContext jspCtx;
+ private RootContext ctx;
+ private SCXMLExecutor exec;
+
+ /**
+ * Set up instance variables required by this test case.
+ */
+ public void setUp() {
+ rootCtxSample = this.getClass().getClassLoader().
+ getResource("org/apache/commons/scxml/env/jsp-rootctx-test.xml");
+ evaluator = new ELEvaluator();
+ jspCtx = new MockJspContext();
+ jspCtx.setAttribute("foo", "1");
+ ctx = new RootContext(jspCtx);
+ }
+
+ /**
+ * Tear down instance variables required by this test case.
+ */
+ public void tearDown() {
+ rootCtxSample = null;
+ evaluator = null;
+ jspCtx = null;
+ ctx = null;
+ exec = null;
+ }
+
+ /**
+ * Test the implementation
+ */
+ public void testRootContext() {
+ assertEquals("1", String.valueOf(ctx.get("foo")));
+ exec = SCXMLTestHelper.getExecutor(rootCtxSample, ctx, evaluator);
+ assertEquals("1", String.valueOf(jspCtx.getAttribute("foo")));
+ assertEquals("2", String.valueOf(ctx.get("foo")));
+ assertNull(jspCtx.getAttribute("bar"));
+ assertNotNull(ctx.get("bar"));
+ try {
+ assertNull(jspCtx.getVariableResolver().resolveVariable("bar"));
+ assertNotNull(ctx.resolveVariable("bar"));
+ assertEquals(ctx.resolveVariable("bar"), "a brand new value");
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+ assertNotNull(ctx.iterator());
+ }
+
+ public static void main(String args[]) {
+ TestRunner.run(suite());
+ }
+
+}
+
Propchange: jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/env/RootContextTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/env/RootContextTest.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/env/jsp-rootctx-test.xml
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/env/jsp-rootctx-test.xml?rev=239518&view=auto
==============================================================================
--- jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/env/jsp-rootctx-test.xml (added)
+++ jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/env/jsp-rootctx-test.xml Tue Aug 23 20:52:02 2005
@@ -0,0 +1,29 @@
+<?xml version="1.0"?>
+<!--
+ Copyright 2005 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/01/SCXML"
+ version="1.0"
+ initialstate="rootCtxTest">
+
+ <state id="rootCtxTest" final="true">
+ <onentry>
+ <!-- 'foo' must exist in host JSP context -->
+ <assign name="foo" expr="${foo+1}" />
+ <var name="bar" expr="a brand new value" />
+ </onentry>
+ </state>
+
+</scxml>
Propchange: jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/env/jsp-rootctx-test.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/env/jsp-rootctx-test.xml
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/model/ActionsTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/model/ActionsTest.java?rev=239518&view=auto
==============================================================================
--- jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/model/ActionsTest.java (added)
+++ jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/model/ActionsTest.java Tue Aug 23 20:52:02 2005
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2005 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.model;
+
+import java.net.URL;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+import org.apache.commons.scxml.env.ELEvaluator;
+import org.apache.commons.scxml.env.ELContext;
+import org.apache.commons.scxml.SCXMLExecutor;
+import org.apache.commons.scxml.SCXMLTestHelper;
+/**
+ * Unit tests {@link org.apache.commons.scxml.model.Assign}.
+ * Unit tests {@link org.apache.commons.scxml.model.Cancel}.
+ * Unit tests {@link org.apache.commons.scxml.model.Else}.
+ * Unit tests {@link org.apache.commons.scxml.model.Elseif}.
+ * Unit tests {@link org.apache.commons.scxml.model.Exit}.
+ * Unit tests {@link org.apache.commons.scxml.model.If}.
+ * Unit tests {@link org.apache.commons.scxml.model.Log}.
+ * Unit tests {@link org.apache.commons.scxml.model.Send}.
+ * Unit tests {@link org.apache.commons.scxml.model.Var}.
+ */
+public class ActionsTest extends TestCase {
+ /**
+ * Construct a new instance of ActionsTest with
+ * the specified name
+ */
+ public ActionsTest(String name) {
+ super(name);
+ }
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(ActionsTest.class);
+ suite.setName("SCXML Model Actions Tests");
+ return suite;
+ }
+
+ // Test data
+ private URL actionsSample;
+ private ELEvaluator evaluator;
+ private ELContext ctx;
+ private SCXMLExecutor exec;
+
+ /**
+ * Set up instance variables required by this test case.
+ */
+ public void setUp() {
+ actionsSample = this.getClass().getClassLoader().
+ getResource("org/apache/commons/scxml/model/actions-test.xml");
+ evaluator = new ELEvaluator();
+ ctx = new ELContext();
+ }
+
+ /**
+ * Tear down instance variables required by this test case.
+ */
+ public void tearDown() {
+ actionsSample = null;
+ evaluator = null;
+ ctx = null;
+ exec = null;
+ }
+
+ /**
+ * Test the implementation
+ */
+ public void testModelActions() {
+ exec = SCXMLTestHelper.getExecutor(actionsSample, ctx, evaluator);
+ assertEquals((String) ctx.get("foo"), "foobar");
+ }
+
+ public static void main(String args[]) {
+ TestRunner.run(suite());
+ }
+}
+
Propchange: jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/model/ActionsTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/model/ActionsTest.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/model/ModelTestSuite.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/model/ModelTestSuite.java?rev=239518&r1=239517&r2=239518&view=diff
==============================================================================
--- jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/model/ModelTestSuite.java (original)
+++ jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/model/ModelTestSuite.java Tue Aug 23 20:52:02 2005
@@ -47,6 +47,7 @@
public static Test suite() {
TestSuite suite = new TestSuite();
suite.setName("Commons-SCXML-model Tests");
+ suite.addTest(ActionsTest.suite());
return suite;
}
}
Added: jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/model/actions-test.xml
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/model/actions-test.xml?rev=239518&view=auto
==============================================================================
--- jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/model/actions-test.xml (added)
+++ jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/model/actions-test.xml Tue Aug 23 20:52:02 2005
@@ -0,0 +1,43 @@
+<?xml version="1.0"?>
+<!--
+ Copyright 2005 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/01/SCXML"
+ version="1.0"
+ initialstate="actionsTest">
+
+ <state id="actionsTest" final="true">
+ <onentry>
+ <var name="foo" expr="" />
+ <var name="delta" expr="${1+2+3}" />
+ <if cond="${delta le 3}">
+ <assign name="foo" expr="bar" />
+ <elseif cond="${delta eq 3}"/>
+ <assign name="foo" expr="fubar" />
+ <else/>
+ <assign name="foo" expr="foobar" />
+ </if>
+ <var name="drink" expr="water" />
+ <var name="eat" expr="flies" />
+ <send sendId="send12345" target="freddy" targetType="frog"
+ event="croak" namelist="drink eat" hints="h2o bzz"
+ delay="1000" />
+ <cancel sendId="send12345"/>
+ <log expr="leaving" />
+ <exit expr="later" namelist="freddy" />
+ </onentry>
+ </state>
+
+</scxml>
Propchange: jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/model/actions-test.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/model/actions-test.xml
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/transitions-01.xml
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/transitions-01.xml?rev=239518&view=auto
==============================================================================
--- jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/transitions-01.xml (added)
+++ jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/transitions-01.xml Tue Aug 23 20:52:02 2005
@@ -0,0 +1,81 @@
+<?xml version="1.0"?>
+<!--
+ Copyright 2005 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/01/SCXML"
+ version="1.0"
+ initialstate="ten">
+
+ <state id="ten">
+ <transition event="ten.done">
+ <target next="twenty"/>
+ </transition>
+ </state>
+
+ <state id="twenty">
+
+ <initial>
+ <transition>
+ <target next="twenty_one"/>
+ </transition>
+ </initial>
+
+ <onentry>
+ <log expr="In twenty" label="entry001" />
+ </onentry>
+
+ <state id="twenty_one">
+ <transition event="twenty_one.done">
+ <target next="twenty_two"/>
+ </transition>
+ </state>
+
+ <state id="twenty_two">
+ <transition event="twenty_two.done">
+ <target next="thirty"/>
+ </transition>
+ </state>
+
+ </state>
+
+ <state id="thirty">
+
+ <parallel>
+
+ <state id="thirty_one">
+ <onentry>
+ <log expr="Entering thirty_one" label="entry002" />
+ </onentry>
+ </state>
+
+ <state id="thirty_two">
+ <onentry>
+ <log expr="Entering thirty_two" label="entry003" />
+ </onentry>
+ </state>
+
+ <state id="thirty_three">
+ <onentry>
+ <log expr="Entering thirty_three" label="entry004" />
+ </onentry>
+ </state>
+
+ </parallel>
+
+ </state>
+
+ <state id="forty" final="true" />
+
+</scxml>
Propchange: jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/transitions-01.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/transitions-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