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 08:49:10 UTC

[18/19] ignite git commit: Cosmetics.

Cosmetics.


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

Branch: refs/heads/ignite-3716
Commit: 2023557a187b165bd3444fff5066dd82024cb0d0
Parents: fc578f6
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Aug 24 11:27:29 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Aug 24 11:27:29 2016 +0300

----------------------------------------------------------------------
 .../odbc/OdbcEscapeSequenceSelfTest.java        | 184 +++++++++++++++++++
 .../OdbcScalarFunctionEscapeSequenceTest.java   | 142 --------------
 .../ignite/testsuites/IgniteBasicTestSuite.java |   4 +-
 3 files changed, 186 insertions(+), 144 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/2023557a/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcEscapeSequenceSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcEscapeSequenceSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcEscapeSequenceSelfTest.java
new file mode 100644
index 0000000..73fa0f4
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcEscapeSequenceSelfTest.java
@@ -0,0 +1,184 @@
+/*
+ * 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.odbc;
+
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.internal.processors.odbc.escape.OdbcEscapeUtils;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import java.util.concurrent.Callable;
+
+/**
+ * Scalar function escape sequence parser tests.
+ */
+public class OdbcEscapeSequenceSelfTest extends GridCommonAbstractTest {
+    /**
+     * Test simple cases.
+     */
+    public void testSimple() {
+        check(
+            "select * from table;",
+            "select * from table;"
+        );
+
+        check(
+            "test()",
+            "{fn test()}"
+        );
+
+        check(
+            "select test()",
+            "select {fn test()}"
+        );
+
+        check(
+            "select test() from table;",
+            "select {fn test()} from table;"
+        );
+    }
+
+    /**
+     * Test escape sequence series.
+     */
+    public void testSimpleFunction() throws Exception {
+        check(
+            "func(field1) func(field2)",
+            "{fn func(field1)} {fn func(field2)}"
+        );
+
+        check(
+            "select func(field1), func(field2)",
+            "select {fn func(field1)}, {fn func(field2)}"
+        );
+
+        check(
+            "select func(field1), func(field2) from table;",
+            "select {fn func(field1)}, {fn func(field2)} from table;"
+        );
+    }
+
+    /**
+     * Test simple nested escape sequences. Depth = 2.
+     */
+    public void testNestedFunction() throws Exception {
+        check(
+            "func1(field1, func2(field2))",
+            "{fn func1(field1, {fn func2(field2)})}"
+        );
+
+        check(
+            "select func1(field1, func2(field2))",
+            "select {fn func1(field1, {fn func2(field2)})}"
+        );
+
+        check(
+            "select func1(field1, func2(field2), field3) from SomeTable;",
+            "select {fn func1(field1, {fn func2(field2)}, field3)} from SomeTable;"
+        );
+    }
+
+    /**
+     * Test nested escape sequences. Depth > 2.
+     */
+    public void testDeepNestedFunction() {
+        check(
+            "func1(func2(func3(field1)))",
+            "{fn func1({fn func2({fn func3(field1)})})}"
+        );
+
+        check(
+            "func1(func2(func3(func4(field1))))",
+            "{fn func1({fn func2({fn func3({fn func4(field1)})})})}"
+        );
+
+        check(
+            "select func1(field1, func2(func3(field2), field3))",
+            "select {fn func1(field1, {fn func2({fn func3(field2)}, field3)})}"
+        );
+
+        check(
+            "select func1(field1, func2(func3(field2), field3)) from SomeTable;",
+            "select {fn func1(field1, {fn func2({fn func3(field2)}, field3)})} from SomeTable;"
+        );
+    }
+
+    /**
+     * Test series of nested escape sequences.
+     */
+    public void testNestedFunctionMixed() {
+        check(
+            "func1(func2(field1), func3(field2))",
+            "{fn func1({fn func2(field1)}, {fn func3(field2)})}"
+        );
+
+        check(
+            "select func1(func2(field1), func3(field2)) from table;",
+            "select {fn func1({fn func2(field1)}, {fn func3(field2)})} from table;"
+        );
+
+        check(
+            "func1(func2(func3(field1))) func1(func2(field2))",
+            "{fn func1({fn func2({fn func3(field1)})})} {fn func1({fn func2(field2)})}"
+        );
+    }
+
+    /**
+     * Test non-closed escape sequence.
+     */
+    public void testFailedOnInvalidSequence1() {
+        checkFail("select {fn func1(field1, {fn func2(field2), field3)} from SomeTable;");
+    }
+
+    /**
+     * Test closing undeclared escape sequence.
+     */
+    public void testFailedOnClosingNotOpenedSequence() {
+        checkFail("select {fn func1(field1, func2(field2)}, field3)} from SomeTable;");
+    }
+
+    /**
+     * Check parsing logic.
+     *
+     * @param exp Expected result.
+     * @param qry SQL query text.
+     */
+    private void check(String exp, String qry) {
+        String actualRes = OdbcEscapeUtils.parse(qry);
+
+        assertEquals(exp, actualRes);
+    }
+
+    /**
+     * Check that query parsing fails.
+     *
+     * @param qry Query.
+     */
+    @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
+    private void checkFail(final String qry) {
+        GridTestUtils.assertThrows(null, new Callable<Void>() {
+            @Override public Void call() throws Exception {
+                OdbcEscapeUtils.parse(qry);
+
+                fail("Parsing should fail: " + qry);
+
+                return null;
+            }
+        }, IgniteException.class, null);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/2023557a/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcScalarFunctionEscapeSequenceTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcScalarFunctionEscapeSequenceTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcScalarFunctionEscapeSequenceTest.java
deleted file mode 100644
index edf8e0b..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcScalarFunctionEscapeSequenceTest.java
+++ /dev/null
@@ -1,142 +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.odbc;
-
-import java.util.concurrent.Callable;
-import junit.framework.TestCase;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.internal.processors.odbc.escape.OdbcEscapeUtils;
-import org.apache.ignite.testframework.GridTestUtils;
-
-/**
- * Scalar function escape sequence parser tests.
- */
-public class OdbcScalarFunctionEscapeSequenceTest extends TestCase {
-
-    /**
-     * @param exp - expected result
-     * @param qry - sql query text
-     */
-    private void check(String exp, String qry) {
-        String actualRes = OdbcEscapeUtils.parse(qry);
-
-        assertEquals(exp, actualRes);
-    }
-
-    /**
-     * Trivial tests.
-     */
-    public void testTrivial() throws Exception {
-        check("select * from table;", "select * from table;");
-
-        check("test()", "{fn test()}");
-
-        check("select test()", "select {fn test()}");
-
-        check("select test() from table;", "select {fn test()} from table;");
-    }
-
-    /**
-     * Test escape sequence series.
-     */
-    public void testSimpleFunction() throws Exception {
-        check("func(field1) func(field2)", "{fn func(field1)} {fn func(field2)}");
-
-        check("select func(field1), func(field2)", "select {fn func(field1)}, {fn func(field2)}");
-
-        check("select func(field1), func(field2) from table;",
-            "select {fn func(field1)}, {fn func(field2)} from table;");
-    }
-
-    /**
-     * Test simple nested escape sequences. Depth = 2
-     */
-    public void testNestedFunction() throws Exception {
-        check("func1(field1, func2(field2))", "{fn func1(field1, {fn func2(field2)})}");
-
-        check("select func1(field1, func2(field2))", "select {fn func1(field1, {fn func2(field2)})}");
-
-        check("select func1(field1, func2(field2), field3) from SomeTable;",
-            "select {fn func1(field1, {fn func2(field2)}, field3)} from SomeTable;");
-    }
-
-    /**
-     * Test nested escape sequences. Depth > 2
-     */
-    public void testDeepNestedFunction() throws Exception {
-        check("func1(func2(func3(field1)))",
-            "{fn func1({fn func2({fn func3(field1)})})}");
-
-        check("func1(func2(func3(func4(field1))))",
-            "{fn func1({fn func2({fn func3({fn func4(field1)})})})}");
-
-        check("select func1(field1, func2(func3(field2), field3))",
-            "select {fn func1(field1, {fn func2({fn func3(field2)}, field3)})}");
-
-        check("select func1(field1, func2(func3(field2), field3)) from SomeTable;",
-            "select {fn func1(field1, {fn func2({fn func3(field2)}, field3)})} from SomeTable;");
-    }
-
-    /**
-     * Test series of nested escape sequences
-     */
-    public void testNestedFunctionMixed() throws Exception {
-        check("func1(func2(field1), func3(field2))", "{fn func1({fn func2(field1)}, {fn func3(field2)})}");
-
-        check("select func1(func2(field1), func3(field2)) from table;",
-            "select {fn func1({fn func2(field1)}, {fn func3(field2)})} from table;");
-
-        check("func1(func2(func3(field1))) func1(func2(field2))",
-            "{fn func1({fn func2({fn func3(field1)})})} {fn func1({fn func2(field2)})}");
-    }
-
-
-    /**
-     * Test non-closed escape sequence.
-     */
-    public void testFailedOnInvalidSequence1() throws Exception {
-        GridTestUtils.assertThrows(null, new Callable<Void>() {
-            @Override public Void call() throws Exception {
-                String sqlQry = "select {fn func1(field1, {fn func2(field2), field3)} from SomeTable;";
-
-                OdbcEscapeUtils.parse(sqlQry);
-
-                fail("Scalar function escape sequence parsing should failed");
-
-                return null;
-            }
-        }, IgniteException.class, null);
-    }
-
-    /**
-     * Test closing undeclared escape sequence.
-     */
-    public void testFailedOnClosingNotOpenedSequence() throws Exception {
-        GridTestUtils.assertThrows(null, new Callable<Void>() {
-            @Override public Void call() throws Exception {
-                String sqlQry = "select {fn func1(field1, func2(field2)}, field3)} from SomeTable;";
-
-                OdbcEscapeUtils.parse(sqlQry);
-
-                fail("Scalar function escape sequence parsing should failed");
-
-                return null;
-            }
-        }, IgniteException.class, null);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/2023557a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
index 24cb8a7..982bc40 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
@@ -43,7 +43,7 @@ import org.apache.ignite.internal.processors.closure.GridClosureProcessorSelfTes
 import org.apache.ignite.internal.processors.continuous.GridEventConsumeSelfTest;
 import org.apache.ignite.internal.processors.continuous.GridMessageListenSelfTest;
 import org.apache.ignite.internal.processors.odbc.OdbcProcessorValidationSelfTest;
-import org.apache.ignite.internal.processors.odbc.OdbcScalarFunctionEscapeSequenceTest;
+import org.apache.ignite.internal.processors.odbc.OdbcEscapeSequenceSelfTest;
 import org.apache.ignite.internal.processors.service.ClosureServiceClientsNodesTest;
 import org.apache.ignite.internal.product.GridProductVersionSelfTest;
 import org.apache.ignite.internal.util.nio.IgniteExceptionInNioWorkerSelfTest;
@@ -129,7 +129,7 @@ public class IgniteBasicTestSuite extends TestSuite {
         suite.addTestSuite(IgniteExceptionInNioWorkerSelfTest.class);
         suite.addTestSuite(IgniteLocalNodeMapBeforeStartTest.class);
         suite.addTestSuite(OdbcProcessorValidationSelfTest.class);
-        suite.addTestSuite(OdbcScalarFunctionEscapeSequenceTest.class);
+        suite.addTestSuite(OdbcEscapeSequenceSelfTest.class);
 
         GridTestUtils.addTestIfNeeded(suite, DynamicProxySerializationMultiJvmSelfTest.class, ignoredTests);