test/jdk/jshell/ToolLocaleMessageTest.java

Print this page




  27  * @summary Tests for output customization
  28  * @library /tools/lib
  29  * @modules jdk.compiler/com.sun.tools.javac.api
  30  *          jdk.compiler/com.sun.tools.javac.main
  31  *          jdk.jdeps/com.sun.tools.javap
  32  *          jdk.jshell/jdk.internal.jshell.tool
  33  * @build KullaTesting TestingInputStream toolbox.ToolBox Compiler
  34  * @run testng ToolLocaleMessageTest
  35  * @key intermittent
  36  */
  37 
  38 import java.util.Locale;
  39 import org.testng.annotations.Test;
  40 import static org.testng.Assert.assertFalse;
  41 import static org.testng.Assert.assertTrue;
  42 
  43 @Test
  44 public class ToolLocaleMessageTest extends ReplToolTesting {
  45 
  46     void testLocale(ReplTest... tests) {
  47         test(Locale.getDefault(), false, new String[]{"-nostartup"}, "", tests);
  48     }
  49 
  50     void assertCommandOK(boolean after, String cmd, String... contains) {
  51         assertCommandCheckOutput(after, cmd, s -> {
  52             assertFalse(s.contains("Exception"), "Output of '" + cmd + "' has Exception: " + s);
  53             assertFalse(s.contains("ERROR:"), "Output of '" + cmd + "' has error: " + s);
  54             for (String m : contains) {
  55                 assertTrue(s.contains(m), "Expected to find '" + m + "' in output of '" + cmd + "' -- output: " + s);
  56             }
  57         });
  58     }
  59 
  60     void assertCommandFail(boolean after, String cmd, String... contains) {
  61         assertCommandCheckOutput(after, cmd, s -> {
  62             assertFalse(s.contains("Exception"), "Output of '" + cmd + "' has Exception: " + s);
  63             assertTrue(s.contains("ERROR:"), "Expected to find error in output of '" + cmd + "' has error: " + s);
  64             for (String m : contains) {
  65                 assertTrue(s.contains(m), "Expected to find '" + m + "' in output of '" + cmd + "' -- output: " + s);
  66             }
  67         });




  27  * @summary Tests for output customization
  28  * @library /tools/lib
  29  * @modules jdk.compiler/com.sun.tools.javac.api
  30  *          jdk.compiler/com.sun.tools.javac.main
  31  *          jdk.jdeps/com.sun.tools.javap
  32  *          jdk.jshell/jdk.internal.jshell.tool
  33  * @build KullaTesting TestingInputStream toolbox.ToolBox Compiler
  34  * @run testng ToolLocaleMessageTest
  35  * @key intermittent
  36  */
  37 
  38 import java.util.Locale;
  39 import org.testng.annotations.Test;
  40 import static org.testng.Assert.assertFalse;
  41 import static org.testng.Assert.assertTrue;
  42 
  43 @Test
  44 public class ToolLocaleMessageTest extends ReplToolTesting {
  45 
  46     void testLocale(ReplTest... tests) {
  47         test(Locale.getDefault(), false, new String[]{"--no-startup"}, "", tests);
  48     }
  49 
  50     void assertCommandOK(boolean after, String cmd, String... contains) {
  51         assertCommandCheckOutput(after, cmd, s -> {
  52             assertFalse(s.contains("Exception"), "Output of '" + cmd + "' has Exception: " + s);
  53             assertFalse(s.contains("ERROR:"), "Output of '" + cmd + "' has error: " + s);
  54             for (String m : contains) {
  55                 assertTrue(s.contains(m), "Expected to find '" + m + "' in output of '" + cmd + "' -- output: " + s);
  56             }
  57         });
  58     }
  59 
  60     void assertCommandFail(boolean after, String cmd, String... contains) {
  61         assertCommandCheckOutput(after, cmd, s -> {
  62             assertFalse(s.contains("Exception"), "Output of '" + cmd + "' has Exception: " + s);
  63             assertTrue(s.contains("ERROR:"), "Expected to find error in output of '" + cmd + "' has error: " + s);
  64             for (String m : contains) {
  65                 assertTrue(s.contains(m), "Expected to find '" + m + "' in output of '" + cmd + "' -- output: " + s);
  66             }
  67         });