db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r432645 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness: ProcessStreamResult.java RunTest.java Sed.java
Date Fri, 18 Aug 2006 17:15:38 GMT
Author: kahatlen
Date: Fri Aug 18 10:15:37 2006
New Revision: 432645

URL: http://svn.apache.org/viewvc?rev=432645&view=rev
Log:
DERBY-244: with linux, depending on env setting $LANG and console
encoding, some i18n tests fail

  * Run the i18n tests run with -Dfile.encoding=UTF-8 and
    -Dconsole.encoding=UTF-8
  * Use UTF-8 encoding in ProcessStreamResult for the i18n tests
  * Make Sed.java read result files from i18n tests using UTF-8 encoding
  * Respect the derby.ui.codeset setting in i18n tests, and use UTF-8 if it
    is not specified.

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/ProcessStreamResult.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/RunTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/Sed.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/ProcessStreamResult.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/ProcessStreamResult.java?rev=432645&r1=432644&r2=432645&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/ProcessStreamResult.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/ProcessStreamResult.java
Fri Aug 18 10:15:37 2006
@@ -42,15 +42,20 @@
 	public ProcessStreamResult(InputStream in, BufferedOutputStream bos,
 		    String timemin) throws IOException, InterruptedException
 	{
-		this(in, bos, timemin, null);
+		this(in, bos, timemin, null, null);
 	}
-	
+
 	public ProcessStreamResult(InputStream in, BufferedOutputStream bos,
-	  String timemin, String encoding) throws IOException, InterruptedException
+	  String timemin, String inEncoding, String outEncoding)
+		throws IOException, InterruptedException
 	{
 		this.in = in;
-		this.outStream = new OutputStreamWriter(bos);
-		this.encoding = encoding;
+        if (outEncoding == null) {
+            this.outStream = new OutputStreamWriter(bos);
+        } else {
+            this.outStream = new OutputStreamWriter(bos, outEncoding);
+        }
+        this.encoding = inEncoding;
         this.startTime = System.currentTimeMillis();
         if (timemin != null)
         {

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/RunTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/RunTest.java?rev=432645&r1=432644&r2=432645&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/RunTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/RunTest.java
Fri Aug 18 10:15:37 2006
@@ -183,6 +183,9 @@
     static boolean lastTestFailed = false;
 
     static boolean isI18N = false;
+    /** The value of derby.ui.codeset if it has been specified in the
+     * properties file. */
+    static String codeset = null;
     static boolean junitXASingle = false;
     
     /**
@@ -262,6 +265,10 @@
         // Setup the directories for the test and test output
         setDirectories(scriptName,sp);
 
+        if (testDirName.startsWith("i18n")) {
+            isI18N=true;
+        }
+
         // Check for properties files, including derby.properties
         // and if needed, build the -p string to pass to the test
         String propString = createPropString();
@@ -381,11 +388,6 @@
 		
 		String outName = finalOutFile.getPath();
 
-        if (testDirName.startsWith("i18n"))
-        {
-            isI18N=true;
-        }
-        
         if (skipsed)
         {
             tmpOutFile.renameTo(finalOutFile);
@@ -1541,11 +1543,17 @@
 			// For IBM14 the console encoding is different from the platform
 			// encoding on windows.  We want it to be the same for our
 			// test output like the other JDK's.
+			//
+			// For i18n test, we want UTF-8 encoding (DERBY-244).
 			String conEnc = System.getProperty("console.encoding");
 			String fileEnc = System.getProperty("file.encoding");
 		
-			if ((conEnc != null) &&  (fileEnc != null )  &&
-				(ap.getProperty("derby.ui.codeset") == null) &&
+			if (ap.getProperty("derby.ui.codeset") != null) {
+				// derby.ui.codeset is specified explicitly, don't override
+				codeset = ap.getProperty("derby.ui.codeset");
+			} else if (isI18N) {
+				ap.put("derby.ui.codeset", "UTF-8");
+			} else if ((conEnc != null) &&  (fileEnc != null )  &&
 				conEnc.startsWith("Cp850"))
 			{
 				ap.put("derby.ui.codeset",fileEnc);
@@ -2290,6 +2298,13 @@
             jvmProps.addElement("file.encoding=" + testEncoding);
             jvmflags = (jvmflags==null?"":jvmflags+" ") 
                          + "-Dfile.encoding=" + testEncoding; 
+        } else if (isI18N) {
+            // The I18N tests should be run with UTF-8 encoding to avoid
+            // problems with characters that cannot be represented in the
+            // default encoding (DERBY-244).
+            jvmProps.addElement("file.encoding=UTF-8");
+            jvmflags = (jvmflags==null ? "" : jvmflags + " ") +
+                        "-Dfile.encoding=UTF-8";
         }
         
         if (upgradejarpath != null)
@@ -2340,8 +2355,13 @@
             // force the console encoding to Cp1252 for ij tests - unless 
             // we're on non-ascii systems.
             String isNotAscii = System.getProperty("platform.notASCII");
-            if ( (isNotAscii == null) || (isNotAscii.equals("false"))) 
+            if (isI18N) {
+                // DERBY-244: Use UTF-8 console encoding for the i18n tests to
+                // avoid MalformedInputException with the IBM jvm.
+                v.addElement("-Dconsole.encoding=UTF-8");
+            } else if ((isNotAscii == null) || (isNotAscii.equals("false"))) {
                 v.addElement("-Dconsole.encoding=Cp1252" );
+            }
             v.addElement("org.apache.derby.tools." + ij);
             if (ij.equals("ij"))
             {
@@ -2505,25 +2525,42 @@
             if (verbose) System.out.println(sb.toString());
             pr = Runtime.getRuntime().exec(testCmd);
 
+            String inEncoding = null;
+            String outEncoding = null;
+            if (isI18N) {
+                // DERBY-244: I18N tests are run with -Dfile.encoding=UTF-8, so
+                // we need to specify encoding to the streams as well.
+                inEncoding = "UTF-8";
+                outEncoding = inEncoding;
+            }
+
+            if (codeset != null) {
+                // The test explicitly specified a codeset, use that codeset
+                // when reading the test output.
+                inEncoding = codeset;
+            }
+
+            if (testEncoding != null) {
+                inEncoding = testEncoding;
+            }
+
             if (useOutput)
             {
                 fos = new FileOutputStream(tmpOutFile);
-                bos = new BufferedOutputStream(fos, 1024);
-                prout = 
-                    new ProcessStreamResult(pr.getInputStream(), bos, 
-                    					timeoutStr, testEncoding);
             }
             else
             {
                 fos = new FileOutputStream(stdOutFile);
-                bos = new BufferedOutputStream(fos, 1024);
-                prout = 
-                    new ProcessStreamResult(pr.getInputStream(), bos, 
-                    					timeoutStr, testEncoding);
             }
+            bos = new BufferedOutputStream(fos, 1024);
+            prout = 
+                new ProcessStreamResult(pr.getInputStream(), bos, 
+                                        timeoutStr,
+                                        inEncoding, outEncoding);
             prerr =
                 new ProcessStreamResult(pr.getErrorStream(), bos, 
-                						timeoutStr, testEncoding);
+                                        timeoutStr,
+                                        inEncoding, outEncoding);
     
             if (framework != null && ! framework.equals(""))
                 if (verbose) System.out.println("The test should be running...");

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/Sed.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/Sed.java?rev=432645&r1=432644&r2=432645&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/Sed.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/Sed.java
Fri Aug 18 10:15:37 2006
@@ -372,10 +372,16 @@
         matcher = new Perl5Matcher();
 
         // Define the input and output files based on args
-        if (is == null)
+        if (is == null && isI18N) {
+            // read UTF-8 encoded file
+            InputStream fs = new FileInputStream(srcFile);
+            inFile = new BufferedReader(new InputStreamReader(fs, "UTF-8"));
+        } else if (is == null) {
+            // read the file using the default encoding
             inFile = new BufferedReader(new FileReader(srcFile));
-        else
+        } else {
             inFile = new BufferedReader(new InputStreamReader(is, "UTF-8"));
+        }
         outFile = new PrintWriter
         ( new BufferedWriter(new FileWriter(dstFile), 10000), true );
 



Mime
View raw message