ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [5/5] incubator-ignite git commit: # ignite-437: fix random comparison mode
Date Fri, 20 Mar 2015 16:29:48 GMT
# ignite-437: fix random comparison mode


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/eeedf73a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/eeedf73a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/eeedf73a

Branch: refs/heads/ignite-437-sqltests
Commit: eeedf73aa64f3d5299a93b482344ffee72e8a6f8
Parents: 0271114
Author: Artem Shutak <ashutak@gridgain.com>
Authored: Fri Mar 20 19:29:50 2015 +0300
Committer: Artem Shutak <ashutak@gridgain.com>
Committed: Fri Mar 20 19:29:50 2015 +0300

----------------------------------------------------------------------
 .../query/h2/sql/IgniteVsH2QueryTest.java       | 34 ++++++++++++++++++--
 1 file changed, 31 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eeedf73a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/IgniteVsH2QueryTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/IgniteVsH2QueryTest.java
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/IgniteVsH2QueryTest.java
index ce2b661..85319f3 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/IgniteVsH2QueryTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/IgniteVsH2QueryTest.java
@@ -476,9 +476,19 @@ public class IgniteVsH2QueryTest extends GridCommonAbstractTest {
 
                 break;
             case RANDOM:
-                for (List<?> row1 : rs1)
-                    assertTrue("Actual result set has to contain row.\n" + "Result set="
+ rs2 + "\n" + "Row=" + row1, 
-                        rs2.contains(row1));
+                Map<List<?>, Integer> rowsWithCnt1 = extractUniqueueRowsWithCounts(rs1);
+                Map<List<?>, Integer> rowsWithCnt2 = extractUniqueueRowsWithCounts(rs2);
+                
+                assertEquals("Uniqueue rows count has to be equal.", rowsWithCnt1.size(),
rowsWithCnt2.size());
+
+                for (Map.Entry<List<?>, Integer> entry1 : rowsWithCnt1.entrySet())
{
+                    List<?> row = entry1.getKey();
+                    Integer cnt1 = entry1.getValue();
+
+                    Integer cnt2 = rowsWithCnt2.get(row);
+
+                    assertEquals("Row has different occurance number.\nRow=" + row, cnt1,
cnt2);
+                }
                 
                 break;
             default: 
@@ -487,6 +497,24 @@ public class IgniteVsH2QueryTest extends GridCommonAbstractTest {
     }
 
     /**
+     * @param rs Result set.
+     * @return Map of uniqueue rows at the result set to number of occuriances at the result
set.
+     */
+    private Map<List<?>, Integer> extractUniqueueRowsWithCounts(Iterable<List<?>>
rs) {
+        Map<List<?>, Integer> res = new HashMap<>();
+
+        for (List<?> row : rs) {
+            Integer cnt = res.get(row);
+            
+            if (cnt == null)
+                cnt = 0;
+            
+            res.put(row, cnt + 1);
+        }
+        return res;
+    }
+
+    /**
      * @throws Exception If failed.
      */
     private void checkAllDataEquals() throws Exception {


Mime
View raw message