ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [17/19] ignite git commit: Tests fixed.
Date Wed, 24 Aug 2016 08:49:09 GMT
Tests fixed.


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

Branch: refs/heads/ignite-3716
Commit: fc578f6dcdf10cf1977f482a932dde2e1dbadc57
Parents: 557ff86
Author: Andrey V. Mashenkov <andrey.mashenkov@gmail.com>
Authored: Tue Aug 23 17:15:27 2016 +0300
Committer: Andrey V. Mashenkov <andrey.mashenkov@gmail.com>
Committed: Tue Aug 23 17:15:27 2016 +0300

----------------------------------------------------------------------
 .../OdbcScalarFunctionEscapeSequenceTest.java   | 181 ++++++-------------
 1 file changed, 58 insertions(+), 123 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/fc578f6d/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
index 7d31fbb..edf8e0b 100644
--- 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
@@ -23,160 +23,93 @@ 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 {
 
-    /** */
-    public void testTrivial() throws Exception {
-        String sqlQry= "select * from table;";
-        String expRes = "select * from table;";
-
-        String actualRes = OdbcEscapeUtils.parse(sqlQry);
+    /**
+     * @param exp - expected result
+     * @param qry - sql query text
+     */
+    private void check(String exp, String qry) {
+        String actualRes = OdbcEscapeUtils.parse(qry);
 
-        assertEquals("Scalar function escape sequence parsing fails", expRes, actualRes);
+        assertEquals(exp, actualRes);
     }
 
-    /** */
-    public void testTrivial2() throws Exception {
-        String sqlQry = "select {fn test()} from table;";
-        String expRes = "select test() from table;";
-
-        String actualRes = OdbcEscapeUtils.parse(sqlQry);
-
-        assertEquals("Scalar function escape sequence parsing fails", expRes, actualRes);
-    }
-
-    /** */
-    public void testTrivial3() throws Exception {
-        String sqlQry = "select {fn test()}";
-        String expRes = "select test()";
-
-        String actualRes = OdbcEscapeUtils.parse(sqlQry);
-
-        assertEquals("Scalar function escape sequence parsing fails", expRes, actualRes);
-    }
+    /**
+     * Trivial tests.
+     */
+    public void testTrivial() throws Exception {
+        check("select * from table;", "select * from table;");
 
-    /** */
-    public void testTrivial4() throws Exception {
-        String sqlQry = "{fn test()}";
-        String expRes = "test()";
+        check("test()", "{fn test()}");
 
-        String actualRes = OdbcEscapeUtils.parse(sqlQry);
+        check("select test()", "select {fn test()}");
 
-        assertEquals("Scalar function escape sequence parsing fails", expRes, actualRes);
+        check("select test() from table;", "select {fn test()} from table;");
     }
 
-    /** */
+    /**
+     * Test escape sequence series.
+     */
     public void testSimpleFunction() throws Exception {
-        String sqlQry = "select {fn func(field1)}, {fn func(field2)} from table;";
-        String expRes = "select func(field1), func(field2) from table;";
-
-        String actualRes = OdbcEscapeUtils.parse(sqlQry);
-
-        assertEquals("Scalar function escape sequence parsing fails", expRes, actualRes);
-    }
-    /** */
-    public void testSimpleFunction2() throws Exception {
-        String sqlQry = "select {fn func(field1)}, {fn func(field2)}";
-        String expRes = "select func(field1), func(field2)";
-
-        String actualRes = OdbcEscapeUtils.parse(sqlQry);
-
-        assertEquals("Scalar function escape sequence parsing fails", expRes, actualRes);
-    }
-
-    /** */
-    public void testSimpleFunction3() throws Exception {
-        String sqlQry = "{fn func(field1)} {fn func(field2)}";
-        String expRes = "func(field1) func(field2)";
+        check("func(field1) func(field2)", "{fn func(field1)} {fn func(field2)}");
 
-        String actualRes = OdbcEscapeUtils.parse(sqlQry);
+        check("select func(field1), func(field2)", "select {fn func(field1)}, {fn func(field2)}");
 
-        assertEquals("Scalar function escape sequence parsing fails", expRes, actualRes);
+        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 {
-        String sqlQry = "select {fn func1(field1, {fn func2(field2)}, field3)} from SomeTable;";
-        String expRes = "select func1(field1, func2(field2), field3) from SomeTable;";
+        check("func1(field1, func2(field2))", "{fn func1(field1, {fn func2(field2)})}");
 
-        String actualRes = OdbcEscapeUtils.parse(sqlQry);
+        check("select func1(field1, func2(field2))", "select {fn func1(field1, {fn func2(field2)})}");
 
-        assertEquals("Scalar function escape sequence parsing fails", expRes, actualRes);
+        check("select func1(field1, func2(field2), field3) from SomeTable;",
+            "select {fn func1(field1, {fn func2(field2)}, field3)} from SomeTable;");
     }
 
-    /** */
-    public void testNestedFunction2() throws Exception {
-        String sqlQry = "select {fn func1(field1, {fn func2(field2)}, field3)}";
-        String expRes = "select func1(field1, func2(field2), field3)";
-
-        String actualRes = OdbcEscapeUtils.parse(sqlQry);
-
-        assertEquals("Scalar function escape sequence parsing fails", expRes, actualRes);
-    }
-
-    /** */
+    /**
+     * Test nested escape sequences. Depth > 2
+     */
     public void testDeepNestedFunction() throws Exception {
-        String sqlQry = "select {fn func1(field1, {fn func2({fn func3(field2)}, field3)})}
from SomeTable;";
-        String expRes = "select func1(field1, func2(func3(field2), field3)) from SomeTable;";
-
-        String actualRes = OdbcEscapeUtils.parse(sqlQry);
-
-        assertEquals("Scalar function escape sequence parsing fails", expRes, actualRes);
-    }
-
-    /** */
-    public void testDeepNestedFunction2() throws Exception {
-        String sqlQry = "select {fn func1(field1, {fn func2({fn func3(field2)}, field3)})}";
-        String expRes = "select func1(field1, func2(func3(field2), field3))";
-
-        String actualRes = OdbcEscapeUtils.parse(sqlQry);
+        check("func1(func2(func3(field1)))",
+            "{fn func1({fn func2({fn func3(field1)})})}");
 
-        assertEquals("Scalar function escape sequence parsing fails", expRes, actualRes);
-    }
-
-    /** */
-    public void testDeepNestedFunction3() throws Exception {
-        String sqlQry = "{fn func1({fn func2({fn func3(field1)})})}";
-        String expRes = "func1(func2(func3(field1)))";
+        check("func1(func2(func3(func4(field1))))",
+            "{fn func1({fn func2({fn func3({fn func4(field1)})})})}");
 
-        String actualRes = OdbcEscapeUtils.parse(sqlQry);
+        check("select func1(field1, func2(func3(field2), field3))",
+            "select {fn func1(field1, {fn func2({fn func3(field2)}, field3)})}");
 
-        assertEquals("Scalar function escape sequence parsing fails", expRes, actualRes);
+        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 {
-        String sqlQry = "select {fn func1({fn func2(field1)}, {fn func3(field2)})} from table;";
-        String expRes = "select func1(func2(field1), func3(field2)) from table;";
+        check("func1(func2(field1), func3(field2))", "{fn func1({fn func2(field1)}, {fn func3(field2)})}");
 
-        String actualRes = OdbcEscapeUtils.parse(sqlQry);
+        check("select func1(func2(field1), func3(field2)) from table;",
+            "select {fn func1({fn func2(field1)}, {fn func3(field2)})} from table;");
 
-        assertEquals("Scalar function escape sequence parsing fails", expRes, actualRes);
+        check("func1(func2(func3(field1))) func1(func2(field2))",
+            "{fn func1({fn func2({fn func3(field1)})})} {fn func1({fn func2(field2)})}");
     }
 
-    /** */
-    public void testNestedFunctionMixed1() throws Exception {
-        String sqlQry = "{fn func1({fn func2(field1)}, {fn func3(field2)})}";
-        String expRes = "func1(func2(field1), func3(field2))";
-
-        String actualRes = OdbcEscapeUtils.parse(sqlQry);
-
-        assertEquals("Scalar function escape sequence parsing fails", expRes, actualRes);
-    }
-
-    /** */
-    public void testNestedFunctionMixed2() throws Exception {
-        String sqlQry = "{fn func1({fn func2({fn func3(field1)})})} {fn func1({fn func2(field2)})}";
-        String expRes = "func1(func2(func3(field1))) func1(func2(field2))";
-
-        String actualRes = OdbcEscapeUtils.parse(sqlQry);
-
-        assertEquals("Scalar function escape sequence parsing fails", expRes, actualRes);
-    }
 
-    /** */
-    public void testFailedOnNotClosedSequence() throws Exception {
+    /**
+     * 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;";
@@ -190,7 +123,9 @@ public class OdbcScalarFunctionEscapeSequenceTest extends TestCase {
         }, 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 {


Mime
View raw message