ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject incubator-ignite git commit: # ignite-437: fix small issues
Date Mon, 16 Mar 2015 15:17:21 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-437-sqltests e4433296d -> 835c1448c


# ignite-437: fix small issues


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

Branch: refs/heads/ignite-437-sqltests
Commit: 835c1448c6661b28a4507c7f4e62e52e272d686c
Parents: e443329
Author: Artem Shutak <ashutak@gridgain.com>
Authored: Mon Mar 16 18:17:27 2015 +0300
Committer: Artem Shutak <ashutak@gridgain.com>
Committed: Mon Mar 16 18:17:27 2015 +0300

----------------------------------------------------------------------
 .../query/h2/sql/IgniteVsH2QueryTest.java       | 70 +++++++++++---------
 .../IgniteCacheQuerySelfTestSuite.java          |  3 +
 .../IgniteH2IndexingSpiTestSuite.java           |  4 --
 3 files changed, 43 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/835c1448/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 373cd46..7b1460b 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
@@ -23,6 +23,7 @@ import org.apache.ignite.cache.affinity.*;
 import org.apache.ignite.cache.query.*;
 import org.apache.ignite.cache.query.annotations.*;
 import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.util.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.marshaller.optimized.*;
 import org.apache.ignite.spi.discovery.tcp.*;
@@ -40,9 +41,6 @@ import static org.apache.ignite.cache.CacheDistributionMode.*;
  *
  */
 public class IgniteVsH2QueryTest extends GridCommonAbstractTest {
-    /** Cache name. */
-    private static final String PARTITIONED_CACHE = "partitioned";
-
     /** */
     private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
 
@@ -297,15 +295,12 @@ public class IgniteVsH2QueryTest extends GridCommonAbstractTest {
         try {
             st = conn.prepareStatement(sql);
             
-            //TODO apply args ot stat.
+            //TODO apply args to statment.
 
             h2Rs = st.executeQuery();
 
             List<List<?>> cacheRes = cache.queryFields(new SqlFieldsQuery(sql).setArgs(args)).getAll();
 
-//            print("H2 query result.", h2Res);
-            print("Ignite Cache query result.", cacheRes);
-
             assertRsEquals(h2Rs, cacheRes);
         }
         finally {
@@ -313,30 +308,25 @@ public class IgniteVsH2QueryTest extends GridCommonAbstractTest {
             U.closeQuiet(h2Rs);
         }
     }
-
-    private void print(String msg, List<List<?>> rs) {
-        log.info(msg);
-
-        for (List<?> objects : rs)
-            log.info(objects.toString());
-    }
-
-    private void assertRsEquals(ResultSet rs, List<List<?>> actualRs) throws
SQLException {
+    
+    private static void assertRsEquals(ResultSet rs, List<List<?>> actualRs)
throws SQLException {
         int rsRowsCnt = 0;
 
+        assertEquals("Column count have to be equal.", rs.getMetaData().getColumnCount(),

+            actualRs.isEmpty() ? 0 : actualRs.get(0).size());
+
         while (rs.next()) {
-            boolean currRowFound = false;
+            boolean currRowIsFound = false;
 
             for (List<?> row : actualRs) {
                 if (rowEqualsCurrentRsRow(rs, row)) {
-                    currRowFound = true;
+                    currRowIsFound = true;
 
                     break;
                 }
             }
-
-            assertTrue("A row with number " + rsRowsCnt + " from " + rs + " not found at
" + actualRs + '.',
-                currRowFound);
+            
+            assertTrue("A row " + currentRsRow2String(rs) + " not found at " + actualRs +
'.', currRowIsFound);
 
             rsRowsCnt++;
         }
@@ -344,22 +334,34 @@ public class IgniteVsH2QueryTest extends GridCommonAbstractTest {
         assertEquals("Count of results.", rsRowsCnt, actualRs.size());
     }
 
-    private boolean rowEqualsCurrentRsRow(ResultSet rs, List<?> row) throws SQLException
{
-        for (int columnNum = 0; columnNum < row.size(); columnNum++) {
-            Object o1 = row.get(columnNum);
+    private static String currentRsRow2String(ResultSet rs) throws SQLException {
+        GridStringBuilder sb = new GridStringBuilder("[");
 
-            Object o2 = extractColumn(rs, columnNum + 1, o1.getClass());
+        for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++)
+            sb.a(rs.getObject(i).toString()).a(',');
+        
+        sb.d(sb.length() - 1).a(']');
+        
+        return sb.toString();
+    }
+
+    private static boolean rowEqualsCurrentRsRow(ResultSet rs, List<?> row) throws
SQLException {
+        for (int colNum = 0; colNum < row.size(); colNum++) {
+            Object o1 = row.get(colNum);
+
+            Object o2 = extractColumn(rs, colNum + 1, o1.getClass());
 
-            if (!o1.equals(o2))
+            assertNotNull("Unexpected null value.", o1);
+            assertNotNull("Unexpected null value.", o2);
+
+            if (!(o1.equals(o2)))
                 return false;
         }
 
         return true;
     }
 
-    protected Object extractColumn(ResultSet rs, int idx, Class<?> propType)
-        throws SQLException {
-
+    private static Object extractColumn(ResultSet rs, int idx, Class<?> propType) throws
SQLException {
         if (!propType.isPrimitive() && rs.getObject(idx) == null)
             return null;
 
@@ -385,9 +387,9 @@ public class IgniteVsH2QueryTest extends GridCommonAbstractTest {
             return rs.getSQLXML(idx);
         else // Object.
             return rs.getObject(idx);
-
     }
 
+    // TODO delete.
     private void assertRsEquals(List<List<?>> expRs, List<List<?>>
actualRs) {
         assertEquals("Count of results.", expRs.size(), actualRs.size());
 
@@ -396,6 +398,7 @@ public class IgniteVsH2QueryTest extends GridCommonAbstractTest {
                 actualRs.contains(expectedRow));
     }
 
+    // TODO delete.
     private void assertOrderedRsEquals(List<List<?>> expRs, List<List<?>>
actualRs) {
         assertEquals("Count of results.", expRs.size(), actualRs.size());
 
@@ -442,6 +445,13 @@ public class IgniteVsH2QueryTest extends GridCommonAbstractTest {
     /**
      * @throws Exception If failed.
      */
+    public void testAllColumns() throws Exception {
+        test0("select * from Organization");
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
     public void testCrossCache() throws Exception {
         log.info("-- Organizations --");
         test0("select id, name from Organization");

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/835c1448/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
index dcf4914..f956349 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
@@ -100,6 +100,9 @@ public class IgniteCacheQuerySelfTestSuite extends TestSuite {
 
         suite.addTestSuite(GridOrderedMessageCancelSelfTest.class);
 
+        // H2 comparison.
+        suite.addTestSuite(IgniteVsH2QueryTest.class);
+
         return suite;
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/835c1448/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteH2IndexingSpiTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteH2IndexingSpiTestSuite.java
b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteH2IndexingSpiTestSuite.java
index 9c15a83..bd9cca6 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteH2IndexingSpiTestSuite.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteH2IndexingSpiTestSuite.java
@@ -21,7 +21,6 @@ import junit.framework.*;
 import org.apache.ignite.internal.processors.cache.*;
 import org.apache.ignite.internal.processors.query.h2.*;
 import org.apache.ignite.internal.processors.query.h2.opt.*;
-import org.apache.ignite.internal.processors.query.h2.sql.*;
 
 /**
  * H2 indexing SPI tests.
@@ -52,9 +51,6 @@ public class IgniteH2IndexingSpiTestSuite extends TestSuite {
         suite.addTestSuite(GridCacheSwapSelfTest.class);
         suite.addTestSuite(GridCacheOffHeapSelfTest.class);
 
-        // H2 comparison.
-        suite.addTestSuite(IgniteVsH2QueryTest.class);
-
         return suite;
     }
 }


Mime
View raw message