use of org.elasticsearch.cli.UserException in project elasticsearch by elastic.
the class RemoveSettingKeyStoreCommandTests method testNonExistentSetting.
public void testNonExistentSetting() throws Exception {
createKeystore("");
UserException e = expectThrows(UserException.class, () -> execute("foo"));
assertEquals(ExitCodes.CONFIG, e.exitCode);
assertThat(e.getMessage(), containsString("[foo] does not exist"));
}
use of org.elasticsearch.cli.UserException in project elasticsearch by elastic.
the class AddStringKeyStoreCommandTests method testNonAsciiValue.
public void testNonAsciiValue() throws Exception {
KeyStoreWrapper.create(new char[0]).save(env.configFile());
terminal.addSecretInput("non-äsčîï");
UserException e = expectThrows(UserException.class, () -> execute("foo"));
assertEquals(ExitCodes.DATA_ERROR, e.exitCode);
assertEquals("String value must contain only ASCII", e.getMessage());
}
use of org.elasticsearch.cli.UserException in project elasticsearch by elastic.
the class AddStringKeyStoreCommandTests method testNpe.
public void testNpe() throws Exception {
createKeystore("");
terminal.addTextInput("");
UserException e = expectThrows(UserException.class, this::execute);
assertEquals(ExitCodes.USAGE, e.exitCode);
assertThat(e.getMessage(), containsString("The setting name can not be null"));
}
use of org.elasticsearch.cli.UserException in project elasticsearch by elastic.
the class ListKeyStoreCommandTests method testMissing.
public void testMissing() throws Exception {
UserException e = expectThrows(UserException.class, this::execute);
assertEquals(ExitCodes.DATA_ERROR, e.exitCode);
assertThat(e.getMessage(), containsString("keystore not found"));
}
use of org.elasticsearch.cli.UserException in project elasticsearch by elastic.
the class RemovePluginCommandTests method testRemoveUninstalledPluginErrors.
public void testRemoveUninstalledPluginErrors() throws Exception {
UserException e = expectThrows(UserException.class, () -> removePlugin("fake", home));
assertEquals(ExitCodes.CONFIG, e.exitCode);
assertEquals("plugin fake not found; run 'elasticsearch-plugin list' to get list of installed plugins", e.getMessage());
MockTerminal terminal = new MockTerminal();
new RemovePluginCommand() {
@Override
protected boolean addShutdownHook() {
return false;
}
}.main(new String[] { "-Epath.home=" + home, "fake" }, terminal);
try (BufferedReader reader = new BufferedReader(new StringReader(terminal.getOutput()))) {
assertEquals("-> Removing fake...", reader.readLine());
assertEquals("ERROR: plugin fake not found; run 'elasticsearch-plugin list' to get list of installed plugins", reader.readLine());
assertNull(reader.readLine());
}
}
Aggregations