use of org.apache.oozie.cli.OozieCLI in project oozie by apache.
the class TestAuthFilterAuthOozieClient method testClientAuthMethod.
/**
* Test authentication
*/
public void testClientAuthMethod() throws Exception {
runTest(new Callable<Void>() {
public Void call() throws Exception {
String oozieUrl = getContextURL();
String[] args = new String[] { "admin", "-status", "-oozie", oozieUrl, "-auth", "SIMPLE" };
assertEquals(0, new OozieCLI().run(args));
return null;
}
}, null);
// bad method
runTest(new Callable<Void>() {
public Void call() throws Exception {
String oozieUrl = getContextURL();
String[] args = new String[] { "admin", "-status", "-oozie", oozieUrl, "-auth", "fake" };
assertEquals(-1, new OozieCLI().run(args));
return null;
}
}, null);
}
use of org.apache.oozie.cli.OozieCLI in project oozie by apache.
the class TestAuthFilterAuthOozieClient method testClientWithAnonymous.
public void testClientWithAnonymous() throws Exception {
Configuration conf = new Configuration(false);
conf.set("oozie.authentication.simple.anonymous.allowed", "true");
runTest(new Callable<Void>() {
public Void call() throws Exception {
String oozieUrl = getContextURL();
String[] args = new String[] { "admin", "-status", "-oozie", oozieUrl };
assertEquals(0, new OozieCLI().run(args));
return null;
}
}, conf);
}
use of org.apache.oozie.cli.OozieCLI in project oozie by apache.
the class TestOozieCLI method testNoRetryForError.
public void testNoRetryForError() throws Exception {
runTest(END_POINTS, SERVLET_CLASSES, false, new Callable<Void>() {
@Override
public Void call() throws Exception {
HeaderTestingVersionServlet.OOZIE_HEADERS.clear();
String oozieUrl = getContextURL();
String[] args = new String[] { "job", "-info", "aaa", "-oozie", oozieUrl, "-debug" };
OozieCLI cli = new OozieCLI();
CLIParser parser = cli.getCLIParser();
try {
final CLIParser.Command command = parser.parse(args);
cli.processCommand(parser, command);
} catch (Exception e) {
// Create connection will be successful, no retry
assertFalse(e.getMessage().contains("Error while connecting Oozie server"));
assertTrue(e.getMessage().contains("invalid job id [aaa]"));
}
return null;
}
});
}
use of org.apache.oozie.cli.OozieCLI in project oozie by apache.
the class TestOozieCLI method runOozieCLIAndGetStdout.
private String runOozieCLIAndGetStdout(String[] args) {
PrintStream original = System.out;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(baos);
String outStr = null;
System.out.flush();
try {
System.setOut(ps);
assertEquals(0, new OozieCLI().run(args));
System.out.flush();
outStr = baos.toString();
} finally {
System.setOut(original);
if (outStr != null) {
System.out.print(outStr);
}
System.out.flush();
}
return outStr;
}
use of org.apache.oozie.cli.OozieCLI in project oozie by apache.
the class TestOozieCLI method runOozieCLIAndGetStderr.
private String runOozieCLIAndGetStderr(String[] args) {
PrintStream original = System.err;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(baos);
String outStr = null;
System.err.flush();
try {
System.setErr(ps);
assertEquals(-1, new OozieCLI().run(args));
System.err.flush();
outStr = baos.toString();
} finally {
System.setErr(original);
if (outStr != null) {
System.err.print(outStr);
}
System.err.flush();
}
return outStr;
}
Aggregations