db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r425846 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests: master/Upgrade_10_1_10_2.out tests/upgradeTests/UpgradeTester.java
Date Wed, 26 Jul 2006 21:26:50 GMT
Author: djd
Date: Wed Jul 26 14:26:49 2006
New Revision: 425846

URL: http://svn.apache.org/viewvc?rev=425846&view=rev
Log:
DERBY-1521 Attaching a patch 'd1521-patch1-v1.diff' which modifies UpgradeTester to test the
grant/revoke feature. This is a preliminary patch which tests the default upgrade behaviour:
In upgrades from versions earlier than 10.2,
* grant/revoke feature is not available in soft upgrade
* grant/revoke feature is not available in full upgrade (by default). This feature will be
available after full upgrade only if "derby.database.sqlAuthorization" is true. 

Patch contributed by Deepa Remesh

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/Upgrade_10_1_10_2.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeTester.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/Upgrade_10_1_10_2.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/Upgrade_10_1_10_2.out?rev=425846&r1=425845&r2=425846&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/Upgrade_10_1_10_2.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/Upgrade_10_1_10_2.out
Wed Jul 26 14:26:49 2006
@@ -9,6 +9,7 @@
 1, DERBY-438_STMT
 D438.T438_T2
 complete caseTriggerVTI - passed true
+complete caseGrantRevoke - passed true
 Test metadata starting
 Union Result -- precision: 10 scale: 2 display size: 13 type name: DECIMAL
 dec(10,2) -- precision: 10 scale: 2 display size: 13 type name: DECIMAL
@@ -279,6 +280,7 @@
 ,SYSIBM,SYSDUMMY1,SYSTEM TABLE,
 ,APP,ALLTYPES,TABLE,
 ,APP,CT1,TABLE,
+,APP,GR_TAB,TABLE,
 ,APP,INFLIGHT,TABLE,
 ,APP,LOUIE,TABLE,
 ,APP,PHASE,TABLE,
@@ -294,6 +296,7 @@
 TABLE_CAT[VARCHAR],TABLE_SCHEM[VARCHAR],TABLE_NAME[VARCHAR],TABLE_TYPE[VARCHAR],REMARKS[VARCHAR]
 ,APP,ALLTYPES,TABLE,
 ,APP,CT1,TABLE,
+,APP,GR_TAB,TABLE,
 ,APP,INFLIGHT,TABLE,
 ,APP,LOUIE,TABLE,
 ,APP,PHASE,TABLE,
@@ -714,6 +717,7 @@
 1, 104
 1, 4004
 complete caseTriggerVTI - passed true
+complete caseGrantRevoke - passed true
 Test metadata starting
 Union Result -- precision: 10 scale: 2 display size: 13 type name: DECIMAL
 dec(10,2) -- precision: 10 scale: 2 display size: 12 type name: DECIMAL
@@ -1070,6 +1074,7 @@
 ,SYSIBM,SYSDUMMY1,SYSTEM TABLE,,null,null,null,null,null
 ,APP,ALLTYPES,TABLE,,null,null,null,null,null
 ,APP,CT1,TABLE,,null,null,null,null,null
+,APP,GR_TAB,TABLE,,null,null,null,null,null
 ,APP,INFLIGHT,TABLE,,null,null,null,null,null
 ,APP,LOUIE,TABLE,,null,null,null,null,null
 ,APP,PHASE,TABLE,,null,null,null,null,null
@@ -1085,6 +1090,7 @@
 TABLE_CAT[VARCHAR],TABLE_SCHEM[VARCHAR],TABLE_NAME[VARCHAR],TABLE_TYPE[VARCHAR],REMARKS[VARCHAR],TYPE_CAT[VARCHAR],TYPE_SCHEM[VARCHAR],TYPE_NAME[VARCHAR],SELF_REFERENCING_COL_NAME[VARCHAR],REF_GENERATION[VARCHAR]
 ,APP,ALLTYPES,TABLE,,null,null,null,null,null
 ,APP,CT1,TABLE,,null,null,null,null,null
+,APP,GR_TAB,TABLE,,null,null,null,null,null
 ,APP,INFLIGHT,TABLE,,null,null,null,null,null
 ,APP,LOUIE,TABLE,,null,null,null,null,null
 ,APP,PHASE,TABLE,,null,null,null,null,null
@@ -1465,6 +1471,7 @@
 1, 105
 1, 4005
 complete caseTriggerVTI - passed true
+complete caseGrantRevoke - passed true
 Test metadata starting
 Union Result -- precision: 10 scale: 2 display size: 13 type name: DECIMAL
 dec(10,2) -- precision: 10 scale: 2 display size: 13 type name: DECIMAL
@@ -1735,6 +1742,7 @@
 ,SYSIBM,SYSDUMMY1,SYSTEM TABLE,
 ,APP,ALLTYPES,TABLE,
 ,APP,CT1,TABLE,
+,APP,GR_TAB,TABLE,
 ,APP,INFLIGHT,TABLE,
 ,APP,LOUIE,TABLE,
 ,APP,PHASE,TABLE,
@@ -1750,6 +1758,7 @@
 TABLE_CAT[VARCHAR],TABLE_SCHEM[VARCHAR],TABLE_NAME[VARCHAR],TABLE_TYPE[VARCHAR],REMARKS[VARCHAR]
 ,APP,ALLTYPES,TABLE,
 ,APP,CT1,TABLE,
+,APP,GR_TAB,TABLE,
 ,APP,INFLIGHT,TABLE,
 ,APP,LOUIE,TABLE,
 ,APP,PHASE,TABLE,
@@ -2169,6 +2178,7 @@
 1, 106
 1, 4006
 complete caseTriggerVTI - passed true
+complete caseGrantRevoke - passed true
 Test metadata starting
 Union Result -- precision: 10 scale: 2 display size: 13 type name: DECIMAL
 dec(10,2) -- precision: 10 scale: 2 display size: 12 type name: DECIMAL
@@ -2533,6 +2543,7 @@
 ,SYSIBM,SYSDUMMY1,SYSTEM TABLE,,null,null,null,null,null
 ,APP,ALLTYPES,TABLE,,null,null,null,null,null
 ,APP,CT1,TABLE,,null,null,null,null,null
+,APP,GR_TAB,TABLE,,null,null,null,null,null
 ,APP,INFLIGHT,TABLE,,null,null,null,null,null
 ,APP,LOUIE,TABLE,,null,null,null,null,null
 ,APP,PHASE,TABLE,,null,null,null,null,null
@@ -2548,6 +2559,7 @@
 TABLE_CAT[VARCHAR],TABLE_SCHEM[VARCHAR],TABLE_NAME[VARCHAR],TABLE_TYPE[VARCHAR],REMARKS[VARCHAR],TYPE_CAT[VARCHAR],TYPE_SCHEM[VARCHAR],TYPE_NAME[VARCHAR],SELF_REFERENCING_COL_NAME[VARCHAR],REF_GENERATION[VARCHAR]
 ,APP,ALLTYPES,TABLE,,null,null,null,null,null
 ,APP,CT1,TABLE,,null,null,null,null,null
+,APP,GR_TAB,TABLE,,null,null,null,null,null
 ,APP,INFLIGHT,TABLE,,null,null,null,null,null
 ,APP,LOUIE,TABLE,,null,null,null,null,null
 ,APP,PHASE,TABLE,,null,null,null,null,null

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeTester.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeTester.java?rev=425846&r1=425845&r2=425846&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeTester.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeTester.java
Wed Jul 26 14:26:49 2006
@@ -362,6 +362,8 @@
 									oldMinorVersion) && passed;
             passed = caseTriggerVTI(conn, phase, oldMajorVersion, 
                     oldMinorVersion) && passed;
+            passed = caseGrantRevoke(conn, phase, oldMajorVersion, 
+            						oldMinorVersion) && passed;
 			runMetadataTest(classLoader, conn);
 			conn.close();
 			shutdown(classLoader, dbName);
@@ -796,8 +798,85 @@
         s.executeUpdate("DELETE FROM D438.T438_T2");
         s.getConnection().commit();
     }
+    
+    /**
+     * Grant/revoke is a new feature in 10.2. Test that this feature is not 
+     * supported by default after upgrade from versions earlier than 10.2. 
+     * This feature will not be available in soft upgrade. For grant/revoke 
+     * to be available after a full upgrade, the property 
+     * "derby.database.sqlAuthorization" has to be set to true during upgrade. 
+     * 
+     * @param conn Connection
+     * @param phase Upgrade test phase
+	 * @param dbMajor Major version of old release 
+	 * @param dbMinor Minor version of old release 
+     * @return true, if the test passes 
+     * @throws SQLException
+     */
+    private boolean caseGrantRevoke(Connection conn, int phase,
+    												int dbMajor, int dbMinor)
+                                    				throws SQLException {
+                
+        boolean passed = true;
+        boolean grantRevokeNotSupported = dbMajor==10 && dbMinor<2;
+        
+        Statement s = conn.createStatement();
+
+        switch (phase) {
+        case PH_CREATE:
+            s.execute("create table GR_TAB (id int)");
+            break;
+        case PH_SOFT_UPGRADE:
+        case PH_POST_SOFT_UPGRADE:
+        case PH_HARD_UPGRADE:
+        	if(grantRevokeNotSupported)
+        		passed = testGrantRevokeNotSupported(s, phase);
+        	break;
+        default:
+            passed = false;
+            break;
+        }
+        s.close();
+
+        System.out.println("complete caseGrantRevoke - passed " + passed);
+        return passed;
+    }
+    
+    /**
+     * Test to check that grant/revoke is not supported in a specific upgrade 
+     * test phase.
+     * 
+     * @param s	SQL statement
+     * @param phase Upgrade test phase
+     * @return true, if grant/revoke is not supported
+     */
+    private boolean testGrantRevokeNotSupported(Statement s, int phase) {
+    	boolean passed = true;
+    	try {
+    		s.execute("grant select on GR_TAB to some_user");
+    	} catch(SQLException sqle) {
+    		switch (phase) {
+    			case PH_SOFT_UPGRADE:
+    				// feature not available in soft upgrade 
+    				passed = isExpectedException(sqle, "XCL47");
+    				break;
+    			case PH_POST_SOFT_UPGRADE:
+    				// syntax error in versions earlier than 10.2
+    				passed = isExpectedException(sqle, "42X01");
+    				break;
+    			case PH_HARD_UPGRADE:
+    				// not supported because SQL authorization not set
+    				passed = isExpectedException(sqle, "42Z60");
+    				break;
+    			default:
+    				passed = false;
+    		}
+    	}
     	
-	/**
+    	return passed;
+    }
+    
+    /**
 	 * Run metadata test
 	 * 
 	 * @param classLoader Class loader to be used to load the test class
@@ -861,6 +940,25 @@
 								+ sqle.getMessage());
 			sqle = sqle.getNextException();
 		} while (sqle != null);
+	}
+	
+	/**
+	 * Check if the exception is expected. 
+	 * 
+	 * @param sqle SQL Exception
+	 * @param expectedSQLState Expected SQLState
+	 * @return true, if SQLState of the exception is same as expected SQLState
+	 */
+	private boolean isExpectedException(SQLException sqle, String expectedSQLState) {
+		boolean passed = true;
+		
+		if(!expectedSQLState.equals(sqle.getSQLState())) { 
+			passed = false;
+			System.out.println("Fail - Unexpected exception:");
+			dumpSQLExceptions(sqle);
+		}
+		
+		return passed;
 	}
 	
 	/**



Mime
View raw message