IGNITE-5711: Allowed to run queries on caches without query entities. This 
closes #2264.


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

Branch: refs/heads/ignite-5578
Commit: 2c737f0c6f42e983606e70faab5e9e6336b0a241
Parents: 66ccf85
Author: Alexander Paschenko <alexander.a.pasche...@gmail.com>
Authored: Tue Jul 11 15:23:26 2017 +0300
Committer: devozerov <voze...@gridgain.com>
Committed: Tue Jul 11 15:23:26 2017 +0300

----------------------------------------------------------------------
 .../examples/datagrid/CacheQueryDdlExample.java |  3 +-
 .../jdbc2/JdbcDefaultNoOpCacheTest.java         | 33 +++++++++++++
 .../ignite/jdbc/JdbcDefaultNoOpCacheTest.java   | 35 ++++++++++++++
 .../ignite/jdbc/JdbcNoDefaultCacheTest.java     | 50 ++++++++++++--------
 .../jdbc/suite/IgniteJdbcDriverTestSuite.java   |  5 +-
 .../processors/cache/GridCacheProcessor.java    |  4 +-
 .../processors/cache/IgniteCacheProxy.java      |  5 +-
 .../GridCacheQueryIndexingDisabledSelfTest.java | 16 +++----
 .../IgniteCacheAbstractFieldsQuerySelfTest.java | 30 +++++++++---
 ...niteCachePartitionedFieldsQuerySelfTest.java | 20 ++++++--
 .../Cache/Query/CacheQueriesTest.cs             | 19 ++++----
 11 files changed, 161 insertions(+), 59 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/2c737f0c/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheQueryDdlExample.java
----------------------------------------------------------------------
diff --git 
a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheQueryDdlExample.java
 
b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheQueryDdlExample.java
index 201dda1..e27907d 100644
--- 
a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheQueryDdlExample.java
+++ 
b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheQueryDdlExample.java
@@ -50,8 +50,7 @@ public class CacheQueryDdlExample {
 
             // Create dummy cache to act as an entry point for SQL queries 
(new SQL API which do not require this
             // will appear in future versions, JDBC and ODBC drivers do not 
require it already).
-            CacheConfiguration<?, ?> cacheCfg = new 
CacheConfiguration<>(DUMMY_CACHE_NAME)
-                .setSqlSchema("PUBLIC").setIndexedTypes(Integer.class, 
Integer.class);
+            CacheConfiguration<?, ?> cacheCfg = new 
CacheConfiguration<>(DUMMY_CACHE_NAME).setSqlSchema("PUBLIC");
 
             try (
                 IgniteCache<?, ?> cache = ignite.getOrCreateCache(cacheCfg)

http://git-wip-us.apache.org/repos/asf/ignite/blob/2c737f0c/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcDefaultNoOpCacheTest.java
----------------------------------------------------------------------
diff --git 
a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcDefaultNoOpCacheTest.java
 
b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcDefaultNoOpCacheTest.java
new file mode 100644
index 0000000..57ef52c
--- /dev/null
+++ 
b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcDefaultNoOpCacheTest.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.jdbc2;
+
+import static org.apache.ignite.IgniteJdbcDriver.CFG_URL_PREFIX;
+
+/**
+ * Test to check JDBC2 driver behavior when cache specified in connection 
string does not have any query entities.
+ */
+public class JdbcDefaultNoOpCacheTest extends 
org.apache.ignite.jdbc.JdbcDefaultNoOpCacheTest {
+    /** Ignite configuration URL. */
+    private static final String CFG_URL = 
"modules/clients/src/test/config/jdbc-config.xml";
+
+    /** {@inheritDoc} */
+    protected String getUrl() {
+        return CFG_URL_PREFIX + "cache=noop@" + CFG_URL;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/2c737f0c/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcDefaultNoOpCacheTest.java
----------------------------------------------------------------------
diff --git 
a/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcDefaultNoOpCacheTest.java
 
b/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcDefaultNoOpCacheTest.java
new file mode 100644
index 0000000..f1143f9
--- /dev/null
+++ 
b/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcDefaultNoOpCacheTest.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.jdbc;
+
+/**
+ * Test to check JDBC driver behavior when cache specified in connection 
string does not have any query entities.
+ */
+public class JdbcDefaultNoOpCacheTest extends JdbcNoDefaultCacheTest {
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        super.beforeTestsStarted();
+
+        ignite(0).getOrCreateCache("noop");
+    }
+
+    /** {@inheritDoc} */
+    @Override protected String getUrl() {
+        return super.getUrl() + "noop";
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/2c737f0c/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcNoDefaultCacheTest.java
----------------------------------------------------------------------
diff --git 
a/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcNoDefaultCacheTest.java
 
b/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcNoDefaultCacheTest.java
index d3d8454..a37c167 100644
--- 
a/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcNoDefaultCacheTest.java
+++ 
b/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcNoDefaultCacheTest.java
@@ -31,7 +31,6 @@ import 
org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
 
 /**
  *
@@ -106,10 +105,17 @@ public class JdbcNoDefaultCacheTest extends 
GridCommonAbstractTest {
     }
 
     /**
+     * @return Connection URL.
+     */
+    protected String getUrl() {
+        return URL;
+    }
+
+    /**
      * @throws Exception If failed.
      */
     public void testDefaults() throws Exception {
-        String url = URL;
+        String url = getUrl();
 
         try (Connection conn = DriverManager.getConnection(url)) {
             assertNotNull(conn);
@@ -126,35 +132,37 @@ public class JdbcNoDefaultCacheTest extends 
GridCommonAbstractTest {
     public void testNoCacheNameQuery() throws Exception {
         Statement stmt;
 
-        stmt = DriverManager.getConnection(URL).createStatement();
+        try (Connection conn = DriverManager.getConnection(getUrl())) {
+            stmt = conn.createStatement();
 
-        assertNotNull(stmt);
-        assertFalse(stmt.isClosed());
+            assertNotNull(stmt);
+            assertFalse(stmt.isClosed());
 
-        stmt.execute("select t._key, t._val from \"cache1\".Integer t");
+            stmt.execute("select t._key, t._val from \"cache1\".Integer t");
 
-        ResultSet rs = stmt.getResultSet();
+            ResultSet rs = stmt.getResultSet();
 
-        while(rs.next())
-            assertEquals(rs.getInt(2), rs.getInt(1) * 2);
+            while (rs.next())
+                assertEquals(rs.getInt(2), rs.getInt(1) * 2);
 
-        stmt.execute("select t._key, t._val from \"cache2\".Integer t");
+            stmt.execute("select t._key, t._val from \"cache2\".Integer t");
 
-        rs = stmt.getResultSet();
+            rs = stmt.getResultSet();
 
-        while(rs.next())
-            assertEquals(rs.getInt(2), rs.getInt(1) * 3);
+            while (rs.next())
+                assertEquals(rs.getInt(2), rs.getInt(1) * 3);
 
-        stmt.execute("select t._key, t._val, v._val " +
-            "from \"cache1\".Integer t join \"cache2\".Integer v on t._key = 
v._key");
+            stmt.execute("select t._key, t._val, v._val " +
+                "from \"cache1\".Integer t join \"cache2\".Integer v on t._key 
= v._key");
 
-        rs = stmt.getResultSet();
+            rs = stmt.getResultSet();
 
-        while(rs.next()) {
-            assertEquals(rs.getInt(2), rs.getInt(1) * 2);
-            assertEquals(rs.getInt(3), rs.getInt(1) * 3);
-        }
+            while (rs.next()) {
+                assertEquals(rs.getInt(2), rs.getInt(1) * 2);
+                assertEquals(rs.getInt(3), rs.getInt(1) * 3);
+            }
 
-        stmt.close();
+            stmt.close();
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/2c737f0c/modules/clients/src/test/java/org/apache/ignite/jdbc/suite/IgniteJdbcDriverTestSuite.java
----------------------------------------------------------------------
diff --git 
a/modules/clients/src/test/java/org/apache/ignite/jdbc/suite/IgniteJdbcDriverTestSuite.java
 
b/modules/clients/src/test/java/org/apache/ignite/jdbc/suite/IgniteJdbcDriverTestSuite.java
index 9ca3582..8ca3d45 100644
--- 
a/modules/clients/src/test/java/org/apache/ignite/jdbc/suite/IgniteJdbcDriverTestSuite.java
+++ 
b/modules/clients/src/test/java/org/apache/ignite/jdbc/suite/IgniteJdbcDriverTestSuite.java
@@ -22,6 +22,7 @@ import org.apache.ignite.internal.jdbc2.JdbcBlobTest;
 import org.apache.ignite.internal.jdbc2.JdbcDistributedJoinsQueryTest;
 import org.apache.ignite.jdbc.JdbcComplexQuerySelfTest;
 import org.apache.ignite.jdbc.JdbcConnectionSelfTest;
+import org.apache.ignite.jdbc.JdbcDefaultNoOpCacheTest;
 import org.apache.ignite.jdbc.JdbcEmptyCacheSelfTest;
 import org.apache.ignite.jdbc.JdbcLocalCachesSelfTest;
 import org.apache.ignite.jdbc.JdbcMetadataSelfTest;
@@ -33,6 +34,7 @@ import org.apache.ignite.jdbc.JdbcResultSetSelfTest;
 import org.apache.ignite.jdbc.JdbcStatementSelfTest;
 import org.apache.ignite.jdbc.thin.JdbcThinAutoCloseServerCursorTest;
 import org.apache.ignite.jdbc.thin.JdbcThinComplexQuerySelfTest;
+import org.apache.ignite.jdbc.thin.JdbcThinConnectionSelfTest;
 import org.apache.ignite.jdbc.thin.JdbcThinDeleteStatementSelfTest;
 import 
org.apache.ignite.jdbc.thin.JdbcThinDynamicIndexAtomicPartitionedNearSelfTest;
 import 
org.apache.ignite.jdbc.thin.JdbcThinDynamicIndexAtomicPartitionedSelfTest;
@@ -48,7 +50,6 @@ import 
org.apache.ignite.jdbc.thin.JdbcThinNoDefaultSchemaTest;
 import org.apache.ignite.jdbc.thin.JdbcThinPreparedStatementSelfTest;
 import org.apache.ignite.jdbc.thin.JdbcThinResultSetSelfTest;
 import org.apache.ignite.jdbc.thin.JdbcThinStatementSelfTest;
-import org.apache.ignite.jdbc.thin.JdbcThinConnectionSelfTest;
 import org.apache.ignite.jdbc.thin.JdbcThinUpdateStatementSelfTest;
 
 /**
@@ -72,6 +73,7 @@ public class IgniteJdbcDriverTestSuite extends TestSuite {
         suite.addTest(new TestSuite(JdbcEmptyCacheSelfTest.class));
         suite.addTest(new TestSuite(JdbcLocalCachesSelfTest.class));
         suite.addTest(new TestSuite(JdbcNoDefaultCacheTest.class));
+        suite.addTest(new TestSuite(JdbcDefaultNoOpCacheTest.class));
         suite.addTest(new TestSuite(JdbcPojoQuerySelfTest.class));
         suite.addTest(new TestSuite(JdbcPojoLegacyQuerySelfTest.class));
 
@@ -87,6 +89,7 @@ public class IgniteJdbcDriverTestSuite extends TestSuite {
         suite.addTest(new 
TestSuite(org.apache.ignite.internal.jdbc2.JdbcEmptyCacheSelfTest.class));
         suite.addTest(new 
TestSuite(org.apache.ignite.internal.jdbc2.JdbcLocalCachesSelfTest.class));
         suite.addTest(new 
TestSuite(org.apache.ignite.internal.jdbc2.JdbcNoDefaultCacheTest.class));
+        suite.addTest(new 
TestSuite(org.apache.ignite.internal.jdbc2.JdbcDefaultNoOpCacheTest.class));
         suite.addTest(new 
TestSuite(org.apache.ignite.internal.jdbc2.JdbcMergeStatementSelfTest.class));
         suite.addTest(new 
TestSuite(org.apache.ignite.internal.jdbc2.JdbcBinaryMarshallerMergeStatementSelfTest.class));
         suite.addTest(new 
TestSuite(org.apache.ignite.internal.jdbc2.JdbcInsertStatementSelfTest.class));

http://git-wip-us.apache.org/repos/asf/ignite/blob/2c737f0c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
index 0488a14..85772d8 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
@@ -1672,7 +1672,7 @@ public class GridCacheProcessor extends 
GridProcessorAdapter {
 
             String cacheName = ccfg.getName();
 
-            if ((inclLoc || ccfg.getCacheMode() != LOCAL) && 
QueryUtils.isEnabled(ccfg))
+            if ((inclLoc || ccfg.getCacheMode() != LOCAL))
                 return publicJCache(cacheName);
         }
 
@@ -1682,7 +1682,7 @@ public class GridCacheProcessor extends 
GridProcessorAdapter {
 
                 CacheConfiguration ccfg = desc.cacheConfiguration();
 
-                if (ccfg.getCacheMode() != LOCAL && 
QueryUtils.isEnabled(ccfg)) {
+                if (ccfg.getCacheMode() != LOCAL) {
                     dynamicStartCache(null, ccfg.getName(), null, false, true, 
true).get();
 
                     return publicJCache(ccfg.getName());

http://git-wip-us.apache.org/repos/asf/ignite/blob/2c737f0c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
index c8dc8dc..347e030 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
@@ -73,8 +73,8 @@ import 
org.apache.ignite.internal.processors.cache.query.GridCacheQueryType;
 import org.apache.ignite.internal.processors.query.QueryUtils;
 import org.apache.ignite.internal.util.GridCloseableIteratorAdapter;
 import org.apache.ignite.internal.util.GridEmptyIterator;
-import org.apache.ignite.internal.util.future.IgniteFinishedFutureImpl;
 import org.apache.ignite.internal.util.future.GridFutureAdapter;
+import org.apache.ignite.internal.util.future.IgniteFinishedFutureImpl;
 import org.apache.ignite.internal.util.future.IgniteFutureImpl;
 import org.apache.ignite.internal.util.lang.GridCloseableIterator;
 import org.apache.ignite.internal.util.lang.GridClosureException;
@@ -887,7 +887,8 @@ public class IgniteCacheProxy<K, V> extends 
AsyncSupportAdapter<IgniteCache<K, V
      */
     private void validate(Query qry) {
         if (!QueryUtils.isEnabled(ctx.config()) && !(qry instanceof ScanQuery) 
&&
-            !(qry instanceof ContinuousQuery) && !(qry instanceof SpiQuery))
+            !(qry instanceof ContinuousQuery) && !(qry instanceof SpiQuery) && 
!(qry instanceof SqlQuery) &&
+            !(qry instanceof SqlFieldsQuery))
             throw new CacheException("Indexing is disabled for cache: " + 
ctx.cache().name() +
                 ". Use setIndexedTypes or setTypeMetadata methods on 
CacheConfiguration to enable.");
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/2c737f0c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQueryIndexingDisabledSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQueryIndexingDisabledSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQueryIndexingDisabledSelfTest.java
index 1696d3a..92a7084 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQueryIndexingDisabledSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQueryIndexingDisabledSelfTest.java
@@ -49,19 +49,16 @@ public class GridCacheQueryIndexingDisabledSelfTest extends 
GridCacheAbstractSel
     /**
      * @param c Closure.
      */
-    private void doTest(Callable<Object> c) {
-        GridTestUtils.assertThrows(log, c, CacheException.class, "Indexing is 
disabled for cache: default");
+    private void doTest(Callable<Object> c, String expectedMsg) {
+        GridTestUtils.assertThrows(log, c, CacheException.class, expectedMsg);
     }
 
     /**
      * @throws IgniteCheckedException If failed.
      */
     public void testSqlFieldsQuery() throws IgniteCheckedException {
-        doTest(new Callable<Object>() {
-            @Override public Object call() throws IgniteCheckedException {
-                return jcache().query(new SqlFieldsQuery("select * from 
dual")).getAll();
-            }
-        });
+        // Should not throw despite the cache not having QueryEntities.
+        jcache().query(new SqlFieldsQuery("select * from dual")).getAll();
     }
 
     /**
@@ -72,18 +69,19 @@ public class GridCacheQueryIndexingDisabledSelfTest extends 
GridCacheAbstractSel
             @Override public Object call() throws IgniteCheckedException {
                 return jcache().query(new TextQuery<>(String.class, 
"text")).getAll();
             }
-        });
+        }, "Indexing is disabled for cache: default");
     }
 
     /**
      * @throws IgniteCheckedException If failed.
      */
     public void testSqlQuery() throws IgniteCheckedException {
+        // Failure occurs not on validation stage, hence specific error 
message.
         doTest(new Callable<Object>() {
             @Override public Object call() throws IgniteCheckedException {
                 return jcache().query(new SqlQuery<>(String.class, "1 = 
1")).getAll();
             }
-        });
+        }, "Failed to find SQL table for type: String");
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/2c737f0c/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractFieldsQuerySelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractFieldsQuerySelfTest.java
 
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractFieldsQuerySelfTest.java
index 1deee05..322598a 100644
--- 
a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractFieldsQuerySelfTest.java
+++ 
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractFieldsQuerySelfTest.java
@@ -72,9 +72,6 @@ public abstract class IgniteCacheAbstractFieldsQuerySelfTest 
extends GridCommonA
     /** */
     private static IgniteCache<String, Organization> orgCache;
 
-    /** Cache name. */
-    protected static final String CACHE = "cache";
-
     /** */
     private static IgniteCache<AffinityKey<String>, Person> personCache;
 
@@ -84,6 +81,9 @@ public abstract class IgniteCacheAbstractFieldsQuerySelfTest 
extends GridCommonA
     /** */
     protected static IgniteCache<Integer, Integer> intCache;
 
+    /** */
+    protected static IgniteCache<?, ?> noOpCache;
+
     /** Flag indicating if starting node should have cache. */
     protected boolean hasCache;
 
@@ -187,6 +187,8 @@ public abstract class 
IgniteCacheAbstractFieldsQuerySelfTest extends GridCommonA
 
         for (int i = 0; i < 200; i++)
             intCache.put(i, i);
+
+        noOpCache = grid(0).getOrCreateCache("noop");
     }
 
     /** {@inheritDoc} */
@@ -202,6 +204,7 @@ public abstract class 
IgniteCacheAbstractFieldsQuerySelfTest extends GridCommonA
         personCache = null;
         strCache = null;
         intCache = null;
+        noOpCache = null;
     }
 
     /** @return cache mode. */
@@ -345,7 +348,7 @@ public abstract class 
IgniteCacheAbstractFieldsQuerySelfTest extends GridCommonA
                     assert String.class.getName().equals(fields.get("_KEY"));
                     assert String.class.getName().equals(fields.get("_VAL"));
                 }
-                else if (DEFAULT_CACHE_NAME.equals(meta.cacheName()))
+                else if (DEFAULT_CACHE_NAME.equals(meta.cacheName()) || 
noOpCache.getName().equals(meta.cacheName()))
                     assertTrue("Invalid types size", types.isEmpty());
                 else
                     fail("Unknown cache: " + meta.cacheName());
@@ -479,7 +482,22 @@ public abstract class 
IgniteCacheAbstractFieldsQuerySelfTest extends GridCommonA
 
     /** @throws Exception If failed. */
     public void testExecute() throws Exception {
-        QueryCursor<List<?>> qry = personCache.query(sqlFieldsQuery("select 
_KEY, name, age from Person"));
+        doTestExecute(personCache, sqlFieldsQuery("select _KEY, name, age from 
Person"));
+    }
+
+    /** @throws Exception If failed. */
+    public void testExecuteNoOpCache() throws Exception {
+        doTestExecute(noOpCache, sqlFieldsQuery("select _KEY, name, age from 
\"AffinityKey-Person\".Person"));
+    }
+
+    /**
+     * Execute given query and check results.
+     * @param cache Cache to run query on.
+     * @param fldsQry Query.
+     * @throws Exception if failed.
+     */
+    private void doTestExecute (IgniteCache<?, ?> cache, SqlFieldsQuery 
fldsQry) throws Exception {
+        QueryCursor<List<?>> qry = cache.query(fldsQry);
 
         List<List<?>> res = new ArrayList<>(qry.getAll());
 
@@ -529,8 +547,6 @@ public abstract class 
IgniteCacheAbstractFieldsQuerySelfTest extends GridCommonA
 
         List<List<?>> res = new ArrayList<>(qry.getAll());
 
-        assert res != null;
-
         dedup(res);
 
         assertEquals(2, res.size());

http://git-wip-us.apache.org/repos/asf/ignite/blob/2c737f0c/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCachePartitionedFieldsQuerySelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCachePartitionedFieldsQuerySelfTest.java
 
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCachePartitionedFieldsQuerySelfTest.java
index 4934255..7f9989d 100644
--- 
a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCachePartitionedFieldsQuerySelfTest.java
+++ 
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCachePartitionedFieldsQuerySelfTest.java
@@ -52,6 +52,7 @@ public class IgniteCachePartitionedFieldsQuerySelfTest 
extends IgniteCacheAbstra
     }
 
     /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
     @Override protected CacheConfiguration cacheConfiguration() {
         CacheConfiguration cc = super.cacheConfiguration();
 
@@ -62,19 +63,30 @@ public class IgniteCachePartitionedFieldsQuerySelfTest 
extends IgniteCacheAbstra
 
     /** @throws Exception If failed. */
     public void testLocalQuery() throws Exception {
-        IgniteCache<Integer, Integer> cache = jcache(Integer.class, 
Integer.class);
+        doTestLocalQuery(intCache, new SqlFieldsQuery("select _key, _val from 
Integer"));
+    }
+
+    /** @throws Exception If failed. */
+    public void testLocalQueryNoOpCache() throws Exception {
+        doTestLocalQuery(noOpCache, new SqlFieldsQuery("select _key, _val from 
\"Integer-Integer\".Integer"));
+    }
 
+    /**
+     * Execute given query locally and check results.
+     * @param cache Cache to run query on.
+     * @param fldsQry Query.
+     */
+    private void doTestLocalQuery(IgniteCache<?, ?> cache, SqlFieldsQuery 
fldsQry) throws InterruptedException {
         awaitPartitionMapExchange(true, true, null);
 
         int exp = 0;
 
-        for(Cache.Entry e: cache.localEntries(CachePeekMode.PRIMARY)){
+        for(Cache.Entry e: intCache.localEntries(CachePeekMode.PRIMARY)){
             if(e.getValue() instanceof Integer)
                 exp++;
         }
 
-        QueryCursor<List<?>> qry = cache
-            .query(new SqlFieldsQuery("select _key, _val from 
Integer").setLocal(true));
+        QueryCursor<List<?>> qry = cache.query(fldsQry.setLocal(true));
 
         assertEquals(exp, qry.getAll().size());
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/2c737f0c/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
----------------------------------------------------------------------
diff --git 
a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
 
b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
index 62c8230..ae2fe8f 100644
--- 
a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
+++ 
b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
@@ -480,19 +480,16 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
         {
             var cache = GetIgnite().GetOrCreateCache<int, 
QueryPerson>("nonindexed_cache");
 
-            var queries = new QueryBase[]
-            {
-                new TextQuery(typeof (QueryPerson), "1*"),
-                new SqlQuery(typeof (QueryPerson), "age < 50")
-            };
+            // Text query.
+            var err = Assert.Throws<IgniteException>(() => cache.Query(new 
TextQuery(typeof(QueryPerson), "1*")));
 
-            foreach (var qry in queries)
-            {
-                var err = Assert.Throws<IgniteException>(() => 
cache.Query(qry));
+            Assert.AreEqual("Indexing is disabled for cache: nonindexed_cache. 
" +
+                "Use setIndexedTypes or setTypeMetadata methods on 
CacheConfiguration to enable.", err.Message);
 
-                Assert.AreEqual("Indexing is disabled for cache: 
nonindexed_cache. " +
-                    "Use setIndexedTypes or setTypeMetadata methods on 
CacheConfiguration to enable.", err.Message);
-            }
+            // SQL query.
+            err = Assert.Throws<IgniteException>(() => cache.Query(new 
SqlQuery(typeof(QueryPerson), "age < 50")));
+
+            Assert.AreEqual("Failed to find SQL table for type: QueryPerson", 
err.Message);
         }
 
         /// <summary>

Reply via email to