46 import org.testng.annotations.Test;
47
48 import static org.testng.Assert.assertEquals;
49 import static org.testng.Assert.assertTrue;
50
51 @Test
52 public class StartOptionTest {
53
54 private ByteArrayOutputStream cmdout;
55 private ByteArrayOutputStream cmderr;
56 private ByteArrayOutputStream console;
57 private ByteArrayOutputStream userout;
58 private ByteArrayOutputStream usererr;
59
60 private JShellTool getShellTool() {
61 return new JShellTool(
62 new TestingInputStream(),
63 new PrintStream(cmdout),
64 new PrintStream(cmderr),
65 new PrintStream(console),
66 new TestingInputStream(),
67 new PrintStream(userout),
68 new PrintStream(usererr),
69 new ReplToolTesting.MemoryPreferences(),
70 Locale.ROOT);
71 }
72
73 private void check(ByteArrayOutputStream str, Consumer<String> checkOut, String label) {
74 byte[] bytes = str.toByteArray();
75 str.reset();
76 String out = new String(bytes, StandardCharsets.UTF_8);
77 if (checkOut != null) {
78 checkOut.accept(out);
79 } else {
80 assertEquals("", out, label + ": Expected empty -- ");
81 }
82 }
83
84 private void start(Consumer<String> checkOutput, Consumer<String> checkError, String... args) throws Exception {
85 JShellTool tool = getShellTool();
86 tool.start(args);
|
46 import org.testng.annotations.Test;
47
48 import static org.testng.Assert.assertEquals;
49 import static org.testng.Assert.assertTrue;
50
51 @Test
52 public class StartOptionTest {
53
54 private ByteArrayOutputStream cmdout;
55 private ByteArrayOutputStream cmderr;
56 private ByteArrayOutputStream console;
57 private ByteArrayOutputStream userout;
58 private ByteArrayOutputStream usererr;
59
60 private JShellTool getShellTool() {
61 return new JShellTool(
62 new TestingInputStream(),
63 new PrintStream(cmdout),
64 new PrintStream(cmderr),
65 new PrintStream(console),
66 new PrintStream(userout),
67 new PrintStream(usererr),
68 new ReplToolTesting.MemoryPreferences(),
69 Locale.ROOT);
70 }
71
72 private void check(ByteArrayOutputStream str, Consumer<String> checkOut, String label) {
73 byte[] bytes = str.toByteArray();
74 str.reset();
75 String out = new String(bytes, StandardCharsets.UTF_8);
76 if (checkOut != null) {
77 checkOut.accept(out);
78 } else {
79 assertEquals("", out, label + ": Expected empty -- ");
80 }
81 }
82
83 private void start(Consumer<String> checkOutput, Consumer<String> checkError, String... args) throws Exception {
84 JShellTool tool = getShellTool();
85 tool.start(args);
|