/** * 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); } }
/** * 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); } }
/** * 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); } }
/** * 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); } }
/** * 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); } }