You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ra...@apache.org on 2006/06/20 08:06:51 UTC
svn commit: r415512 [2/2] - in /jakarta/commons/proper/scxml/trunk: ./
src/main/java/org/apache/commons/scxml/
src/main/java/org/apache/commons/scxml/invoke/
src/main/java/org/apache/commons/scxml/io/
src/main/java/org/apache/commons/scxml/model/ src/m...
Added: jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/InvokeTest.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/InvokeTest.java?rev=415512&view=auto
==============================================================================
--- jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/InvokeTest.java (added)
+++ jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/InvokeTest.java Mon Jun 19 23:06:49 2006
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.scxml.invoke;
+
+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.SCXMLExecutor;
+import org.apache.commons.scxml.SCXMLTestHelper;
+import org.apache.commons.scxml.env.SimpleDispatcher;
+import org.apache.commons.scxml.env.SimpleErrorHandler;
+import org.apache.commons.scxml.env.SimpleErrorReporter;
+import org.apache.commons.scxml.env.jexl.JexlContext;
+import org.apache.commons.scxml.env.jexl.JexlEvaluator;
+import org.apache.commons.scxml.io.SCXMLDigester;
+import org.apache.commons.scxml.model.SCXML;
+import org.apache.commons.scxml.model.State;
+import org.apache.commons.scxml.model.TransitionTarget;
+/**
+ * Unit tests {@link org.apache.commons.scxml.SCXMLExecutor}.
+ * Testing <invoke>
+ */
+public class InvokeTest extends TestCase {
+ /**
+ * Construct a new instance of SCXMLExecutorTest with
+ * the specified name
+ */
+ public InvokeTest(String name) {
+ super(name);
+ }
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(InvokeTest.class);
+ suite.setName("SCXML Executor Tests, wildcard event match");
+ return suite;
+ }
+
+ // Test data
+ private URL invoke01;
+ private SCXMLExecutor exec;
+
+ /**
+ * Set up instance variables required by this test case.
+ */
+ public void setUp() {
+ invoke01 = this.getClass().getClassLoader().
+ getResource("org/apache/commons/scxml/invoke/invoker-01.xml");
+ }
+
+ /**
+ * Tear down instance variables required by this test case.
+ */
+ public void tearDown() {
+ invoke01 = null;
+ }
+
+ /**
+ * Test the SCXML documents, usage of <invoke>
+ */
+ public void testInvoke01Sample() {
+ try {
+ SCXML scxml = SCXMLDigester.digest(invoke01,
+ new SimpleErrorHandler());
+ exec = new SCXMLExecutor(new JexlEvaluator(), new SimpleDispatcher(),
+ new SimpleErrorReporter());
+ assertNotNull(exec);
+ exec.setRootContext(new JexlContext());
+ exec.setStateMachine(scxml);
+ exec.registerInvokerClass("scxml", SimpleSCXMLInvoker.class);
+ exec.go();
+ Set currentStates = exec.getCurrentStatus().getStates();
+ assertEquals(1, currentStates.size());
+ assertEquals("invoker", ((State)currentStates.iterator().
+ next()).getId());
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+ public static void main(String args[]) {
+ TestRunner.run(suite());
+ }
+}
+
Propchange: jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/InvokeTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/InvokeTest.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/InvokeTestSuite.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/InvokeTestSuite.java?rev=415512&view=auto
==============================================================================
--- jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/InvokeTestSuite.java (added)
+++ jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/InvokeTestSuite.java Mon Jun 19 23:06:49 2006
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.scxml.invoke;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * Test suite for the SCXML "invoke" package.
+ *
+ */
+public class InvokeTestSuite extends TestCase {
+
+ /**
+ * Construct a new instance.
+ */
+ public InvokeTestSuite(String name) {
+ super(name);
+ }
+
+ /**
+ * Command-line interface.
+ */
+ public static void main(String[] args) {
+ TestRunner.run(suite());
+ }
+
+ /**
+ * Get the suite of tests
+ */
+ public static Test suite() {
+ TestSuite suite = new TestSuite();
+ suite.setName("Commons-SCXML Invoke Tests");
+ suite.addTest(InvokeTest.suite());
+ return suite;
+ }
+}
+
Propchange: jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/InvokeTestSuite.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/InvokeTestSuite.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/invoked-01.xml
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/invoked-01.xml?rev=415512&view=auto
==============================================================================
--- jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/invoked-01.xml (added)
+++ jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/invoked-01.xml Mon Jun 19 23:06:49 2006
@@ -0,0 +1,31 @@
+<?xml version="1.0"?>
+<!--
+ Copyright 2006 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<scxml xmlns="http://www.w3.org/2005/07/SCXML"
+ version="1.0"
+ initialstate="state1">
+
+ <state id="state1">
+ <!--onentry>
+ <log expr="'foo is ' + foo + ' and bar is ' + bar" />
+ </onentry-->
+ <transition event="invoked.next" target="state2" />
+ </state>
+
+ <state id="state2" final="true" />
+
+</scxml>
+
Propchange: jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/invoked-01.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/invoked-01.xml
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/invoker-01.xml
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/invoker-01.xml?rev=415512&view=auto
==============================================================================
--- jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/invoker-01.xml (added)
+++ jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/invoker-01.xml Mon Jun 19 23:06:49 2006
@@ -0,0 +1,38 @@
+<?xml version="1.0"?>
+<!--
+ Copyright 2006 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<scxml xmlns="http://www.w3.org/2005/07/SCXML"
+ version="1.0"
+ initialstate="invoker">
+
+ <state id="invoker">
+ <onentry>
+ <log expr="'Begin invoke test ...'" />
+ </onentry>
+ <invoke targettype="scxml" src="invoked-01.xml">
+ <param name="foo" expr="'foo'" />
+ <param name="bar" expr="'bar'" />
+ <finalize>
+ <log expr="'Finalizing ...'" />
+ </finalize>
+ </invoke>
+ <transition event="invoker.invoke.done" target="end" />
+ </state>
+
+ <state id="end" final="true" />
+
+</scxml>
+
Propchange: jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/invoker-01.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/invoker-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