Tests: index.version.created must be set
Due to this [change](https://github.com/elasticsearch/elasticsearch/pull/8018), we need to fix our tests for elasticsearch 1.4.0 and above. Closes #33.
This commit is contained in:
parent
a8a2e83e89
commit
ae1c019e1a
|
@ -21,8 +21,11 @@ package org.elasticsearch.index.analysis;
|
||||||
|
|
||||||
import org.apache.lucene.analysis.Analyzer;
|
import org.apache.lucene.analysis.Analyzer;
|
||||||
import org.apache.lucene.analysis.pl.PolishAnalyzer;
|
import org.apache.lucene.analysis.pl.PolishAnalyzer;
|
||||||
|
import org.elasticsearch.Version;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||||
import org.elasticsearch.common.inject.Injector;
|
import org.elasticsearch.common.inject.Injector;
|
||||||
import org.elasticsearch.common.inject.ModulesBuilder;
|
import org.elasticsearch.common.inject.ModulesBuilder;
|
||||||
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.settings.SettingsModule;
|
import org.elasticsearch.common.settings.SettingsModule;
|
||||||
import org.elasticsearch.env.Environment;
|
import org.elasticsearch.env.Environment;
|
||||||
import org.elasticsearch.env.EnvironmentModule;
|
import org.elasticsearch.env.EnvironmentModule;
|
||||||
|
@ -38,6 +41,7 @@ import org.hamcrest.MatcherAssert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.elasticsearch.common.settings.ImmutableSettings.Builder.EMPTY_SETTINGS;
|
import static org.elasticsearch.common.settings.ImmutableSettings.Builder.EMPTY_SETTINGS;
|
||||||
|
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||||
import static org.hamcrest.Matchers.instanceOf;
|
import static org.hamcrest.Matchers.instanceOf;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -47,10 +51,13 @@ public class PolishAnalysisTests extends ElasticsearchTestCase {
|
||||||
@Test
|
@Test
|
||||||
public void testDefaultsPolishAnalysis() {
|
public void testDefaultsPolishAnalysis() {
|
||||||
Index index = new Index("test");
|
Index index = new Index("test");
|
||||||
|
Settings settings = settingsBuilder()
|
||||||
|
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
|
||||||
|
.build();
|
||||||
|
|
||||||
Injector parentInjector = new ModulesBuilder().add(new SettingsModule(EMPTY_SETTINGS), new EnvironmentModule(new Environment(EMPTY_SETTINGS)), new IndicesAnalysisModule()).createInjector();
|
Injector parentInjector = new ModulesBuilder().add(new SettingsModule(EMPTY_SETTINGS), new EnvironmentModule(new Environment(EMPTY_SETTINGS)), new IndicesAnalysisModule()).createInjector();
|
||||||
Injector injector = new ModulesBuilder().add(
|
Injector injector = new ModulesBuilder().add(
|
||||||
new IndexSettingsModule(index, EMPTY_SETTINGS),
|
new IndexSettingsModule(index, settings),
|
||||||
new IndexNameModule(index),
|
new IndexNameModule(index),
|
||||||
new AnalysisModule(EMPTY_SETTINGS, parentInjector.getInstance(IndicesAnalysisService.class)).addProcessor(new PolishAnalysisBinderProcessor()))
|
new AnalysisModule(EMPTY_SETTINGS, parentInjector.getInstance(IndicesAnalysisService.class)).addProcessor(new PolishAnalysisBinderProcessor()))
|
||||||
.createChildInjector(parentInjector);
|
.createChildInjector(parentInjector);
|
||||||
|
|
|
@ -23,6 +23,8 @@ import org.apache.lucene.analysis.Analyzer;
|
||||||
import org.apache.lucene.analysis.TokenStream;
|
import org.apache.lucene.analysis.TokenStream;
|
||||||
import org.apache.lucene.analysis.core.KeywordTokenizer;
|
import org.apache.lucene.analysis.core.KeywordTokenizer;
|
||||||
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
|
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
|
||||||
|
import org.elasticsearch.Version;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||||
import org.elasticsearch.common.inject.Injector;
|
import org.elasticsearch.common.inject.Injector;
|
||||||
import org.elasticsearch.common.inject.ModulesBuilder;
|
import org.elasticsearch.common.inject.ModulesBuilder;
|
||||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
import org.elasticsearch.common.settings.ImmutableSettings;
|
||||||
|
@ -59,6 +61,7 @@ public class SimplePolishTokenFilterTests extends ElasticsearchTestCase {
|
||||||
private void testToken(String source, String expected) throws IOException {
|
private void testToken(String source, String expected) throws IOException {
|
||||||
Index index = new Index("test");
|
Index index = new Index("test");
|
||||||
Settings settings = ImmutableSettings.settingsBuilder()
|
Settings settings = ImmutableSettings.settingsBuilder()
|
||||||
|
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
|
||||||
.put("index.analysis.filter.myStemmer.type", "polish_stem")
|
.put("index.analysis.filter.myStemmer.type", "polish_stem")
|
||||||
.build();
|
.build();
|
||||||
AnalysisService analysisService = createAnalysisService(index, settings);
|
AnalysisService analysisService = createAnalysisService(index, settings);
|
||||||
|
@ -76,7 +79,9 @@ public class SimplePolishTokenFilterTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
private void testAnalyzer(String source, String... expected_terms) throws IOException {
|
private void testAnalyzer(String source, String... expected_terms) throws IOException {
|
||||||
Index index = new Index("test");
|
Index index = new Index("test");
|
||||||
Settings settings = ImmutableSettings.settingsBuilder().build();
|
Settings settings = ImmutableSettings.settingsBuilder()
|
||||||
|
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
|
||||||
|
.build();
|
||||||
AnalysisService analysisService = createAnalysisService(index, settings);
|
AnalysisService analysisService = createAnalysisService(index, settings);
|
||||||
|
|
||||||
Analyzer analyzer = analysisService.analyzer("polish").analyzer();
|
Analyzer analyzer = analysisService.analyzer("polish").analyzer();
|
||||||
|
|
Loading…
Reference in New Issue