commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ra...@apache.org
Subject svn commit: r651781 - in /commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model: AssignTest.java DatamodelTest.java HistoryTest.java StateTest.java StatelessModelTest.java
Date Sat, 26 Apr 2008 01:47:14 GMT
Author: rahul
Date: Fri Apr 25 18:47:06 2008
New Revision: 651781

URL: http://svn.apache.org/viewvc?rev=651781&view=rev
Log:
Type safety improvements.

Modified:
    commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/AssignTest.java
    commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/DatamodelTest.java
    commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/HistoryTest.java
    commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/StateTest.java
    commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/StatelessModelTest.java

Modified: commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/AssignTest.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/AssignTest.java?rev=651781&r1=651780&r2=651781&view=diff
==============================================================================
--- commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/AssignTest.java
(original)
+++ commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/AssignTest.java
Fri Apr 25 18:47:06 2008
@@ -67,10 +67,9 @@
      * Test the implementation
      */
     public void testAssignSrc() {
-        Set currentStates = exec.getCurrentStatus().getStates();
+        Set<TransitionTarget> currentStates = exec.getCurrentStatus().getStates();
         assertEquals(1, currentStates.size());
-        assertEquals("assign3", ((State)currentStates.iterator().
-            next()).getId());
+        assertEquals("assign3", currentStates.iterator().next().getId());
         assertTrue(exec.getCurrentStatus().isFinal());
     }
 

Modified: commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/DatamodelTest.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/DatamodelTest.java?rev=651781&r1=651780&r2=651781&view=diff
==============================================================================
--- commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/DatamodelTest.java
(original)
+++ commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/DatamodelTest.java
Fri Apr 25 18:47:06 2008
@@ -118,10 +118,9 @@
         exec01 = SCXMLTestHelper.getExecutor(datamodel04jexl,
             new JexlContext(), new JexlEvaluator());
         assertNotNull(exec01);
-        Set currentStates = exec01.getCurrentStatus().getStates();
+        Set<TransitionTarget> currentStates = exec01.getCurrentStatus().getStates();
         assertEquals(1, currentStates.size());
-        assertEquals("ten", ((State)currentStates.iterator().
-            next()).getId());
+        assertEquals("ten", currentStates.iterator().next().getId());
         Map<String, Object> payload = new HashMap<String, Object>();
         payload.put("one", "1");
         payload.put("two", "2");
@@ -129,64 +128,54 @@
         SCXMLTestHelper.fireEvent(exec01, te);
         currentStates = exec01.getCurrentStatus().getStates();
         assertEquals(1, currentStates.size());
-        assertEquals("twenty", ((State)currentStates.iterator().
-            next()).getId());
+        assertEquals("twenty", currentStates.iterator().next().getId());
         SCXMLTestHelper.fireEvent(exec01, "twenty.done");
         currentStates = exec01.getCurrentStatus().getStates();
         assertEquals(1, currentStates.size());
-        assertEquals("thirty", ((State)currentStates.iterator().
-            next()).getId());
+        assertEquals("thirty", currentStates.iterator().next().getId());
     }
 
     private void runtest() {
         try {
             //// Interleaved
             // exec01
-            Set currentStates = exec01.getCurrentStatus().getStates();
+            Set<TransitionTarget> currentStates = exec01.getCurrentStatus().getStates();
             assertEquals(1, currentStates.size());
-            assertEquals("ten", ((State)currentStates.iterator().
-                next()).getId());
+            assertEquals("ten", currentStates.iterator().next().getId());
             exec01 = SCXMLTestHelper.testExecutorSerializability(exec01);
             currentStates = fireEvent("ten.done", exec01);
             assertEquals(1, currentStates.size());
-            assertEquals("twenty", ((State)currentStates.iterator().
-                next()).getId());
+            assertEquals("twenty", currentStates.iterator().next().getId());
             // exec02
             currentStates = exec02.getCurrentStatus().getStates();
             assertEquals(1, currentStates.size());
-            assertEquals("ten", ((State)currentStates.iterator().
-                next()).getId());
+            assertEquals("ten", currentStates.iterator().next().getId());
             // exec01
             currentStates = fireEvent("twenty.done", exec01);
             assertEquals(1, currentStates.size());
-            assertEquals("thirty", ((State)currentStates.iterator().
-                next()).getId());
+            assertEquals("thirty", currentStates.iterator().next().getId());
             exec01 = SCXMLTestHelper.testExecutorSerializability(exec01);
             // exec02
             currentStates = fireEvent("ten.done", exec02);
             assertEquals(1, currentStates.size());
-            assertEquals("twenty", ((State)currentStates.iterator().
-                next()).getId());
+            assertEquals("twenty", currentStates.iterator().next().getId());
             exec02 = SCXMLTestHelper.testExecutorSerializability(exec02);
             currentStates = fireEvent("twenty.done", exec02);
             assertEquals(1, currentStates.size());
-            assertEquals("thirty", ((State)currentStates.iterator().
-                next()).getId());
+            assertEquals("thirty", currentStates.iterator().next().getId());
             currentStates = fireEvent("thirty.done", exec02);
             assertEquals(1, currentStates.size());
-            assertEquals("forty", ((State)currentStates.iterator().
-                next()).getId());
+            assertEquals("forty", currentStates.iterator().next().getId());
             // exec01
             currentStates = fireEvent("thirty.done", exec01);
             assertEquals(1, currentStates.size());
-            assertEquals("forty", ((State)currentStates.iterator().
-                next()).getId());
+            assertEquals("forty", currentStates.iterator().next().getId());
         } catch (Exception e) {
             fail(e.getMessage());
         }
     }
 
-    private Set fireEvent(String name, SCXMLExecutor exec) {
+    private Set<TransitionTarget> fireEvent(String name, SCXMLExecutor exec) {
         TriggerEvent[] evts = {new TriggerEvent(name,
                 TriggerEvent.SIGNAL_EVENT, null)};
         try {

Modified: commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/HistoryTest.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/HistoryTest.java?rev=651781&r1=651780&r2=651781&view=diff
==============================================================================
--- commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/HistoryTest.java
(original)
+++ commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/HistoryTest.java
Fri Apr 25 18:47:06 2008
@@ -98,25 +98,21 @@
 
     public void testHistoryDefaults01() {
         exec = SCXMLTestHelper.getExecutor(defaults01);
-        Set currentStates = exec.getCurrentStatus().getStates();
+        Set<TransitionTarget> currentStates = exec.getCurrentStatus().getStates();
         assertEquals(1, currentStates.size());
-        assertEquals("state11", ((State)currentStates.iterator().
-            next()).getId());
+        assertEquals("state11", currentStates.iterator().next().getId());
         currentStates = SCXMLTestHelper.fireEvent(exec, "state.next");
         assertEquals(1, currentStates.size());
-        assertEquals("state211", ((State)currentStates.iterator().
-            next()).getId());
+        assertEquals("state211", currentStates.iterator().next().getId());
         currentStates = SCXMLTestHelper.fireEvent(exec, "state.next");
         assertEquals(1, currentStates.size());
-        assertEquals("state31", ((State)currentStates.iterator().
-            next()).getId());
+        assertEquals("state31", currentStates.iterator().next().getId());
     }
 
     private void runHistoryFlow() {
-        Set currentStates = exec.getCurrentStatus().getStates();
+        Set<TransitionTarget> currentStates = exec.getCurrentStatus().getStates();
         assertEquals(1, currentStates.size());
-        assertEquals("phase1", ((State)currentStates.iterator().
-            next()).getId());
+        assertEquals("phase1", currentStates.iterator().next().getId());
         assertEquals("phase1", pauseAndResume());
         assertEquals("phase2", nextPhase());
         // pause and resume couple of times for good measure
@@ -136,10 +132,9 @@
     }
 
     private String pauseAndResume() {
-        Set currentStates = SCXMLTestHelper.fireEvent(exec, "flow.pause");
+        Set<TransitionTarget> currentStates = SCXMLTestHelper.fireEvent(exec, "flow.pause");
         assertEquals(1, currentStates.size());
-        assertEquals("interrupted", ((State)currentStates.iterator().
-            next()).getId());
+        assertEquals("interrupted", currentStates.iterator().next().getId());
         exec = SCXMLTestHelper.testExecutorSerializability(exec);
         currentStates = SCXMLTestHelper.fireEvent(exec, "flow.resume");
         assertEquals(1, currentStates.size());
@@ -148,7 +143,7 @@
     }
 
     private String nextPhase() {
-        Set currentStates = SCXMLTestHelper.fireEvent(exec, "phase.done");
+        Set<TransitionTarget> currentStates = SCXMLTestHelper.fireEvent(exec, "phase.done");
         assertEquals(1, currentStates.size());
         return ((State)currentStates.iterator().next()).getId();
     }

Modified: commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/StateTest.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/StateTest.java?rev=651781&r1=651780&r2=651781&view=diff
==============================================================================
--- commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/StateTest.java
(original)
+++ commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/StateTest.java
Fri Apr 25 18:47:06 2008
@@ -60,10 +60,10 @@
         
         state.addTransition(transition);
         
-        List events = (List)state.getTransitionsList("event");
+        List<Transition> events = state.getTransitionsList("event");
         
         assertEquals(1, events.size());
-        assertEquals("event", ((Transition)events.get(0)).getEvent());
+        assertEquals("event", events.get(0).getEvent());
     }
     
     public void testAddTransitionContainKey() {
@@ -76,7 +76,7 @@
         state.addTransition(transition1);
         state.addTransition(transition2);
         
-        List events = (List)state.getTransitionsList("event");
+        List<Transition> events = state.getTransitionsList("event");
         
         assertEquals(2, events.size());
     }
@@ -91,7 +91,7 @@
         state.addTransition(transition1);
         state.addTransition(transition2);
         
-        List events = state.getTransitionsList();
+        List<Transition> events = state.getTransitionsList();
         
         assertEquals(2, events.size());
     }

Modified: commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/StatelessModelTest.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/StatelessModelTest.java?rev=651781&r1=651780&r2=651781&view=diff
==============================================================================
--- commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/StatelessModelTest.java
(original)
+++ commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/StatelessModelTest.java
Fri Apr 25 18:47:06 2008
@@ -139,7 +139,7 @@
         assertNotNull(exec02);
         assertFalse(exec01 == exec02);
 
-        Set currentStates = exec01.getCurrentStatus().getStates();
+        Set<TransitionTarget> currentStates = exec01.getCurrentStatus().getStates();
         checkParallelStates(currentStates, "state1.init", "state2.init", "exec01");
 
         currentStates = exec02.getCurrentStatus().getStates();
@@ -166,7 +166,7 @@
         assertNotNull(exec01);
         assertTrue(scxml01par != scxml02par);
 
-        Set currentStates = exec01.getCurrentStatus().getStates();
+        Set<TransitionTarget> currentStates = exec01.getCurrentStatus().getStates();
         checkParallelStates(currentStates, "state1.init", "state2.init", "exec01");
 
         currentStates = fireEvent("state1.event", exec01);
@@ -177,15 +177,15 @@
         checkParallelStates(currentStates, "next", null, "exec01");
     }
 
-    private void checkParallelStates(Set currentStates, String s1, String s2,
-            String label) {
-        Iterator i = currentStates.iterator();
+    private void checkParallelStates(Set<TransitionTarget> currentStates,
+            String s1, String s2, String label) {
+        Iterator<TransitionTarget> i = currentStates.iterator();
         assertTrue("Not enough states", i.hasNext());
-        String cs1 = ((State) i.next()).getId();
+        String cs1 = i.next().getId();
         String cs2 = null;
         if (s2 != null) {
             assertTrue("Not enough states, found one state: " + cs1, i.hasNext());
-            cs2 = ((State) i.next()).getId();
+            cs2 = i.next().getId();
             assertFalse("Too many states", i.hasNext());
             if (s2.equals(cs2)) {
                 cs2 = null;
@@ -210,33 +210,27 @@
         try {
             //// Interleaved
             // exec01
-            Set currentStates = exec01.getCurrentStatus().getStates();
+            Set<TransitionTarget> currentStates = exec01.getCurrentStatus().getStates();
             assertEquals(1, currentStates.size());
-            assertEquals("ten", ((State)currentStates.iterator().
-                next()).getId());
+            assertEquals("ten", currentStates.iterator().next().getId());
             currentStates = fireEvent("ten.done", exec01);
             assertEquals(1, currentStates.size());
-            assertEquals("twenty", ((State)currentStates.iterator().
-                next()).getId());
+            assertEquals("twenty", currentStates.iterator().next().getId());
             // exec02
             currentStates = exec02.getCurrentStatus().getStates();
             assertEquals(1, currentStates.size());
-            assertEquals("ten", ((State)currentStates.iterator().
-                next()).getId());
+            assertEquals("ten", currentStates.iterator().next().getId());
             // exec01
             currentStates = fireEvent("twenty.done", exec01);
             assertEquals(1, currentStates.size());
-            assertEquals("thirty", ((State)currentStates.iterator().
-                next()).getId());
+            assertEquals("thirty", currentStates.iterator().next().getId());
             // exec02
             currentStates = fireEvent("ten.done", exec02);
             assertEquals(1, currentStates.size());
-            assertEquals("twenty", ((State)currentStates.iterator().
-                next()).getId());
+            assertEquals("twenty", currentStates.iterator().next().getId());
             currentStates = fireEvent("twenty.done", exec02);
             assertEquals(1, currentStates.size());
-            assertEquals("thirty", ((State)currentStates.iterator().
-                next()).getId());
+            assertEquals("thirty", currentStates.iterator().next().getId());
         } catch (Exception e) {
             fail(e.getMessage());
         }
@@ -244,7 +238,7 @@
 
     private void runSequentialTest() {
         try {
-            Set currentStates = exec01.getCurrentStatus().getStates();
+            Set<TransitionTarget> currentStates = exec01.getCurrentStatus().getStates();
             assertEquals(1, currentStates.size());
             assertEquals("ten", ((State)currentStates.iterator().
                 next()).getId());
@@ -261,7 +255,7 @@
         }    	
     }
 
-    private Set fireEvent(String name, SCXMLExecutor exec) {
+    private Set<TransitionTarget> fireEvent(String name, SCXMLExecutor exec) {
         TriggerEvent[] evts = {new TriggerEvent(name,
                 TriggerEvent.SIGNAL_EVENT, null)};
         try {



Mime
View raw message