HDFS-10783. The option '-maxSize' and '-step' fail in OfflineImageViewer. Contributed by Yiqun Lin.
(cherry picked from commite90f3359de
) (cherry picked from commit94a844b4f6
)
This commit is contained in:
parent
71a3b01d51
commit
dde3eaed62
|
@ -186,6 +186,8 @@ public class OfflineImageViewer {
|
|||
|
||||
options.addOption("p", "processor", true, "");
|
||||
options.addOption("h", "help", false, "");
|
||||
options.addOption("maxSize", true, "");
|
||||
options.addOption("step", true, "");
|
||||
options.addOption("skipBlocks", false, "");
|
||||
options.addOption("printToScreen", false, "");
|
||||
options.addOption("delimiter", true, "");
|
||||
|
|
|
@ -601,4 +601,23 @@ public class TestOfflineImageViewer {
|
|||
"FileDistribution", "-maxSize", "23", "-step", "4"});
|
||||
assertEquals(0, status);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOfflineImageViewerMaxSizeAndStepOptions() throws Exception {
|
||||
final ByteArrayOutputStream bytes = new ByteArrayOutputStream();
|
||||
final PrintStream out = new PrintStream(bytes);
|
||||
final PrintStream oldOut = System.out;
|
||||
try {
|
||||
System.setOut(out);
|
||||
// Add the -h option to make the test only for option parsing,
|
||||
// and don't need to do the following operations.
|
||||
OfflineImageViewer.main(new String[] {"-i", "-", "-o", "-", "-p",
|
||||
"FileDistribution", "-maxSize", "512", "-step", "8", "-h"});
|
||||
Assert.assertFalse(bytes.toString().contains(
|
||||
"Error parsing command-line options: "));
|
||||
} finally {
|
||||
System.setOut(oldOut);
|
||||
IOUtils.closeStream(out);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue