Absorb ImmutableSettings into Settings; fix other pre-existing compilation issues, but there are still forbidden API failures
This commit is contained in:
parent
7263437ca5
commit
2da374f39d
|
@ -28,7 +28,7 @@ import org.apache.tika.metadata.Metadata;
|
||||||
import org.elasticsearch.Version;
|
import org.elasticsearch.Version;
|
||||||
import org.elasticsearch.common.collect.Iterators;
|
import org.elasticsearch.common.collect.Iterators;
|
||||||
import org.elasticsearch.common.collect.Lists;
|
import org.elasticsearch.common.collect.Lists;
|
||||||
import org.elasticsearch.common.io.stream.BytesStreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.logging.ESLogger;
|
import org.elasticsearch.common.logging.ESLogger;
|
||||||
import org.elasticsearch.common.logging.ESLoggerFactory;
|
import org.elasticsearch.common.logging.ESLoggerFactory;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
|
@ -68,7 +68,7 @@ import static org.elasticsearch.plugin.mapper.attachments.tika.TikaInstance.tika
|
||||||
* _content_length = Specify the maximum amount of characters to extract from the attachment. If not specified, then the default for
|
* _content_length = Specify the maximum amount of characters to extract from the attachment. If not specified, then the default for
|
||||||
* tika is 100,000 characters. Caution is required when setting large values as this can cause memory issues.
|
* tika is 100,000 characters. Caution is required when setting large values as this can cause memory issues.
|
||||||
*/
|
*/
|
||||||
public class AttachmentMapper extends AbstractFieldMapper<Object> {
|
public class AttachmentMapper extends AbstractFieldMapper {
|
||||||
|
|
||||||
private static ESLogger logger = ESLoggerFactory.getLogger("mapper.attachment");
|
private static ESLogger logger = ESLoggerFactory.getLogger("mapper.attachment");
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ public class AttachmentMapper extends AbstractFieldMapper<Object> {
|
||||||
ContentPath.Type origPathType = context.path().pathType();
|
ContentPath.Type origPathType = context.path().pathType();
|
||||||
context.path().pathType(pathType);
|
context.path().pathType(pathType);
|
||||||
|
|
||||||
FieldMapper<?> contentMapper;
|
FieldMapper contentMapper;
|
||||||
if (context.indexCreatedVersion().before(Version.V_2_0_0)) {
|
if (context.indexCreatedVersion().before(Version.V_2_0_0)) {
|
||||||
// old behavior, we need the content to be indexed under the attachment field name
|
// old behavior, we need the content to be indexed under the attachment field name
|
||||||
if (contentBuilder instanceof AbstractFieldMapper.Builder == false) {
|
if (contentBuilder instanceof AbstractFieldMapper.Builder == false) {
|
||||||
|
@ -187,21 +187,21 @@ public class AttachmentMapper extends AbstractFieldMapper<Object> {
|
||||||
}
|
}
|
||||||
((AbstractFieldMapper.Builder)contentBuilder).indexName(name);
|
((AbstractFieldMapper.Builder)contentBuilder).indexName(name);
|
||||||
contentBuilder.name = name + "." + FieldNames.CONTENT;
|
contentBuilder.name = name + "." + FieldNames.CONTENT;
|
||||||
contentMapper = (FieldMapper<?>) contentBuilder.build(context);
|
contentMapper = (FieldMapper) contentBuilder.build(context);
|
||||||
context.path().add(name);
|
context.path().add(name);
|
||||||
} else {
|
} else {
|
||||||
context.path().add(name);
|
context.path().add(name);
|
||||||
contentMapper = (FieldMapper<?>) contentBuilder.build(context);
|
contentMapper = (FieldMapper) contentBuilder.build(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
FieldMapper<?> dateMapper = (FieldMapper<?>) dateBuilder.build(context);
|
FieldMapper dateMapper = (FieldMapper) dateBuilder.build(context);
|
||||||
FieldMapper<?> authorMapper = (FieldMapper<?>) authorBuilder.build(context);
|
FieldMapper authorMapper = (FieldMapper) authorBuilder.build(context);
|
||||||
FieldMapper<?> titleMapper = (FieldMapper<?>) titleBuilder.build(context);
|
FieldMapper titleMapper = (FieldMapper) titleBuilder.build(context);
|
||||||
FieldMapper<?> nameMapper = (FieldMapper<?>) nameBuilder.build(context);
|
FieldMapper nameMapper = (FieldMapper) nameBuilder.build(context);
|
||||||
FieldMapper<?> keywordsMapper = (FieldMapper<?>) keywordsBuilder.build(context);
|
FieldMapper keywordsMapper = (FieldMapper) keywordsBuilder.build(context);
|
||||||
FieldMapper<?> contentTypeMapper = (FieldMapper<?>) contentTypeBuilder.build(context);
|
FieldMapper contentTypeMapper = (FieldMapper) contentTypeBuilder.build(context);
|
||||||
FieldMapper<?> contentLength = (FieldMapper<?>) contentLengthBuilder.build(context);
|
FieldMapper contentLength = (FieldMapper) contentLengthBuilder.build(context);
|
||||||
FieldMapper<?> language = (FieldMapper<?>) languageBuilder.build(context);
|
FieldMapper language = (FieldMapper) languageBuilder.build(context);
|
||||||
context.path().remove();
|
context.path().remove();
|
||||||
|
|
||||||
context.path().pathType(origPathType);
|
context.path().pathType(origPathType);
|
||||||
|
@ -353,29 +353,29 @@ public class AttachmentMapper extends AbstractFieldMapper<Object> {
|
||||||
|
|
||||||
private final boolean defaultLangDetect;
|
private final boolean defaultLangDetect;
|
||||||
|
|
||||||
private final FieldMapper<?> contentMapper;
|
private final FieldMapper contentMapper;
|
||||||
|
|
||||||
private final FieldMapper<?> dateMapper;
|
private final FieldMapper dateMapper;
|
||||||
|
|
||||||
private final FieldMapper<?> authorMapper;
|
private final FieldMapper authorMapper;
|
||||||
|
|
||||||
private final FieldMapper<?> titleMapper;
|
private final FieldMapper titleMapper;
|
||||||
|
|
||||||
private final FieldMapper<?> nameMapper;
|
private final FieldMapper nameMapper;
|
||||||
|
|
||||||
private final FieldMapper<?> keywordsMapper;
|
private final FieldMapper keywordsMapper;
|
||||||
|
|
||||||
private final FieldMapper<?> contentTypeMapper;
|
private final FieldMapper contentTypeMapper;
|
||||||
|
|
||||||
private final FieldMapper<?> contentLengthMapper;
|
private final FieldMapper contentLengthMapper;
|
||||||
|
|
||||||
private final FieldMapper<?> languageMapper;
|
private final FieldMapper languageMapper;
|
||||||
|
|
||||||
public AttachmentMapper(Names names, ContentPath.Type pathType, int defaultIndexedChars, Boolean ignoreErrors,
|
public AttachmentMapper(Names names, ContentPath.Type pathType, int defaultIndexedChars, Boolean ignoreErrors,
|
||||||
Boolean defaultLangDetect, FieldMapper<?> contentMapper,
|
Boolean defaultLangDetect, FieldMapper contentMapper,
|
||||||
FieldMapper<?> dateMapper, FieldMapper<?> titleMapper, FieldMapper<?> nameMapper, FieldMapper<?> authorMapper,
|
FieldMapper dateMapper, FieldMapper titleMapper, FieldMapper nameMapper, FieldMapper authorMapper,
|
||||||
FieldMapper<?> keywordsMapper, FieldMapper<?> contentTypeMapper, FieldMapper<?> contentLengthMapper,
|
FieldMapper keywordsMapper, FieldMapper contentTypeMapper, FieldMapper contentLengthMapper,
|
||||||
FieldMapper<?> languageMapper, Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
|
FieldMapper languageMapper, Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
|
||||||
super(names, 1.0f, AbstractFieldMapper.Defaults.FIELD_TYPE, false, null, null, null, null, null,
|
super(names, 1.0f, AbstractFieldMapper.Defaults.FIELD_TYPE, false, null, null, null, null, null,
|
||||||
indexSettings, multiFields, copyTo);
|
indexSettings, multiFields, copyTo);
|
||||||
this.pathType = pathType;
|
this.pathType = pathType;
|
||||||
|
@ -476,7 +476,7 @@ public class AttachmentMapper extends AbstractFieldMapper<Object> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Set the maximum length of strings returned by the parseToString method, -1 sets no limit
|
// Set the maximum length of strings returned by the parseToString method, -1 sets no limit
|
||||||
parsedContent = tika.parseToString(new BytesStreamInput(content), metadata, indexedChars);
|
parsedContent = tika.parseToString(StreamInput.wrap(content), metadata, indexedChars);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
// It could happen that Tika adds a System property `sun.font.fontmanager` which should not happen
|
// It could happen that Tika adds a System property `sun.font.fontmanager` which should not happen
|
||||||
// TODO Remove when this will be fixed in Tika. See https://issues.apache.org/jira/browse/TIKA-1548
|
// TODO Remove when this will be fixed in Tika. See https://issues.apache.org/jira/browse/TIKA-1548
|
||||||
|
@ -611,7 +611,7 @@ public class AttachmentMapper extends AbstractFieldMapper<Object> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterator<Mapper> iterator() {
|
public Iterator<Mapper> iterator() {
|
||||||
List<FieldMapper<?>> extras = Lists.newArrayList(
|
List<FieldMapper> extras = Lists.newArrayList(
|
||||||
contentMapper,
|
contentMapper,
|
||||||
dateMapper,
|
dateMapper,
|
||||||
titleMapper,
|
titleMapper,
|
||||||
|
@ -642,7 +642,7 @@ public class AttachmentMapper extends AbstractFieldMapper<Object> {
|
||||||
builder.startObject(name());
|
builder.startObject(name());
|
||||||
builder.field("type", CONTENT_TYPE);
|
builder.field("type", CONTENT_TYPE);
|
||||||
if (indexCreatedBefore2x) {
|
if (indexCreatedBefore2x) {
|
||||||
builder.field("path", pathType.name().toLowerCase());
|
builder.field("path", pathType.name().toLowerCase(Locale.ROOT));
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.startObject("fields");
|
builder.startObject("fields");
|
||||||
|
|
|
@ -24,7 +24,6 @@ import org.elasticsearch.Version;
|
||||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
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.Settings;
|
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;
|
||||||
|
@ -54,7 +53,7 @@ import static org.elasticsearch.plugin.mapper.attachments.tika.LocaleChecker.isL
|
||||||
public class MapperTestUtils {
|
public class MapperTestUtils {
|
||||||
|
|
||||||
public static MapperService newMapperService(Path tempDir, ThreadPool testingThreadPool) {
|
public static MapperService newMapperService(Path tempDir, ThreadPool testingThreadPool) {
|
||||||
return newMapperService(new Index("test"), ImmutableSettings.builder()
|
return newMapperService(new Index("test"), Settings.builder()
|
||||||
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
|
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
|
||||||
.put("path.home", tempDir)
|
.put("path.home", tempDir)
|
||||||
.build(), testingThreadPool);
|
.build(), testingThreadPool);
|
||||||
|
@ -65,8 +64,8 @@ public class MapperTestUtils {
|
||||||
return new MapperService(index,
|
return new MapperService(index,
|
||||||
indexSettings,
|
indexSettings,
|
||||||
newAnalysisService(indexSettings),
|
newAnalysisService(indexSettings),
|
||||||
new IndexFieldDataService(index, ImmutableSettings.Builder.EMPTY_SETTINGS,
|
new IndexFieldDataService(index, Settings.Builder.EMPTY_SETTINGS,
|
||||||
new IndicesFieldDataCache(ImmutableSettings.Builder.EMPTY_SETTINGS,
|
new IndicesFieldDataCache(Settings.Builder.EMPTY_SETTINGS,
|
||||||
new IndicesFieldDataCacheListener(circuitBreakerService),
|
new IndicesFieldDataCacheListener(circuitBreakerService),
|
||||||
testingThreadPool),
|
testingThreadPool),
|
||||||
circuitBreakerService),
|
circuitBreakerService),
|
||||||
|
@ -75,7 +74,7 @@ public class MapperTestUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AnalysisService newAnalysisService(Path tempDir) {
|
public static AnalysisService newAnalysisService(Path tempDir) {
|
||||||
return newAnalysisService(ImmutableSettings.builder()
|
return newAnalysisService(Settings.builder()
|
||||||
.put("path.home", tempDir)
|
.put("path.home", tempDir)
|
||||||
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
|
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
|
||||||
.build());
|
.build());
|
||||||
|
@ -97,13 +96,13 @@ public class MapperTestUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DocumentMapperParser newMapperParser(Path tempDir) {
|
public static DocumentMapperParser newMapperParser(Path tempDir) {
|
||||||
return newMapperParser(ImmutableSettings.builder()
|
return newMapperParser(Settings.builder()
|
||||||
.put("path.home", tempDir)
|
.put("path.home", tempDir)
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DocumentMapperParser newMapperParser(Settings settings) {
|
public static DocumentMapperParser newMapperParser(Settings settings) {
|
||||||
Settings forcedSettings = ImmutableSettings.builder()
|
Settings forcedSettings = Settings.builder()
|
||||||
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
|
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
|
||||||
.put(settings)
|
.put(settings)
|
||||||
.build();
|
.build();
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
package org.elasticsearch.index.mapper.attachment.test.integration;
|
package org.elasticsearch.index.mapper.attachment.test.integration;
|
||||||
|
|
||||||
import org.elasticsearch.action.count.CountResponse;
|
import org.elasticsearch.action.count.CountResponse;
|
||||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.index.mapper.MapperParsingException;
|
import org.elasticsearch.index.mapper.MapperParsingException;
|
||||||
import org.elasticsearch.plugins.PluginsService;
|
import org.elasticsearch.plugins.PluginsService;
|
||||||
|
@ -29,7 +28,7 @@ import org.junit.Test;
|
||||||
import static org.elasticsearch.client.Requests.putMappingRequest;
|
import static org.elasticsearch.client.Requests.putMappingRequest;
|
||||||
import static org.elasticsearch.common.io.Streams.copyToBytesFromClasspath;
|
import static org.elasticsearch.common.io.Streams.copyToBytesFromClasspath;
|
||||||
import static org.elasticsearch.common.io.Streams.copyToStringFromClasspath;
|
import static org.elasticsearch.common.io.Streams.copyToStringFromClasspath;
|
||||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
|
||||||
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
||||||
import static org.elasticsearch.index.query.QueryBuilders.queryStringQuery;
|
import static org.elasticsearch.index.query.QueryBuilders.queryStringQuery;
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
|
@ -42,7 +41,7 @@ public class EncryptedAttachmentIntegrationTests extends AttachmentIntegrationTe
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Settings nodeSettings(int nodeOrdinal) {
|
protected Settings nodeSettings(int nodeOrdinal) {
|
||||||
return ImmutableSettings.builder()
|
return Settings.builder()
|
||||||
.put(super.nodeSettings(nodeOrdinal))
|
.put(super.nodeSettings(nodeOrdinal))
|
||||||
.put("plugins." + PluginsService.LOAD_PLUGIN_FROM_CLASSPATH, true)
|
.put("plugins." + PluginsService.LOAD_PLUGIN_FROM_CLASSPATH, true)
|
||||||
.build();
|
.build();
|
||||||
|
|
|
@ -21,7 +21,6 @@ package org.elasticsearch.index.mapper.attachment.test.integration;
|
||||||
|
|
||||||
import org.elasticsearch.action.count.CountResponse;
|
import org.elasticsearch.action.count.CountResponse;
|
||||||
import org.elasticsearch.action.search.SearchResponse;
|
import org.elasticsearch.action.search.SearchResponse;
|
||||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.text.Text;
|
import org.elasticsearch.common.text.Text;
|
||||||
import org.elasticsearch.index.mapper.MapperParsingException;
|
import org.elasticsearch.index.mapper.MapperParsingException;
|
||||||
|
@ -47,7 +46,7 @@ public class SimpleAttachmentIntegrationTests extends AttachmentIntegrationTestC
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Settings nodeSettings(int nodeOrdinal) {
|
protected Settings nodeSettings(int nodeOrdinal) {
|
||||||
return ImmutableSettings.builder()
|
return Settings.builder()
|
||||||
.put(super.nodeSettings(nodeOrdinal))
|
.put(super.nodeSettings(nodeOrdinal))
|
||||||
.put("plugins." + PluginsService.LOAD_PLUGIN_FROM_CLASSPATH, true)
|
.put("plugins." + PluginsService.LOAD_PLUGIN_FROM_CLASSPATH, true)
|
||||||
.build();
|
.build();
|
||||||
|
|
|
@ -21,7 +21,6 @@ package org.elasticsearch.index.mapper.attachment.test.unit;
|
||||||
|
|
||||||
import org.elasticsearch.Version;
|
import org.elasticsearch.Version;
|
||||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.test.ElasticsearchTestCase;
|
import org.elasticsearch.test.ElasticsearchTestCase;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
@ -43,7 +42,7 @@ public class AttachmentUnitTestCase extends ElasticsearchTestCase {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void createSettings() throws Exception {
|
public void createSettings() throws Exception {
|
||||||
testSettings = ImmutableSettings.builder()
|
testSettings = Settings.builder()
|
||||||
.put("path.home", createTempDir())
|
.put("path.home", createTempDir())
|
||||||
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT.id)
|
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT.id)
|
||||||
.build();
|
.build();
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
package org.elasticsearch.index.mapper.attachment.test.unit;
|
package org.elasticsearch.index.mapper.attachment.test.unit;
|
||||||
|
|
||||||
import org.elasticsearch.common.bytes.BytesReference;
|
import org.elasticsearch.common.bytes.BytesReference;
|
||||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.index.mapper.DocumentMapper;
|
import org.elasticsearch.index.mapper.DocumentMapper;
|
||||||
import org.elasticsearch.index.mapper.DocumentMapperParser;
|
import org.elasticsearch.index.mapper.DocumentMapperParser;
|
||||||
import org.elasticsearch.index.mapper.MapperParsingException;
|
import org.elasticsearch.index.mapper.MapperParsingException;
|
||||||
|
@ -110,7 +110,7 @@ public class EncryptedDocMapperTest extends AttachmentUnitTestCase {
|
||||||
@Test(expected = MapperParsingException.class)
|
@Test(expected = MapperParsingException.class)
|
||||||
public void testMultipleDocsEncryptedNotIgnoringErrors() throws IOException {
|
public void testMultipleDocsEncryptedNotIgnoringErrors() throws IOException {
|
||||||
DocumentMapperParser mapperParser = MapperTestUtils.newMapperParser(
|
DocumentMapperParser mapperParser = MapperTestUtils.newMapperParser(
|
||||||
ImmutableSettings.builder()
|
Settings.builder()
|
||||||
.put("path.home", createTempDir())
|
.put("path.home", createTempDir())
|
||||||
.put("index.mapping.attachment.ignore_errors", false)
|
.put("index.mapping.attachment.ignore_errors", false)
|
||||||
.build());
|
.build());
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/*
|
/*
|
||||||
* Licensed to ElasticSearch and Shay Banon under one
|
* Licensed to Elasticsearch under one or more contributor
|
||||||
* or more contributor license agreements. See the NOTICE file
|
* license agreements. See the NOTICE file distributed with
|
||||||
* distributed with this work for additional information
|
* this work for additional information regarding copyright
|
||||||
* regarding copyright ownership. ElasticSearch licenses this
|
* ownership. Elasticsearch licenses this file to you under
|
||||||
* file to you under the Apache License, Version 2.0 (the
|
* the Apache License, Version 2.0 (the "License"); you may
|
||||||
* "License"); you may not use this file except in compliance
|
* not use this file except in compliance with the License.
|
||||||
* with the License. You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
package org.elasticsearch.index.mapper.attachment.test.unit;
|
package org.elasticsearch.index.mapper.attachment.test.unit;
|
||||||
|
|
||||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.index.mapper.DocumentMapper;
|
import org.elasticsearch.index.mapper.DocumentMapper;
|
||||||
import org.elasticsearch.index.mapper.DocumentMapperParser;
|
import org.elasticsearch.index.mapper.DocumentMapperParser;
|
||||||
|
@ -52,7 +52,7 @@ public class LanguageDetectionAttachmentMapperTests extends AttachmentUnitTestCa
|
||||||
|
|
||||||
public void setupMapperParser(boolean langDetect) throws IOException {
|
public void setupMapperParser(boolean langDetect) throws IOException {
|
||||||
DocumentMapperParser mapperParser = MapperTestUtils.newMapperParser(
|
DocumentMapperParser mapperParser = MapperTestUtils.newMapperParser(
|
||||||
ImmutableSettings.settingsBuilder()
|
Settings.settingsBuilder()
|
||||||
.put("path.home", createTempDir())
|
.put("path.home", createTempDir())
|
||||||
.put("index.mapping.attachment.detect_language", langDetect)
|
.put("index.mapping.attachment.detect_language", langDetect)
|
||||||
.build());
|
.build());
|
||||||
|
|
|
@ -22,7 +22,6 @@ package org.elasticsearch.index.mapper.attachment.test.unit;
|
||||||
import org.elasticsearch.Version;
|
import org.elasticsearch.Version;
|
||||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||||
import org.elasticsearch.common.bytes.BytesReference;
|
import org.elasticsearch.common.bytes.BytesReference;
|
||||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.index.mapper.DocumentMapper;
|
import org.elasticsearch.index.mapper.DocumentMapper;
|
||||||
import org.elasticsearch.index.mapper.DocumentMapperParser;
|
import org.elasticsearch.index.mapper.DocumentMapperParser;
|
||||||
|
@ -45,7 +44,7 @@ import static org.hamcrest.Matchers.*;
|
||||||
public class MetadataMapperTest extends AttachmentUnitTestCase {
|
public class MetadataMapperTest extends AttachmentUnitTestCase {
|
||||||
|
|
||||||
protected void checkMeta(String filename, Settings otherSettings, Long expectedDate, Long expectedLength) throws IOException {
|
protected void checkMeta(String filename, Settings otherSettings, Long expectedDate, Long expectedLength) throws IOException {
|
||||||
Settings settings = ImmutableSettings.builder()
|
Settings settings = Settings.builder()
|
||||||
.put(this.testSettings)
|
.put(this.testSettings)
|
||||||
.put(otherSettings)
|
.put(otherSettings)
|
||||||
.build();
|
.build();
|
||||||
|
@ -81,31 +80,31 @@ public class MetadataMapperTest extends AttachmentUnitTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIgnoreWithoutDate() throws Exception {
|
public void testIgnoreWithoutDate() throws Exception {
|
||||||
checkMeta("htmlWithoutDateMeta.html", ImmutableSettings.builder().build(), null, 300L);
|
checkMeta("htmlWithoutDateMeta.html", Settings.builder().build(), null, 300L);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIgnoreWithEmptyDate() throws Exception {
|
public void testIgnoreWithEmptyDate() throws Exception {
|
||||||
checkMeta("htmlWithEmptyDateMeta.html", ImmutableSettings.builder().build(), null, 334L);
|
checkMeta("htmlWithEmptyDateMeta.html", Settings.builder().build(), null, 334L);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIgnoreWithCorrectDate() throws Exception {
|
public void testIgnoreWithCorrectDate() throws Exception {
|
||||||
checkMeta("htmlWithValidDateMeta.html", ImmutableSettings.builder().build(), 1354233600000L, 344L);
|
checkMeta("htmlWithValidDateMeta.html", Settings.builder().build(), 1354233600000L, 344L);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWithoutDate() throws Exception {
|
public void testWithoutDate() throws Exception {
|
||||||
checkMeta("htmlWithoutDateMeta.html", ImmutableSettings.builder().put("index.mapping.attachment.ignore_errors", false).build(), null, 300L);
|
checkMeta("htmlWithoutDateMeta.html", Settings.builder().put("index.mapping.attachment.ignore_errors", false).build(), null, 300L);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = MapperParsingException.class)
|
@Test(expected = MapperParsingException.class)
|
||||||
public void testWithEmptyDate() throws Exception {
|
public void testWithEmptyDate() throws Exception {
|
||||||
checkMeta("htmlWithEmptyDateMeta.html", ImmutableSettings.builder().put("index.mapping.attachment.ignore_errors", false).build(), null, null);
|
checkMeta("htmlWithEmptyDateMeta.html", Settings.builder().put("index.mapping.attachment.ignore_errors", false).build(), null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWithCorrectDate() throws Exception {
|
public void testWithCorrectDate() throws Exception {
|
||||||
checkMeta("htmlWithValidDateMeta.html", ImmutableSettings.builder().put("index.mapping.attachment.ignore_errors", false).build(), 1354233600000L, 344L);
|
checkMeta("htmlWithValidDateMeta.html", Settings.builder().put("index.mapping.attachment.ignore_errors", false).build(), 1354233600000L, 344L);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ package org.elasticsearch.index.mapper.attachment.test.unit;
|
||||||
import org.elasticsearch.Version;
|
import org.elasticsearch.Version;
|
||||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||||
import org.elasticsearch.common.bytes.BytesReference;
|
import org.elasticsearch.common.bytes.BytesReference;
|
||||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.index.mapper.DocumentMapper;
|
import org.elasticsearch.index.mapper.DocumentMapper;
|
||||||
import org.elasticsearch.index.mapper.DocumentMapperParser;
|
import org.elasticsearch.index.mapper.DocumentMapperParser;
|
||||||
import org.elasticsearch.index.mapper.ParseContext;
|
import org.elasticsearch.index.mapper.ParseContext;
|
||||||
|
@ -71,7 +71,7 @@ public class SimpleAttachmentMapperTests extends AttachmentUnitTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testContentBackcompat() throws Exception {
|
public void testContentBackcompat() throws Exception {
|
||||||
DocumentMapperParser mapperParser = MapperTestUtils.newMapperParser(ImmutableSettings.builder()
|
DocumentMapperParser mapperParser = MapperTestUtils.newMapperParser(Settings.builder()
|
||||||
.put("path.home", createTempDir())
|
.put("path.home", createTempDir())
|
||||||
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_1_4_2.id)
|
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_1_4_2.id)
|
||||||
.build());
|
.build());
|
||||||
|
|
Loading…
Reference in New Issue