File tree Expand file tree Collapse file tree 4 files changed +30
-8
lines changed
parquet-cli/src/test/java/org/apache/parquet/cli Expand file tree Collapse file tree 4 files changed +30
-8
lines changed Original file line number Diff line number Diff line change @@ -35,9 +35,7 @@ public void showSizeStatistics() throws Exception {
3535
3636 @ Test
3737 public void showsHelpMessage () throws Exception {
38- cli ("help size-stats" )
39- .ok ()
40- .matchOutputFromFile ("src/test/resources/cli-outputs/size-stats-help.txt" );
38+ cli ("help size-stats" ).ok ().matchOutputFromFile ("src/test/resources/cli-outputs/size-stats-help.txt" );
4139 }
4240
4341 @ Test
Original file line number Diff line number Diff line change @@ -45,7 +45,6 @@ String dump() {
4545 return buf .toString ();
4646 }
4747
48-
4948 // Since the CLI logic can call any console method, this is some needed delegator code to
5049 // ensure all methods are coverted and that the test harness does not miss anything.
5150 // Unfortunately slf4j API does not make this easy to do in a generic way, so we
Original file line number Diff line number Diff line change 1919package org .apache .parquet .cli .testing ;
2020
2121import static org .junit .Assert .*;
22+
23+ import java .nio .charset .StandardCharsets ;
2224import java .nio .file .Files ;
2325import java .nio .file .Paths ;
24- import java .nio .charset .StandardCharsets ;
2526
2627public final class CliResult {
2728 public final int exitCode ;
@@ -64,9 +65,7 @@ public CliResult lineCount(int expected) {
6465 }
6566
6667 public CliResult matchOutputFromFile (String filePath ) throws Exception {
67- String expected = new String (
68- Files .readAllBytes (Paths .get (filePath )),
69- StandardCharsets .UTF_8 );
68+ String expected = new String (Files .readAllBytes (Paths .get (filePath )), StandardCharsets .UTF_8 );
7069 return outputContains (expected );
7170 }
7271}
Original file line number Diff line number Diff line change 2020
2121import org .apache .parquet .cli .commands .ParquetFileTest ;
2222
23+ /**
24+ * Base class for CLI integration tests with an API for testing command output.
25+ *
26+ * Developer Usage Examples:
27+ *
28+ * // Basic command execution and assertion
29+ * cli("schema file.parquet")
30+ * .ok()
31+ * .outputContains("int32_field", "int64_field");
32+ *
33+ * // Test help output
34+ * cli("help size-stats")
35+ * .ok()
36+ * .matchOutputFromFile("expected-help.txt");
37+ *
38+ * // Test error conditions
39+ * cli("invalid-command")
40+ * .fails(1)
41+ * .outputContains("Unknown command");
42+ *
43+ * // Test command with multiple arguments
44+ * cli("size-stats parquetFile.getAbsolutePath()")
45+ * .ok()
46+ * .lineCount(8);
47+ *
48+ */
2349public abstract class CliTestBase extends ParquetFileTest {
2450 private final CliHarness harness = new CliHarness ();
2551
You can’t perform that action at this time.
0 commit comments