< prev index next >

test/tools/launcher/I18NArgTest.java

Print this page




  78         execTest("\\" + unicodeStr + "\u00b1" + unicodeStr + "\\", hexValue + "b1" + hexValue);
  79         execTest(" " + unicodeStr + "\u00b1" + unicodeStr + " ", hexValue + "b1"+ hexValue);
  80         execTest("'" + unicodeStr + "\u00b1" + unicodeStr + "'", hexValue + "b1"+ hexValue);
  81         execTest("\t" + unicodeStr + "\u00b1" + unicodeStr + "\t", hexValue + "b1"+ hexValue);
  82         execTest("*" + unicodeStr + "\u00b1" + unicodeStr + "*", hexValue + "b1"+ hexValue);
  83         execTest("?" + unicodeStr + "\u00b1" + unicodeStr + "?", hexValue + "b1"+ hexValue);
  84     }
  85 
  86     static void execTest(String unicodeStr, String hexValue) {
  87         TestResult tr = doExec(javaCmd,
  88                 "-Dtest.src=" + TEST_SOURCES_DIR.getAbsolutePath(),
  89                 "-Dtest.classes=" + TEST_CLASSES_DIR.getAbsolutePath(),
  90                 "-cp", TEST_CLASSES_DIR.getAbsolutePath(),
  91                 "I18NArgTest", unicodeStr, hexValue);
  92         System.out.println(tr.testOutput);
  93         if (!tr.isOK()) {
  94             System.err.println(tr);
  95             throw new RuntimeException("test fails");
  96         }
  97 
  98         // Test via JAVA_OPTIONS
  99 /*
 100         Map<String, String> env = new HashMap<>();
 101         String cmd = "-Dtest.src=" + TEST_SOURCES_DIR.getAbsolutePath() +
 102                 " -Dtest.classes=" + TEST_CLASSES_DIR.getAbsolutePath() +
 103                 " -cp " + TEST_CLASSES_DIR.getAbsolutePath() +
 104                 " I18NArgTest " + unicodeStr + " " + hexValue;
 105         env.put("JAVA_OPTIONS", cmd);
 106         tr = doExec(env, javaCmd);
 107         System.out.println(tr.testOutput);
 108         if (!tr.isOK()) {
 109             System.err.println(tr);
 110             throw new RuntimeException("test fails");
 111         }
 112 */
 113     }
 114 
 115     static void testCharacters(String... args) {
 116         String input = args[0];
 117         String expected = args[1];
 118         String hexValue = "";
 119         for (int i = 0; i < input.length(); i++) {
 120             hexValue = hexValue.concat(Integer.toHexString((int)input.charAt(i)));
 121         }
 122         System.out.println("input:" + input);
 123         System.out.println("expected:" + expected);
 124         System.out.println("obtained:" + hexValue);
 125         if (!hexValue.contains(expected)) {
 126             String message = "Error: output does not contain expected value" +
 127                 "expected:" + expected + " obtained:" + hexValue;
 128             throw new RuntimeException(message);
 129         }
 130     }
 131 }


  78         execTest("\\" + unicodeStr + "\u00b1" + unicodeStr + "\\", hexValue + "b1" + hexValue);
  79         execTest(" " + unicodeStr + "\u00b1" + unicodeStr + " ", hexValue + "b1"+ hexValue);
  80         execTest("'" + unicodeStr + "\u00b1" + unicodeStr + "'", hexValue + "b1"+ hexValue);
  81         execTest("\t" + unicodeStr + "\u00b1" + unicodeStr + "\t", hexValue + "b1"+ hexValue);
  82         execTest("*" + unicodeStr + "\u00b1" + unicodeStr + "*", hexValue + "b1"+ hexValue);
  83         execTest("?" + unicodeStr + "\u00b1" + unicodeStr + "?", hexValue + "b1"+ hexValue);
  84     }
  85 
  86     static void execTest(String unicodeStr, String hexValue) {
  87         TestResult tr = doExec(javaCmd,
  88                 "-Dtest.src=" + TEST_SOURCES_DIR.getAbsolutePath(),
  89                 "-Dtest.classes=" + TEST_CLASSES_DIR.getAbsolutePath(),
  90                 "-cp", TEST_CLASSES_DIR.getAbsolutePath(),
  91                 "I18NArgTest", unicodeStr, hexValue);
  92         System.out.println(tr.testOutput);
  93         if (!tr.isOK()) {
  94             System.err.println(tr);
  95             throw new RuntimeException("test fails");
  96         }
  97 
  98         // Test via JDK_JAVA_OPTIONS

  99         Map<String, String> env = new HashMap<>();
 100         String cmd = "-Dtest.src=" + TEST_SOURCES_DIR.getAbsolutePath() +
 101                 " -Dtest.classes=" + TEST_CLASSES_DIR.getAbsolutePath() +
 102                 " -cp " + TEST_CLASSES_DIR.getAbsolutePath() +
 103                 " I18NArgTest " + unicodeStr + " " + hexValue;
 104         env.put("JDK_JAVA_OPTIONS", cmd);
 105         tr = doExec(env, javaCmd);
 106         System.out.println(tr.testOutput);
 107         if (!tr.isOK()) {
 108             System.err.println(tr);
 109             throw new RuntimeException("test fails");
 110         }

 111     }
 112 
 113     static void testCharacters(String... args) {
 114         String input = args[0];
 115         String expected = args[1];
 116         String hexValue = "";
 117         for (int i = 0; i < input.length(); i++) {
 118             hexValue = hexValue.concat(Integer.toHexString((int)input.charAt(i)));
 119         }
 120         System.out.println("input:" + input);
 121         System.out.println("expected:" + expected);
 122         System.out.println("obtained:" + hexValue);
 123         if (!hexValue.contains(expected)) {
 124             String message = "Error: output does not contain expected value" +
 125                 "expected:" + expected + " obtained:" + hexValue;
 126             throw new RuntimeException(message);
 127         }
 128     }
 129 }
< prev index next >