Java 类org.apache.hadoop.hbase.util.LauncherSecurityManager 实例源码

项目:ditb    文件:TestCellCounter.java   
@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);
  }
}
项目:ditb    文件:TestImportExport.java   
/**
 * test main method. Import should print help and call System.exit
 */
@Test
public void testImportMain() throws Exception {
  PrintStream oldPrintStream = System.err;
  SecurityManager SECURITY_MANAGER = System.getSecurityManager();
  LauncherSecurityManager newSecurityManager= new LauncherSecurityManager();
  System.setSecurityManager(newSecurityManager);
  ByteArrayOutputStream data = new ByteArrayOutputStream();
  String[] args = {};
  System.setErr(new PrintStream(data));
  try {
    System.setErr(new PrintStream(data));
    Import.main(args);
    fail("should be SecurityException");
  } catch (SecurityException e) {
    assertEquals(-1, newSecurityManager.getExitCode());
    assertTrue(data.toString().contains("Wrong number of arguments:"));
    assertTrue(data.toString().contains("-Dimport.bulk.output=/path/for/output"));
    assertTrue(data.toString().contains("-Dimport.filter.class=<name of filter class>"));
    assertTrue(data.toString().contains("-Dimport.bulk.output=/path/for/output"));
    assertTrue(data.toString().contains("-Dmapreduce.reduce.speculative=false"));
  } finally {
    System.setErr(oldPrintStream);
    System.setSecurityManager(SECURITY_MANAGER);
  }
}
项目:ditb    文件:TestCopyTable.java   
/**
 * Test main method of CopyTable.
 */
@Test
public void testMainMethod() throws Exception {
  String[] emptyArgs = { "-h" };
  PrintStream oldWriter = System.err;
  ByteArrayOutputStream data = new ByteArrayOutputStream();
  PrintStream writer = new PrintStream(data);
  System.setErr(writer);
  SecurityManager SECURITY_MANAGER = System.getSecurityManager();
  LauncherSecurityManager newSecurityManager= new LauncherSecurityManager();
  System.setSecurityManager(newSecurityManager);
  try {
    CopyTable.main(emptyArgs);
    fail("should be exit");
  } catch (SecurityException e) {
    assertEquals(1, newSecurityManager.getExitCode());
  } finally {
    System.setErr(oldWriter);
    System.setSecurityManager(SECURITY_MANAGER);
  }
  assertTrue(data.toString().contains("rs.class"));
  // should print usage information
  assertTrue(data.toString().contains("Usage:"));
}
项目:pbase    文件:TestCellCounter.java   
@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);
  }
}
项目:pbase    文件:TestImportExport.java   
/**
 * test main method. Import should print help and call System.exit
 */
@Test
public void testImportMain() throws Exception {
  PrintStream oldPrintStream = System.err;
  SecurityManager SECURITY_MANAGER = System.getSecurityManager();
  LauncherSecurityManager newSecurityManager= new LauncherSecurityManager();
  System.setSecurityManager(newSecurityManager);
  ByteArrayOutputStream data = new ByteArrayOutputStream();
  String[] args = {};
  System.setErr(new PrintStream(data));
  try {
    System.setErr(new PrintStream(data));
    Import.main(args);
    fail("should be SecurityException");
  } catch (SecurityException e) {
    assertEquals(-1, newSecurityManager.getExitCode());
    assertTrue(data.toString().contains("Wrong number of arguments:"));
    assertTrue(data.toString().contains("-Dimport.bulk.output=/path/for/output"));
    assertTrue(data.toString().contains("-Dimport.filter.class=<name of filter class>"));
    assertTrue(data.toString().contains("-Dimport.bulk.output=/path/for/output"));
    assertTrue(data.toString().contains("-Dmapreduce.reduce.speculative=false"));
  } finally {
    System.setErr(oldPrintStream);
    System.setSecurityManager(SECURITY_MANAGER);
  }
}
项目:pbase    文件:TestCopyTable.java   
/**
 * Test main method of CopyTable.
 */
@Test
public void testMainMethod() throws Exception {
  String[] emptyArgs = { "-h" };
  PrintStream oldWriter = System.err;
  ByteArrayOutputStream data = new ByteArrayOutputStream();
  PrintStream writer = new PrintStream(data);
  System.setErr(writer);
  SecurityManager SECURITY_MANAGER = System.getSecurityManager();
  LauncherSecurityManager newSecurityManager= new LauncherSecurityManager();
  System.setSecurityManager(newSecurityManager);
  try {
    CopyTable.main(emptyArgs);
    fail("should be exit");
  } catch (SecurityException e) {
    assertEquals(1, newSecurityManager.getExitCode());
  } finally {
    System.setErr(oldWriter);
    System.setSecurityManager(SECURITY_MANAGER);
  }
  assertTrue(data.toString().contains("rs.class"));
  // should print usage information
  assertTrue(data.toString().contains("Usage:"));
}
项目:HIndex    文件:TestImportExport.java   
/**
 * test main method. Import should print help and call System.exit
 */
@Test
public void testImportMain() throws Exception {
  PrintStream oldPrintStream = System.err;
  SecurityManager SECURITY_MANAGER = System.getSecurityManager();
  LauncherSecurityManager newSecurityManager= new LauncherSecurityManager();
  System.setSecurityManager(newSecurityManager);
  ByteArrayOutputStream data = new ByteArrayOutputStream();
  String[] args = {};
  System.setErr(new PrintStream(data));
  try {
    System.setErr(new PrintStream(data));
    Import.main(args);
    fail("should be SecurityException");
  } catch (SecurityException e) {
    assertEquals(-1, newSecurityManager.getExitCode());
    assertTrue(data.toString().contains("Wrong number of arguments:"));
    assertTrue(data.toString().contains("-Dimport.bulk.output=/path/for/output"));
    assertTrue(data.toString().contains("-Dimport.filter.class=<name of filter class>"));
    assertTrue(data.toString().contains("-Dimport.bulk.output=/path/for/output"));
    assertTrue(data.toString().contains("-Dmapred.reduce.tasks.speculative.execution=false"));
  } finally {
    System.setErr(oldPrintStream);
    System.setSecurityManager(SECURITY_MANAGER);
  }
}
项目:HIndex    文件:TestCopyTable.java   
/**
 * Test main method of CopyTable.
 */
@Test
public void testMainMethod() throws Exception {
  String[] emptyArgs = { "-h" };
  PrintStream oldWriter = System.err;
  ByteArrayOutputStream data = new ByteArrayOutputStream();
  PrintStream writer = new PrintStream(data);
  System.setErr(writer);
  SecurityManager SECURITY_MANAGER = System.getSecurityManager();
  LauncherSecurityManager newSecurityManager= new LauncherSecurityManager();
  System.setSecurityManager(newSecurityManager);
  try {
    CopyTable.main(emptyArgs);
    fail("should be exit");
  } catch (SecurityException e) {
    assertEquals(1, newSecurityManager.getExitCode());
  } finally {
    System.setErr(oldWriter);
    System.setSecurityManager(SECURITY_MANAGER);
  }
  assertTrue(data.toString().contains("rs.class"));
  // should print usage information
  assertTrue(data.toString().contains("Usage:"));
}
项目:hbase    文件:TestImportExport.java   
/**
 * test main method. Import should print help and call System.exit
 */
@Test
public void testImportMain() throws Throwable {
  PrintStream oldPrintStream = System.err;
  SecurityManager SECURITY_MANAGER = System.getSecurityManager();
  LauncherSecurityManager newSecurityManager= new LauncherSecurityManager();
  System.setSecurityManager(newSecurityManager);
  ByteArrayOutputStream data = new ByteArrayOutputStream();
  String[] args = {};
  System.setErr(new PrintStream(data));
  try {
    System.setErr(new PrintStream(data));
    Import.main(args);
    fail("should be SecurityException");
  } catch (SecurityException e) {
    assertEquals(-1, newSecurityManager.getExitCode());
    assertTrue(data.toString().contains("Wrong number of arguments:"));
    assertTrue(data.toString().contains("-Dimport.bulk.output=/path/for/output"));
    assertTrue(data.toString().contains("-Dimport.filter.class=<name of filter class>"));
    assertTrue(data.toString().contains("-Dimport.bulk.output=/path/for/output"));
    assertTrue(data.toString().contains("-Dmapreduce.reduce.speculative=false"));
  } finally {
    System.setErr(oldPrintStream);
    System.setSecurityManager(SECURITY_MANAGER);
  }
}
项目:hbase    文件:TestCopyTable.java   
/**
 * Test main method of CopyTable.
 */
@Test
public void testMainMethod() throws Exception {
  String[] emptyArgs = { "-h" };
  PrintStream oldWriter = System.err;
  ByteArrayOutputStream data = new ByteArrayOutputStream();
  PrintStream writer = new PrintStream(data);
  System.setErr(writer);
  SecurityManager SECURITY_MANAGER = System.getSecurityManager();
  LauncherSecurityManager newSecurityManager= new LauncherSecurityManager();
  System.setSecurityManager(newSecurityManager);
  try {
    CopyTable.main(emptyArgs);
    fail("should be exit");
  } catch (SecurityException e) {
    assertEquals(1, newSecurityManager.getExitCode());
  } finally {
    System.setErr(oldWriter);
    System.setSecurityManager(SECURITY_MANAGER);
  }
  assertTrue(data.toString().contains("rs.class"));
  // should print usage information
  assertTrue(data.toString().contains("Usage:"));
}
项目:PyroDB    文件:TestImportExport.java   
/**
 * test main method. Import should print help and call System.exit
 */
@Test
public void testImportMain() throws Exception {
  PrintStream oldPrintStream = System.err;
  SecurityManager SECURITY_MANAGER = System.getSecurityManager();
  LauncherSecurityManager newSecurityManager= new LauncherSecurityManager();
  System.setSecurityManager(newSecurityManager);
  ByteArrayOutputStream data = new ByteArrayOutputStream();
  String[] args = {};
  System.setErr(new PrintStream(data));
  try {
    System.setErr(new PrintStream(data));
    Import.main(args);
    fail("should be SecurityException");
  } catch (SecurityException e) {
    assertEquals(-1, newSecurityManager.getExitCode());
    assertTrue(data.toString().contains("Wrong number of arguments:"));
    assertTrue(data.toString().contains("-Dimport.bulk.output=/path/for/output"));
    assertTrue(data.toString().contains("-Dimport.filter.class=<name of filter class>"));
    assertTrue(data.toString().contains("-Dimport.bulk.output=/path/for/output"));
    assertTrue(data.toString().contains("-Dmapreduce.reduce.speculative=false"));
  } finally {
    System.setErr(oldPrintStream);
    System.setSecurityManager(SECURITY_MANAGER);
  }
}
项目:PyroDB    文件:TestCopyTable.java   
/**
 * Test main method of CopyTable.
 */
@Test
public void testMainMethod() throws Exception {
  String[] emptyArgs = { "-h" };
  PrintStream oldWriter = System.err;
  ByteArrayOutputStream data = new ByteArrayOutputStream();
  PrintStream writer = new PrintStream(data);
  System.setErr(writer);
  SecurityManager SECURITY_MANAGER = System.getSecurityManager();
  LauncherSecurityManager newSecurityManager= new LauncherSecurityManager();
  System.setSecurityManager(newSecurityManager);
  try {
    CopyTable.main(emptyArgs);
    fail("should be exit");
  } catch (SecurityException e) {
    assertEquals(1, newSecurityManager.getExitCode());
  } finally {
    System.setErr(oldWriter);
    System.setSecurityManager(SECURITY_MANAGER);
  }
  assertTrue(data.toString().contains("rs.class"));
  // should print usage information
  assertTrue(data.toString().contains("Usage:"));
}
项目:ditb    文件:TestCellCounter.java   
/**
 * Test main method of CellCounter
 */
@Test (timeout=300000)
public void testCellCounterMain() throws Exception {

  PrintStream oldPrintStream = System.err;
  SecurityManager SECURITY_MANAGER = System.getSecurityManager();
  LauncherSecurityManager newSecurityManager= new LauncherSecurityManager();
  System.setSecurityManager(newSecurityManager);
  ByteArrayOutputStream data = new ByteArrayOutputStream();
  String[] args = {};
  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);
  }
}
项目:ditb    文件:TestImportExport.java   
/**
 * test main method. Export should print help and call System.exit
 */
@Test
public void testExportMain() throws Exception {
  PrintStream oldPrintStream = System.err;
  SecurityManager SECURITY_MANAGER = System.getSecurityManager();
  LauncherSecurityManager newSecurityManager= new LauncherSecurityManager();
  System.setSecurityManager(newSecurityManager);
  ByteArrayOutputStream data = new ByteArrayOutputStream();
  String[] args = {};
  System.setErr(new PrintStream(data));
  try {
    System.setErr(new PrintStream(data));
    Export.main(args);
    fail("should be SecurityException");
  } catch (SecurityException e) {
    assertEquals(-1, newSecurityManager.getExitCode());
    assertTrue(data.toString().contains("Wrong number of arguments:"));
    assertTrue(data.toString().contains(
            "Usage: Export [-D <property=value>]* <tablename> <outputdir> [<versions> " +
            "[<starttime> [<endtime>]] [^[regex pattern] or [Prefix] to filter]]"));
    assertTrue(data.toString().contains("-D hbase.mapreduce.scan.column.family=<familyName>"));
    assertTrue(data.toString().contains("-D hbase.mapreduce.include.deleted.rows=true"));
    assertTrue(data.toString().contains("-Dhbase.client.scanner.caching=100"));
    assertTrue(data.toString().contains("-Dmapreduce.map.speculative=false"));
    assertTrue(data.toString().contains("-Dmapreduce.reduce.speculative=false"));
    assertTrue(data.toString().contains("-Dhbase.export.scanner.batch=10"));
  } finally {
    System.setErr(oldPrintStream);
    System.setSecurityManager(SECURITY_MANAGER);
  }
}
项目:ditb    文件:TestWALPlayer.java   
/**
 * Test main method
 */
@Test
public void testMainMethod() throws Exception {

  PrintStream oldPrintStream = System.err;
  SecurityManager SECURITY_MANAGER = System.getSecurityManager();
  LauncherSecurityManager newSecurityManager= new LauncherSecurityManager();
  System.setSecurityManager(newSecurityManager);
  ByteArrayOutputStream data = new ByteArrayOutputStream();
  String[] args = {};
  System.setErr(new PrintStream(data));
  try {
    System.setErr(new PrintStream(data));
    try {
      WALPlayer.main(args);
      fail("should be SecurityException");
    } catch (SecurityException e) {
      assertEquals(-1, newSecurityManager.getExitCode());
      assertTrue(data.toString().contains("ERROR: Wrong number of arguments:"));
      assertTrue(data.toString().contains("Usage: WALPlayer [options] <wal inputdir>" +
          " <tables> [<tableMappings>]"));
      assertTrue(data.toString().contains("-Dwal.bulk.output=/path/for/output"));
    }

  } finally {
    System.setErr(oldPrintStream);
    System.setSecurityManager(SECURITY_MANAGER);
  }

}
项目:ditb    文件:TestMapReduceExamples.java   
/**
 * Test main method of SampleUploader.
 */
@Test
public void testMainSampleUploader() throws Exception {
  PrintStream oldPrintStream = System.err;
  SecurityManager SECURITY_MANAGER = System.getSecurityManager();
  LauncherSecurityManager newSecurityManager= new LauncherSecurityManager();
  System.setSecurityManager(newSecurityManager);
  ByteArrayOutputStream data = new ByteArrayOutputStream();
  String[] args = {};
  System.setErr(new PrintStream(data));
  try {
    System.setErr(new PrintStream(data));

    try {
      SampleUploader.main(args);
      fail("should be SecurityException");
    } catch (SecurityException e) {
      assertEquals(-1, newSecurityManager.getExitCode());
      assertTrue(data.toString().contains("Wrong number of arguments:"));
      assertTrue(data.toString().contains("Usage: SampleUploader <input> <tablename>"));
    }

  } finally {
    System.setErr(oldPrintStream);
    System.setSecurityManager(SECURITY_MANAGER);
  }

}
项目:ditb    文件:TestMapReduceExamples.java   
/**
 * Test main method of IndexBuilder
 */
@Test
public void testMainIndexBuilder() throws Exception {
  PrintStream oldPrintStream = System.err;
  SecurityManager SECURITY_MANAGER = System.getSecurityManager();
  LauncherSecurityManager newSecurityManager= new LauncherSecurityManager();
  System.setSecurityManager(newSecurityManager);
  ByteArrayOutputStream data = new ByteArrayOutputStream();
  String[] args = {};
  System.setErr(new PrintStream(data));
  try {
    System.setErr(new PrintStream(data));
    try {
      IndexBuilder.main(args);
      fail("should be SecurityException");
    } catch (SecurityException e) {
      assertEquals(-1, newSecurityManager.getExitCode());
      assertTrue(data.toString().contains("arguments supplied, required: 3"));
      assertTrue(data.toString().contains(
          "Usage: IndexBuilder <TABLE_NAME> <COLUMN_FAMILY> <ATTR> [<ATTR> ...]"));
    }

  } finally {
    System.setErr(oldPrintStream);
    System.setSecurityManager(SECURITY_MANAGER);
  }

}
项目:pbase    文件:TestCellCounter.java   
/**
 * Test main method of CellCounter
 */
@Test (timeout=300000)
public void testCellCounterMain() throws Exception {

  PrintStream oldPrintStream = System.err;
  SecurityManager SECURITY_MANAGER = System.getSecurityManager();
  LauncherSecurityManager newSecurityManager= new LauncherSecurityManager();
  System.setSecurityManager(newSecurityManager);
  ByteArrayOutputStream data = new ByteArrayOutputStream();
  String[] args = {};
  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);
  }
}
项目:pbase    文件:TestImportExport.java   
/**
 * test main method. Export should print help and call System.exit
 */
@Test
public void testExportMain() throws Exception {
  PrintStream oldPrintStream = System.err;
  SecurityManager SECURITY_MANAGER = System.getSecurityManager();
  LauncherSecurityManager newSecurityManager= new LauncherSecurityManager();
  System.setSecurityManager(newSecurityManager);
  ByteArrayOutputStream data = new ByteArrayOutputStream();
  String[] args = {};
  System.setErr(new PrintStream(data));
  try {
    System.setErr(new PrintStream(data));
    Export.main(args);
    fail("should be SecurityException");
  } catch (SecurityException e) {
    assertEquals(-1, newSecurityManager.getExitCode());
    assertTrue(data.toString().contains("Wrong number of arguments:"));
    assertTrue(data.toString().contains(
            "Usage: Export [-D <property=value>]* <tablename> <outputdir> [<versions> " +
            "[<starttime> [<endtime>]] [^[regex pattern] or [Prefix] to filter]]"));
    assertTrue(data.toString().contains("-D hbase.mapreduce.scan.column.family=<familyName>"));
    assertTrue(data.toString().contains("-D hbase.mapreduce.include.deleted.rows=true"));
    assertTrue(data.toString().contains("-Dhbase.client.scanner.caching=100"));
    assertTrue(data.toString().contains("-Dmapreduce.map.speculative=false"));
    assertTrue(data.toString().contains("-Dmapreduce.reduce.speculative=false"));
    assertTrue(data.toString().contains("-Dhbase.export.scanner.batch=10"));
  } finally {
    System.setErr(oldPrintStream);
    System.setSecurityManager(SECURITY_MANAGER);
  }
}
项目:pbase    文件:TestWALPlayer.java   
/**
 * Test main method
 */
@Test
public void testMainMethod() throws Exception {

  PrintStream oldPrintStream = System.err;
  SecurityManager SECURITY_MANAGER = System.getSecurityManager();
  LauncherSecurityManager newSecurityManager= new LauncherSecurityManager();
  System.setSecurityManager(newSecurityManager);
  ByteArrayOutputStream data = new ByteArrayOutputStream();
  String[] args = {};
  System.setErr(new PrintStream(data));
  try {
    System.setErr(new PrintStream(data));
    try {
      WALPlayer.main(args);
      fail("should be SecurityException");
    } catch (SecurityException e) {
      assertEquals(-1, newSecurityManager.getExitCode());
      assertTrue(data.toString().contains("ERROR: Wrong number of arguments:"));
      assertTrue(data.toString().contains("Usage: WALPlayer [options] <wal inputdir>" +
          " <tables> [<tableMappings>]"));
      assertTrue(data.toString().contains("-Dwal.bulk.output=/path/for/output"));
    }

  } finally {
    System.setErr(oldPrintStream);
    System.setSecurityManager(SECURITY_MANAGER);
  }

}
项目:pbase    文件:TestMapReduceExamples.java   
/**
 * Test main method of SampleUploader.
 */
@Test
public void testMainSampleUploader() throws Exception {
  PrintStream oldPrintStream = System.err;
  SecurityManager SECURITY_MANAGER = System.getSecurityManager();
  LauncherSecurityManager newSecurityManager= new LauncherSecurityManager();
  System.setSecurityManager(newSecurityManager);
  ByteArrayOutputStream data = new ByteArrayOutputStream();
  String[] args = {};
  System.setErr(new PrintStream(data));
  try {
    System.setErr(new PrintStream(data));

    try {
      SampleUploader.main(args);
      fail("should be SecurityException");
    } catch (SecurityException e) {
      assertEquals(-1, newSecurityManager.getExitCode());
      assertTrue(data.toString().contains("Wrong number of arguments:"));
      assertTrue(data.toString().contains("Usage: SampleUploader <input> <tablename>"));
    }

  } finally {
    System.setErr(oldPrintStream);
    System.setSecurityManager(SECURITY_MANAGER);
  }

}
项目:pbase    文件:TestMapReduceExamples.java   
/**
 * Test main method of IndexBuilder
 */
@Test
public void testMainIndexBuilder() throws Exception {
  PrintStream oldPrintStream = System.err;
  SecurityManager SECURITY_MANAGER = System.getSecurityManager();
  LauncherSecurityManager newSecurityManager= new LauncherSecurityManager();
  System.setSecurityManager(newSecurityManager);
  ByteArrayOutputStream data = new ByteArrayOutputStream();
  String[] args = {};
  System.setErr(new PrintStream(data));
  try {
    System.setErr(new PrintStream(data));
    try {
      IndexBuilder.main(args);
      fail("should be SecurityException");
    } catch (SecurityException e) {
      assertEquals(-1, newSecurityManager.getExitCode());
      assertTrue(data.toString().contains("arguments supplied, required: 3"));
      assertTrue(data.toString().contains(
          "Usage: IndexBuilder <TABLE_NAME> <COLUMN_FAMILY> <ATTR> [<ATTR> ...]"));
    }

  } finally {
    System.setErr(oldPrintStream);
    System.setSecurityManager(SECURITY_MANAGER);
  }

}
项目:HIndex    文件:TestCellCounter.java   
/**
 * Test main method of CellCounter
 */
@Test (timeout=300000)
public void testCellCounterMain() throws Exception {

  PrintStream oldPrintStream = System.err;
  SecurityManager SECURITY_MANAGER = System.getSecurityManager();
  LauncherSecurityManager newSecurityManager= new LauncherSecurityManager();
  System.setSecurityManager(newSecurityManager);
  ByteArrayOutputStream data = new ByteArrayOutputStream();
  String[] args = {};
  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);
  }
}
项目:HIndex    文件:TestImportExport.java   
/**
 * test main method. Export should print help and call System.exit
 */
@Test
public void testExportMain() throws Exception {
  PrintStream oldPrintStream = System.err;
  SecurityManager SECURITY_MANAGER = System.getSecurityManager();
  LauncherSecurityManager newSecurityManager= new LauncherSecurityManager();
  System.setSecurityManager(newSecurityManager);
  ByteArrayOutputStream data = new ByteArrayOutputStream();
  String[] args = {};
  System.setErr(new PrintStream(data));
  try {
    System.setErr(new PrintStream(data));
    Export.main(args);
    fail("should be SecurityException");
  } catch (SecurityException e) {
    assertEquals(-1, newSecurityManager.getExitCode());
    assertTrue(data.toString().contains("Wrong number of arguments:"));
    assertTrue(data.toString().contains(
            "Usage: Export [-D <property=value>]* <tablename> <outputdir> [<versions> " +
            "[<starttime> [<endtime>]] [^[regex pattern] or [Prefix] to filter]]"));
    assertTrue(data.toString().contains("-D hbase.mapreduce.scan.column.family=<familyName>"));
    assertTrue(data.toString().contains("-D hbase.mapreduce.include.deleted.rows=true"));
    assertTrue(data.toString().contains("-Dhbase.client.scanner.caching=100"));
    assertTrue(data.toString().contains("-Dmapred.map.tasks.speculative.execution=false"));
    assertTrue(data.toString().contains("-Dmapred.reduce.tasks.speculative.execution=false"));
    assertTrue(data.toString().contains("-Dhbase.export.scanner.batch=10"));
  } finally {
    System.setErr(oldPrintStream);
    System.setSecurityManager(SECURITY_MANAGER);
  }
}
项目:HIndex    文件:TestWALPlayer.java   
/**
 * Test main method
 */
@Test
public void testMainMethod() throws Exception {

  PrintStream oldPrintStream = System.err;
  SecurityManager SECURITY_MANAGER = System.getSecurityManager();
  LauncherSecurityManager newSecurityManager= new LauncherSecurityManager();
  System.setSecurityManager(newSecurityManager);
  ByteArrayOutputStream data = new ByteArrayOutputStream();
  String[] args = {};
  System.setErr(new PrintStream(data));
  try {
    System.setErr(new PrintStream(data));
    try {
      WALPlayer.main(args);
      fail("should be SecurityException");
    } catch (SecurityException e) {
      assertEquals(-1, newSecurityManager.getExitCode());
      assertTrue(data.toString().contains("ERROR: Wrong number of arguments:"));
      assertTrue(data.toString().contains("Usage: WALPlayer [options] <wal inputdir>" +
          " <tables> [<tableMappings>]"));
      assertTrue(data.toString().contains("-Dhlog.bulk.output=/path/for/output"));
    }

  } finally {
    System.setErr(oldPrintStream);
    System.setSecurityManager(SECURITY_MANAGER);
  }

}
项目:HIndex    文件:TestMapReduceExamples.java   
/**
 * Test main method of SampleUploader.
 */
@Test
public void testMainSampleUploader() throws Exception {
  PrintStream oldPrintStream = System.err;
  SecurityManager SECURITY_MANAGER = System.getSecurityManager();
  LauncherSecurityManager newSecurityManager= new LauncherSecurityManager();
  System.setSecurityManager(newSecurityManager);
  ByteArrayOutputStream data = new ByteArrayOutputStream();
  String[] args = {};
  System.setErr(new PrintStream(data));
  try {
    System.setErr(new PrintStream(data));

    try {
      SampleUploader.main(args);
      fail("should be SecurityException");
    } catch (SecurityException e) {
      assertEquals(-1, newSecurityManager.getExitCode());
      assertTrue(data.toString().contains("Wrong number of arguments:"));
      assertTrue(data.toString().contains("Usage: SampleUploader <input> <tablename>"));
    }

  } finally {
    System.setErr(oldPrintStream);
    System.setSecurityManager(SECURITY_MANAGER);
  }

}
项目:HIndex    文件:TestMapReduceExamples.java   
/**
 * Test main method of IndexBuilder
 */
@Test
public void testMainIndexBuilder() throws Exception {
  PrintStream oldPrintStream = System.err;
  SecurityManager SECURITY_MANAGER = System.getSecurityManager();
  LauncherSecurityManager newSecurityManager= new LauncherSecurityManager();
  System.setSecurityManager(newSecurityManager);
  ByteArrayOutputStream data = new ByteArrayOutputStream();
  String[] args = {};
  System.setErr(new PrintStream(data));
  try {
    System.setErr(new PrintStream(data));
    try {
      IndexBuilder.main(args);
      fail("should be SecurityException");
    } catch (SecurityException e) {
      assertEquals(-1, newSecurityManager.getExitCode());
      assertTrue(data.toString().contains("arguments supplied, required: 3"));
      assertTrue(data.toString().contains(
          "Usage: IndexBuilder <TABLE_NAME> <COLUMN_FAMILY> <ATTR> [<ATTR> ...]"));
    }

  } finally {
    System.setErr(oldPrintStream);
    System.setSecurityManager(SECURITY_MANAGER);
  }

}
项目:hbase    文件:TestCellCounter.java   
/**
 * Test main method of CellCounter
 */
@Test (timeout=300000)
public void testCellCounterMain() throws Exception {

  PrintStream oldPrintStream = System.err;
  SecurityManager SECURITY_MANAGER = System.getSecurityManager();
  LauncherSecurityManager newSecurityManager= new LauncherSecurityManager();
  System.setSecurityManager(newSecurityManager);
  ByteArrayOutputStream data = new ByteArrayOutputStream();
  String[] args = {};
  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);
  }
}
项目:hbase    文件:TestImportExport.java   
/**
 * test main method. Export should print help and call System.exit
 */
@Test
public void testExportMain() throws Throwable {
  PrintStream oldPrintStream = System.err;
  SecurityManager SECURITY_MANAGER = System.getSecurityManager();
  LauncherSecurityManager newSecurityManager= new LauncherSecurityManager();
  System.setSecurityManager(newSecurityManager);
  ByteArrayOutputStream data = new ByteArrayOutputStream();
  String[] args = {};
  System.setErr(new PrintStream(data));
  try {
    System.setErr(new PrintStream(data));
    runExportMain(args);
    fail("should be SecurityException");
  } catch (SecurityException e) {
    assertEquals(-1, newSecurityManager.getExitCode());
    String errMsg = data.toString();
    assertTrue(errMsg.contains("Wrong number of arguments:"));
    assertTrue(errMsg.contains(
            "Usage: Export [-D <property=value>]* <tablename> <outputdir> [<versions> " +
            "[<starttime> [<endtime>]] [^[regex pattern] or [Prefix] to filter]]"));
    assertTrue(
      errMsg.contains("-D hbase.mapreduce.scan.column.family=<family1>,<family2>, ..."));
    assertTrue(errMsg.contains("-D hbase.mapreduce.include.deleted.rows=true"));
    assertTrue(errMsg.contains("-D hbase.client.scanner.caching=100"));
    assertTrue(errMsg.contains("-D hbase.export.scanner.batch=10"));
    assertTrue(errMsg.contains("-D hbase.export.scanner.caching=100"));
  } finally {
    System.setErr(oldPrintStream);
    System.setSecurityManager(SECURITY_MANAGER);
  }
}
项目:hbase    文件:TestWALPlayer.java   
/**
 * Test main method
 */
@Test
public void testMainMethod() throws Exception {

  PrintStream oldPrintStream = System.err;
  SecurityManager SECURITY_MANAGER = System.getSecurityManager();
  LauncherSecurityManager newSecurityManager= new LauncherSecurityManager();
  System.setSecurityManager(newSecurityManager);
  ByteArrayOutputStream data = new ByteArrayOutputStream();
  String[] args = {};
  System.setErr(new PrintStream(data));
  try {
    System.setErr(new PrintStream(data));
    try {
      WALPlayer.main(args);
      fail("should be SecurityException");
    } catch (SecurityException e) {
      assertEquals(-1, newSecurityManager.getExitCode());
      assertTrue(data.toString().contains("ERROR: Wrong number of arguments:"));
      assertTrue(data.toString().contains("Usage: WALPlayer [options] <wal inputdir>" +
          " <tables> [<tableMappings>]"));
      assertTrue(data.toString().contains("-Dwal.bulk.output=/path/for/output"));
    }

  } finally {
    System.setErr(oldPrintStream);
    System.setSecurityManager(SECURITY_MANAGER);
  }

}
项目:hbase    文件:TestMapReduceExamples.java   
/**
 * Test main method of SampleUploader.
 */
@Test
public void testMainSampleUploader() throws Exception {
  PrintStream oldPrintStream = System.err;
  SecurityManager SECURITY_MANAGER = System.getSecurityManager();
  LauncherSecurityManager newSecurityManager= new LauncherSecurityManager();
  System.setSecurityManager(newSecurityManager);
  ByteArrayOutputStream data = new ByteArrayOutputStream();
  String[] args = {};
  System.setErr(new PrintStream(data));
  try {
    System.setErr(new PrintStream(data));

    try {
      SampleUploader.main(args);
      fail("should be SecurityException");
    } catch (SecurityException e) {
      assertEquals(-1, newSecurityManager.getExitCode());
      assertTrue(data.toString().contains("Wrong number of arguments:"));
      assertTrue(data.toString().contains("Usage: SampleUploader <input> <tablename>"));
    }

  } finally {
    System.setErr(oldPrintStream);
    System.setSecurityManager(SECURITY_MANAGER);
  }

}
项目:hbase    文件:TestMapReduceExamples.java   
/**
 * Test main method of IndexBuilder
 */
@Test
public void testMainIndexBuilder() throws Exception {
  PrintStream oldPrintStream = System.err;
  SecurityManager SECURITY_MANAGER = System.getSecurityManager();
  LauncherSecurityManager newSecurityManager= new LauncherSecurityManager();
  System.setSecurityManager(newSecurityManager);
  ByteArrayOutputStream data = new ByteArrayOutputStream();
  String[] args = {};
  System.setErr(new PrintStream(data));
  try {
    System.setErr(new PrintStream(data));
    try {
      IndexBuilder.main(args);
      fail("should be SecurityException");
    } catch (SecurityException e) {
      assertEquals(-1, newSecurityManager.getExitCode());
      assertTrue(data.toString().contains("arguments supplied, required: 3"));
      assertTrue(data.toString().contains(
          "Usage: IndexBuilder <TABLE_NAME> <COLUMN_FAMILY> <ATTR> [<ATTR> ...]"));
    }

  } finally {
    System.setErr(oldPrintStream);
    System.setSecurityManager(SECURITY_MANAGER);
  }

}
项目:PyroDB    文件:TestCellCounter.java   
/**
 * Test main method of CellCounter
 */
@Test (timeout=300000)
public void testCellCounterMain() throws Exception {

  PrintStream oldPrintStream = System.err;
  SecurityManager SECURITY_MANAGER = System.getSecurityManager();
  LauncherSecurityManager newSecurityManager= new LauncherSecurityManager();
  System.setSecurityManager(newSecurityManager);
  ByteArrayOutputStream data = new ByteArrayOutputStream();
  String[] args = {};
  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);
  }
}
项目:PyroDB    文件:TestImportExport.java   
/**
 * test main method. Export should print help and call System.exit
 */
@Test
public void testExportMain() throws Exception {
  PrintStream oldPrintStream = System.err;
  SecurityManager SECURITY_MANAGER = System.getSecurityManager();
  LauncherSecurityManager newSecurityManager= new LauncherSecurityManager();
  System.setSecurityManager(newSecurityManager);
  ByteArrayOutputStream data = new ByteArrayOutputStream();
  String[] args = {};
  System.setErr(new PrintStream(data));
  try {
    System.setErr(new PrintStream(data));
    Export.main(args);
    fail("should be SecurityException");
  } catch (SecurityException e) {
    assertEquals(-1, newSecurityManager.getExitCode());
    assertTrue(data.toString().contains("Wrong number of arguments:"));
    assertTrue(data.toString().contains(
            "Usage: Export [-D <property=value>]* <tablename> <outputdir> [<versions> " +
            "[<starttime> [<endtime>]] [^[regex pattern] or [Prefix] to filter]]"));
    assertTrue(data.toString().contains("-D hbase.mapreduce.scan.column.family=<familyName>"));
    assertTrue(data.toString().contains("-D hbase.mapreduce.include.deleted.rows=true"));
    assertTrue(data.toString().contains("-Dhbase.client.scanner.caching=100"));
    assertTrue(data.toString().contains("-Dmapreduce.map.speculative=false"));
    assertTrue(data.toString().contains("-Dmapreduce.reduce.speculative=false"));
    assertTrue(data.toString().contains("-Dhbase.export.scanner.batch=10"));
  } finally {
    System.setErr(oldPrintStream);
    System.setSecurityManager(SECURITY_MANAGER);
  }
}
项目:PyroDB    文件:TestWALPlayer.java   
/**
 * Test main method
 */
@Test
public void testMainMethod() throws Exception {

  PrintStream oldPrintStream = System.err;
  SecurityManager SECURITY_MANAGER = System.getSecurityManager();
  LauncherSecurityManager newSecurityManager= new LauncherSecurityManager();
  System.setSecurityManager(newSecurityManager);
  ByteArrayOutputStream data = new ByteArrayOutputStream();
  String[] args = {};
  System.setErr(new PrintStream(data));
  try {
    System.setErr(new PrintStream(data));
    try {
      WALPlayer.main(args);
      fail("should be SecurityException");
    } catch (SecurityException e) {
      assertEquals(-1, newSecurityManager.getExitCode());
      assertTrue(data.toString().contains("ERROR: Wrong number of arguments:"));
      assertTrue(data.toString().contains("Usage: WALPlayer [options] <wal inputdir>" +
          " <tables> [<tableMappings>]"));
      assertTrue(data.toString().contains("-Dhlog.bulk.output=/path/for/output"));
    }

  } finally {
    System.setErr(oldPrintStream);
    System.setSecurityManager(SECURITY_MANAGER);
  }

}
项目:PyroDB    文件:TestMapReduceExamples.java   
/**
 * Test main method of SampleUploader.
 */
@Test
public void testMainSampleUploader() throws Exception {
  PrintStream oldPrintStream = System.err;
  SecurityManager SECURITY_MANAGER = System.getSecurityManager();
  LauncherSecurityManager newSecurityManager= new LauncherSecurityManager();
  System.setSecurityManager(newSecurityManager);
  ByteArrayOutputStream data = new ByteArrayOutputStream();
  String[] args = {};
  System.setErr(new PrintStream(data));
  try {
    System.setErr(new PrintStream(data));

    try {
      SampleUploader.main(args);
      fail("should be SecurityException");
    } catch (SecurityException e) {
      assertEquals(-1, newSecurityManager.getExitCode());
      assertTrue(data.toString().contains("Wrong number of arguments:"));
      assertTrue(data.toString().contains("Usage: SampleUploader <input> <tablename>"));
    }

  } finally {
    System.setErr(oldPrintStream);
    System.setSecurityManager(SECURITY_MANAGER);
  }

}
项目:PyroDB    文件:TestMapReduceExamples.java   
/**
 * Test main method of IndexBuilder
 */
@Test
public void testMainIndexBuilder() throws Exception {
  PrintStream oldPrintStream = System.err;
  SecurityManager SECURITY_MANAGER = System.getSecurityManager();
  LauncherSecurityManager newSecurityManager= new LauncherSecurityManager();
  System.setSecurityManager(newSecurityManager);
  ByteArrayOutputStream data = new ByteArrayOutputStream();
  String[] args = {};
  System.setErr(new PrintStream(data));
  try {
    System.setErr(new PrintStream(data));
    try {
      IndexBuilder.main(args);
      fail("should be SecurityException");
    } catch (SecurityException e) {
      assertEquals(-1, newSecurityManager.getExitCode());
      assertTrue(data.toString().contains("arguments supplied, required: 3"));
      assertTrue(data.toString().contains(
          "Usage: IndexBuilder <TABLE_NAME> <COLUMN_FAMILY> <ATTR> [<ATTR> ...]"));
    }

  } finally {
    System.setErr(oldPrintStream);
    System.setSecurityManager(SECURITY_MANAGER);
  }

}