@Test public void testBadArguments4() { String[] args = new String[] {"-tMYINDEX", "-l1"}; String expectedMsg = "Unknown indextype 'MYINDEX' requested."; try { CreateIndex.main(args); fail("It should not be allowed to call CreateIndex with bad arguments"); } catch (SecurityException e) { // expected } String errMsg = pss.getErr(); int exitCode = pse.getExitValue(); assertEquals("Should have exit code 1, but was: " + exitCode, 1, exitCode); assertTrue( "The error message should contain '" + expectedMsg + "', but saw '" + errMsg + "'.", errMsg.contains(expectedMsg)); }
@Test public void testBadArguments1() { String[] args = new String[] {"-asdf"}; String expectedMsg = "Parsing of parameters failed: Unrecognized option: -a"; try { CreateIndex.main(args); fail("It should not be allowed to call CreateIndex with bad arguments"); } catch (SecurityException e) { // expected } String errMsg = pss.getErr(); int exitCode = pse.getExitValue(); assertEquals("Should have exit code 1, but was: " + exitCode, 1, exitCode); assertTrue( "The error message should contain '" + expectedMsg + "', but saw '" + errMsg + "'.", errMsg.contains(expectedMsg)); }
@Test public void testBadArguments3() { String[] args = new String[] {"-l1"}; // String expectedMsg = // "Some of the required parameters are missing: -t"; String expectedMsg = "Some of the required parameters are missing: Missing required option: t"; try { CreateIndex.main(args); fail("It should not be allowed to call CreateIndex with bad arguments"); } catch (SecurityException e) { // expected } String errMsg = pss.getErr(); int exitCode = pse.getExitValue(); assertEquals("Should have exit code 1, but was: " + exitCode, 1, exitCode); assertTrue( "The error message should contain '" + expectedMsg + "', but saw '" + errMsg + "'.", errMsg.contains(expectedMsg)); }