use of org.elasticsearch.cli.MockTerminal in project elasticsearch by elastic.
the class ESElasticsearchCliTestCase method runTest.
void runTest(final int expectedStatus, final boolean expectedInit, final Consumer<String> outputConsumer, final InitConsumer initConsumer, String... args) throws Exception {
final MockTerminal terminal = new MockTerminal();
Path home = createTempDir();
try {
final AtomicBoolean init = new AtomicBoolean();
final int status = Elasticsearch.main(args, new Elasticsearch() {
@Override
protected Environment createEnv(Terminal terminal, Map<String, String> settings) {
Settings realSettings = Settings.builder().put("path.home", home).put(settings).build();
return new Environment(realSettings);
}
@Override
void init(final boolean daemonize, final Path pidFile, final boolean quiet, Environment initialEnv) {
init.set(true);
initConsumer.accept(!daemonize, pidFile, quiet, initialEnv);
}
@Override
protected boolean addShutdownHook() {
return false;
}
}, terminal);
assertThat(status, equalTo(expectedStatus));
assertThat(init.get(), equalTo(expectedInit));
outputConsumer.accept(terminal.getOutput());
} catch (Exception e) {
// if an unexpected exception is thrown, we log
// terminal output to aid debugging
logger.info(terminal.getOutput());
// rethrow so the test fails
throw e;
}
}
use of org.elasticsearch.cli.MockTerminal in project elasticsearch by elastic.
the class InstallPluginCommandTests method testOfficialPluginsIncludesXpack.
public void testOfficialPluginsIncludesXpack() throws Exception {
MockTerminal terminal = new MockTerminal();
new InstallPluginCommand() {
@Override
protected boolean addShutdownHook() {
return false;
}
}.main(new String[] { "--help" }, terminal);
assertTrue(terminal.getOutput(), terminal.getOutput().contains("x-pack"));
}
use of org.elasticsearch.cli.MockTerminal in project elasticsearch by elastic.
the class ListPluginsCommandTests method testPluginWithoutVerboseMultiplePlugins.
public void testPluginWithoutVerboseMultiplePlugins() throws Exception {
buildFakePlugin(env, "fake desc 1", "fake_plugin1", "org.fake");
buildFakePlugin(env, "fake desc 2", "fake_plugin2", "org.fake2");
MockTerminal terminal = listPlugins(home, new String[0]);
String output = terminal.getOutput();
assertEquals(output, buildMultiline("fake_plugin1", "fake_plugin2"));
}
use of org.elasticsearch.cli.MockTerminal in project elasticsearch by elastic.
the class ListPluginsCommandTests method testNoPlugins.
public void testNoPlugins() throws Exception {
MockTerminal terminal = listPlugins(home);
assertTrue(terminal.getOutput(), terminal.getOutput().isEmpty());
}
use of org.elasticsearch.cli.MockTerminal in project elasticsearch by elastic.
the class ListPluginsCommandTests method testPluginWithVerbose.
public void testPluginWithVerbose() throws Exception {
buildFakePlugin(env, "fake desc", "fake_plugin", "org.fake");
String[] params = { "-v" };
MockTerminal terminal = listPlugins(home, params);
assertEquals(terminal.getOutput(), buildMultiline("Plugins directory: " + env.pluginsFile(), "fake_plugin", "- Plugin information:", "Name: fake_plugin", "Description: fake desc", "Version: 1.0", " * Classname: org.fake"));
}
Aggregations