Skip to content

Commit

Permalink
Tests: index.version.created must be set
Browse files Browse the repository at this point in the history
Due to this [change](elastic/elasticsearch#8018), we need to fix our tests for elasticsearch 1.4.0 and above.

Closes #33.
  • Loading branch information
dadoonet committed Oct 15, 2014
1 parent 037f31d commit 847f04f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Expand Up @@ -21,8 +21,11 @@

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;
Expand All @@ -38,6 +41,7 @@
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;

/**
Expand All @@ -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);
Expand Down
Expand Up @@ -23,6 +23,8 @@
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;
Expand Down Expand Up @@ -59,6 +61,7 @@ public void testBasicUsage() throws Exception {
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);
Expand All @@ -76,7 +79,9 @@ private void testToken(String source, String expected) throws IOException {

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();
Expand Down

0 comments on commit 847f04f

Please sign in to comment.