|
33 | 33 | import static schemacrawler.test.utility.FileHasContent.hasSameContentAs; |
34 | 34 | import static schemacrawler.test.utility.FileHasContent.outputOf; |
35 | 35 |
|
36 | | -import java.io.FileDescriptor; |
37 | | -import java.io.FileOutputStream; |
38 | | -import java.io.PrintStream; |
39 | | - |
40 | | -import org.junit.jupiter.api.AfterEach; |
41 | | -import org.junit.jupiter.api.BeforeEach; |
42 | 36 | import org.junit.jupiter.api.Test; |
43 | 37 |
|
44 | 38 | import schemacrawler.Main; |
| 39 | +import schemacrawler.test.utility.CaptureSystemStreams; |
| 40 | +import schemacrawler.test.utility.CapturedSystemStreams; |
45 | 41 | import schemacrawler.test.utility.ResolveTestContext; |
46 | 42 | import schemacrawler.test.utility.TestContext; |
47 | | -import schemacrawler.test.utility.TestOutputStream; |
48 | 43 |
|
49 | 44 | @ResolveTestContext |
| 45 | +@CaptureSystemStreams |
50 | 46 | public class CommandLineHelpTest { |
51 | 47 |
|
52 | 48 | private static final String COMMAND_LINE_HELP_OUTPUT = "command_line_help_output/"; |
53 | 49 |
|
54 | | - private TestOutputStream err; |
55 | | - private TestOutputStream out; |
56 | | - |
57 | | - @AfterEach |
58 | | - public void cleanUpStreams() { |
59 | | - System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); |
60 | | - System.setErr(new PrintStream(new FileOutputStream(FileDescriptor.err))); |
61 | | - } |
62 | | - |
63 | 50 | @Test |
64 | | - public void commandLineHelp(final TestContext testContext) throws Exception { |
| 51 | + public void commandLineHelp(final TestContext testContext, final CapturedSystemStreams streams) |
| 52 | + throws Exception { |
65 | 53 | final String server = "timesten"; |
66 | 54 | Main.main("--help", "server:" + server); |
67 | 55 |
|
68 | | - assertThat(outputOf(err), hasNoContent()); |
| 56 | + assertThat(outputOf(streams.err()), hasNoContent()); |
69 | 57 | assertThat( |
70 | | - outputOf(out), |
| 58 | + outputOf(streams.out()), |
71 | 59 | hasSameContentAs(classpathResource(COMMAND_LINE_HELP_OUTPUT + server + ".help.txt"))); |
72 | 60 | } |
73 | | - |
74 | | - @BeforeEach |
75 | | - public void setUpStreams() throws Exception { |
76 | | - out = new TestOutputStream(); |
77 | | - System.setOut(new PrintStream(out)); |
78 | | - |
79 | | - err = new TestOutputStream(); |
80 | | - System.setErr(new PrintStream(err)); |
81 | | - } |
82 | 61 | } |
0 commit comments