db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r587553 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests: master/DerbyNet/synonym.out master/DerbyNetClient/synonym.out master/synonym.out tests/lang/SynonymTest.java tests/lang/_Suite.java tests/lang/synonym.sql
Date Tue, 23 Oct 2007 16:51:52 GMT
Author: mamta
Date: Tue Oct 23 09:51:48 2007
New Revision: 587553

URL: http://svn.apache.org/viewvc?rev=587553&view=rev
Log:
DERBY-3054 

The non-junit test, synonym.sql, tests the synonym dependency. The particular test case 2
views dependent on it. 
Depending on the jvm being used, the 2 exceptions(with same sql state but different object
dependency in the sql
message text) thrown for dependency might be in different order and that causes test failure.
In order to fix this,
I have carved out that test from synonym.sql into a new junit test and since in junit test,
we can simply assert
the sql state, the order of 2 exceptions does not matter. I will migrate this fix into Derby
10.3 soon.


Added:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/SynonymTest.java
  (with props)
Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/synonym.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/synonym.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/synonym.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/synonym.sql

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/synonym.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/synonym.out?rev=587553&r1=587552&r2=587553&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/synonym.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/synonym.out
Tue Oct 23 09:51:48 2007
@@ -363,25 +363,6 @@
 ij> -- Previously compiled cached statement should get invalidated
 select * from mySynonym;
 ERROR 42X05: Table/View 'MYSYNONYM' does not exist.
-ij> create synonym mySyn for table1;
-0 rows inserted/updated/deleted
-ij> create view v1 as select * from mySyn;
-0 rows inserted/updated/deleted
-ij> create view v2 as select * from v1;
-0 rows inserted/updated/deleted
-ij> -- Drop synonym should fail since it is used in two views.
-drop synonym mySyn;
-ERROR X0Y23: Operation 'DROP SYNONYM' cannot be performed on object 'MYSYN' because VIEW
'V1' is dependent on that object. SQLSTATE: X0Y23: Operation 'DROP SYNONYM' cannot be performed
on object 'MYSYN' because VIEW 'V2' is dependent on that object.
-ij> drop view v2;
-0 rows inserted/updated/deleted
-ij> -- fail still
-drop synonym mySyn;
-ERROR X0Y23: Operation 'DROP SYNONYM' cannot be performed on object 'MYSYN' because VIEW
'V1' is dependent on that object.
-ij> drop view v1;
-0 rows inserted/updated/deleted
-ij> -- should pass
-drop synonym mySyn;
-0 rows inserted/updated/deleted
 ij> -- drop and recreate schema test
 create schema testSchema;
 0 rows inserted/updated/deleted

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/synonym.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/synonym.out?rev=587553&r1=587552&r2=587553&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/synonym.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/synonym.out
Tue Oct 23 09:51:48 2007
@@ -363,25 +363,6 @@
 ij> -- Previously compiled cached statement should get invalidated
 select * from mySynonym;
 ERROR 42X05: Table/View 'MYSYNONYM' does not exist.
-ij> create synonym mySyn for table1;
-0 rows inserted/updated/deleted
-ij> create view v1 as select * from mySyn;
-0 rows inserted/updated/deleted
-ij> create view v2 as select * from v1;
-0 rows inserted/updated/deleted
-ij> -- Drop synonym should fail since it is used in two views.
-drop synonym mySyn;
-ERROR X0Y23: Operation 'DROP SYNONYM' cannot be performed on object 'MYSYN' because VIEW
'V1' is dependent on that object. SQLSTATE: X0Y23: Operation 'DROP SYNONYM' cannot be performed
on object 'MYSYN' because VIEW 'V2' is dependent on that object.
-ij> drop view v2;
-0 rows inserted/updated/deleted
-ij> -- fail still
-drop synonym mySyn;
-ERROR X0Y23: Operation 'DROP SYNONYM' cannot be performed on object 'MYSYN' because VIEW
'V1' is dependent on that object.
-ij> drop view v1;
-0 rows inserted/updated/deleted
-ij> -- should pass
-drop synonym mySyn;
-0 rows inserted/updated/deleted
 ij> -- drop and recreate schema test
 create schema testSchema;
 0 rows inserted/updated/deleted

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/synonym.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/synonym.out?rev=587553&r1=587552&r2=587553&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/synonym.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/synonym.out
Tue Oct 23 09:51:48 2007
@@ -372,26 +372,6 @@
 ij> -- Previously compiled cached statement should get invalidated
 select * from mySynonym;
 ERROR 42X05: Table/View 'MYSYNONYM' does not exist.
-ij> create synonym mySyn for table1;
-0 rows inserted/updated/deleted
-ij> create view v1 as select * from mySyn;
-0 rows inserted/updated/deleted
-ij> create view v2 as select * from v1;
-0 rows inserted/updated/deleted
-ij> -- Drop synonym should fail since it is used in two views.
-drop synonym mySyn;
-ERROR X0Y23: Operation 'DROP SYNONYM' cannot be performed on object 'MYSYN' because VIEW
'V1' is dependent on that object.
-ERROR X0Y23: Operation 'DROP SYNONYM' cannot be performed on object 'MYSYN' because VIEW
'V2' is dependent on that object.
-ij> drop view v2;
-0 rows inserted/updated/deleted
-ij> -- fail still
-drop synonym mySyn;
-ERROR X0Y23: Operation 'DROP SYNONYM' cannot be performed on object 'MYSYN' because VIEW
'V1' is dependent on that object.
-ij> drop view v1;
-0 rows inserted/updated/deleted
-ij> -- should pass
-drop synonym mySyn;
-0 rows inserted/updated/deleted
 ij> -- drop and recreate schema test
 create schema testSchema;
 0 rows inserted/updated/deleted

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/SynonymTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/SynonymTest.java?rev=587553&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/SynonymTest.java
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/SynonymTest.java
Tue Oct 23 09:51:48 2007
@@ -0,0 +1,71 @@
+/**
+ *  Derby - Class org.apache.derbyTesting.functionTests.tests.lang.SynonymTest
+ *  
+ * 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 junit.framework.TestSuite;
+
+import org.apache.derbyTesting.junit.BaseJDBCTestCase;
+
+/**
+ * Synonym testing using junit
+ */
+public class SynonymTest extends BaseJDBCTestCase {
+
+    /**
+     * Basic constructor.
+     */
+    public SynonymTest(String name) {
+        super(name);
+    }
+
+    /**
+     * Create a suite of tests.
+     */
+    public static Test suite() {
+        TestSuite suite = new TestSuite(SynonymTest.class, "SynonymTest");
+        return suite;
+    }
+
+    /**
+     * The test makes sure that we correctly throw dependency exception when
+     * user requests to drop a synonym which has dependent objects on it. Once
+     * the dependency is removed, we should be able to drop the synonym.
+     * @throws SQLException
+     */
+    public void testViewDependency() throws SQLException {
+        Statement stmt = createStatement();  
+        stmt.executeUpdate("create synonym mySyn for sys.systables");
+        stmt.executeUpdate("create view v1 as select * from mySyn");
+        stmt.executeUpdate("create view v2 as select * from v1");
+        // Drop synonym should fail since it is used in two views.
+        assertStatementError("X0Y23", stmt, "drop synonym mySyn");
+        stmt.executeUpdate("drop view v2");
+        // fails still because of view v1's dependency
+        assertStatementError("X0Y23", stmt, "drop synonym mySyn");
+        stmt.executeUpdate("drop view v1");
+        stmt.executeUpdate("drop synonym mySyn");
+        stmt.close();
+    }
+}

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/SynonymTest.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=587553&r1=587552&r2=587553&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
Tue Oct 23 09:51:48 2007
@@ -120,6 +120,7 @@
         suite.addTest(Bug5052rtsTest.suite());
         suite.addTest(Bug5054Test.suite());
         suite.addTest(Bug4356Test.suite());
+        suite.addTest(SynonymTest.suite());
 
         // Add the XML tests, which exist as a separate suite
         // so that users can "run all XML tests" easily.

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/synonym.sql
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/synonym.sql?rev=587553&r1=587552&r2=587553&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/synonym.sql
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/synonym.sql
Tue Oct 23 09:51:48 2007
@@ -15,6 +15,8 @@
 --   limitations under the License.
 --
 -- tests for synonym support
+-- When we decide to convert this test to junit test, the converted tests can 
+-- go in existing SynonymTest.java
 
 set schema APP;
 -- negative tests
@@ -228,23 +230,6 @@
 
 -- Previously compiled cached statement should get invalidated
 select * from mySynonym;
-
-create synonym mySyn for table1;
-create view v1 as select * from mySyn;
-create view v2 as select * from v1;
-
--- Drop synonym should fail since it is used in two views.
-drop synonym mySyn;
-
-drop view v2;
-
--- fail still
-drop synonym mySyn;
-
-drop view v1;
-
--- should pass
-drop synonym mySyn;
 
 -- drop and recreate schema test
 create schema testSchema;



Mime
View raw message