diff --git a/pom.xml b/pom.xml index bb2c5c4..6139cb1 100644 --- a/pom.xml +++ b/pom.xml @@ -31,7 +31,7 @@ - 1.4.0.Beta1 + 1.4.0-SNAPSHOT 4.10.1 4.10.1 3.10.1 diff --git a/src/test/java/org/elasticsearch/index/mapper/xcontent/DateAttachmentMapperTests.java b/src/test/java/org/elasticsearch/index/mapper/xcontent/DateAttachmentMapperTests.java index b627980..c55e2d1 100644 --- a/src/test/java/org/elasticsearch/index/mapper/xcontent/DateAttachmentMapperTests.java +++ b/src/test/java/org/elasticsearch/index/mapper/xcontent/DateAttachmentMapperTests.java @@ -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()); } diff --git a/src/test/java/org/elasticsearch/index/mapper/xcontent/EncryptedDocMapperTest.java b/src/test/java/org/elasticsearch/index/mapper/xcontent/EncryptedDocMapperTest.java index b166e25..816ffc4 100644 --- a/src/test/java/org/elasticsearch/index/mapper/xcontent/EncryptedDocMapperTest.java +++ b/src/test/java/org/elasticsearch/index/mapper/xcontent/EncryptedDocMapperTest.java @@ -21,8 +21,6 @@ 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 void testMultipleDocsEncryptedLast() throws IOException { @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 void testMultipleDocsEncryptedFirst() throws IOException { @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"); diff --git a/src/test/java/org/elasticsearch/index/mapper/xcontent/LanguageDetectionAttachmentMapperTests.java b/src/test/java/org/elasticsearch/index/mapper/xcontent/LanguageDetectionAttachmentMapperTests.java index 6529f7a..7427554 100644 --- a/src/test/java/org/elasticsearch/index/mapper/xcontent/LanguageDetectionAttachmentMapperTests.java +++ b/src/test/java/org/elasticsearch/index/mapper/xcontent/LanguageDetectionAttachmentMapperTests.java @@ -21,8 +21,6 @@ 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 void setupMapperParser() throws IOException { } 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); diff --git a/src/test/java/org/elasticsearch/index/mapper/xcontent/MapperTestUtils.java b/src/test/java/org/elasticsearch/index/mapper/xcontent/MapperTestUtils.java index 6b00e11..153cd01 100644 --- a/src/test/java/org/elasticsearch/index/mapper/xcontent/MapperTestUtils.java +++ b/src/test/java/org/elasticsearch/index/mapper/xcontent/MapperTestUtils.java @@ -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.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 @@ 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 @@ circuitBreakerService, new IndicesFieldDataCacheListener(circuitBreakerService)) } 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 static AnalysisService newAnalysisService(Settings indexSettings) { 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); + } } diff --git a/src/test/java/org/elasticsearch/index/mapper/xcontent/MetadataMapperTest.java b/src/test/java/org/elasticsearch/index/mapper/xcontent/MetadataMapperTest.java index 3c55c35..02f184f 100644 --- a/src/test/java/org/elasticsearch/index/mapper/xcontent/MetadataMapperTest.java +++ b/src/test/java/org/elasticsearch/index/mapper/xcontent/MetadataMapperTest.java @@ -22,8 +22,6 @@ 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 @@ 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"); diff --git a/src/test/java/org/elasticsearch/index/mapper/xcontent/MultifieldAttachmentMapperTests.java b/src/test/java/org/elasticsearch/index/mapper/xcontent/MultifieldAttachmentMapperTests.java index 89f0741..b854360 100644 --- a/src/test/java/org/elasticsearch/index/mapper/xcontent/MultifieldAttachmentMapperTests.java +++ b/src/test/java/org/elasticsearch/index/mapper/xcontent/MultifieldAttachmentMapperTests.java @@ -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()); } diff --git a/src/test/java/org/elasticsearch/index/mapper/xcontent/SimpleAttachmentMapperTests.java b/src/test/java/org/elasticsearch/index/mapper/xcontent/SimpleAttachmentMapperTests.java index ac426ac..6c5213d 100644 --- a/src/test/java/org/elasticsearch/index/mapper/xcontent/SimpleAttachmentMapperTests.java +++ b/src/test/java/org/elasticsearch/index/mapper/xcontent/SimpleAttachmentMapperTests.java @@ -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()); }