IGNITE-844 Added tests for SQL queries on cache with type metadata.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/e7f3f96d Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/e7f3f96d Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/e7f3f96d Branch: refs/heads/ignite-844 Commit: e7f3f96db244a91dad2f7b50850df5941dc082cb Parents: 0ad9b1b Author: AKuznetsov <akuznet...@gridgain.com> Authored: Mon May 4 16:06:49 2015 +0700 Committer: AKuznetsov <akuznet...@gridgain.com> Committed: Mon May 4 16:06:49 2015 +0700 ---------------------------------------------------------------------- ...eCacheAtomicFieldsQueryTypeMetaSelfTest.java | 59 +++++++++++++++ ...cNearEnabledFieldsQueryTypeMetaSelfTest.java | 30 ++++++++ ...edFieldsQueryP2PEnabledTypeMetaSelfTest.java | 34 +++++++++ ...ePartitionedFieldsQueryTypeMetaSelfTest.java | 56 ++++++++++++++ ...edFieldsQueryP2PEnabledTypeMetaSelfTest.java | 34 +++++++++ ...heReplicatedFieldsQueryTypeMetaSelfTest.java | 79 ++++++++++++++++++++ ...teCacheLocalFieldsQueryTypeMetaSelfTest.java | 38 ++++++++++ ...cheLocalFieldsQueryTypeMetadataSelfTest.java | 38 ---------- .../IgniteCacheQuerySelfTestSuite.java | 12 ++- 9 files changed, 341 insertions(+), 39 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e7f3f96d/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheAtomicFieldsQueryTypeMetaSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheAtomicFieldsQueryTypeMetaSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheAtomicFieldsQueryTypeMetaSelfTest.java new file mode 100644 index 0000000..fb41a4d --- /dev/null +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheAtomicFieldsQueryTypeMetaSelfTest.java @@ -0,0 +1,59 @@ +/* + * 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.processors.cache.distributed.near; + +import org.apache.ignite.cache.*; +import org.apache.ignite.cache.query.*; +import org.apache.ignite.configuration.*; +import org.apache.ignite.internal.util.typedef.*; + +import java.util.*; + +import static org.apache.ignite.cache.CacheAtomicityMode.*; + +/** + * Tests for fields queries. + */ +public class IgniteCacheAtomicFieldsQueryTypeMetaSelfTest extends IgniteCachePartitionedFieldsQueryTypeMetaSelfTest { + /** {@inheritDoc} */ + @Override protected CacheAtomicityMode atomicityMode() { + return ATOMIC; + } + + /** {@inheritDoc} */ + @Override protected NearCacheConfiguration nearConfiguration() { + return null; + } + + /** + * + */ + public void testUnsupportedOperations() { + try { + QueryCursor<List<?>> qry = grid(0).cache(null).query(new SqlFieldsQuery( + "update Person set name = ?").setArgs("Mary Poppins")); + + qry.getAll(); + + fail("We don't support updates."); + } + catch (Exception e) { + X.println("___ " + e.getMessage()); + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e7f3f96d/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheAtomicNearEnabledFieldsQueryTypeMetaSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheAtomicNearEnabledFieldsQueryTypeMetaSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheAtomicNearEnabledFieldsQueryTypeMetaSelfTest.java new file mode 100644 index 0000000..337f39c --- /dev/null +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheAtomicNearEnabledFieldsQueryTypeMetaSelfTest.java @@ -0,0 +1,30 @@ +/* + * 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.processors.cache.distributed.near; + +import org.apache.ignite.configuration.*; + +/** + * Tests for atomic cache with near cache enabled. + */ +public class IgniteCacheAtomicNearEnabledFieldsQueryTypeMetaSelfTest extends IgniteCacheAtomicFieldsQueryTypeMetaSelfTest { + /** {@inheritDoc} */ + @Override protected NearCacheConfiguration nearConfiguration() { + return new NearCacheConfiguration(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e7f3f96d/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCachePartitionedFieldsQueryP2PEnabledTypeMetaSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCachePartitionedFieldsQueryP2PEnabledTypeMetaSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCachePartitionedFieldsQueryP2PEnabledTypeMetaSelfTest.java new file mode 100644 index 0000000..7ed8f9b --- /dev/null +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCachePartitionedFieldsQueryP2PEnabledTypeMetaSelfTest.java @@ -0,0 +1,34 @@ +/* + * 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.processors.cache.distributed.near; + +import org.apache.ignite.configuration.*; + +/** + * Tests for fields queries. + */ +public class IgniteCachePartitionedFieldsQueryP2PEnabledTypeMetaSelfTest extends IgniteCachePartitionedFieldsQueryTypeMetaSelfTest { + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { + IgniteConfiguration c = super.getConfiguration(gridName); + + c.setPeerClassLoadingEnabled(true); + + return c; + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e7f3f96d/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCachePartitionedFieldsQueryTypeMetaSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCachePartitionedFieldsQueryTypeMetaSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCachePartitionedFieldsQueryTypeMetaSelfTest.java new file mode 100644 index 0000000..468ed4c --- /dev/null +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCachePartitionedFieldsQueryTypeMetaSelfTest.java @@ -0,0 +1,56 @@ +/* + * 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.processors.cache.distributed.near; + +import org.apache.ignite.cache.*; +import org.apache.ignite.configuration.*; +import org.apache.ignite.internal.processors.cache.*; +import org.jetbrains.annotations.*; + +import static org.apache.ignite.cache.CacheMode.*; + +/** + * Tests for fields queries. + */ +public class IgniteCachePartitionedFieldsQueryTypeMetaSelfTest extends IgniteCacheAbstractFieldsQueryTypeMetaSelfTest { + /** {@inheritDoc} */ + @Override protected CacheMode cacheMode() { + return PARTITIONED; + } + + /** + * @return Distribution. + */ + protected NearCacheConfiguration nearConfiguration() { + return new NearCacheConfiguration(); + } + + /** {@inheritDoc} */ + @Override protected int gridCount() { + return 3; + } + + /** {@inheritDoc} */ + @Override protected CacheConfiguration cache(@Nullable String name, boolean primitives) { + CacheConfiguration cc = super.cache(name, primitives); + + cc.setNearConfiguration(nearConfiguration()); + + return cc; + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e7f3f96d/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedFieldsQueryP2PEnabledTypeMetaSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedFieldsQueryP2PEnabledTypeMetaSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedFieldsQueryP2PEnabledTypeMetaSelfTest.java new file mode 100644 index 0000000..7204589 --- /dev/null +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedFieldsQueryP2PEnabledTypeMetaSelfTest.java @@ -0,0 +1,34 @@ +/* + * 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.processors.cache.distributed.replicated; + +import org.apache.ignite.configuration.*; + +/** + * Tests for fields queries. + */ +public class IgniteCacheReplicatedFieldsQueryP2PEnabledTypeMetaSelfTest extends IgniteCacheReplicatedFieldsQueryTypeMetaSelfTest { + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { + IgniteConfiguration c = super.getConfiguration(gridName); + + c.setPeerClassLoadingEnabled(true); + + return c; + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e7f3f96d/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedFieldsQueryTypeMetaSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedFieldsQueryTypeMetaSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedFieldsQueryTypeMetaSelfTest.java new file mode 100644 index 0000000..cb4aa90 --- /dev/null +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedFieldsQueryTypeMetaSelfTest.java @@ -0,0 +1,79 @@ +/* + * 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.processors.cache.distributed.replicated; + +import org.apache.ignite.*; +import org.apache.ignite.cache.*; +import org.apache.ignite.cache.query.*; +import org.apache.ignite.internal.processors.cache.*; +import org.apache.ignite.internal.processors.cache.query.*; +import org.apache.ignite.testframework.*; + +import java.util.*; +import java.util.concurrent.*; + +import static org.apache.ignite.cache.CacheMode.*; + +/** + * Tests for fields queries. + */ +public class IgniteCacheReplicatedFieldsQueryTypeMetaSelfTest extends IgniteCacheAbstractFieldsQueryTypeMetaSelfTest { + /** {@inheritDoc} */ + @Override protected CacheMode cacheMode() { + return REPLICATED; + } + + /** {@inheritDoc} */ + @Override protected int gridCount() { + return 3; + } + + /** + * @throws Exception If failed. + */ + public void testLostIterator() throws Exception { + IgniteCache<Object, Object> cache = grid(0).cache(null); + + QueryCursor<List<?>> qry = null; + + int maximumQueryIteratorCount = GridCacheQueryManager.MAX_ITERATORS; + + for (int i = 0; i < maximumQueryIteratorCount + 1; i++) { + QueryCursor<List<?>> q = cache + .query(new SqlFieldsQuery("select _key from Integer where _key >= 0 order by _key")); + + assertEquals(0, q.iterator().next().get(0)); + + if (qry == null) + qry = q; + } + + final QueryCursor<List<?>> qry0 = qry; + + GridTestUtils.assertThrows(log, new Callable<Object>() { + @Override public Object call() throws Exception { + int i = 0; + + for (List<?> row : qry0) + assertEquals(++i % 50, row.get(0)); + + return null; + } + }, IgniteException.class, null); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e7f3f96d/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/local/IgniteCacheLocalFieldsQueryTypeMetaSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/local/IgniteCacheLocalFieldsQueryTypeMetaSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/local/IgniteCacheLocalFieldsQueryTypeMetaSelfTest.java new file mode 100644 index 0000000..3106c82 --- /dev/null +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/local/IgniteCacheLocalFieldsQueryTypeMetaSelfTest.java @@ -0,0 +1,38 @@ +/* + * 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.processors.cache.local; + +import org.apache.ignite.cache.*; +import org.apache.ignite.internal.processors.cache.*; + +import static org.apache.ignite.cache.CacheMode.*; + +/** + * Tests for fields queries. + */ +public class IgniteCacheLocalFieldsQueryTypeMetaSelfTest extends IgniteCacheAbstractFieldsQueryTypeMetaSelfTest { + /** {@inheritDoc} */ + @Override protected CacheMode cacheMode() { + return LOCAL; + } + + /** {@inheritDoc} */ + @Override protected int gridCount() { + return 1; + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e7f3f96d/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/local/IgniteCacheLocalFieldsQueryTypeMetadataSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/local/IgniteCacheLocalFieldsQueryTypeMetadataSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/local/IgniteCacheLocalFieldsQueryTypeMetadataSelfTest.java deleted file mode 100644 index 2a47343..0000000 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/local/IgniteCacheLocalFieldsQueryTypeMetadataSelfTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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.processors.cache.local; - -import org.apache.ignite.cache.*; -import org.apache.ignite.internal.processors.cache.*; - -import static org.apache.ignite.cache.CacheMode.*; - -/** - * Tests for fields queries. - */ -public class IgniteCacheLocalFieldsQueryTypeMetadataSelfTest extends IgniteCacheAbstractFieldsQueryTypeMetaSelfTest { - /** {@inheritDoc} */ - @Override protected CacheMode cacheMode() { - return LOCAL; - } - - /** {@inheritDoc} */ - @Override protected int gridCount() { - return 1; - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e7f3f96d/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 ce05980..467ab90 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 @@ -70,7 +70,7 @@ public class IgniteCacheQuerySelfTestSuite extends TestSuite { suite.addTestSuite(GridCacheQuerySerializationSelfTest.class); - // Fields queries. + // Fields queries with indexed types. suite.addTestSuite(IgniteCacheLocalFieldsQuerySelfTest.class); suite.addTestSuite(IgniteCacheReplicatedFieldsQuerySelfTest.class); suite.addTestSuite(IgniteCacheReplicatedFieldsQueryP2PEnabledSelfTest.class); @@ -80,6 +80,16 @@ public class IgniteCacheQuerySelfTestSuite extends TestSuite { suite.addTestSuite(IgniteCachePartitionedFieldsQueryP2PEnabledSelfTest.class); suite.addTestSuite(IgniteCacheFieldsQueryNoDataSelfTest.class); + // Fields queries with cache type metadata. + suite.addTestSuite(IgniteCacheLocalFieldsQueryTypeMetaSelfTest.class); + suite.addTestSuite(IgniteCacheReplicatedFieldsQueryTypeMetaSelfTest.class); + suite.addTestSuite(IgniteCacheReplicatedFieldsQueryP2PEnabledTypeMetaSelfTest.class); + suite.addTestSuite(IgniteCachePartitionedFieldsQueryTypeMetaSelfTest.class); + suite.addTestSuite(IgniteCacheAtomicFieldsQueryTypeMetaSelfTest.class); + suite.addTestSuite(IgniteCacheAtomicNearEnabledFieldsQueryTypeMetaSelfTest.class); + suite.addTestSuite(IgniteCachePartitionedFieldsQueryP2PEnabledTypeMetaSelfTest.class); + suite.addTestSuite(IgniteCacheFieldsQueryNoDataSelfTest.class); + // Continuous queries. suite.addTestSuite(GridCacheContinuousQueryLocalSelfTest.class); suite.addTestSuite(GridCacheContinuousQueryLocalAtomicSelfTest.class);