diff --git a/pom.xml b/pom.xml index d4c7dbe02e9..b26787cf3e5 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,13 @@ - 0.90.3 + 0.90.10 + 4.6.0 + 1 + true + onerror + + INFO @@ -57,6 +63,13 @@ + + org.apache.lucene + lucene-test-framework + ${lucene.version} + test + + org.elasticsearch elasticsearch @@ -79,20 +92,11 @@ - org.testng - testng - 6.8 + org.elasticsearch + elasticsearch + ${elasticsearch.version} + test-jar test - - - org.hamcrest - hamcrest-core - - - junit - junit - - @@ -116,15 +120,98 @@ + com.carrotsearch.randomizedtesting + junit4-maven-plugin + 2.0.12 + + + tests + test + + junit4 + + + 20 + pipe,warn + true + + + + + + + + + ${tests.jvms} + + + + + + + **/*Tests.class + **/*Test.class + + + **/Abstract*.class + **/*StressTest.class + + + -Xmx512m + -XX:MaxDirectMemorySize=512m + -Des.logger.prefix= + + ${tests.shuffle} + ${tests.verbose} + ${tests.seed} + ${tests.failfast} + + + ${tests.iters} + ${tests.maxfailures} + ${tests.failfast} + ${tests.class} + ${tests.method} + ${tests.nightly} + ${tests.badapples} + ${tests.weekly} + ${tests.slow} + ${tests.awaitsfix} + ${tests.slow} + ${tests.timeoutSuite} + ${tests.showSuccess} + ${tests.integration} + ${tests.cluster_seed} + ${tests.client.ratio} + ${env.ES_TEST_LOCAL} + ${es.node.mode} + ${es.logger.level} + true + + + + + + + org.apache.maven.plugins maven-surefire-plugin - 2.12.3 + 2.15 - - **/*Tests.java - + true + org.apache.maven.plugins maven-source-plugin 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 f8807ca02b3..ec438d42e0b 100644 --- a/src/test/java/org/elasticsearch/index/mapper/xcontent/DateAttachmentMapperTests.java +++ b/src/test/java/org/elasticsearch/index/mapper/xcontent/DateAttachmentMapperTests.java @@ -25,22 +25,21 @@ import org.elasticsearch.index.mapper.DocumentMapper; import org.elasticsearch.index.mapper.DocumentMapperParser; import org.elasticsearch.index.mapper.attachment.AttachmentMapper; import org.elasticsearch.index.mapper.core.StringFieldMapper; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; +import org.elasticsearch.test.ElasticsearchTestCase; +import org.junit.Before; +import org.junit.Test; import static org.elasticsearch.common.io.Streams.copyToStringFromClasspath; -import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.instanceOf; /** * */ -@Test -public class DateAttachmentMapperTests { +public class DateAttachmentMapperTests extends ElasticsearchTestCase { private DocumentMapperParser mapperParser; - @BeforeClass + @Before public void setupMapperParser() { mapperParser = new DocumentMapperParser(new Index("test"), new AnalysisService(new Index("test")), null, null); 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 cee9393a013..682e2dd5d4b 100644 --- a/src/test/java/org/elasticsearch/index/mapper/xcontent/EncryptedDocMapperTest.java +++ b/src/test/java/org/elasticsearch/index/mapper/xcontent/EncryptedDocMapperTest.java @@ -28,14 +28,14 @@ import org.elasticsearch.index.mapper.DocumentMapper; import org.elasticsearch.index.mapper.DocumentMapperParser; import org.elasticsearch.index.mapper.MapperParsingException; import org.elasticsearch.index.mapper.attachment.AttachmentMapper; -import org.testng.annotations.Test; +import org.elasticsearch.test.ElasticsearchTestCase; +import org.junit.Test; import java.io.IOException; import static org.elasticsearch.common.io.Streams.copyToBytesFromClasspath; import static org.elasticsearch.common.io.Streams.copyToStringFromClasspath; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; -import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; /** @@ -43,7 +43,7 @@ import static org.hamcrest.Matchers.*; * Note that we have converted /org/elasticsearch/index/mapper/xcontent/testContentLength.txt * to a /org/elasticsearch/index/mapper/xcontent/encrypted.pdf with password `12345678`. */ -public class EncryptedDocMapperTest { +public class EncryptedDocMapperTest extends ElasticsearchTestCase { @Test public void testMultipleDocsEncryptedLast() throws IOException { @@ -111,7 +111,7 @@ public class EncryptedDocMapperTest { assertThat(doc.getField(docMapper.mappers().smartName("file2.content_length").mapper().names().indexName()).numericValue().longValue(), is(344L)); } - @Test(expectedExceptions = MapperParsingException.class) + @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(), 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 7ce0a51114d..2896c9581b7 100644 --- a/src/test/java/org/elasticsearch/index/mapper/xcontent/MetadataMapperTest.java +++ b/src/test/java/org/elasticsearch/index/mapper/xcontent/MetadataMapperTest.java @@ -29,20 +29,20 @@ import org.elasticsearch.index.mapper.DocumentMapper; import org.elasticsearch.index.mapper.DocumentMapperParser; import org.elasticsearch.index.mapper.MapperParsingException; import org.elasticsearch.index.mapper.attachment.AttachmentMapper; -import org.testng.annotations.Test; +import org.elasticsearch.test.ElasticsearchTestCase; +import org.junit.Test; import java.io.IOException; import static org.elasticsearch.common.io.Streams.copyToBytesFromClasspath; import static org.elasticsearch.common.io.Streams.copyToStringFromClasspath; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; -import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; /** * Test for https://github.com/elasticsearch/elasticsearch-mapper-attachments/issues/38 */ -public class MetadataMapperTest { +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); @@ -96,7 +96,7 @@ public class MetadataMapperTest { checkMeta("htmlWithoutDateMeta.html", ImmutableSettings.builder().put("index.mapping.attachment.ignore_errors", false).build(), null, 300L); } - @Test(expectedExceptions = MapperParsingException.class) + @Test(expected = MapperParsingException.class) public void testWithEmptyDate() throws Exception { checkMeta("htmlWithEmptyDateMeta.html", ImmutableSettings.builder().put("index.mapping.attachment.ignore_errors", false).build(), null, null); } 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 c043da003f7..82c241cfa40 100644 --- a/src/test/java/org/elasticsearch/index/mapper/xcontent/MultifieldAttachmentMapperTests.java +++ b/src/test/java/org/elasticsearch/index/mapper/xcontent/MultifieldAttachmentMapperTests.java @@ -26,22 +26,21 @@ import org.elasticsearch.index.mapper.DocumentMapperParser; import org.elasticsearch.index.mapper.attachment.AttachmentMapper; import org.elasticsearch.index.mapper.core.DateFieldMapper; import org.elasticsearch.index.mapper.core.StringFieldMapper; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; +import org.elasticsearch.test.ElasticsearchTestCase; +import org.junit.Before; +import org.junit.Test; import static org.elasticsearch.common.io.Streams.copyToStringFromClasspath; -import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.instanceOf; /** * */ -@Test -public class MultifieldAttachmentMapperTests { +public class MultifieldAttachmentMapperTests extends ElasticsearchTestCase { private DocumentMapperParser mapperParser; - @BeforeClass + @Before public void setupMapperParser() { mapperParser = new DocumentMapperParser(new Index("test"), new AnalysisService(new Index("test")), null, null); 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 dadd3f0388c..19a9b696eab 100644 --- a/src/test/java/org/elasticsearch/index/mapper/xcontent/SimpleAttachmentMapperTests.java +++ b/src/test/java/org/elasticsearch/index/mapper/xcontent/SimpleAttachmentMapperTests.java @@ -26,25 +26,24 @@ 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; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; +import org.elasticsearch.test.ElasticsearchTestCase; +import org.junit.Before; +import org.junit.Test; import static org.elasticsearch.common.io.Streams.copyToBytesFromClasspath; import static org.elasticsearch.common.io.Streams.copyToStringFromClasspath; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; -import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; /** * */ -@Test -public class SimpleAttachmentMapperTests { +public class SimpleAttachmentMapperTests extends ElasticsearchTestCase { private DocumentMapperParser mapperParser; - @BeforeClass + @Before public void setupMapperParser() { mapperParser = new DocumentMapperParser(new Index("test"), new AnalysisService(new Index("test")), null, null); mapperParser.putTypeParser(AttachmentMapper.CONTENT_TYPE, new AttachmentMapper.TypeParser()); diff --git a/src/test/java/org/elasticsearch/plugin/mapper/attachments/test/MultipleAttachmentIntegrationTests.java b/src/test/java/org/elasticsearch/plugin/mapper/attachments/test/MultipleAttachmentIntegrationTests.java index c8a1d68f781..10a1438628e 100644 --- a/src/test/java/org/elasticsearch/plugin/mapper/attachments/test/MultipleAttachmentIntegrationTests.java +++ b/src/test/java/org/elasticsearch/plugin/mapper/attachments/test/MultipleAttachmentIntegrationTests.java @@ -19,20 +19,12 @@ package org.elasticsearch.plugin.mapper.attachments.test; -import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; -import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus; import org.elasticsearch.action.count.CountResponse; -import org.elasticsearch.common.logging.ESLogger; -import org.elasticsearch.common.logging.Loggers; -import org.elasticsearch.common.network.NetworkUtils; -import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.mapper.MapperParsingException; -import org.elasticsearch.node.Node; -import org.testng.annotations.AfterClass; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; +import org.elasticsearch.test.ElasticsearchIntegrationTest; +import org.junit.Before; +import org.junit.Test; import static org.elasticsearch.client.Requests.*; import static org.elasticsearch.common.io.Streams.copyToBytesFromClasspath; @@ -40,47 +32,25 @@ import static org.elasticsearch.common.io.Streams.copyToStringFromClasspath; import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.index.query.QueryBuilders.fieldQuery; -import static org.elasticsearch.node.NodeBuilder.nodeBuilder; -import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; /** * Test case for issue https://github.com/elasticsearch/elasticsearch-mapper-attachments/issues/18 */ -@Test -public class MultipleAttachmentIntegrationTests { +public class MultipleAttachmentIntegrationTests extends ElasticsearchIntegrationTest { + private boolean ignore_errors = true; - private final ESLogger logger = Loggers.getLogger(getClass()); - - private Node node; - - @BeforeClass - public void setupServer() { - node = nodeBuilder().local(true).settings(settingsBuilder() - .put("path.data", "target/data") - .put("cluster.name", "test-cluster-" + NetworkUtils.getLocalAddress()) - .put("gateway.type", "none")).node(); + @Before + public void cleanTestIndex() throws Exception { + wipeIndices("test"); } - @AfterClass - public void closeServer() { - node.close(); - } - - private void createIndex(Settings settings) { - logger.info("creating index [test]"); - node.client().admin().indices().create(createIndexRequest("test").settings(settingsBuilder().put("index.numberOfReplicas", 0).put(settings))).actionGet(); - logger.info("Running Cluster Health"); - ClusterHealthResponse clusterHealth = node.client().admin().cluster().health(clusterHealthRequest().waitForGreenStatus()).actionGet(); - logger.info("Done Cluster Health, status " + clusterHealth.getStatus()); - assertThat(clusterHealth.isTimedOut(), equalTo(false)); - assertThat(clusterHealth.getStatus(), equalTo(ClusterHealthStatus.GREEN)); - } - - @AfterMethod - public void deleteIndex() { - logger.info("deleting index [test]"); - node.client().admin().indices().delete(deleteIndexRequest("test")).actionGet(); + @Override + public Settings indexSettings() { + return settingsBuilder() + .put("index.numberOfReplicas", 0) + .put("index.mapping.attachment.ignore_errors", ignore_errors) + .build(); } /** @@ -88,38 +58,45 @@ public class MultipleAttachmentIntegrationTests { */ @Test public void testMultipleAttachmentsWithEncryptedDoc() throws Exception { - createIndex(ImmutableSettings.builder().build()); + ignore_errors = true; + logger.info("creating index [test]"); + createIndex("test"); + ensureGreen(); + String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/multipledocs/test-mapping.json"); byte[] html = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/xcontent/htmlWithValidDateMeta.html"); byte[] pdf = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/xcontent/encrypted.pdf"); - node.client().admin().indices().putMapping(putMappingRequest("test").type("person").source(mapping)).actionGet(); + client().admin().indices().putMapping(putMappingRequest("test").type("person").source(mapping)).actionGet(); - node.client().index(indexRequest("test").type("person") - .source(jsonBuilder().startObject().field("file1", html).field("file2", pdf).field("hello","world").endObject())).actionGet(); - node.client().admin().indices().refresh(refreshRequest()).actionGet(); + index("test", "person", jsonBuilder().startObject().field("file1", html).field("file2", pdf).field("hello","world").endObject()); + refresh(); - CountResponse countResponse = node.client().count(countRequest("test").query(fieldQuery("file1", "World"))).actionGet(); + CountResponse countResponse = client().count(countRequest("test").query(fieldQuery("file1", "World"))).actionGet(); assertThat(countResponse.getCount(), equalTo(1l)); - countResponse = node.client().count(countRequest("test").query(fieldQuery("hello", "World"))).actionGet(); + countResponse = client().count(countRequest("test").query(fieldQuery("hello", "World"))).actionGet(); assertThat(countResponse.getCount(), equalTo(1l)); } /** * When we don't want to ignore errors */ - @Test(expectedExceptions = MapperParsingException.class) + @Test(expected = MapperParsingException.class) public void testMultipleAttachmentsWithEncryptedDocNotIgnoringErrors() throws Exception { - createIndex(ImmutableSettings.builder().put("index.mapping.attachment.ignore_errors", false).build()); + ignore_errors = false; + + logger.info("creating index [test]"); + createIndex("test"); + ensureGreen(); + String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/multipledocs/test-mapping.json"); byte[] html = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/xcontent/htmlWithValidDateMeta.html"); byte[] pdf = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/xcontent/encrypted.pdf"); - node.client().admin().indices() + client().admin().indices() .putMapping(putMappingRequest("test").type("person").source(mapping)).actionGet(); - node.client().index(indexRequest("test").type("person") - .source(jsonBuilder().startObject().field("file1", html).field("file2", pdf).field("hello","world").endObject())).actionGet(); + index("test", "person", jsonBuilder().startObject().field("file1", html).field("file2", pdf).field("hello","world").endObject()); } } diff --git a/src/test/java/org/elasticsearch/plugin/mapper/attachments/test/SimpleAttachmentIntegrationTests.java b/src/test/java/org/elasticsearch/plugin/mapper/attachments/test/SimpleAttachmentIntegrationTests.java index d34dfccfc8b..0034c598331 100644 --- a/src/test/java/org/elasticsearch/plugin/mapper/attachments/test/SimpleAttachmentIntegrationTests.java +++ b/src/test/java/org/elasticsearch/plugin/mapper/attachments/test/SimpleAttachmentIntegrationTests.java @@ -19,15 +19,12 @@ package org.elasticsearch.plugin.mapper.attachments.test; -import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; -import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus; import org.elasticsearch.action.count.CountResponse; -import org.elasticsearch.common.logging.ESLogger; -import org.elasticsearch.common.logging.Loggers; -import org.elasticsearch.common.network.NetworkUtils; +import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.mapper.MapperParsingException; -import org.elasticsearch.node.Node; -import org.testng.annotations.*; +import org.elasticsearch.test.ElasticsearchIntegrationTest; +import org.junit.Before; +import org.junit.Test; import static org.elasticsearch.client.Requests.*; import static org.elasticsearch.common.io.Streams.copyToBytesFromClasspath; @@ -35,48 +32,26 @@ import static org.elasticsearch.common.io.Streams.copyToStringFromClasspath; import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.index.query.QueryBuilders.fieldQuery; -import static org.elasticsearch.node.NodeBuilder.nodeBuilder; -import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; /** * */ -@Test -public class SimpleAttachmentIntegrationTests { +public class SimpleAttachmentIntegrationTests extends ElasticsearchIntegrationTest { - private final ESLogger logger = Loggers.getLogger(getClass()); - - private Node node; - - @BeforeClass - public void setupServer() { - node = nodeBuilder().local(true).settings(settingsBuilder() - .put("path.data", "target/data") - .put("cluster.name", "test-cluster-" + NetworkUtils.getLocalAddress()) - .put("gateway.type", "none")).node(); - } - - @AfterClass - public void closeServer() { - node.close(); - } - - @BeforeMethod - public void createIndex() { + @Before + public void createEmptyIndex() throws Exception { logger.info("creating index [test]"); - node.client().admin().indices().create(createIndexRequest("test").settings(settingsBuilder().put("index.numberOfReplicas", 0))).actionGet(); - logger.info("Running Cluster Health"); - ClusterHealthResponse clusterHealth = node.client().admin().cluster().health(clusterHealthRequest().waitForGreenStatus()).actionGet(); - logger.info("Done Cluster Health, status " + clusterHealth.getStatus()); - assertThat(clusterHealth.isTimedOut(), equalTo(false)); - assertThat(clusterHealth.getStatus(), equalTo(ClusterHealthStatus.GREEN)); + wipeIndices("test"); + createIndex("test"); + ensureGreen(); } - @AfterMethod - public void deleteIndex() { - logger.info("deleting index [test]"); - node.client().admin().indices().delete(deleteIndexRequest("test")).actionGet(); + @Override + public Settings indexSettings() { + return settingsBuilder() + .put("index.numberOfReplicas", 0) + .build(); } @Test @@ -84,16 +59,15 @@ public class SimpleAttachmentIntegrationTests { String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/xcontent/test-mapping.json"); byte[] html = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/xcontent/testXHTML.html"); - node.client().admin().indices().putMapping(putMappingRequest("test").type("person").source(mapping)).actionGet(); + client().admin().indices().putMapping(putMappingRequest("test").type("person").source(mapping)).actionGet(); - node.client().index(indexRequest("test").type("person") - .source(jsonBuilder().startObject().field("file", html).endObject())).actionGet(); - node.client().admin().indices().refresh(refreshRequest()).actionGet(); + index("test", "person", jsonBuilder().startObject().field("file", html).endObject()); + refresh(); - CountResponse countResponse = node.client().count(countRequest("test").query(fieldQuery("file.title", "test document"))).actionGet(); + CountResponse countResponse = client().count(countRequest("test").query(fieldQuery("file.title", "test document"))).actionGet(); assertThat(countResponse.getCount(), equalTo(1l)); - countResponse = node.client().count(countRequest("test").query(fieldQuery("file", "tests the ability"))).actionGet(); + countResponse = client().count(countRequest("test").query(fieldQuery("file", "tests the ability"))).actionGet(); assertThat(countResponse.getCount(), equalTo(1l)); } @@ -103,16 +77,15 @@ public class SimpleAttachmentIntegrationTests { byte[] txt = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/xcontent/testContentLength.txt"); final int CONTENT_LENGTH_LIMIT = 20; - node.client().admin().indices().putMapping(putMappingRequest("test").type("person").source(mapping)).actionGet(); + client().admin().indices().putMapping(putMappingRequest("test").type("person").source(mapping)).actionGet(); - node.client().index(indexRequest("test").type("person") - .source(jsonBuilder().startObject().field("file").startObject().field("content", txt).field("_indexed_chars", CONTENT_LENGTH_LIMIT).endObject())).actionGet(); - node.client().admin().indices().refresh(refreshRequest()).actionGet(); + index("test", "person", jsonBuilder().startObject().field("file").startObject().field("content", txt).field("_indexed_chars", CONTENT_LENGTH_LIMIT).endObject()); + refresh(); - CountResponse countResponse = node.client().count(countRequest("test").query(fieldQuery("file", "BeforeLimit"))).actionGet(); + CountResponse countResponse = client().count(countRequest("test").query(fieldQuery("file", "BeforeLimit"))).actionGet(); assertThat(countResponse.getCount(), equalTo(1l)); - countResponse = node.client().count(countRequest("test").query(fieldQuery("file", "AfterLimit"))).actionGet(); + countResponse = client().count(countRequest("test").query(fieldQuery("file", "AfterLimit"))).actionGet(); assertThat(countResponse.getCount(), equalTo(0l)); } @@ -122,16 +95,15 @@ public class SimpleAttachmentIntegrationTests { byte[] txt = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/xcontent/testContentLength.txt"); final int CONTENT_LENGTH_LIMIT = -1; - node.client().admin().indices().putMapping(putMappingRequest("test").type("person").source(mapping)).actionGet(); + client().admin().indices().putMapping(putMappingRequest("test").type("person").source(mapping)).actionGet(); - node.client().index(indexRequest("test").type("person") - .source(jsonBuilder().startObject().field("file").startObject().field("content", txt).field("_indexed_chars", CONTENT_LENGTH_LIMIT).endObject())).actionGet(); - node.client().admin().indices().refresh(refreshRequest()).actionGet(); + index("test", "person", jsonBuilder().startObject().field("file").startObject().field("content", txt).field("_indexed_chars", CONTENT_LENGTH_LIMIT).endObject()); + refresh(); - CountResponse countResponse = node.client().count(countRequest("test").query(fieldQuery("file", "Begin"))).actionGet(); + CountResponse countResponse = client().count(countRequest("test").query(fieldQuery("file", "Begin"))).actionGet(); assertThat(countResponse.getCount(), equalTo(1l)); - countResponse = node.client().count(countRequest("test").query(fieldQuery("file", "End"))).actionGet(); + countResponse = client().count(countRequest("test").query(fieldQuery("file", "End"))).actionGet(); assertThat(countResponse.getCount(), equalTo(1l)); } @@ -140,13 +112,12 @@ public class SimpleAttachmentIntegrationTests { *
We throw a nicer exception when no content is provided * @throws Exception */ - @Test(expectedExceptions = MapperParsingException.class) + @Test(expected = MapperParsingException.class) public void testNoContent() throws Exception { - String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/xcontent/test-mapping.json"); + String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/xcontent/test-mapping.json"); - node.client().admin().indices().putMapping(putMappingRequest("test").type("person").source(mapping)).actionGet(); + client().admin().indices().putMapping(putMappingRequest("test").type("person").source(mapping)).actionGet(); - node.client().index(indexRequest("test").type("person") - .source(jsonBuilder().startObject().field("file").startObject().endObject())).actionGet(); + index("test", "person", jsonBuilder().startObject().field("file").startObject().endObject()); } }