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:
David Pilato 2014-10-15 15:46:02 +02:00
parent a8a2e83e89
commit ae1c019e1a
2 changed files with 14 additions and 2 deletions

View File

@ -21,8 +21,11 @@ package org.elasticsearch.index.analysis;
import org.apache.lucene.analysis.Analyzer;
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.ModulesBuilder;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.settings.SettingsModule;
import org.elasticsearch.env.Environment;
import org.elasticsearch.env.EnvironmentModule;
@ -38,6 +41,7 @@ import org.hamcrest.MatcherAssert;
import org.junit.Test;
import static org.elasticsearch.common.settings.ImmutableSettings.Builder.EMPTY_SETTINGS;
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
import static org.hamcrest.Matchers.instanceOf;
/**
@ -47,10 +51,13 @@ public class PolishAnalysisTests extends ElasticsearchTestCase {
@Test
public void testDefaultsPolishAnalysis() {
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 injector = new ModulesBuilder().add(
new IndexSettingsModule(index, EMPTY_SETTINGS),
new IndexSettingsModule(index, settings),
new IndexNameModule(index),
new AnalysisModule(EMPTY_SETTINGS, parentInjector.getInstance(IndicesAnalysisService.class)).addProcessor(new PolishAnalysisBinderProcessor()))
.createChildInjector(parentInjector);

View File

@ -23,6 +23,8 @@ import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.core.KeywordTokenizer;
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.ModulesBuilder;
import org.elasticsearch.common.settings.ImmutableSettings;
@ -59,6 +61,7 @@ public class SimplePolishTokenFilterTests extends ElasticsearchTestCase {
private void testToken(String source, String expected) throws IOException {
Index index = new Index("test");
Settings settings = ImmutableSettings.settingsBuilder()
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
.put("index.analysis.filter.myStemmer.type", "polish_stem")
.build();
AnalysisService analysisService = createAnalysisService(index, settings);
@ -76,7 +79,9 @@ public class SimplePolishTokenFilterTests extends ElasticsearchTestCase {
private void testAnalyzer(String source, String... expected_terms) throws IOException {
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);
Analyzer analyzer = analysisService.analyzer("polish").analyzer();