Search in sources :

Example 1 with TestEngineService

use of org.elasticsearch.script.ScriptServiceTests.TestEngineService in project elasticsearch by elastic.

the class AbstractSortTestCase method init.

@BeforeClass
public static void init() throws IOException {
    Path genericConfigFolder = createTempDir();
    Settings baseSettings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()).put(Environment.PATH_CONF_SETTING.getKey(), genericConfigFolder).build();
    Environment environment = new Environment(baseSettings);
    ScriptContextRegistry scriptContextRegistry = new ScriptContextRegistry(Collections.emptyList());
    ScriptEngineRegistry scriptEngineRegistry = new ScriptEngineRegistry(Collections.singletonList(new TestEngineService()));
    ScriptSettings scriptSettings = new ScriptSettings(scriptEngineRegistry, scriptContextRegistry);
    scriptService = new ScriptService(baseSettings, environment, new ResourceWatcherService(baseSettings, null), scriptEngineRegistry, scriptContextRegistry, scriptSettings) {

        @Override
        public CompiledScript compile(Script script, ScriptContext scriptContext) {
            return new CompiledScript(ScriptType.INLINE, "mockName", "test", script);
        }
    };
    SearchModule searchModule = new SearchModule(Settings.EMPTY, false, emptyList());
    namedWriteableRegistry = new NamedWriteableRegistry(searchModule.getNamedWriteables());
    xContentRegistry = new NamedXContentRegistry(searchModule.getNamedXContents());
}
Also used : Path(java.nio.file.Path) ContentPath(org.elasticsearch.index.mapper.ContentPath) CompiledScript(org.elasticsearch.script.CompiledScript) NamedWriteableRegistry(org.elasticsearch.common.io.stream.NamedWriteableRegistry) Script(org.elasticsearch.script.Script) CompiledScript(org.elasticsearch.script.CompiledScript) ScriptContext(org.elasticsearch.script.ScriptContext) ScriptContextRegistry(org.elasticsearch.script.ScriptContextRegistry) ScriptService(org.elasticsearch.script.ScriptService) ScriptSettings(org.elasticsearch.script.ScriptSettings) ScriptEngineRegistry(org.elasticsearch.script.ScriptEngineRegistry) Environment(org.elasticsearch.env.Environment) SearchModule(org.elasticsearch.search.SearchModule) TestEngineService(org.elasticsearch.script.ScriptServiceTests.TestEngineService) ResourceWatcherService(org.elasticsearch.watcher.ResourceWatcherService) NamedXContentRegistry(org.elasticsearch.common.xcontent.NamedXContentRegistry) Settings(org.elasticsearch.common.settings.Settings) ScriptSettings(org.elasticsearch.script.ScriptSettings) IndexSettings(org.elasticsearch.index.IndexSettings) BeforeClass(org.junit.BeforeClass)

Aggregations

Path (java.nio.file.Path)1 NamedWriteableRegistry (org.elasticsearch.common.io.stream.NamedWriteableRegistry)1 Settings (org.elasticsearch.common.settings.Settings)1 NamedXContentRegistry (org.elasticsearch.common.xcontent.NamedXContentRegistry)1 Environment (org.elasticsearch.env.Environment)1 IndexSettings (org.elasticsearch.index.IndexSettings)1 ContentPath (org.elasticsearch.index.mapper.ContentPath)1 CompiledScript (org.elasticsearch.script.CompiledScript)1 Script (org.elasticsearch.script.Script)1 ScriptContext (org.elasticsearch.script.ScriptContext)1 ScriptContextRegistry (org.elasticsearch.script.ScriptContextRegistry)1 ScriptEngineRegistry (org.elasticsearch.script.ScriptEngineRegistry)1 ScriptService (org.elasticsearch.script.ScriptService)1 TestEngineService (org.elasticsearch.script.ScriptServiceTests.TestEngineService)1 ScriptSettings (org.elasticsearch.script.ScriptSettings)1 SearchModule (org.elasticsearch.search.SearchModule)1 ResourceWatcherService (org.elasticsearch.watcher.ResourceWatcherService)1 BeforeClass (org.junit.BeforeClass)1