use of org.elasticsearch.env.Environment in project elasticsearch by elastic.
the class HunspellServiceTests method testLocaleDirectoryWithLocaleSpecificConfig.
public void testLocaleDirectoryWithLocaleSpecificConfig() throws Exception {
Settings settings = Settings.builder().put(Environment.PATH_CONF_SETTING.getKey(), getDataPath("/indices/analyze/conf_dir")).put(HUNSPELL_LAZY_LOAD.getKey(), randomBoolean()).put(HUNSPELL_IGNORE_CASE.getKey(), true).put("indices.analysis.hunspell.dictionary.en_US.strict_affix_parsing", false).put("indices.analysis.hunspell.dictionary.en_US.ignore_case", false).put(Environment.PATH_HOME_SETTING.getKey(), createTempDir()).build();
Dictionary dictionary = new HunspellService(settings, new Environment(settings), emptyMap()).getDictionary("en_US");
assertThat(dictionary, notNullValue());
assertFalse(dictionary.getIgnoreCase());
// testing that dictionary specific settings override node level settings
dictionary = new HunspellService(settings, new Environment(settings), emptyMap()).getDictionary("en_US_custom");
assertThat(dictionary, notNullValue());
assertTrue(dictionary.getIgnoreCase());
}
use of org.elasticsearch.env.Environment in project elasticsearch by elastic.
the class HunspellServiceTests method testDicWithNoAff.
public void testDicWithNoAff() throws Exception {
Settings settings = Settings.builder().put(Environment.PATH_CONF_SETTING.getKey(), getDataPath("/indices/analyze/no_aff_conf_dir")).put(HUNSPELL_LAZY_LOAD.getKey(), randomBoolean()).put(Environment.PATH_HOME_SETTING.getKey(), createTempDir()).build();
IllegalStateException e = expectThrows(IllegalStateException.class, () -> new HunspellService(settings, new Environment(settings), emptyMap()).getDictionary("en_US"));
assertEquals("failed to load hunspell dictionary for locale: en_US", e.getMessage());
assertThat(e.getCause(), hasToString(containsString("Missing affix file")));
}
use of org.elasticsearch.env.Environment in project elasticsearch by elastic.
the class AbstractScriptTestCase method init.
@Before
public void init() throws Exception {
Settings settings = Settings.builder().put("path.home", createTempDir()).put(ScriptService.SCRIPT_AUTO_RELOAD_ENABLED_SETTING.getKey(), false).build();
ScriptEngineRegistry scriptEngineRegistry = new ScriptEngineRegistry(Arrays.asList(new MustacheScriptEngineService()));
ScriptContextRegistry scriptContextRegistry = new ScriptContextRegistry(Collections.emptyList());
ScriptSettings scriptSettings = new ScriptSettings(scriptEngineRegistry, scriptContextRegistry);
ScriptService scriptService = new ScriptService(settings, new Environment(settings), null, scriptEngineRegistry, scriptContextRegistry, scriptSettings);
templateService = new InternalTemplateService(scriptService);
}
use of org.elasticsearch.env.Environment in project elasticsearch by elastic.
the class RemovePluginCommandTests method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
home = createTempDir();
Files.createDirectories(home.resolve("bin"));
Files.createFile(home.resolve("bin").resolve("elasticsearch"));
Files.createDirectories(home.resolve("plugins"));
Settings settings = Settings.builder().put("path.home", home).build();
env = new Environment(settings);
}
use of org.elasticsearch.env.Environment in project elasticsearch by elastic.
the class RemovePluginCommandTests method removePlugin.
static MockTerminal removePlugin(String name, Path home) throws Exception {
Environment env = new Environment(Settings.builder().put("path.home", home).build());
MockTerminal terminal = new MockTerminal();
new RemovePluginCommand().execute(terminal, name, env);
return terminal;
}
Aggregations