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 ka...@apache.org on 2006/07/20 23:32:16 UTC

svn commit: r424072 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests: harness/NetServer.java harness/RunTest.java harness/jvm.java tests/tools/derbyrunjartest.java

Author: kahatlen
Date: Thu Jul 20 14:32:15 2006
New Revision: 424072

URL: http://svn.apache.org/viewvc?rev=424072&view=rev
Log:
DERBY-323: Locale problem in test of derby

Description of the patch:

  1) Rewrite tools/derbyrunjartest.java to use jvm.getCommandLine() to
     get the command line to start the test with.

  2) Move the setting of user.language and user.country from RunTest
     and NetServer to jvm.getCommandLine(). This way, all of the java
     processes that are forked from the test harness or from a test
     get the same locale.

  3) Add Locale.setDefault(Locale.US) to RunTest.main(). This fixes
     the issue with the nist tests.

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/NetServer.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/jvm.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/derbyrunjartest.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/NetServer.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/NetServer.java?rev=424072&r1=424071&r2=424072&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/NetServer.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/NetServer.java Thu Jul 20 14:32:15 2006
@@ -183,8 +183,6 @@
         }
 
         jvmProps.addElement("derby.system.home=" + homeDirName);
-		jvmProps.addElement("user.language=en");
-		jvmProps.addElement("user.country=US");
 		jvm.setD(jvmProps);
 		jvm.setSecurityProps();
         // For some platforms (like Mac) the process exec command

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=424072&r1=424071&r2=424072&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 Thu Jul 20 14:32:15 2006
@@ -46,6 +46,7 @@
 import java.lang.Thread;
 import java.lang.reflect.Method;
 import java.util.Enumeration;
+import java.util.Locale;
 import java.util.Vector;
 import java.sql.Timestamp;
 import java.sql.Connection;
@@ -196,6 +197,7 @@
 	public static void main(String[] args)
 		throws Exception
 	{
+		Locale.setDefault(Locale.US);
 		skiptestReason.setLength(0); // 0 out for useprocess
 		// Determine the test type
 		if (args.length == 0)
@@ -2212,8 +2214,6 @@
 			derbySystemHome = userDirName;
 		testJvmProps.addElement("derby.system.home=" + derbySystemHome);
 		testJvmProps.addElement("derby.infolog.append=true ");
-		testJvmProps.addElement("user.language=en");
-		testJvmProps.addElement("user.country=US");
 		// Why is this being done here
 		//if (jvm != null)
 		    //testJvmProps.addElement("jvm="+jvm.getName());

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/jvm.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/jvm.java?rev=424072&r1=424071&r2=424072&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/jvm.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/jvm.java Thu Jul 20 14:32:15 2006
@@ -174,6 +174,8 @@
     {
         Vector v = new Vector();
         v.addElement(javaCmd);
+        v.addElement("-Duser.language=en");
+        v.addElement("-Duser.country=US");
         if ( (flags != null) && (flags.length()>0) )
         {
             StringTokenizer st = new StringTokenizer(flags);

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/derbyrunjartest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/derbyrunjartest.java?rev=424072&r1=424071&r2=424072&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/derbyrunjartest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/derbyrunjartest.java Thu Jul 20 14:32:15 2006
@@ -27,12 +27,14 @@
 import java.lang.SecurityException;
 import java.net.URL;
 import java.security.CodeSource;
+import java.util.Vector;
 
 import org.apache.derbyTesting.functionTests.harness.BackgroundStreamSaver;
+import org.apache.derbyTesting.functionTests.harness.jvm;
 
 public class derbyrunjartest {
 
-    public static void main(String[] args) throws IOException
+    public static void main(String[] args) throws Exception
     {
         // get location of run class.
         CodeSource cs = null;
@@ -43,40 +45,54 @@
         }
  
         URL result = cs.getLocation();
+        jvm jvm = null;
+        String derbyrunloc = null;
 
         if (result.toString().endsWith(".jar")) {
-            String derbyrunloc = result.toString().substring(5);
+            derbyrunloc = result.toString().substring(5);
             if (System.getProperty("os.name").startsWith("Windows"))
               derbyrunloc = derbyrunloc.substring(1);
-            runtool(derbyrunloc, "ij --help");
-            runtool(derbyrunloc, "sysinfo -cp help");
-            runtool(derbyrunloc, "dblook");
-            runtool(derbyrunloc, "server");
-        } else {
-            String[] ij = {"ij", "--help"};
-            System.out.println("ij --help:");
-            org.apache.derby.iapi.tools.run.main(ij);
-
-            String[] sysinfo = {"sysinfo", "-cp", "help"}; 
-            System.out.println("sysinfo -cp help:");
-            org.apache.derby.iapi.tools.run.main(sysinfo);
-
-            String[] dblook = {"dblook"};
-            System.out.println("dblook:");
-            org.apache.derby.iapi.tools.run.main(dblook);
-
-            String[] server = {"server"};
-            System.out.println("server:");
-            org.apache.derby.iapi.tools.run.main(server);
+
+            if ((System.getProperty("java.vm.name") != null) &&
+                    System.getProperty("java.vm.name").equals("J9")) {
+                jvm = jvm.getJvm("j9_13");
+            } else {
+                jvm = jvm.getJvm("currentjvm"); // ensure compatibility
+            }
+        }
+
+        String[][] testCommands = new String[][] {
+            {"ij", "--help"},
+            {"sysinfo", "-cp", "help"},
+            {"dblook"},
+            {"server"},
+        };
+
+        for (int i = 0; i < testCommands.length; i++) {
+            runtool(jvm, derbyrunloc, testCommands[i]);
         }
     }
 
-    private static void runtool(String loc, String tool)
+    private static void runtool(jvm jvm, String loc, String[] args)
+        throws IOException
     {
-        String command = "java -jar " + loc + ' ' + tool;
+        System.out.println(concatenate(args) + ':');
+
+        if (jvm == null) {
+            org.apache.derby.iapi.tools.run.main(args);
+            return;
+        }
+
+        Vector cmd = jvm.getCommandLine();
+        cmd.addElement("-jar");
+        cmd.addElement(loc);
+        for (int i=0; i < args.length; i++) {
+            cmd.addElement(args[i]);
+        }
+        String command = concatenate((String[]) cmd.toArray(new String[0]));
+
         Process pr = null;
 
-        System.out.println(tool + ':');
         try
         {
             pr = Runtime.getRuntime().exec(command);
@@ -92,5 +108,14 @@
                 pr = null;
             }
         }
+    }
+
+    private static String concatenate(String[] args) {
+        StringBuffer buf = new StringBuffer();
+        for (int i = 0; i < args.length; i++) {
+            buf.append(args[i]);
+            if (i + 1 < args.length) buf.append(' ');
+        }
+        return buf.toString();
     }
 }