Tests: AnalysisService constructor signature change
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 #87. (cherry picked from commit b3b0d34)
This commit is contained in:
parent
03b47d5a4c
commit
c3bf3b1ce9
|
@ -19,9 +19,6 @@
|
|||
|
||||
package org.elasticsearch.index.mapper.xcontent;
|
||||
|
||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.analysis.AnalysisService;
|
||||
import org.elasticsearch.index.mapper.DocumentMapper;
|
||||
import org.elasticsearch.index.mapper.DocumentMapperParser;
|
||||
import org.elasticsearch.index.mapper.attachment.AttachmentMapper;
|
||||
|
@ -42,7 +39,7 @@ public class DateAttachmentMapperTests extends ElasticsearchTestCase {
|
|||
|
||||
@Before
|
||||
public void setupMapperParser() {
|
||||
mapperParser = new DocumentMapperParser(new Index("test"), ImmutableSettings.EMPTY, new AnalysisService(new Index("test")), null, null, null, null);
|
||||
mapperParser = MapperTestUtils.newMapperParser();
|
||||
mapperParser.putTypeParser(AttachmentMapper.CONTENT_TYPE, new AttachmentMapper.TypeParser());
|
||||
}
|
||||
|
||||
|
|
|
@ -21,8 +21,6 @@ package org.elasticsearch.index.mapper.xcontent;
|
|||
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.analysis.AnalysisService;
|
||||
import org.elasticsearch.index.mapper.DocumentMapper;
|
||||
import org.elasticsearch.index.mapper.DocumentMapperParser;
|
||||
import org.elasticsearch.index.mapper.MapperParsingException;
|
||||
|
@ -47,7 +45,7 @@ public class EncryptedDocMapperTest extends ElasticsearchTestCase {
|
|||
|
||||
@Test
|
||||
public void testMultipleDocsEncryptedLast() throws IOException {
|
||||
DocumentMapperParser mapperParser = new DocumentMapperParser(new Index("test"), ImmutableSettings.EMPTY, new AnalysisService(new Index("test")), null, null, null, null);
|
||||
DocumentMapperParser mapperParser = MapperTestUtils.newMapperParser();
|
||||
mapperParser.putTypeParser(AttachmentMapper.CONTENT_TYPE, new AttachmentMapper.TypeParser());
|
||||
|
||||
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/multipledocs/test-mapping.json");
|
||||
|
@ -80,7 +78,7 @@ public class EncryptedDocMapperTest extends ElasticsearchTestCase {
|
|||
|
||||
@Test
|
||||
public void testMultipleDocsEncryptedFirst() throws IOException {
|
||||
DocumentMapperParser mapperParser = new DocumentMapperParser(new Index("test"), ImmutableSettings.EMPTY, new AnalysisService(new Index("test")), null, null, null, null);
|
||||
DocumentMapperParser mapperParser = MapperTestUtils.newMapperParser();
|
||||
mapperParser.putTypeParser(AttachmentMapper.CONTENT_TYPE, new AttachmentMapper.TypeParser());
|
||||
|
||||
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/multipledocs/test-mapping.json");
|
||||
|
@ -113,9 +111,7 @@ public class EncryptedDocMapperTest extends ElasticsearchTestCase {
|
|||
|
||||
@Test(expected = MapperParsingException.class)
|
||||
public void testMultipleDocsEncryptedNotIgnoringErrors() throws IOException {
|
||||
DocumentMapperParser mapperParser = new DocumentMapperParser(new Index("test"),
|
||||
ImmutableSettings.builder().put("index.mapping.attachment.ignore_errors", false).build(),
|
||||
new AnalysisService(new Index("test")), null, null, null, null);
|
||||
DocumentMapperParser mapperParser = MapperTestUtils.newMapperParser(ImmutableSettings.builder().put("index.mapping.attachment.ignore_errors", false).build());
|
||||
mapperParser.putTypeParser(AttachmentMapper.CONTENT_TYPE, new AttachmentMapper.TypeParser());
|
||||
|
||||
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/multipledocs/test-mapping.json");
|
||||
|
|
|
@ -21,8 +21,6 @@ package org.elasticsearch.index.mapper.xcontent;
|
|||
|
||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.analysis.AnalysisService;
|
||||
import org.elasticsearch.index.mapper.DocumentMapper;
|
||||
import org.elasticsearch.index.mapper.DocumentMapperParser;
|
||||
import org.elasticsearch.index.mapper.ParseContext;
|
||||
|
@ -53,9 +51,8 @@ public class LanguageDetectionAttachmentMapperTests extends ElasticsearchTestCas
|
|||
}
|
||||
|
||||
public void setupMapperParser(boolean langDetect) throws IOException {
|
||||
DocumentMapperParser mapperParser = new DocumentMapperParser(new Index("test"),
|
||||
ImmutableSettings.settingsBuilder().put("index.mapping.attachment.detect_language", langDetect).build(),
|
||||
new AnalysisService(new Index("test")), null, null, null, null);
|
||||
DocumentMapperParser mapperParser = MapperTestUtils.newMapperParser(
|
||||
ImmutableSettings.settingsBuilder().put("index.mapping.attachment.detect_language", langDetect).build());
|
||||
mapperParser.putTypeParser(AttachmentMapper.CONTENT_TYPE, new AttachmentMapper.TypeParser());
|
||||
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/language/language-mapping.json");
|
||||
docMapper = mapperParser.parse(mapping);
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
|
||||
package org.elasticsearch.index.mapper.xcontent;
|
||||
|
||||
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;
|
||||
|
@ -33,6 +35,7 @@ import org.elasticsearch.index.analysis.AnalysisService;
|
|||
import org.elasticsearch.index.codec.docvaluesformat.DocValuesFormatService;
|
||||
import org.elasticsearch.index.codec.postingsformat.PostingsFormatService;
|
||||
import org.elasticsearch.index.fielddata.IndexFieldDataService;
|
||||
import org.elasticsearch.index.mapper.DocumentMapperParser;
|
||||
import org.elasticsearch.index.mapper.MapperService;
|
||||
import org.elasticsearch.index.settings.IndexSettingsModule;
|
||||
import org.elasticsearch.index.similarity.SimilarityLookupService;
|
||||
|
@ -46,7 +49,9 @@ import org.elasticsearch.threadpool.ThreadPool;
|
|||
public class MapperTestUtils {
|
||||
|
||||
public static MapperService newMapperService() {
|
||||
return newMapperService(new Index("test"), ImmutableSettings.Builder.EMPTY_SETTINGS);
|
||||
return newMapperService(new Index("test"), ImmutableSettings.builder()
|
||||
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
|
||||
.build());
|
||||
}
|
||||
|
||||
public static MapperService newMapperService(Index index, Settings indexSettings) {
|
||||
|
@ -58,14 +63,17 @@ public class MapperTestUtils {
|
|||
}
|
||||
|
||||
public static AnalysisService newAnalysisService() {
|
||||
return newAnalysisService(ImmutableSettings.Builder.EMPTY_SETTINGS);
|
||||
return newAnalysisService(ImmutableSettings.builder()
|
||||
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
|
||||
.build());
|
||||
}
|
||||
|
||||
public static AnalysisService newAnalysisService(Settings indexSettings) {
|
||||
Injector parentInjector = new ModulesBuilder().add(new SettingsModule(indexSettings), new EnvironmentModule(new Environment(ImmutableSettings.Builder.EMPTY_SETTINGS)), new IndicesAnalysisModule()).createInjector();
|
||||
Index index = new Index("test");
|
||||
Injector injector = new ModulesBuilder().add(
|
||||
new IndexSettingsModule(new Index("test"), indexSettings),
|
||||
new IndexNameModule(new Index("test")),
|
||||
new IndexSettingsModule(index, indexSettings),
|
||||
new IndexNameModule(index),
|
||||
new AnalysisModule(indexSettings, parentInjector.getInstance(IndicesAnalysisService.class))).createChildInjector(parentInjector);
|
||||
|
||||
return injector.getInstance(AnalysisService.class);
|
||||
|
@ -74,4 +82,16 @@ public class MapperTestUtils {
|
|||
public static SimilarityLookupService newSimilarityLookupService() {
|
||||
return new SimilarityLookupService(new Index("test"), ImmutableSettings.Builder.EMPTY_SETTINGS);
|
||||
}
|
||||
|
||||
public static DocumentMapperParser newMapperParser() {
|
||||
return newMapperParser(ImmutableSettings.Builder.EMPTY_SETTINGS);
|
||||
}
|
||||
|
||||
public static DocumentMapperParser newMapperParser(Settings settings) {
|
||||
Settings forcedSettings = ImmutableSettings.builder()
|
||||
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
|
||||
.put(settings)
|
||||
.build();
|
||||
return new DocumentMapperParser(new Index("test"), forcedSettings, MapperTestUtils.newAnalysisService(forcedSettings), null, null, null, null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,8 +22,6 @@ package org.elasticsearch.index.mapper.xcontent;
|
|||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.analysis.AnalysisService;
|
||||
import org.elasticsearch.index.mapper.DocumentMapper;
|
||||
import org.elasticsearch.index.mapper.DocumentMapperParser;
|
||||
import org.elasticsearch.index.mapper.MapperParsingException;
|
||||
|
@ -45,7 +43,7 @@ import static org.hamcrest.Matchers.*;
|
|||
public class MetadataMapperTest extends ElasticsearchTestCase {
|
||||
|
||||
protected void checkMeta(String filename, Settings settings, Long expectedDate, Long expectedLength) throws IOException {
|
||||
DocumentMapperParser mapperParser = new DocumentMapperParser(new Index("test"), settings, new AnalysisService(new Index("test")), null, null, null, null);
|
||||
DocumentMapperParser mapperParser = MapperTestUtils.newMapperParser(settings);
|
||||
mapperParser.putTypeParser(AttachmentMapper.CONTENT_TYPE, new AttachmentMapper.TypeParser());
|
||||
|
||||
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/xcontent/test-mapping.json");
|
||||
|
|
|
@ -20,10 +20,7 @@
|
|||
package org.elasticsearch.index.mapper.xcontent;
|
||||
|
||||
import org.elasticsearch.common.Base64;
|
||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.analysis.AnalysisService;
|
||||
import org.elasticsearch.index.mapper.DocumentMapper;
|
||||
import org.elasticsearch.index.mapper.DocumentMapperParser;
|
||||
import org.elasticsearch.index.mapper.MapperService;
|
||||
|
@ -47,7 +44,7 @@ public class MultifieldAttachmentMapperTests extends ElasticsearchTestCase {
|
|||
|
||||
@Before
|
||||
public void setupMapperParser() {
|
||||
mapperParser = new DocumentMapperParser(new Index("test"), ImmutableSettings.EMPTY, new AnalysisService(new Index("test")), null, null, null, null);
|
||||
mapperParser = MapperTestUtils.newMapperParser();
|
||||
mapperParser.putTypeParser(AttachmentMapper.CONTENT_TYPE, new AttachmentMapper.TypeParser());
|
||||
}
|
||||
|
||||
|
|
|
@ -20,9 +20,6 @@
|
|||
package org.elasticsearch.index.mapper.xcontent;
|
||||
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.analysis.AnalysisService;
|
||||
import org.elasticsearch.index.mapper.DocumentMapper;
|
||||
import org.elasticsearch.index.mapper.DocumentMapperParser;
|
||||
import org.elasticsearch.index.mapper.ParseContext;
|
||||
|
@ -46,7 +43,7 @@ public class SimpleAttachmentMapperTests extends ElasticsearchTestCase {
|
|||
|
||||
@Before
|
||||
public void setupMapperParser() {
|
||||
mapperParser = new DocumentMapperParser(new Index("test"), ImmutableSettings.EMPTY, new AnalysisService(new Index("test")), null, null, null, null);
|
||||
mapperParser = MapperTestUtils.newMapperParser();
|
||||
mapperParser.putTypeParser(AttachmentMapper.CONTENT_TYPE, new AttachmentMapper.TypeParser());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue