<i18n dev> [8]: diff patch for jdk test on a non US platform
Francis ANDRE
francis.andre.kampbell at orange.fr
Thu Oct 31 10:39:37 PDT 2013
Hi
Following are a list of patch for making the jdk jtreg test suite happy with a
WXP/Cygwin/VS2010 Franch platform. For most of them, the fix consists in adding
Locale.setDefault(Locale.US); as the first statement in main.
diff --git a/test/java/rmi/activation/CommandEnvironment/SetChildEnv.java
b/test/java/rmi/activation/CommandEnvironment/SetChildEnv.java
--- a/test/java/rmi/activation/CommandEnvironment/SetChildEnv.java
+++ b/test/java/rmi/activation/CommandEnvironment/SetChildEnv.java
@@ -238,7 +238,7 @@
public synchronized void notifyLine(String s)
{
- if (s != null && s.indexOf("rmid: debugExec") != -1)
+ if (s != null && s.indexOf("rmid : debugExec") != -1)
found = s;
}
diff --git a/test/java/rmi/activation/checkusage/CheckUsage.java
b/test/java/rmi/activation/checkusage/CheckUsage.java
--- a/test/java/rmi/activation/checkusage/CheckUsage.java
+++ b/test/java/rmi/activation/checkusage/CheckUsage.java
@@ -31,12 +31,20 @@
*/
import java.io.ByteArrayOutputStream;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
/**
* Make sure that rmid prints out a correct usage statement when run with an
* incorrect command line.
*/
public class CheckUsage {
+ private static final Map<String, String> maps = new HashMap<String, String>();
+ static {
+ maps.put(Locale.ENGLISH.getDisplayLanguage(), "runtime flag");
+ maps.put(Locale.FRENCH.getDisplayLanguage(), "indicateur d'exécution");
+ }
public static void main(String[] args) {
try {
ByteArrayOutputStream berr = new ByteArrayOutputStream();
@@ -54,8 +62,9 @@
String usage = new String(berr.toByteArray());
System.err.println("rmid usage: " + usage);
-
- if (usage.indexOf("-J<runtime flag>") < 0) {
+
+ String jflag = "-J<" +
maps.get(Locale.getDefault().getDisplayLanguage()) + ">";
+ if (usage.indexOf(jflag) < 0) {
TestLibrary.bomb("rmid has incorrect usage message");
} else {
System.err.println("test passed");
diff --git a/test/java/util/Formattable/StockName.java
b/test/java/util/Formattable/StockName.java
--- a/test/java/util/Formattable/StockName.java
+++ b/test/java/util/Formattable/StockName.java
@@ -33,83 +33,90 @@
import static java.util.FormattableFlags.*;
public class StockName implements Formattable {
- private String symbol, companyName, frenchCompanyName;
+ private String symbol, companyName, frenchCompanyName;
- public StockName(String symbol, String companyName,
- String frenchCompanyName)
- {
- this.symbol = symbol;
- this.companyName = companyName;
- this.frenchCompanyName = frenchCompanyName;
- }
+ public StockName(String symbol, String companyName, String frenchCompanyName) {
+ this.symbol = symbol;
+ this.companyName = companyName;
+ this.frenchCompanyName = frenchCompanyName;
+ }
- public void formatTo(Formatter fmt, int f, int width, int precision) {
- StringBuilder sb = new StringBuilder();
+ public void formatTo(Formatter fmt, int f, int width, int precision) {
+ StringBuilder sb = new StringBuilder();
- // decide form of name
- String name = companyName;
- if (fmt.locale().equals(Locale.FRANCE))
- name = frenchCompanyName;
- boolean alternate = (f & ALTERNATE) == ALTERNATE;
- boolean usesymbol = alternate || (precision != -1 && precision < 10);
- String out = (usesymbol ? symbol : name);
+ // decide form of name
+ String name = companyName;
+ if (fmt.locale().equals(Locale.FRANCE))
+ name = frenchCompanyName;
+ boolean alternate = (f & ALTERNATE) == ALTERNATE;
+ boolean usesymbol = alternate || (precision != -1 && precision < 10);
+ String out = (usesymbol ? symbol : name);
- // apply precision
- if (precision == -1 || out.length() < precision) {
- // write it all
- sb.append(out);
- } else {
- sb.append(out.substring(0, precision - 1)).append('*');
- }
+ // apply precision
+ if (precision == -1 || out.length() < precision) {
+ // write it all
+ sb.append(out);
+ } else {
+ sb.append(out.substring(0, precision - 1)).append('*');
+ }
- // apply width and justification
- int len = sb.length();
- if (len < width)
- for (int i = 0; i < width - len; i++)
- if ((f & LEFT_JUSTIFY) == LEFT_JUSTIFY)
- sb.append(' ');
- else
- sb.insert(0, ' ');
+ // apply width and justification
+ int len = sb.length();
+ if (len < width)
+ for (int i = 0; i < width - len; i++)
+ if ((f & LEFT_JUSTIFY) == LEFT_JUSTIFY)
+ sb.append(' ');
+ else
+ sb.insert(0, ' ');
- fmt.format(sb.toString());
- }
+ fmt.format(sb.toString());
+ }
- public String toString() {
- return String.format("%s - %s", symbol, companyName);
- }
+ public String toString() {
+ return String.format("%s - %s", symbol, companyName);
+ }
- public static void main(String [] args) {
- StockName sn = new StockName("HUGE", "Huge Fruit, Inc.",
- "Fruit Titanesque, Inc.");
- CharBuffer cb = CharBuffer.allocate(128);
- Formatter fmt = new Formatter(cb);
+ public static void main(String[] args) {
+ StockName sn = new StockName("HUGE", "Huge Fruit, Inc.",
+ "Fruit Titanesque, Inc.");
+ CharBuffer cb = CharBuffer.allocate(128);
+ Formatter fmt = new Formatter(cb);
- fmt.format("%s", sn); // -> "Huge Fruit, Inc."
- test(cb, "Huge Fruit, Inc.");
+ if (fmt.locale().equals(Locale.FRANCE)) {
+ fmt.format("%s", sn); // -> "Fruit Titanesque, Inc."
+ test(cb, "Fruit Titanesque, Inc.");
+ } else {
+ fmt.format("%s", sn); // -> "Huge Fruit, Inc."
+ test(cb, "Huge Fruit, Inc.");
+ }
+ fmt.format("%s", sn.toString()); // -> "HUGE - Huge Fruit, Inc."
+ test(cb, "HUGE - Huge Fruit, Inc.");
- fmt.format("%s", sn.toString()); // -> "HUGE - Huge Fruit, Inc."
- test(cb, "HUGE - Huge Fruit, Inc.");
+ fmt.format("%#s", sn); // -> "HUGE"
+ test(cb, "HUGE");
- fmt.format("%#s", sn); // -> "HUGE"
- test(cb, "HUGE");
+ fmt.format("%-10.8s", sn); // -> "HUGE "
+ test(cb, "HUGE ");
- fmt.format("%-10.8s", sn); // -> "HUGE "
- test(cb, "HUGE ");
+ if (fmt.locale().equals(Locale.FRANCE)) {
+ fmt.format("%.12s", sn); // -> "Fruit Titan*"
+ test(cb, "Fruit Titan*");
+ } else {
+ fmt.format("%.12s", sn); // -> "Huge Fruit,*"
+ test(cb, "Huge Fruit,*");
+ }
- fmt.format("%.12s", sn); // -> "Huge Fruit,*"
- test(cb, "Huge Fruit,*");
+ fmt.format(Locale.FRANCE, "%25s", sn);
+ // -> " Fruit Titanesque, Inc."
+ test(cb, " Fruit Titanesque, Inc.");
+ }
- fmt.format(Locale.FRANCE, "%25s", sn);
- // -> " Fruit Titanesque, Inc."
- test(cb, " Fruit Titanesque, Inc.");
- }
-
- private static void test(CharBuffer cb, String exp) {
- cb.limit(cb.position());
- cb.rewind();
- if (!cb.toString().equals(exp))
- throw new RuntimeException("expect: '" + exp + "'; got: '"
- + cb.toString() + "'");
- cb.clear();
- }
+ private static void test(CharBuffer cb, String exp) {
+ cb.limit(cb.position());
+ cb.rewind();
+ if (!cb.toString().equals(exp))
+ throw new RuntimeException("expect: '" + exp + "'; got: '"
+ + cb.toString() + "'");
+ cb.clear();
+ }
}
diff --git a/test/java/util/ResourceBundle/ResourceBundleTest.java
b/test/java/util/ResourceBundle/ResourceBundleTest.java
--- a/test/java/util/ResourceBundle/ResourceBundleTest.java
+++ b/test/java/util/ResourceBundle/ResourceBundleTest.java
@@ -67,6 +67,7 @@
public class ResourceBundleTest extends RBTestFmwk {
public static void main(String[] args) throws Exception {
+ Locale.setDefault(Locale.US);
new ResourceBundleTest().run(args);
}
diff --git
a/test/java/util/ResourceBundle/getBaseBundleName/TestGetBaseBundleName.java
b/test/java/util/ResourceBundle/getBaseBundleName/TestGetBaseBundleName.java
--- a/test/java/util/ResourceBundle/getBaseBundleName/TestGetBaseBundleName.java
+++ b/test/java/util/ResourceBundle/getBaseBundleName/TestGetBaseBundleName.java
@@ -45,6 +45,7 @@
}
public static void main(String... args) throws Exception {
+ Locale.setDefault(Locale.US);
Locale defaultLocale = Locale.getDefault();
System.out.println("Default locale is: " + defaultLocale);
diff --git a/test/java/util/logging/LocalizedLevelName.java
b/test/java/util/logging/LocalizedLevelName.java
--- a/test/java/util/logging/LocalizedLevelName.java
+++ b/test/java/util/logging/LocalizedLevelName.java
@@ -49,6 +49,7 @@
};
public static void main(String args[]) throws Exception {
+ Locale.setDefault(Locale.US);
Locale defaultLocale = Locale.getDefault();
for (int i=0; i<namesMap.length; i += 4) {
final String key = (String) namesMap[i];
diff --git a/test/java/util/logging/SimpleFormatterFormat.java
b/test/java/util/logging/SimpleFormatterFormat.java
--- a/test/java/util/logging/SimpleFormatterFormat.java
+++ b/test/java/util/logging/SimpleFormatterFormat.java
@@ -30,6 +30,7 @@
*/
import java.io.*;
+import java.util.Locale;
import java.util.logging.*;
import java.util.regex.*;
@@ -38,7 +39,8 @@
private static final String origFormat = System.getProperty(key);
private static final PrintStream err = System.err;
public static void main(String[] args) throws Exception {
- try {
+ Locale.setDefault(Locale.US);
+ try {
File dir = new File(System.getProperty("user.dir", "."));
File log = new File(dir, "simpleformat.txt");
java.nio.file.Files.deleteIfExists(log.toPath());
diff --git a/test/sun/util/logging/SourceClassName.java
b/test/sun/util/logging/SourceClassName.java
--- a/test/sun/util/logging/SourceClassName.java
+++ b/test/sun/util/logging/SourceClassName.java
@@ -31,12 +31,14 @@
* @run main/othervm SourceClassName
*/
+import java.util.Locale;
import java.util.logging.*;
import java.io.*;
import sun.util.logging.PlatformLogger;
public class SourceClassName {
public static void main(String[] args) throws Exception {
+ Locale.setDefault(Locale.US);
File dir = new File(System.getProperty("user.dir", "."));
File log = new File(dir, "testlog.txt");
PrintStream logps = new PrintStream(log);
More information about the i18n-dev
mailing list