db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krist...@apache.org
Subject svn commit: r676515 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests: master/miscerrors.out tests/lang/LangScripts.java tests/lang/MiscErrorsTest.java tests/lang/_Suite.java tests/lang/miscerrors.sql
Date Mon, 14 Jul 2008 08:59:02 GMT
Author: kristwaa
Date: Mon Jul 14 01:59:01 2008
New Revision: 676515

URL: http://svn.apache.org/viewvc?rev=676515&view=rev
Log:
DERBY-3760: Convert "org.apache.derbyTesting.functionTests.tests.lang.miscerrors.sql" to junit.
Patch file: derby-3760-3a.diff

Patch contributed by Junjie Peng.

Added:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/MiscErrorsTest.java
  (with props)
Removed:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/miscerrors.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/miscerrors.sql
Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LangScripts.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LangScripts.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LangScripts.java?rev=676515&r1=676514&r2=676515&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LangScripts.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LangScripts.java
Mon Jul 14 01:59:01 2008
@@ -81,7 +81,6 @@
         "intersect",
         "joins",
         "logop",
-        "miscerrors",
         "modifyColumn",
         "nonreserved",
         "orderby",

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/MiscErrorsTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/MiscErrorsTest.java?rev=676515&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/MiscErrorsTest.java
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/MiscErrorsTest.java
Mon Jul 14 01:59:01 2008
@@ -0,0 +1,113 @@
+/*
+
+Derby - Class org.apache.derbyTesting.functionTests.tests.lang.MiscErrorsTest
+
+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.derbyTesting.functionTests.tests.lang;
+
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import junit.framework.Test;
+
+import org.apache.derbyTesting.junit.BaseJDBCTestCase;
+import org.apache.derbyTesting.junit.JDBC;
+import org.apache.derbyTesting.junit.TestConfiguration;
+
+/**
+ * Tests miscellaneous error situations.
+ */
+public class MiscErrorsTest extends BaseJDBCTestCase {
+
+    public MiscErrorsTest(String name) {
+        super(name);
+    }
+
+    public static Test suite() {
+        return TestConfiguration.defaultSuite(MiscErrorsTest.class);
+    }
+
+    public void testLexicalError() {
+        String sql = "select @#^%*&! from swearwords";
+        assertCompileError("42X02", sql);
+    }
+
+    /**
+     * Try to create duplicate table.
+     */
+    public void testDuplicateTableCreation() throws SQLException {
+        String sql = "create table a (one int)";
+        Statement st = createStatement();
+        st.executeUpdate(sql);
+
+        sql = "create table a (one int, two int)";
+        assertStatementError("X0Y32", st, sql);
+
+        sql = "create table a (one int)";
+        assertStatementError("X0Y32", st, sql);
+
+        dropTable("a");
+
+        sql = "create table a (one int, two int, three int)";
+        st.executeUpdate(sql);
+
+        sql = "insert into a values (1,2,3)";
+        assertEquals(1, st.executeUpdate(sql));
+
+        sql = "select * from a";
+        JDBC.assertUnorderedResultSet(st.executeQuery(sql),
+                new String[][] { { "1", "2", "3", } });
+
+        dropTable("a");
+    }
+
+    /**
+     * See that statements that fail at parse or bind time
+     * are not put in the statement cache.
+     */
+    public void testStatementCache() throws SQLException {
+        String sql = "values 1";
+        Statement st = createStatement();
+        JDBC.assertSingleValueResultSet(st.executeQuery(sql), "1");
+
+        //a stronger test.
+        sql = "select SQL_TEXT from syscs_diag.statement_cache"
+            + " where CAST(SQL_TEXT AS LONG VARCHAR)" + " LIKE '%values 1%'";
+        JDBC.assertUnorderedResultSet(st.executeQuery(sql),
+                new String[][] {
+                    { sql }, { "values 1" }, }
+        );
+
+        sql = "select SQL_TEXT from syscs_diag.statement_cache"
+                + " where CAST(SQL_TEXT AS LONG VARCHAR)" + " LIKE '%932432%'";
+        JDBC.assertSingleValueResultSet(st.executeQuery(sql), sql);
+
+        sql = "VALUES FRED932432";
+        assertCompileError("42X04", sql);
+
+        sql = "SELECT * FROM BILL932432";
+        assertCompileError("42X05", sql);
+
+        sql = "SELECT 932432";
+        assertCompileError("42X01", sql);
+
+        sql = "select SQL_TEXT from syscs_diag.statement_cache"
+                + " where CAST(SQL_TEXT AS LONG VARCHAR)" + " LIKE '%932432%'";
+        JDBC.assertSingleValueResultSet(st.executeQuery(sql), sql);
+    }
+}

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/MiscErrorsTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java?rev=676515&r1=676514&r2=676515&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java
Mon Jul 14 01:59:01 2008
@@ -168,6 +168,7 @@
         
         suite.addTest(BigDataTest.suite());
         suite.addTest(MixedCaseExpressionTest.suite());
+        suite.addTest(MiscErrorsTest.suite());
 
         return suite;
 	}



Mime
View raw message