do not assert charset for mapper-attachments tests.
Its enough to test the content type for what we are testing. Currently tests are flaky if charset is detected as e.g. windows-1252 vs iso-8859-1 and so on. In fact, they fail on windows 100% of the time. We are not trying to test charset detection heuristics (which might be different even due to newlines in tests or other things). If we want to do test that, we should test it separately.
This commit is contained in:
parent
f8a027e591
commit
415c37340a
|
@ -60,7 +60,7 @@ public class EncryptedDocMapperTests extends AttachmentUnitTestCase {
|
|||
assertThat(doc.get(docMapper.mappers().getMapper("file1.title").fieldType().names().indexName()), equalTo("Hello"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file1.author").fieldType().names().indexName()), equalTo("kimchy"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file1.keywords").fieldType().names().indexName()), equalTo("elasticsearch,cool,bonsai"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file1.content_type").fieldType().names().indexName()), equalTo("text/html; charset=ISO-8859-1"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file1.content_type").fieldType().names().indexName()), startsWith("text/html;"));
|
||||
assertThat(doc.getField(docMapper.mappers().getMapper("file1.content_length").fieldType().names().indexName()).numericValue().longValue(), is(344L));
|
||||
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file2").fieldType().names().indexName()), nullValue());
|
||||
|
@ -96,7 +96,7 @@ public class EncryptedDocMapperTests extends AttachmentUnitTestCase {
|
|||
assertThat(doc.get(docMapper.mappers().getMapper("file2.title").fieldType().names().indexName()), equalTo("Hello"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file2.author").fieldType().names().indexName()), equalTo("kimchy"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file2.keywords").fieldType().names().indexName()), equalTo("elasticsearch,cool,bonsai"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file2.content_type").fieldType().names().indexName()), equalTo("text/html; charset=ISO-8859-1"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file2.content_type").fieldType().names().indexName()), startsWith("text/html;"));
|
||||
assertThat(doc.getField(docMapper.mappers().getMapper("file2.content_length").fieldType().names().indexName()).numericValue().longValue(), is(344L));
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ public class MetadataMapperTests extends AttachmentUnitTestCase {
|
|||
assertThat(doc.get(docMapper.mappers().getMapper("file.title").fieldType().names().indexName()), equalTo("Hello"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file.author").fieldType().names().indexName()), equalTo("kimchy"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file.keywords").fieldType().names().indexName()), equalTo("elasticsearch,cool,bonsai"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file.content_type").fieldType().names().indexName()), equalTo("text/html; charset=ISO-8859-1"));
|
||||
assertThat(doc.get(docMapper.mappers().getMapper("file.content_type").fieldType().names().indexName()), startsWith("text/html;"));
|
||||
assertThat(doc.getField(docMapper.mappers().getMapper("file.content_length").fieldType().names().indexName()).numericValue().longValue(), is(expectedLength));
|
||||
}
|
||||
|
||||
|
|
|
@ -86,7 +86,6 @@ public class MultifieldAttachmentMapperTests extends AttachmentUnitTestCase {
|
|||
|
||||
public void testExternalValues() throws Exception {
|
||||
String originalText = "This is an elasticsearch mapper attachment test.";
|
||||
String contentType = "text/plain; charset=ISO-8859-1";
|
||||
String forcedName = "dummyname.txt";
|
||||
|
||||
String bytes = Base64.encodeBytes(originalText.getBytes(StandardCharsets.ISO_8859_1));
|
||||
|
@ -108,9 +107,9 @@ public class MultifieldAttachmentMapperTests extends AttachmentUnitTestCase {
|
|||
assertThat(doc.rootDoc().getField("file.content").stringValue(), is(originalText + "\n"));
|
||||
|
||||
assertThat(doc.rootDoc().getField("file.content_type"), notNullValue());
|
||||
assertThat(doc.rootDoc().getField("file.content_type").stringValue(), is(contentType));
|
||||
assertThat(doc.rootDoc().getField("file.content_type").stringValue(), startsWith("text/plain;"));
|
||||
assertThat(doc.rootDoc().getField("file.content_type.suggest"), notNullValue());
|
||||
assertThat(doc.rootDoc().getField("file.content_type.suggest").stringValue(), is(contentType));
|
||||
assertThat(doc.rootDoc().getField("file.content_type.suggest").stringValue(), startsWith("text/plain;"));
|
||||
assertThat(doc.rootDoc().getField("file.content_length"), notNullValue());
|
||||
assertThat(doc.rootDoc().getField("file.content_length").numericValue().intValue(), is(originalText.length()));
|
||||
|
||||
|
@ -131,9 +130,9 @@ public class MultifieldAttachmentMapperTests extends AttachmentUnitTestCase {
|
|||
assertThat(doc.rootDoc().getField("file.content").stringValue(), is(originalText + "\n"));
|
||||
|
||||
assertThat(doc.rootDoc().getField("file.content_type"), notNullValue());
|
||||
assertThat(doc.rootDoc().getField("file.content_type").stringValue(), is(contentType));
|
||||
assertThat(doc.rootDoc().getField("file.content_type").stringValue(), startsWith("text/plain;"));
|
||||
assertThat(doc.rootDoc().getField("file.content_type.suggest"), notNullValue());
|
||||
assertThat(doc.rootDoc().getField("file.content_type.suggest").stringValue(), is(contentType));
|
||||
assertThat(doc.rootDoc().getField("file.content_type.suggest").stringValue(), startsWith("text/plain;"));
|
||||
assertThat(doc.rootDoc().getField("file.content_length"), notNullValue());
|
||||
assertThat(doc.rootDoc().getField("file.content_length").numericValue().intValue(), is(originalText.length()));
|
||||
|
||||
|
|
Loading…
Reference in New Issue