commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ra...@apache.org
Subject svn commit: r718747 - in /commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml: SCXMLTestHelper.java model/ParallelTest.java model/parallel-01.xml model/parallel-02.xml
Date Tue, 18 Nov 2008 22:35:08 GMT
Author: rahul
Date: Tue Nov 18 14:35:08 2008
New Revision: 718747

URL: http://svn.apache.org/viewvc?rev=718747&view=rev
Log:
Two new tests for <transition>s within <parallel>.

Added:
    commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/ParallelTest.java
  (with props)
    commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/parallel-01.xml
  (with props)
    commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/parallel-02.xml
  (with props)
Modified:
    commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/SCXMLTestHelper.java

Modified: commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/SCXMLTestHelper.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/SCXMLTestHelper.java?rev=718747&r1=718746&r2=718747&view=diff
==============================================================================
--- commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/SCXMLTestHelper.java
(original)
+++ commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/SCXMLTestHelper.java
Tue Nov 18 14:35:08 2008
@@ -24,6 +24,7 @@
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.net.URL;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Set;
@@ -262,7 +263,7 @@
             + " on firing event " + triggerEvent + " but found "
             + currentStates.size() + " states instead.",
             n, currentStates.size());
-        List<String> expectedStateIdList = Arrays.asList(expectedStateIds);
+        List<String> expectedStateIdList = new ArrayList<String>(Arrays.asList(expectedStateIds));
         for (TransitionTarget tt : currentStates) {
             String stateId = tt.getId();
             if(!expectedStateIdList.remove(stateId)) {

Added: commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/ParallelTest.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/ParallelTest.java?rev=718747&view=auto
==============================================================================
--- commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/ParallelTest.java
(added)
+++ commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/ParallelTest.java
Tue Nov 18 14:35:08 2008
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.scxml.model;
+
+import java.net.URL;
+
+import org.apache.commons.scxml.SCXMLExecutor;
+import org.apache.commons.scxml.SCXMLTestHelper;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class ParallelTest extends TestCase {
+
+    public ParallelTest(String testName) {
+        super(testName);
+    }
+
+    public static Test suite() {
+        return new TestSuite(ParallelTest.class);
+    }
+
+    public static void main(String args[]) {
+        String[] testCaseName = { ParallelTest.class.getName() };
+        junit.textui.TestRunner.main(testCaseName);
+    }
+
+    // Test data
+    private URL parallel01, parallel02;
+    private SCXMLExecutor exec;
+    
+    public void setUp() {
+        parallel01 = this.getClass().getClassLoader().
+            getResource("org/apache/commons/scxml/model/parallel-01.xml");
+        parallel02 = this.getClass().getClassLoader().
+            getResource("org/apache/commons/scxml/model/parallel-02.xml");
+    }
+
+    public void tearDown() {
+        parallel01 = parallel02 = null;
+        exec = null;
+    }
+
+    public void testParallel01() {
+        exec = SCXMLTestHelper.getExecutor(parallel01);
+        assertNotNull(exec);
+        try {
+            SCXMLTestHelper.assertPostTriggerState(exec, "foo", "end");
+        } catch (Exception e) {
+            fail(e.getMessage());
+        }
+    }
+
+    public void testParallel02() {
+        exec = SCXMLTestHelper.getExecutor(parallel02);
+        assertNotNull(exec);
+        try {
+        	SCXMLTestHelper.assertPostTriggerStates(exec, "dummy.event", new String[] { "state01",
"state02" });
+            SCXMLTestHelper.assertPostTriggerState(exec, "event1", "state1");
+        } catch (Exception e) {
+            fail(e.getMessage());
+        }
+    }
+
+}

Propchange: commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/ParallelTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/ParallelTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/parallel-01.xml
URL: http://svn.apache.org/viewvc/commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/parallel-01.xml?rev=718747&view=auto
==============================================================================
--- commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/parallel-01.xml
(added)
+++ commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/parallel-01.xml
Tue Nov 18 14:35:08 2008
@@ -0,0 +1,70 @@
+<?xml version="1.0"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+<!--
+    Needs SCXMLParser
+-->
+<scxml xmlns="http://www.w3.org/2005/07/scxml"
+       version="1.0"
+       initialstate="para">
+
+    <parallel id="para">
+
+        <state id="para1">
+
+            <initial>
+                <transition target="para11"/>
+            </initial>
+
+            <state id="para11">
+                <transition event="foo" target="para12"/>
+            </state>
+
+            <state id="para12">
+                <onexit>
+                    <log expr="'Exiting para12'" />
+                </onexit>
+            </state>
+
+        </state>
+
+        <state id="para2">
+
+            <initial>
+                <transition target="para21"/>
+            </initial>
+
+            <state id="para21">
+                <transition cond="In('para12')" target="para22"/>
+            </state>
+
+            <state id="para22">
+                <onexit>
+                    <log expr="'Exiting para22'" />
+                </onexit>
+
+                <transition target="end"/>
+            </state>
+
+        </state>
+
+    </parallel>
+
+    <state id="end" final="true" />
+
+</scxml>
+

Propchange: commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/parallel-01.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/parallel-01.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/parallel-02.xml
URL: http://svn.apache.org/viewvc/commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/parallel-02.xml?rev=718747&view=auto
==============================================================================
--- commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/parallel-02.xml
(added)
+++ commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/parallel-02.xml
Tue Nov 18 14:35:08 2008
@@ -0,0 +1,31 @@
+<?xml version="1.0"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+<!--
+   Needs SCXMLParser
+-->
+<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" initialstate="state0">
+
+    <parallel id="state0">
+        <transition event="event1" target="state1" />
+        <!-- dummy regions -->
+        <state id="state01"/>
+        <state id="state02"/>
+    </parallel>
+    <final id="state1"/>
+
+</scxml>

Propchange: commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/parallel-02.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/parallel-02.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL



Mime
View raw message