You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by dj...@apache.org on 2006/01/05 20:36:13 UTC

svn commit: r366258 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests: master/ tests/i18n/ util/

Author: djd
Date: Thu Jan  5 11:36:09 2006
New Revision: 366258

URL: http://svn.apache.org/viewcvs?rev=366258&view=rev
Log:
Modify the i18n/JapanCodeConversion.sql test not to perform execs of native2ascii.
Instead use a Java SQL function to perform the same function, display the content
of a file in ascii with unicode escapes. Function was added as a standard test
routine so dml160 and databaseProperties master files were updated as they install
the standard test functions.
Execing a program requires wide permissions under the security manager and
was failing on IBM JVMs.

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/JapanCodeConversion.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/databaseProperties.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dml160.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/i18n/JapanCodeConversion.sql
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/TestRoutines.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/testRoutines.sql

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/JapanCodeConversion.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/JapanCodeConversion.out?rev=366258&r1=366257&r2=366258&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/JapanCodeConversion.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/JapanCodeConversion.out Thu Jan  5 11:36:09 2006
@@ -1,3 +1,14 @@
+ij> run resource '/org/apache/derbyTesting/functionTests/util/testRoutines.sql';
+ij> -- Changed to create individual procedures so that this will work with JSR169. 
+-- Direct call to 'installRoutines' uses nested connection
+CREATE PROCEDURE TESTROUTINE.SET_SYSTEM_PROPERTY(IN PROPERTY_KEY VARCHAR(32000), IN PROPERTY_VALUE VARCHAR(32000)) NO SQL EXTERNAL NAME 'org.apache.derbyTesting.functionTests.util.TestRoutines.setSystemProperty' language java parameter style java;
+0 rows inserted/updated/deleted
+ij> CREATE PROCEDURE TESTROUTINE.SLEEP(IN SLEEP_TIME_MS BIGINT) NO SQL EXTERNAL NAME 'org.apache.derbyTesting.functionTests.util.TestRoutines.sleep' language java parameter style java;
+0 rows inserted/updated/deleted
+ij> CREATE FUNCTION TESTROUTINE.HAS_SECURITY_MANAGER() RETURNS INT NO SQL EXTERNAL NAME 'org.apache.derbyTesting.functionTests.util.TestRoutines.hasSecurityManager' language java parameter style java;
+0 rows inserted/updated/deleted
+ij> CREATE FUNCTION TESTROUTINE.READ_FILE(FILE_NAME VARCHAR(60), ENCODING VARCHAR(60)) RETURNS VARCHAR(32000) NO SQL EXTERNAL NAME 'org.apache.derbyTesting.functionTests.util.TestRoutines.readFile' language java parameter style java;
+0 rows inserted/updated/deleted
 ij> drop table T1_EUC_JP;
 ERROR 42Y55: 'DROP TABLE' cannot be performed on 'T1_EUC_JP' because it does not exist.
 ij> -- table for data in EUC_JP encoding
@@ -107,68 +118,11 @@
 16 rows inserted/updated/deleted
 ij> delete from T1_EUC_JP_IMPORT_AS_SJIS;
 16 rows inserted/updated/deleted
-ij> -- now import using the wrong encoding file just to ensure that different
--- encodings are being used.
-call SYSCS_UTIL.SYSCS_IMPORT_TABLE (null, 'T1_EUC_JP_IMPORT_AS_EUC_JP',
-   'extinout/jap_SJIS.dump',
-   NULL, NULL,
-   'EUC_JP', 0);
-0 rows inserted/updated/deleted
-ij> SELECT jnum, jtime, { fn length(jstring) } AS JLEN from T1_EUC_JP_IMPORT_AS_EUC_JP;
-JNUM       |JTIME   |JLEN       
---------------------------------
-1          |15:32:06|14         
-2          |15:32:10|20         
-3          |15:32:28|38         
-4          |15:32:29|27         
-5          |15:32:29|29         
-6          |15:32:30|10         
-7          |15:32:31|24         
-8          |15:33:22|14         
-9          |15:33:23|116        
-10         |15:33:40|14         
-11         |15:33:41|116        
-12         |15:33:43|27         
-13         |15:34:29|14         
-14         |15:34:30|116        
-15         |15:35:35|26         
-16         |15:39:10|27         
-ij> SELECT count(*) FROM T1_EUC_JP OG, T1_EUC_JP_IMPORT_AS_EUC_JP IM
-  WHERE OG.jnum = IM.jnum AND OG.jtime = IM.jtime AND OG.jstring = IM.jstring;
-1          
------------
-0          
-ij> call SYSCS_UTIL.SYSCS_IMPORT_TABLE (null, 'T1_EUC_JP_IMPORT_AS_SJIS',
-   'extinout/jap_EUC_JP.dump',
-   NULL, NULL,
-   'SJIS', 0);
-0 rows inserted/updated/deleted
-ij> SELECT jnum, jtime, { fn length(jstring) } AS JLEN from T1_EUC_JP_IMPORT_AS_SJIS;
-JNUM       |JTIME   |JLEN       
---------------------------------
-1          |15:32:06|26         
-2          |15:32:10|24         
-3          |15:32:28|59         
-4          |15:32:29|51         
-5          |15:32:29|55         
-6          |15:32:30|12         
-7          |15:32:31|35         
-8          |15:33:22|26         
-9          |15:33:23|152        
-10         |15:33:40|26         
-11         |15:33:41|152        
-12         |15:33:43|51         
-13         |15:34:29|26         
-14         |15:34:30|152        
-15         |15:35:35|43         
-16         |15:39:10|51         
-ij> SELECT count(*) FROM T1_EUC_JP OG, T1_EUC_JP_IMPORT_AS_SJIS IM
-  WHERE OG.jnum = IM.jnum AND OG.jtime = IM.jtime AND OG.jstring = IM.jstring;
-1          
------------
-0          
+ij> maximumdisplaywidth 40000;
 ij> -- convert from EUC_JP to unicode with native2ascii
-! 'native2ascii -encoding EUC_JP extinout/jap_EUC_JP.dump';
+VALUES TESTROUTINE.READ_FILE('extinout/jap_EUC_JP.dump', 'EUC_JP');
+1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
                                    
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 -----------------------------------
 1,"15:32:06","\u30a4\u30d9\u30f3\u30c8\u30a2\u30e9\u30fc\u30e0\u304c\u6709\u52b9\u3067\u3059\u3002                                                                                                                                                                                          "
 2,"15:32:10","DR:DRAUTO\u306f0 (Off)\u3067\u3059\u3002                                                                                                                                                                                    "
 3,"15:32:28","INFORMIX-OnLine\u304c\u521d\u671f\u5316\u3055\u308c\u3001\u30c7\u30a3\u30b9\u30af\u306e\u521d\u671f\u5316\u304c\u5b8c\u4e86\u3057\u307e\u3057\u305f\u3002                                                                                                                                                                  "
@@ -186,7 +140,9 @@
 15,"15:35:35","sysmaster\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u4f5c\u6210\u306f\u5b8c\u4e86\u3057\u307e\u3057\u305f\u3002                                                                                                                                                                              "
 16,"15:39:10","\u30c1\u30a7\u30c3\u30af\u30dd\u30a4\u30f3\u30c8\u304c\u5b8c\u4e86\u3057\u307e\u3057\u305f:\u7d99\u7d9a\u6642\u9593\u306f 8\u79d2\u3067\u3057\u305f                                                                                                                                                                             "
 ij> -- convert from SJIS to unicode with native2ascii
-! 'native2ascii -encoding SJIS extinout/jap_SJIS.dump';
+VALUES TESTROUTINE.READ_FILE('extinout/jap_SJIS.dump', 'SJIS');
+1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
                                    
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 -----------------------------------
 1,"15:32:06","\u30a4\u30d9\u30f3\u30c8\u30a2\u30e9\u30fc\u30e0\u304c\u6709\u52b9\u3067\u3059\u3002                                                                                                                                                                                          "
 2,"15:32:10","DR:DRAUTO\u306f0 (Off)\u3067\u3059\u3002                                                                                                                                                                                    "
 3,"15:32:28","INFORMIX-OnLine\u304c\u521d\u671f\u5316\u3055\u308c\u3001\u30c7\u30a3\u30b9\u30af\u306e\u521d\u671f\u5316\u304c\u5b8c\u4e86\u3057\u307e\u3057\u305f\u3002                                                                                                                                                                  "

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/databaseProperties.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/databaseProperties.out?rev=366258&r1=366257&r2=366258&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/databaseProperties.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/databaseProperties.out Thu Jan  5 11:36:09 2006
@@ -7,6 +7,8 @@
 0 rows inserted/updated/deleted
 ij> CREATE FUNCTION TESTROUTINE.HAS_SECURITY_MANAGER() RETURNS INT NO SQL EXTERNAL NAME 'org.apache.derbyTesting.functionTests.util.TestRoutines.hasSecurityManager' language java parameter style java;
 0 rows inserted/updated/deleted
+ij> CREATE FUNCTION TESTROUTINE.READ_FILE(FILE_NAME VARCHAR(60), ENCODING VARCHAR(60)) RETURNS VARCHAR(32000) NO SQL EXTERNAL NAME 'org.apache.derbyTesting.functionTests.util.TestRoutines.readFile' language java parameter style java;
+0 rows inserted/updated/deleted
 ij> CREATE FUNCTION GET_TABLE_PROPERTY (SCHEMA_NAME VARCHAR(128), TABLE_NAME VARCHAR(128), PROP_KEY VARCHAR(1000)) RETURNS VARCHAR(1000) EXTERNAL NAME 'org.apache.derbyTesting.functionTests.util.TestPropertyInfo.getTableProperty' LANGUAGE JAVA PARAMETER STYLE JAVA;
 0 rows inserted/updated/deleted
 ij> -- Get a property that hasn't been set yet - should return null

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dml160.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dml160.out?rev=366258&r1=366257&r2=366258&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dml160.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dml160.out Thu Jan  5 11:36:09 2006
@@ -282,6 +282,8 @@
 0 rows inserted/updated/deleted
 ij> CREATE FUNCTION TESTROUTINE.HAS_SECURITY_MANAGER() RETURNS INT NO SQL EXTERNAL NAME 'org.apache.derbyTesting.functionTests.util.TestRoutines.hasSecurityManager' language java parameter style java;
 0 rows inserted/updated/deleted
+ij> CREATE FUNCTION TESTROUTINE.READ_FILE(FILE_NAME VARCHAR(60), ENCODING VARCHAR(60)) RETURNS VARCHAR(32000) NO SQL EXTERNAL NAME 'org.apache.derbyTesting.functionTests.util.TestRoutines.readFile' language java parameter style java;
+0 rows inserted/updated/deleted
 ij> values TESTROUTINE.HAS_SECURITY_MANAGER();
 1          
 -----------

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/i18n/JapanCodeConversion.sql
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/i18n/JapanCodeConversion.sql?rev=366258&r1=366257&r2=366258&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/i18n/JapanCodeConversion.sql (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/i18n/JapanCodeConversion.sql Thu Jan  5 11:36:09 2006
@@ -1,3 +1,5 @@
+run resource '/org/apache/derbyTesting/functionTests/util/testRoutines.sql';
+
 drop table T1_EUC_JP;
 -- table for data in EUC_JP encoding
 create table T1_EUC_JP (	jnum int,
@@ -51,28 +53,11 @@
 delete from T1_EUC_JP_IMPORT_AS_EUC_JP;
 delete from T1_EUC_JP_IMPORT_AS_SJIS;
 
--- now import using the wrong encoding file just to ensure that different
--- encodings are being used.
-
-call SYSCS_UTIL.SYSCS_IMPORT_TABLE (null, 'T1_EUC_JP_IMPORT_AS_EUC_JP',
-   'extinout/jap_SJIS.dump',
-   NULL, NULL,
-   'EUC_JP', 0);
-SELECT jnum, jtime, { fn length(jstring) } AS JLEN from T1_EUC_JP_IMPORT_AS_EUC_JP;
-SELECT count(*) FROM T1_EUC_JP OG, T1_EUC_JP_IMPORT_AS_EUC_JP IM
-  WHERE OG.jnum = IM.jnum AND OG.jtime = IM.jtime AND OG.jstring = IM.jstring;   
-  
-call SYSCS_UTIL.SYSCS_IMPORT_TABLE (null, 'T1_EUC_JP_IMPORT_AS_SJIS',
-   'extinout/jap_EUC_JP.dump',
-   NULL, NULL,
-   'SJIS', 0);
-SELECT jnum, jtime, { fn length(jstring) } AS JLEN from T1_EUC_JP_IMPORT_AS_SJIS;
-SELECT count(*) FROM T1_EUC_JP OG, T1_EUC_JP_IMPORT_AS_SJIS IM
-  WHERE OG.jnum = IM.jnum AND OG.jtime = IM.jtime AND OG.jstring = IM.jstring;
 
+maximumdisplaywidth 40000;
 
 -- convert from EUC_JP to unicode with native2ascii
-! 'native2ascii -encoding EUC_JP extinout/jap_EUC_JP.dump';
+VALUES TESTROUTINE.READ_FILE('extinout/jap_EUC_JP.dump', 'EUC_JP');
 
 -- convert from SJIS to unicode with native2ascii
-! 'native2ascii -encoding SJIS extinout/jap_SJIS.dump';
+VALUES TESTROUTINE.READ_FILE('extinout/jap_SJIS.dump', 'SJIS');

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/TestRoutines.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/TestRoutines.java?rev=366258&r1=366257&r2=366258&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/TestRoutines.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/TestRoutines.java Thu Jan  5 11:36:09 2006
@@ -22,8 +22,11 @@
 
 import java.security.AccessController;
 import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
 import java.sql.*;
 import java.io.*;
+
 import org.apache.derby.iapi.reference.JDBC30Translation;
 
 
@@ -66,6 +69,7 @@
 
 		s.execute("CREATE FUNCTION TESTROUTINE.HAS_SECURITY_MANAGER() RETURNS INT NO SQL EXTERNAL NAME 'org.apache.derbyTesting.functionTests.util.TestRoutines.hasSecurityManager' language java parameter style java");
 
+		s.execute("CREATE FUNCTION TESTROUTINE.READ_FILE(FILE_NAME VARCHAR(60), ENCODING VARCHAR(60)) RETURNS VARCHAR(32000) NO SQL EXTERNAL NAME 'org.apache.derbyTesting.functionTests.util.TestRoutines.readFile' language java parameter style java");
 		s.close();
 	}
 
@@ -105,6 +109,63 @@
 	public static int hasSecurityManager()
 	{
 		return System.getSecurityManager() == null ? 0 : 1;
+	}
+	
+	/**
+	TESTROUTINE.READ_FILE(FILE_NAME VARCHAR(60), ENCODING VARCHAR(60)) RETURNS VARCHAR(32000)
+	Read a file using the passed in encoding display its contents
+	as ASCII with unicode esacpes..
+	 * @throws PrivilegedActionException 
+	 * @throws IOException 
+   */
+    public static String readFile(final String fileName, final String encoding)
+    throws PrivilegedActionException, IOException
+    {
+
+		// needs to run in a privileged block as it will be
+		// called through a SQL statement and thus a generated
+		// class. The generated class on the stack has no permissions
+		// granted to it.
+    	FileInputStream fin = (FileInputStream)
+    	    AccessController.doPrivileged(new PrivilegedExceptionAction() {
+			public Object run() throws FileNotFoundException {
+				return new FileInputStream(fileName); // nothing to return
+			}
+		});
+    	
+    	InputStreamReader isr = new InputStreamReader(
+    			new BufferedInputStream(fin, 32*1024), encoding);
+    	    	
+    	StringBuffer sb = new StringBuffer();
+    	for (;;)
+    	{
+    		int ci = isr.read();
+    		if (ci < 0)
+    			break;
+    		
+    		if (ci <= 0x7f)
+    		{
+    			sb.append((char) ci);
+    		}
+    		else
+    		{
+    			sb.append("\\u");
+    			String hex = Integer.toHexString(ci);
+    			   			
+    			switch (hex.length())
+    			{
+    			case 2:
+    				sb.append("00");
+    				break;
+    			case 3:
+    				sb.append("0");
+    				break;
+    			}
+    			sb.append(hex);
+    		}
+      	}
+
+    	return sb.toString();
 	}
 }
 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/testRoutines.sql
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/testRoutines.sql?rev=366258&r1=366257&r2=366258&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/testRoutines.sql (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/testRoutines.sql Thu Jan  5 11:36:09 2006
@@ -3,3 +3,4 @@
 CREATE PROCEDURE TESTROUTINE.SET_SYSTEM_PROPERTY(IN PROPERTY_KEY VARCHAR(32000), IN PROPERTY_VALUE VARCHAR(32000)) NO SQL EXTERNAL NAME 'org.apache.derbyTesting.functionTests.util.TestRoutines.setSystemProperty' language java parameter style java;
 CREATE PROCEDURE TESTROUTINE.SLEEP(IN SLEEP_TIME_MS BIGINT) NO SQL EXTERNAL NAME 'org.apache.derbyTesting.functionTests.util.TestRoutines.sleep' language java parameter style java;
 CREATE FUNCTION TESTROUTINE.HAS_SECURITY_MANAGER() RETURNS INT NO SQL EXTERNAL NAME 'org.apache.derbyTesting.functionTests.util.TestRoutines.hasSecurityManager' language java parameter style java;
+CREATE FUNCTION TESTROUTINE.READ_FILE(FILE_NAME VARCHAR(60), ENCODING VARCHAR(60)) RETURNS VARCHAR(32000) NO SQL EXTERNAL NAME 'org.apache.derbyTesting.functionTests.util.TestRoutines.readFile' language java parameter style java;