< prev index next >

test/langtools/jdk/jshell/StartOptionTest.java

Print this page
rev 48074 : 8189102: All tools should support -?, -h and --help
Reviewed-by: kvn, jjg, weijun, alanb, rfield, ksrini


 197     protected void setIn(String s) {
 198         cmdInStream = new ByteArrayInputStream(s.getBytes());
 199     }
 200 
 201     // Test load files
 202     public void testCommandFile() {
 203         String fn = writeToFile("String str = \"Hello \"\n" +
 204                 "/list\n" +
 205                 "System.out.println(str + str)\n" +
 206                 "/exit\n");
 207         startExCoUoCeCn(0,
 208                 "1 : String str = \"Hello \";\n",
 209                 "Hello Hello",
 210                 null,
 211                 null,
 212                 "--no-startup", fn, "-s");
 213     }
 214 
 215     // Test that the usage message is printed
 216     public void testUsage() {
 217         for (String opt : new String[]{"-h", "--help"}) {
 218             startCo(s -> {
 219                 assertTrue(s.split("\n").length >= 7, "Not enough usage lines: " + s);
 220                 assertTrue(s.startsWith("Usage:   jshell <option>..."), "Unexpect usage start: " + s);
 221                 assertTrue(s.contains("--show-version"), "Expected help: " + s);
 222                 assertFalse(s.contains("Welcome"), "Unexpected start: " + s);
 223             }, opt);
 224         }
 225     }
 226 
 227     // Test the --help-extra message
 228     public void testHelpExtra() {
 229         for (String opt : new String[]{"-X", "--help-extra"}) {
 230             startCo(s -> {
 231                 assertTrue(s.split("\n").length >= 5, "Not enough help-extra lines: " + s);
 232                 assertTrue(s.contains("--add-exports"), "Expected --add-exports: " + s);
 233                 assertTrue(s.contains("--execution"), "Expected --add-exports: " + s);
 234                 assertFalse(s.contains("Welcome"), "Unexpected start: " + s);
 235             }, opt);
 236         }
 237     }




 197     protected void setIn(String s) {
 198         cmdInStream = new ByteArrayInputStream(s.getBytes());
 199     }
 200 
 201     // Test load files
 202     public void testCommandFile() {
 203         String fn = writeToFile("String str = \"Hello \"\n" +
 204                 "/list\n" +
 205                 "System.out.println(str + str)\n" +
 206                 "/exit\n");
 207         startExCoUoCeCn(0,
 208                 "1 : String str = \"Hello \";\n",
 209                 "Hello Hello",
 210                 null,
 211                 null,
 212                 "--no-startup", fn, "-s");
 213     }
 214 
 215     // Test that the usage message is printed
 216     public void testUsage() {
 217         for (String opt : new String[]{"-?", "-h", "--help"}) {
 218             startCo(s -> {
 219                 assertTrue(s.split("\n").length >= 7, "Not enough usage lines: " + s);
 220                 assertTrue(s.startsWith("Usage:   jshell <option>..."), "Unexpect usage start: " + s);
 221                 assertTrue(s.contains("--show-version"), "Expected help: " + s);
 222                 assertFalse(s.contains("Welcome"), "Unexpected start: " + s);
 223             }, opt);
 224         }
 225     }
 226 
 227     // Test the --help-extra message
 228     public void testHelpExtra() {
 229         for (String opt : new String[]{"-X", "--help-extra"}) {
 230             startCo(s -> {
 231                 assertTrue(s.split("\n").length >= 5, "Not enough help-extra lines: " + s);
 232                 assertTrue(s.contains("--add-exports"), "Expected --add-exports: " + s);
 233                 assertTrue(s.contains("--execution"), "Expected --add-exports: " + s);
 234                 assertFalse(s.contains("Welcome"), "Unexpected start: " + s);
 235             }, opt);
 236         }
 237     }


< prev index next >