Skip to main content

[el-spec commits] [el-spec~source-code:45] Add toMap test

  • From: kchung@...
  • To: commits@...
  • Subject: [el-spec commits] [el-spec~source-code:45] Add toMap test
  • Date: Mon, 23 Jan 2012 17:59:39 +0000

Project:    el-spec
Repository: source-code
Revision:   45
Author:     kchung
Date:       2012-01-23 17:59:35 UTC
Link:       

Log Message:
------------
Add toMap test



Revisions:
----------
45


Modified Paths:
---------------
trunk/impl/src/test/java/org/glassfish/el/test/LinqTest.java


Diffs:
------
Index: trunk/impl/src/test/java/org/glassfish/el/test/LinqTest.java
===================================================================
--- trunk/impl/src/test/java/org/glassfish/el/test/LinqTest.java        
(revision 44)
+++ trunk/impl/src/test/java/org/glassfish/el/test/LinqTest.java        
(revision 45)
@@ -1,6 +1,7 @@
 package org.glassfish.el.test;
 
 import java.util.List;
+import java.util.Map;
 
 import org.junit.Test;
 import org.junit.Before;
@@ -25,11 +26,15 @@
         System.out.println(msg);
     }
 
-    void testO(String name, String query) {
+    void testMap(String name, String query, String[] expected) {
         p("=== Test " + name + "===");
         p(query);
         Object ret = elp.getValue(query);
-        p(ret.toString());
+        assertTrue(ret instanceof Map);
+        for (Object item: ((Map) ret).entrySet()) {
+            p(" " + item.toString());
+            assertEquals(item.toString(), expected[indx++]);
+        }
     }
     /*
      * Test a Linq query that returns an Iterable.
@@ -209,12 +214,19 @@
             exp11);
     }
     
+    static String[] exp12 = {
+        "11=Order: 11, 100, 5/3/2011, 34.5",
+        "12=Order: 12, 100, 8/2/2011, 210.75",
+        "13=Order: 13, 101, 1/15/2011, 50.23",
+        "15=Order: 15, 102, 4/15/2011, 101.2"};
+
     @Test
     public void testToMap() {
-        testO("toMap",
+        testMap("toMap",
              " customers.selectMany(c->c.orders).\n" +
              "           where(o->o.orderDate.year == 2011).\n" +
-             "           toMap(o->o.orderID)");
+             "           toMap(o->o.orderID)",
+        exp12);
     }
 }
 





[el-spec commits] [el-spec~source-code:45] Add toMap test

kchung 01/23/2012
 
 
Close
loading
Please Confirm
Close