use of org.elasticsearch.cli.MockTerminal in project elasticsearch by elastic.
the class ListPluginsCommandTests method listPlugins.
static MockTerminal listPlugins(Path home, String[] args) throws Exception {
String[] argsAndHome = new String[args.length + 1];
System.arraycopy(args, 0, argsAndHome, 0, args.length);
argsAndHome[args.length] = "-Epath.home=" + home;
MockTerminal terminal = new MockTerminal();
int status = new ListPluginsCommand() {
@Override
protected boolean addShutdownHook() {
return false;
}
}.main(argsAndHome, terminal);
assertEquals(ExitCodes.OK, status);
return terminal;
}
use of org.elasticsearch.cli.MockTerminal in project elasticsearch by elastic.
the class InstallPluginCommandTests method testOfficialPluginsHelpSorted.
public void testOfficialPluginsHelpSorted() throws Exception {
MockTerminal terminal = new MockTerminal();
new InstallPluginCommand() {
@Override
protected boolean addShutdownHook() {
return false;
}
}.main(new String[] { "--help" }, terminal);
try (BufferedReader reader = new BufferedReader(new StringReader(terminal.getOutput()))) {
String line = reader.readLine();
// first find the beginning of our list of official plugins
while (line.endsWith("may be installed by name:") == false) {
line = reader.readLine();
}
// now check each line compares greater than the last, until we reach an empty line
String prev = reader.readLine();
line = reader.readLine();
while (line != null && line.trim().isEmpty() == false) {
assertTrue(prev + " < " + line, prev.compareTo(line) < 0);
prev = line;
line = reader.readLine();
}
}
}
use of org.elasticsearch.cli.MockTerminal in project elasticsearch by elastic.
the class InstallPluginCommandTests method testQuietFlagEnabled.
public void testQuietFlagEnabled() throws Exception {
MockTerminal terminal = new MockTerminal();
terminal.setVerbosity(Terminal.Verbosity.SILENT);
installPlugin(terminal, false);
assertThat(terminal.getOutput(), not(containsString("100%")));
}
use of org.elasticsearch.cli.MockTerminal in project elasticsearch by elastic.
the class InstallPluginCommandTests method installPlugin.
static MockTerminal installPlugin(String pluginUrl, Path home, boolean jarHellCheck) throws Exception {
Environment env = new Environment(Settings.builder().put("path.home", home).build());
MockTerminal terminal = new MockTerminal();
new InstallPluginCommand() {
@Override
void jarHellCheck(Path candidate, Path pluginsDir) throws Exception {
if (jarHellCheck) {
super.jarHellCheck(candidate, pluginsDir);
}
}
}.execute(terminal, pluginUrl, true, env);
return terminal;
}
use of org.elasticsearch.cli.MockTerminal in project elasticsearch by elastic.
the class InstallPluginCommandTests method testBatchFlag.
public void testBatchFlag() throws Exception {
MockTerminal terminal = new MockTerminal();
installPlugin(terminal, true);
assertThat(terminal.getOutput(), containsString("WARNING: plugin requires additional permissions"));
}
Aggregations