HBASE-12304 CellCounter will throw AIOBE when output directory is not specified. (Ashish Singhi)
This commit is contained in:
parent
1d2c4bca56
commit
f9fce4caf0
|
@ -243,7 +243,7 @@ public class CellCounter {
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
Configuration conf = HBaseConfiguration.create();
|
Configuration conf = HBaseConfiguration.create();
|
||||||
String[] otherArgs = new GenericOptionsParser(conf, args).getRemainingArgs();
|
String[] otherArgs = new GenericOptionsParser(conf, args).getRemainingArgs();
|
||||||
if (otherArgs.length < 1) {
|
if (otherArgs.length < 2) {
|
||||||
System.err.println("ERROR: Wrong number of parameters: " + args.length);
|
System.err.println("ERROR: Wrong number of parameters: " + args.length);
|
||||||
System.err.println("Usage: CellCounter <tablename> <outputDir> <reportSeparator> " +
|
System.err.println("Usage: CellCounter <tablename> <outputDir> <reportSeparator> " +
|
||||||
"[^[regex pattern] or [Prefix] for row filter]] ");
|
"[^[regex pattern] or [Prefix] for row filter]] ");
|
||||||
|
|
|
@ -200,4 +200,31 @@ public class TestCellCounter {
|
||||||
FileUtil.fullyDelete(new File(outputPath));
|
FileUtil.fullyDelete(new File(outputPath));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test (timeout=300000)
|
||||||
|
public void TestCellCounterWithoutOutputDir() throws Exception {
|
||||||
|
PrintStream oldPrintStream = System.err;
|
||||||
|
SecurityManager SECURITY_MANAGER = System.getSecurityManager();
|
||||||
|
LauncherSecurityManager newSecurityManager= new LauncherSecurityManager();
|
||||||
|
System.setSecurityManager(newSecurityManager);
|
||||||
|
ByteArrayOutputStream data = new ByteArrayOutputStream();
|
||||||
|
String[] args = {"tableName"};
|
||||||
|
System.setErr(new PrintStream(data));
|
||||||
|
try {
|
||||||
|
System.setErr(new PrintStream(data));
|
||||||
|
try {
|
||||||
|
CellCounter.main(args);
|
||||||
|
fail("should be SecurityException");
|
||||||
|
} catch (SecurityException e) {
|
||||||
|
assertEquals(-1, newSecurityManager.getExitCode());
|
||||||
|
assertTrue(data.toString().contains("ERROR: Wrong number of parameters:"));
|
||||||
|
// should be information about usage
|
||||||
|
assertTrue(data.toString().contains("Usage:"));
|
||||||
|
}
|
||||||
|
|
||||||
|
} finally {
|
||||||
|
System.setErr(oldPrintStream);
|
||||||
|
System.setSecurityManager(SECURITY_MANAGER);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue