You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2016/08/24 14:04:31 UTC

[08/50] [abbrv] ignite git commit: ignite-3254 - fixed

ignite-3254 - fixed


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

Branch: refs/heads/ignite-2649
Commit: 4d2be722935da42c82310ce70db996c5752f72f6
Parents: 10224df
Author: Sergi Vladykin <se...@gmail.com>
Authored: Wed Jul 13 20:19:25 2016 +0300
Committer: Sergi Vladykin <se...@gmail.com>
Committed: Wed Jul 13 20:19:25 2016 +0300

----------------------------------------------------------------------
 .../examples/IndexingBridgeMethodTest.java      | 93 ++++++++++++++++++++
 .../IgniteExamplesJ8SelfTestSuite.java          |  2 +
 .../configuration/CacheConfiguration.java       |  3 +
 3 files changed, 98 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/4d2be722/examples/src/test/java8/org/apache/ignite/java8/examples/IndexingBridgeMethodTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/examples/IndexingBridgeMethodTest.java b/examples/src/test/java8/org/apache/ignite/java8/examples/IndexingBridgeMethodTest.java
new file mode 100644
index 0000000..2837ed6
--- /dev/null
+++ b/examples/src/test/java8/org/apache/ignite/java8/examples/IndexingBridgeMethodTest.java
@@ -0,0 +1,93 @@
+/*
+ * 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.java8.examples;
+
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.cache.query.annotations.QuerySqlField;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ * Test covering bridge methods changes in Java 8.
+ */
+public class IndexingBridgeMethodTest extends GridCommonAbstractTest {
+    /**
+     * @throws Exception If failed.
+     */
+    public void testBridgeMethod() throws Exception {
+        Ignite ignite = startGrid();
+
+        CacheConfiguration<Integer, MyType> ccfg = new CacheConfiguration<>();
+
+        ccfg.setName("mytype");
+        ccfg.setIndexedTypes(Integer.class, MyType.class);
+
+        IgniteCache<Integer,MyType> c = ignite.getOrCreateCache(ccfg);
+
+        for (int i = 0; i < 100; i++)
+            c.put(i, new MyType(i));
+
+        assertEquals(100L, c.query(new SqlFieldsQuery(
+            "select count(*) from MyType")).getAll().get(0).get(0));
+        assertEquals(15, c.query(new SqlFieldsQuery(
+            "select id from MyType where _key = 15")).getAll().get(0).get(0));
+        assertEquals(25, c.query(new SqlFieldsQuery(
+            "select _key from MyType where id = 25")).getAll().get(0).get(0));
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        stopAllGrids();
+    }
+
+    /**
+     * Classes implementing this method, will have bridge method.
+     */
+    private static interface HasId<T extends Number> {
+        /**
+         * @return ID.
+         */
+        public T getId();
+    }
+
+    /**
+     *
+     */
+    private static class MyType implements HasId<Integer> {
+        /** */
+        private int id;
+
+        /**
+         * @param id Id.
+         */
+        private MyType(int id) {
+            this.id = id;
+        }
+
+        /**
+         * @return ID.
+         */
+        @QuerySqlField(index = true)
+        @Override public Integer getId() {
+            return id;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/4d2be722/examples/src/test/java8/org/apache/ignite/java8/testsuites/IgniteExamplesJ8SelfTestSuite.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/testsuites/IgniteExamplesJ8SelfTestSuite.java b/examples/src/test/java8/org/apache/ignite/java8/testsuites/IgniteExamplesJ8SelfTestSuite.java
index 57e48f9..949324c 100644
--- a/examples/src/test/java8/org/apache/ignite/java8/testsuites/IgniteExamplesJ8SelfTestSuite.java
+++ b/examples/src/test/java8/org/apache/ignite/java8/testsuites/IgniteExamplesJ8SelfTestSuite.java
@@ -24,6 +24,7 @@ import org.apache.ignite.java8.examples.CacheExamplesMultiNodeSelfTest;
 import org.apache.ignite.java8.examples.CacheExamplesSelfTest;
 import org.apache.ignite.java8.examples.EventsExamplesMultiNodeSelfTest;
 import org.apache.ignite.java8.examples.EventsExamplesSelfTest;
+import org.apache.ignite.java8.examples.IndexingBridgeMethodTest;
 import org.apache.ignite.java8.examples.MessagingExamplesSelfTest;
 import org.apache.ignite.testframework.GridTestUtils;
 
@@ -45,6 +46,7 @@ public class IgniteExamplesJ8SelfTestSuite extends TestSuite {
 
         TestSuite suite = new TestSuite("Ignite Examples Test Suite");
 
+        suite.addTest(new TestSuite(IndexingBridgeMethodTest.class));
         suite.addTest(new TestSuite(CacheExamplesSelfTest.class));
         suite.addTest(new TestSuite(BasicExamplesSelfTest.class));
 //        suite.addTest(new TestSuite(ContinuationExamplesSelfTest.class));

http://git-wip-us.apache.org/repos/asf/ignite/blob/4d2be722/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
index 07542de..3276627 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
@@ -2292,6 +2292,9 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
             }
 
             for (Method mtd : c.getDeclaredMethods()) {
+                if (mtd.isBridge())
+                    continue;
+
                 QuerySqlField sqlAnn = mtd.getAnnotation(QuerySqlField.class);
                 QueryTextField txtAnn = mtd.getAnnotation(QueryTextField.class);