#ignite-738: GridH2IndexingGeoSelfTest uses new query API.

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

Branch: refs/heads/ignite-485
Commit: b388252ee366fcb8d8b14f9f05d1b10bbcaa8067
Parents: 4dd76db
Author: ivasilinets <ivasilin...@gridgain.com>
Authored: Mon Apr 13 17:57:42 2015 +0300
Committer: ivasilinets <ivasilin...@gridgain.com>
Committed: Mon Apr 13 17:57:42 2015 +0300

----------------------------------------------------------------------
 .../query/h2/GridH2IndexingGeoSelfTest.java     | 52 +++++++++++---------
 1 file changed, 29 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b388252e/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/GridH2IndexingGeoSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/GridH2IndexingGeoSelfTest.java
 
b/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/GridH2IndexingGeoSelfTest.java
index 9abf228..8566960 100644
--- 
a/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/GridH2IndexingGeoSelfTest.java
+++ 
b/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/GridH2IndexingGeoSelfTest.java
@@ -19,14 +19,16 @@ package org.apache.ignite.internal.processors.query.h2;
 
 import com.vividsolutions.jts.geom.*;
 import com.vividsolutions.jts.io.*;
+import org.apache.ignite.*;
+import org.apache.ignite.cache.query.*;
 import org.apache.ignite.cache.query.annotations.*;
 import org.apache.ignite.internal.*;
 import org.apache.ignite.internal.processors.cache.*;
-import org.apache.ignite.internal.processors.cache.query.*;
 import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.testframework.*;
 
+import javax.cache.*;
 import java.io.*;
 import java.util.*;
 import java.util.concurrent.*;
@@ -64,7 +66,7 @@ public class GridH2IndexingGeoSelfTest extends 
GridCacheAbstractSelfTest {
      */
     @SuppressWarnings("unchecked")
     public void testGeo() throws Exception {
-        GridCacheAdapter<Integer, EnemyCamp> cache = 
((IgniteKernal)grid(0)).internalCache(null);
+        IgniteCache<Integer, EnemyCamp> cache = grid(0).cache(null);
 
         WKTReader r = new WKTReader();
 
@@ -73,46 +75,50 @@ public class GridH2IndexingGeoSelfTest extends 
GridCacheAbstractSelfTest {
         cache.getAndPut(2, new EnemyCamp(r.read("POINT(70 30)"), "C"));
         cache.getAndPut(3, new EnemyCamp(r.read("POINT(75 25)"), "D"));
 
-        CacheQuery<Map.Entry<Integer, EnemyCamp>> qry = 
cache.queries().createSqlQuery(EnemyCamp.class,
-            "coords && ?");
+        SqlQuery<Integer, EnemyCamp> qry = new SqlQuery(EnemyCamp.class, 
"coords && ?");
 
-        Collection<Map.Entry<Integer, EnemyCamp>> res = 
qry.execute(r.read("POLYGON((5 70, 5 80, 30 80, 30 70, 5 70))"))
-            .get();
+        Collection<Cache.Entry<Integer, EnemyCamp>> res = cache.query(
+            qry.setArgs(r.read("POLYGON((5 70, 5 80, 30 80, 30 70, 5 
70))"))).getAll();
 
         checkPoints(res, "A");
 
-        res = qry.execute(r.read("POLYGON((10 5, 10 35, 70 30, 75 25, 10 
5))")).get();
+        res = cache.query(
+            qry.setArgs(r.read("POLYGON((10 5, 10 35, 70 30, 75 25, 10 
5))"))).getAll();
 
         checkPoints(res, "C", "D");
 
         // Move B to the first polygon.
         cache.getAndPut(1, new EnemyCamp(r.read("POINT(20 75)"), "B"));
 
-        res = qry.execute(r.read("POLYGON((5 70, 5 80, 30 80, 30 70, 5 
70))")).get();
+        res = cache.query(
+            qry.setArgs(r.read("POLYGON((5 70, 5 80, 30 80, 30 70, 5 
70))"))).getAll();
 
         checkPoints(res, "A", "B");
 
         // Move B to the second polygon.
         cache.getAndPut(1, new EnemyCamp(r.read("POINT(30 30)"), "B"));
 
-        res = qry.execute(r.read("POLYGON((10 5, 10 35, 70 30, 75 25, 10 
5))")).get();
+        res = cache.query(
+            qry.setArgs(r.read("POLYGON((10 5, 10 35, 70 30, 75 25, 10 
5))"))).getAll();
 
         checkPoints(res, "B", "C", "D");
 
         // Remove B.
         cache.getAndRemove(1);
 
-        res = qry.execute(r.read("POLYGON((5 70, 5 80, 30 80, 30 70, 5 
70))")).get();
+        res = cache.query(
+            qry.setArgs(r.read("POLYGON((5 70, 5 80, 30 80, 30 70, 5 
70))"))).getAll();
 
         checkPoints(res, "A");
 
-        res = qry.execute(r.read("POLYGON((10 5, 10 35, 70 30, 75 25, 10 
5))")).get();
+        res = cache.query(
+            qry.setArgs(r.read("POLYGON((10 5, 10 35, 70 30, 75 25, 10 
5))"))).getAll();
 
         checkPoints(res, "C", "D");
 
         // Check explaint request.
-        assertTrue(F.first(cache.queries().createSqlFieldsQuery("explain 
select * from EnemyCamp " +
-            "where coords && 'POINT(25 
75)'").execute().get()).get(0).toString().contains("coords_idx"));
+        assertTrue(F.first(cache.query(new SqlFieldsQuery("explain select * 
from EnemyCamp " +
+            "where coords && 'POINT(25 
75)'")).getAll()).get(0).toString().contains("coords_idx"));
     }
 
     /**
@@ -120,9 +126,9 @@ public class GridH2IndexingGeoSelfTest extends 
GridCacheAbstractSelfTest {
      */
     @SuppressWarnings("unchecked")
     public void testGeoMultithreaded() throws Exception {
-        final GridCacheAdapter<Integer, EnemyCamp> cache1 = 
((IgniteKernal)grid(0)).internalCache(null);
-        final GridCacheAdapter<Integer, EnemyCamp> cache2 = 
((IgniteKernal)grid(1)).internalCache(null);
-        final GridCacheAdapter<Integer, EnemyCamp> cache3 = 
((IgniteKernal)grid(2)).internalCache(null);
+        final IgniteCache<Integer, EnemyCamp> cache1 = grid(0).cache(null);
+        final IgniteCache<Integer, EnemyCamp> cache2 = grid(1).cache(null);
+        final IgniteCache<Integer, EnemyCamp> cache3 = grid(2).cache(null);
 
         final String[] points = new String[CNT];
 
@@ -153,7 +159,7 @@ public class GridH2IndexingGeoSelfTest extends 
GridCacheAbstractSelfTest {
                 while (!stop.get()) {
                     int cacheIdx = rnd.nextInt(0, 3);
 
-                    GridCacheAdapter<Integer, EnemyCamp> cache = cacheIdx == 0 
? cache1 : cacheIdx == 1 ? cache2 : cache3;
+                    IgniteCache<Integer, EnemyCamp> cache = cacheIdx == 0 ? 
cache1 : cacheIdx == 1 ? cache2 : cache3;
 
                     int idx = rnd.nextInt(CNT);
                     int x = rnd.nextInt(1, 100);
@@ -178,13 +184,13 @@ public class GridH2IndexingGeoSelfTest extends 
GridCacheAbstractSelfTest {
                     try {
                         int cacheIdx = rnd.nextInt(0, 3);
 
-                        GridCacheAdapter<Integer, EnemyCamp> cache = cacheIdx 
== 0 ? cache1 : cacheIdx == 1 ? cache2 : cache3;
+                        IgniteCache<Integer, EnemyCamp> cache = cacheIdx == 0 
? cache1 : cacheIdx == 1 ? cache2 : cache3;
 
-                        CacheQuery<Map.Entry<Integer, EnemyCamp>> qry = 
cache.queries().createSqlQuery(
+                        SqlQuery<Integer, EnemyCamp> qry = new SqlQuery<>(
                             EnemyCamp.class, "coords && ?");
 
-                        Collection<Map.Entry<Integer, EnemyCamp>> res = 
qry.execute(
-                            r.read("POLYGON((0 0, 0 100, 100 100, 100 0, 0 
0))")).get();
+                        Collection<Cache.Entry<Integer, EnemyCamp>> res = 
cache.query(qry.setArgs(
+                            r.read("POLYGON((0 0, 0 100, 100 100, 100 0, 0 
0))"))).getAll();
 
                         checkPoints(res, points);
 
@@ -222,12 +228,12 @@ public class GridH2IndexingGeoSelfTest extends 
GridCacheAbstractSelfTest {
      * @param res Result.
      * @param points Expected points.
      */
-    private void checkPoints( Collection<Map.Entry<Integer, EnemyCamp>> res, 
String... points) {
+    private void checkPoints( Collection<Cache.Entry<Integer, EnemyCamp>> res, 
String... points) {
         Set<String> set = new HashSet<>(Arrays.asList(points));
 
         assertEquals(set.size(), res.size());
 
-        for (Map.Entry<Integer, EnemyCamp> e : res)
+        for (Cache.Entry<Integer, EnemyCamp> e : res)
             assertTrue(set.remove(e.getValue().name));
     }
 

Reply via email to