This is an automated email from the ASF dual-hosted git repository.

gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 42ff15a85d5309f523cd77c2cd9067483550fd1e
Author: Guillaume Nodet <[email protected]>
AuthorDate: Wed Jun 24 11:49:38 2020 +0200

    [CAMEL-11807] Upgrade camel-elasticsearch-rest to junit5
---
 components/camel-elasticsearch-rest/pom.xml        |  4 +-
 .../elasticsearch/ElasticsearchBaseTest.java       | 44 +++++-----
 .../elasticsearch/ElasticsearchBulkTest.java       |  8 +-
 .../ElasticsearchClusterIndexTest.java             | 16 ++--
 ...asticsearchGetSearchDeleteExistsUpdateTest.java | 98 ++++++++++++----------
 .../elasticsearch/ElasticsearchIndexTest.java      | 19 +++--
 .../elasticsearch/ElasticsearchPingTest.java       |  6 +-
 ...icsearchRestComponentVerifierExtensionTest.java | 11 +--
 .../ElasticsearchScrollSearchTest.java             | 37 ++++----
 .../elasticsearch/ElasticsearchSizeLimitTest.java  |  6 +-
 10 files changed, 138 insertions(+), 111 deletions(-)

diff --git a/components/camel-elasticsearch-rest/pom.xml 
b/components/camel-elasticsearch-rest/pom.xml
index 1a46a44..1ec8a3e 100644
--- a/components/camel-elasticsearch-rest/pom.xml
+++ b/components/camel-elasticsearch-rest/pom.xml
@@ -59,7 +59,7 @@
         <!-- for testing -->
         <dependency>
             <groupId>org.apache.camel</groupId>
-            <artifactId>camel-test</artifactId>
+            <artifactId>camel-test-junit5</artifactId>
             <scope>test</scope>
         </dependency>
         <dependency>
@@ -76,7 +76,7 @@
 
         <dependency>
             <groupId>org.apache.camel</groupId>
-            <artifactId>camel-testcontainers</artifactId>
+            <artifactId>camel-testcontainers-junit5</artifactId>
             <scope>test</scope>
         </dependency>
 
diff --git 
a/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchBaseTest.java
 
b/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchBaseTest.java
index 367a112..02b87e2 100644
--- 
a/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchBaseTest.java
+++ 
b/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchBaseTest.java
@@ -16,30 +16,30 @@
  */
 package org.apache.camel.component.elasticsearch;
 
-import java.io.IOException;
 import java.net.HttpURLConnection;
 import java.time.Duration;
 import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.camel.CamelContext;
-import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.test.testcontainers.junit5.ContainerAwareTestSupport;
 import org.apache.http.HttpHost;
 import org.elasticsearch.client.RestClient;
 import org.elasticsearch.client.RestHighLevelClient;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
+import org.junit.jupiter.api.TestInstance;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.testcontainers.containers.GenericContainer;
 import org.testcontainers.containers.wait.strategy.HttpWaitStrategy;
 import org.testcontainers.utility.Base58;
 
-public class ElasticsearchBaseTest extends CamelTestSupport {
+@TestInstance(TestInstance.Lifecycle.PER_CLASS)
+public class ElasticsearchBaseTest extends ContainerAwareTestSupport {
+
     public static final String ELASTICSEARCH_IMAGE = "elasticsearch:7.3.2";
     public static final int ELASTICSEARCH_DEFAULT_PORT = 9200;
     public static final int ELASTICSEARCH_DEFAULT_TCP_PORT = 9300;
-
-    @ClassRule
+    
     public static GenericContainer elasticsearch = new 
GenericContainer<>(ELASTICSEARCH_IMAGE)
         .withNetworkAliases("elasticsearch-" + Base58.randomString(6))
         .withEnv("discovery.type", "single-node")
@@ -53,28 +53,30 @@ public class ElasticsearchBaseTest extends CamelTestSupport 
{
     protected static RestClient restClient;
     protected static RestHighLevelClient client;
 
-    @BeforeClass
-    public static void setUpOnce() throws Exception {
-        HttpHost host = new HttpHost(elasticsearch.getContainerIpAddress(),  
elasticsearch.getMappedPort(ELASTICSEARCH_DEFAULT_PORT));
+    private static final Logger LOG = 
LoggerFactory.getLogger(ElasticsearchBaseTest.class);
+
+    @Override
+    protected GenericContainer<?> createContainer() {
+        return elasticsearch;
+    }
 
+    @Override
+    protected void setupResources() throws Exception {
+        super.setupResources();
+        HttpHost host = new HttpHost(elasticsearch.getContainerIpAddress(),  
elasticsearch.getMappedPort(ELASTICSEARCH_DEFAULT_PORT));
         client = new RestHighLevelClient(RestClient.builder(host));
         restClient = client.getLowLevelClient();
     }
 
-    @AfterClass
-    public static void teardownOnce() throws IOException {
+    @Override
+    protected void cleanupResources() throws Exception {
+        super.cleanupResources();
         if (client != null) {
             client.close();
         }
     }
 
     @Override
-    public boolean isCreateCamelContextPerClass() {
-        // let's speed up the tests using the same context
-        return true;
-    }
-
-    @Override
     protected CamelContext createCamelContext() throws Exception {
         final ElasticsearchComponent elasticsearchComponent = new 
ElasticsearchComponent();
         
elasticsearchComponent.setHostAddresses(elasticsearch.getContainerIpAddress() + 
":" + elasticsearch.getMappedPort(ELASTICSEARCH_DEFAULT_PORT));
@@ -105,7 +107,7 @@ public class ElasticsearchBaseTest extends CamelTestSupport 
{
 
         String key = prefix + "key";
         String value = prefix + "value";
-        log.info("Creating indexed data using the key/value pair {} => {}", 
key, value);
+        LOG.info("Creating indexed data using the key/value pair {} => {}", 
key, value);
 
         Map<String, String> map = new HashMap<>();
         map.put(key, value);
@@ -114,7 +116,7 @@ public class ElasticsearchBaseTest extends CamelTestSupport 
{
 
     String createPrefix() {
         // make use of the test method name to avoid collision
-        return getTestMethodName().toLowerCase() + "-";
+        return getCurrentTestName().toLowerCase() + "-";
     }
 
     RestClient getClient() {
diff --git 
a/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchBulkTest.java
 
b/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchBulkTest.java
index 249437d..e96d74a 100644
--- 
a/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchBulkTest.java
+++ 
b/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchBulkTest.java
@@ -25,10 +25,14 @@ import org.apache.camel.builder.RouteBuilder;
 import org.elasticsearch.action.bulk.BulkItemResponse;
 import org.elasticsearch.action.bulk.BulkRequest;
 import org.elasticsearch.action.index.IndexRequest;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
+import static org.apache.camel.test.junit5.TestSupport.assertCollectionSize;
 import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 public class ElasticsearchBulkTest extends ElasticsearchBaseTest {
 
@@ -42,7 +46,7 @@ public class ElasticsearchBulkTest extends 
ElasticsearchBaseTest {
         documents.add(document2);
 
         List<?> indexIds = template.requestBody("direct:bulk_index", 
documents, List.class);
-        assertNotNull("indexIds should be set", indexIds);
+        assertNotNull(indexIds, "indexIds should be set");
         assertCollectionSize("Indexed documents should match the size of 
documents", indexIds, documents.size());
     }
 
diff --git 
a/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchClusterIndexTest.java
 
b/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchClusterIndexTest.java
index 1db0fe8..7f6e48c 100644
--- 
a/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchClusterIndexTest.java
+++ 
b/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchClusterIndexTest.java
@@ -24,7 +24,11 @@ import org.apache.http.impl.client.BasicResponseHandler;
 import org.elasticsearch.action.get.GetRequest;
 import org.elasticsearch.client.Request;
 import org.elasticsearch.client.RequestOptions;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.apache.camel.test.junit5.TestSupport.assertStringContains;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 public class ElasticsearchClusterIndexTest extends ElasticsearchBaseTest {
     @Test
@@ -36,14 +40,14 @@ public class ElasticsearchClusterIndexTest extends 
ElasticsearchBaseTest {
         headers.put(ElasticsearchConstants.PARAM_INDEX_ID, "1");
 
         String indexId = 
template.requestBodyAndHeaders("direct:indexWithIpAndPort", map, headers, 
String.class);
-        assertNotNull("indexId should be set", indexId);
+        assertNotNull(indexId, "indexId should be set");
 
 
         indexId = template.requestBodyAndHeaders("direct:indexWithIpAndPort", 
map, headers, String.class);
-        assertNotNull("indexId should be set", indexId);
+        assertNotNull(indexId, "indexId should be set");
 
         //assertEquals("Cluster must be of one node", runner.getNodeSize(), 1);
-        assertEquals("Index id 1 must exists", true, client.get(new 
GetRequest("twitter").id("1"), RequestOptions.DEFAULT).isExists());
+        assertTrue(client.get(new GetRequest("twitter").id("1"), 
RequestOptions.DEFAULT).isExists(), "Index id 1 must exists");
     }
 
     @Test
@@ -55,10 +59,10 @@ public class ElasticsearchClusterIndexTest extends 
ElasticsearchBaseTest {
         headers.put(ElasticsearchConstants.PARAM_INDEX_ID, "4");
 
         String indexId = 
template.requestBodyAndHeaders("direct:indexWithSniffer", map, headers, 
String.class);
-        assertNotNull("indexId should be set", indexId);
+        assertNotNull(indexId, "indexId should be set");
 
         //assertEquals("Cluster must be of three nodes", runner.getNodeSize(), 
1);
-        assertEquals("Index id 4 must exists", true, client.get(new 
GetRequest("facebook").id("4"), RequestOptions.DEFAULT).isExists());
+        assertTrue(client.get(new GetRequest("facebook").id("4"), 
RequestOptions.DEFAULT).isExists(), "Index id 4 must exists");
 
         final BasicResponseHandler responseHandler = new 
BasicResponseHandler();
         Request request = new Request("GET", "/_cluster/health?pretty");
diff --git 
a/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchGetSearchDeleteExistsUpdateTest.java
 
b/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchGetSearchDeleteExistsUpdateTest.java
index 512f98f..f302716 100644
--- 
a/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchGetSearchDeleteExistsUpdateTest.java
+++ 
b/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchGetSearchDeleteExistsUpdateTest.java
@@ -30,10 +30,16 @@ import org.elasticsearch.action.search.MultiSearchRequest;
 import org.elasticsearch.action.search.MultiSearchResponse.Item;
 import org.elasticsearch.action.search.SearchRequest;
 import org.elasticsearch.search.SearchHits;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 public class ElasticsearchGetSearchDeleteExistsUpdateTest extends 
ElasticsearchBaseTest {
 
@@ -43,12 +49,12 @@ public class ElasticsearchGetSearchDeleteExistsUpdateTest 
extends ElasticsearchB
         Map<String, String> map = createIndexedData();
         sendBody("direct:index", map);
         String indexId = template.requestBody("direct:index", map, 
String.class);
-        assertNotNull("indexId should be set", indexId);
+        assertNotNull(indexId, "indexId should be set");
 
         //now, verify GET succeeded
         GetResponse response = template.requestBody("direct:get", indexId, 
GetResponse.class);
-        assertNotNull("response should not be null", response);
-        assertNotNull("response source should not be null", 
response.getSource());
+        assertNotNull(response, "response should not be null");
+        assertNotNull(response.getSource(), "response source should not be 
null");
     }
 
     @Test
@@ -57,21 +63,21 @@ public class ElasticsearchGetSearchDeleteExistsUpdateTest 
extends ElasticsearchB
         Map<String, String> map = createIndexedData();
         sendBody("direct:index", map);
         String indexId = template.requestBody("direct:index", map, 
String.class);
-        assertNotNull("indexId should be set", indexId);
+        assertNotNull(indexId, "indexId should be set");
 
         //now, verify GET succeeded
         GetResponse response = template.requestBody("direct:get", indexId, 
GetResponse.class);
-        assertNotNull("response should not be null", response);
-        assertNotNull("response source should not be null", 
response.getSource());
+        assertNotNull(response, "response should not be null");
+        assertNotNull(response.getSource(), "response source should not be 
null");
 
         //now, perform Delete
         DeleteResponse.Result deleteResponse = 
template.requestBody("direct:delete", indexId, DeleteResponse.Result.class);
-        assertNotNull("response should not be null", deleteResponse);
+        assertNotNull(deleteResponse, "response should not be null");
 
         //now, verify GET fails to find the indexed value
         response = template.requestBody("direct:get", indexId, 
GetResponse.class);
-        assertNotNull("response should not be null", response);
-        assertNull("response source should be null", response.getSource());
+        assertNotNull(response, "response should not be null");
+        assertNull(response.getSource(), "response source should be null");
     }
 
     @Test
@@ -79,12 +85,12 @@ public class ElasticsearchGetSearchDeleteExistsUpdateTest 
extends ElasticsearchB
         //first, Index a value
         Map<String, String> map = createIndexedData();
         String indexId = template.requestBody("direct:index", map, 
String.class);
-        assertNotNull("indexId should be set", indexId);
+        assertNotNull(indexId, "indexId should be set");
 
         //now, verify GET succeeded
         GetResponse getResponse = template.requestBody("direct:get", indexId, 
GetResponse.class);
-        assertNotNull("response should not be null", getResponse);
-        assertNotNull("response source should not be null", 
getResponse.getSource());
+        assertNotNull(getResponse, "response should not be null");
+        assertNotNull(getResponse.getSource(), "response source should not be 
null");
         //now, verify GET succeeded
         Map<String, Object> actualQuery = new HashMap<>();
         actualQuery.put("testsearchwithmapquery-key", 
"testsearchwithmapquery-value");
@@ -93,8 +99,8 @@ public class ElasticsearchGetSearchDeleteExistsUpdateTest 
extends ElasticsearchB
         Map<String, Object> query = new HashMap<>();
         query.put("query", match);
         SearchHits response = template.requestBody("direct:search", query, 
SearchHits.class);
-        assertNotNull("response should not be null", response);
-        assertEquals("response hits should be == 0", 0, 
response.getTotalHits().value);
+        assertNotNull(response, "response should not be null");
+        assertEquals(0, response.getTotalHits().value, "response hits should 
be == 0");
     }
 
     @Test
@@ -102,25 +108,25 @@ public class ElasticsearchGetSearchDeleteExistsUpdateTest 
extends ElasticsearchB
         //first, Index a value
         Map<String, String> map = createIndexedData();
         String indexId = template.requestBody("direct:index", map, 
String.class);
-        assertNotNull("indexId should be set", indexId);
+        assertNotNull(indexId, "indexId should be set");
 
         //now, verify GET succeeded
         GetResponse getResponse = template.requestBody("direct:get", indexId, 
GetResponse.class);
-        assertNotNull("response should not be null", getResponse);
-        assertNotNull("response source should not be null", 
getResponse.getSource());
+        assertNotNull(getResponse, "response should not be null");
+        assertNotNull(getResponse.getSource(), "response source should not be 
null");
         // need to create a query string
         String query = "{\n"
                 + "    \"query\" : { \"match\" : { \"key\" : \"value\" }}\n"
                 + "}\n";
         SearchHits response = template.requestBody("direct:search", query, 
SearchHits.class);
-        assertNotNull("response should not be null", response);
-        assertEquals("response hits should be == 0", 0, 
response.getTotalHits().value);
+        assertNotNull(response, "response should not be null");
+        assertEquals(0, response.getTotalHits().value, "response hits should 
be == 0");
 
         // testing
 
         response = template.requestBody("direct:search-1", query, 
SearchHits.class);
-        assertNotNull("response should not be null", response);
-        assertEquals("response hits should be == 0", 0, 
response.getTotalHits().value);
+        assertNotNull(response, "response should not be null");
+        assertEquals(0, response.getTotalHits().value, "response hits should 
be == 0");
     }
 
     @Test
@@ -128,12 +134,12 @@ public class ElasticsearchGetSearchDeleteExistsUpdateTest 
extends ElasticsearchB
         //first, Index a value
         Map<String, String> map = createIndexedData();
         String indexId = template.requestBody("direct:index", map, 
String.class);
-        assertNotNull("indexId should be set", indexId);
+        assertNotNull(indexId, "indexId should be set");
 
         //now, verify GET succeeded
         GetResponse getResponse = template.requestBody("direct:get", indexId, 
GetResponse.class);
-        assertNotNull("response should not be null", getResponse);
-        assertNotNull("response source should not be null", 
getResponse.getSource());
+        assertNotNull(getResponse, "response should not be null");
+        assertNotNull(getResponse.getSource(), "response source should not be 
null");
         //now, verify GET succeeded
         SearchRequest req = new SearchRequest();
         req.indices("twitter");
@@ -143,22 +149,22 @@ public class ElasticsearchGetSearchDeleteExistsUpdateTest 
extends ElasticsearchB
         req.types("tweets");
         MultiSearchRequest request = new 
MultiSearchRequest().add(req1).add(req);
         Item[] response = template.requestBody("direct:search", request, 
Item[].class);
-        assertNotNull("response should not be null", response);
-        assertEquals("response should be == 2", 2, response.length);
+        assertNotNull(response, "response should not be null");
+        assertEquals(2, response.length, "response should be == 2");
     }
 
     @Test
     public void testUpdate() throws Exception {
         Map<String, String> map = createIndexedData();
         String indexId = template.requestBody("direct:index", map, 
String.class);
-        assertNotNull("indexId should be set", indexId);
+        assertNotNull(indexId, "indexId should be set");
 
         Map<String, String> newMap = new HashMap<>();
         newMap.put(createPrefix() + "key2", createPrefix() + "value2");
         Map<String, Object> headers = new HashMap<>();
         headers.put(ElasticsearchConstants.PARAM_INDEX_ID, indexId);
         indexId = template.requestBodyAndHeaders("direct:update", newMap, 
headers, String.class);
-        assertNotNull("indexId should be set", indexId);
+        assertNotNull(indexId, "indexId should be set");
     }
 
     @Test
@@ -174,8 +180,8 @@ public class ElasticsearchGetSearchDeleteExistsUpdateTest 
extends ElasticsearchB
         //now, verify GET
         headers.put(ElasticsearchConstants.PARAM_OPERATION, 
ElasticsearchOperation.GetById);
         GetResponse response = template.requestBodyAndHeaders("direct:start", 
indexId, headers, GetResponse.class);
-        assertNotNull("response should not be null", response);
-        assertNotNull("response source should not be null", 
response.getSource());
+        assertNotNull(response, "response should not be null");
+        assertNotNull(response.getSource(), "response source should not be 
null");
     }
 
     @Test
@@ -192,8 +198,8 @@ public class ElasticsearchGetSearchDeleteExistsUpdateTest 
extends ElasticsearchB
         headers.put(ElasticsearchConstants.PARAM_OPERATION, 
ElasticsearchOperation.Exists);
         headers.put(ElasticsearchConstants.PARAM_INDEX_NAME, "twitter");
         Boolean exists = template.requestBodyAndHeaders("direct:exists", "", 
headers, Boolean.class);
-        assertNotNull("response should not be null", exists);
-        assertTrue("Index should exists", exists);
+        assertNotNull(exists, "response should not be null");
+        assertTrue(exists, "Index should exists");
     }
 
     @Test
@@ -210,8 +216,8 @@ public class ElasticsearchGetSearchDeleteExistsUpdateTest 
extends ElasticsearchB
         headers.put(ElasticsearchConstants.PARAM_OPERATION, 
ElasticsearchOperation.Exists);
         headers.put(ElasticsearchConstants.PARAM_INDEX_NAME, "twitter-tweet");
         Boolean exists = template.requestBodyAndHeaders("direct:exists", "", 
headers, Boolean.class);
-        assertNotNull("response should not be null", exists);
-        assertFalse("Index should not exists", exists);
+        assertNotNull(exists, "response should not be null");
+        assertFalse(exists, "Index should not exists");
     }
 
 
@@ -228,19 +234,19 @@ public class ElasticsearchGetSearchDeleteExistsUpdateTest 
extends ElasticsearchB
         //now, verify GET
         headers.put(ElasticsearchConstants.PARAM_OPERATION, 
ElasticsearchOperation.GetById);
         GetResponse response = template.requestBodyAndHeaders("direct:start", 
indexId, headers, GetResponse.class);
-        assertNotNull("response should not be null", response);
-        assertNotNull("response source should not be null", 
response.getSource());
+        assertNotNull(response, "response should not be null");
+        assertNotNull(response.getSource(), "response source should not be 
null");
 
         //now, perform Delete
         headers.put(ElasticsearchConstants.PARAM_OPERATION, 
ElasticsearchOperation.Delete);
         DocWriteResponse.Result deleteResponse = 
template.requestBodyAndHeaders("direct:start", indexId, headers, 
DocWriteResponse.Result.class);
-        assertEquals("response should not be null", 
DocWriteResponse.Result.DELETED, deleteResponse);
+        assertEquals(DocWriteResponse.Result.DELETED, deleteResponse, 
"response should not be null");
 
         //now, verify GET fails to find the indexed value
         headers.put(ElasticsearchConstants.PARAM_OPERATION, 
ElasticsearchOperation.GetById);
         response = template.requestBodyAndHeaders("direct:start", indexId, 
headers, GetResponse.class);
-        assertNotNull("response should not be null", response);
-        assertNull("response source should be null", response.getSource());
+        assertNotNull(response, "response should not be null");
+        assertNull(response.getSource(), "response source should be null");
     }
 
     @Test
@@ -252,14 +258,14 @@ public class ElasticsearchGetSearchDeleteExistsUpdateTest 
extends ElasticsearchB
         headers.put(ElasticsearchConstants.PARAM_INDEX_ID, "123");
 
         String indexId = template.requestBodyAndHeaders("direct:start", map, 
headers, String.class);
-        assertNotNull("indexId should be set", indexId);
-        assertEquals("indexId should be equals to the provided id", "123", 
indexId);
+        assertNotNull(indexId, "indexId should be set");
+        assertEquals("123", indexId, "indexId should be equals to the provided 
id");
 
         headers.put(ElasticsearchConstants.PARAM_OPERATION, 
ElasticsearchOperation.Update);
 
         indexId = template.requestBodyAndHeaders("direct:start", map, headers, 
String.class);
-        assertNotNull("indexId should be set", indexId);
-        assertEquals("indexId should be equals to the provided id", "123", 
indexId);
+        assertNotNull(indexId, "indexId should be set");
+        assertEquals("123", indexId, "indexId should be equals to the provided 
id");
     }
 
     @Test
@@ -303,14 +309,14 @@ public class ElasticsearchGetSearchDeleteExistsUpdateTest 
extends ElasticsearchB
     public void testStringUpdate() throws Exception {
         Map<String, String> map = createIndexedData();
         String indexId = template.requestBody("direct:index", map, 
String.class);
-        assertNotNull("indexId should be set", indexId);
+        assertNotNull(indexId, "indexId should be set");
 
         String body = "{\"teststringupdate-key\" : 
\"teststringupdate-updated\"}";
 
         Map<String, Object> headers = new HashMap<>();
         headers.put(ElasticsearchConstants.PARAM_INDEX_ID, indexId);
         indexId = template.requestBodyAndHeaders("direct:update", body, 
headers, String.class);
-        assertNotNull("indexId should be set", indexId);
+        assertNotNull(indexId, "indexId should be set");
 
         GetResponse response = template.requestBody("direct:get", indexId, 
GetResponse.class);
         assertEquals("teststringupdate-updated", 
response.getSource().get("teststringupdate-key"));
diff --git 
a/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchIndexTest.java
 
b/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchIndexTest.java
index ffff25f..1c2d45c 100644
--- 
a/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchIndexTest.java
+++ 
b/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchIndexTest.java
@@ -21,7 +21,10 @@ import java.util.Map;
 
 import org.apache.camel.builder.RouteBuilder;
 import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 public class ElasticsearchIndexTest extends ElasticsearchBaseTest {
 
@@ -29,25 +32,25 @@ public class ElasticsearchIndexTest extends 
ElasticsearchBaseTest {
     public void testIndex() throws Exception {
         Map<String, String> map = createIndexedData();
         String indexId = template.requestBody("direct:index", map, 
String.class);
-        assertNotNull("indexId should be set", indexId);
+        assertNotNull(indexId, "indexId should be set");
     }
 
     @Test
     public void testIndexDelete() throws Exception {
         Map<String, String> map = createIndexedData();
         String indexId = template.requestBody("direct:index", map, 
String.class);
-        assertNotNull("indexId should be set", indexId);
+        assertNotNull(indexId, "indexId should be set");
 
         DeleteIndexRequest index = new DeleteIndexRequest("_all");
         Boolean status = template.requestBody("direct:deleteIndex", index, 
Boolean.class);
-        assertEquals("status should be 200", true, status);
+        assertEquals(true, status, "status should be 200");
     }
 
     @Test
     public void testIndexWithReplication() throws Exception {
         Map<String, String> map = createIndexedData();
         String indexId = template.requestBody("direct:indexWithReplication", 
map, String.class);
-        assertNotNull("indexId should be set", indexId);
+        assertNotNull(indexId, "indexId should be set");
     }
 
     @Test
@@ -58,7 +61,7 @@ public class ElasticsearchIndexTest extends 
ElasticsearchBaseTest {
         headers.put(ElasticsearchConstants.PARAM_INDEX_NAME, "twitter");
 
         String indexId = template.requestBodyAndHeaders("direct:start", map, 
headers, String.class);
-        assertNotNull("indexId should be set", indexId);
+        assertNotNull(indexId, "indexId should be set");
     }
 
     @Test
@@ -70,8 +73,8 @@ public class ElasticsearchIndexTest extends 
ElasticsearchBaseTest {
         headers.put(ElasticsearchConstants.PARAM_INDEX_ID, "123");
 
         String indexId = template.requestBodyAndHeaders("direct:start", map, 
headers, String.class);
-        assertNotNull("indexId should be set", indexId);
-        assertEquals("indexId should be equals to the provided id", "123", 
indexId);
+        assertNotNull(indexId, "indexId should be set");
+        assertEquals("123", indexId, "indexId should be equals to the provided 
id");
     }
 
     @Override
diff --git 
a/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchPingTest.java
 
b/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchPingTest.java
index 5ce6588..6513e37 100644
--- 
a/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchPingTest.java
+++ 
b/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchPingTest.java
@@ -17,14 +17,16 @@
 package org.apache.camel.component.elasticsearch;
 
 import org.apache.camel.builder.RouteBuilder;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 public class ElasticsearchPingTest extends ElasticsearchBaseTest {
 
     @Test
     public void testPing() throws Exception {
         boolean pingResult = template.requestBody("direct:ping", "test", 
Boolean.class);
-        assertTrue("indexId should be set", pingResult);
+        assertTrue(pingResult, "indexId should be set");
     }
 
     @Override
diff --git 
a/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchRestComponentVerifierExtensionTest.java
 
b/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchRestComponentVerifierExtensionTest.java
index 93044a5..fd8a0cf 100644
--- 
a/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchRestComponentVerifierExtensionTest.java
+++ 
b/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchRestComponentVerifierExtensionTest.java
@@ -21,9 +21,10 @@ import java.util.Map;
 
 import org.apache.camel.Component;
 import org.apache.camel.component.extension.ComponentVerifierExtension;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Assert;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 public class ElasticsearchRestComponentVerifierExtensionTest extends 
CamelTestSupport {
     @Override
@@ -43,7 +44,7 @@ public class ElasticsearchRestComponentVerifierExtensionTest 
extends CamelTestSu
 
         ComponentVerifierExtension.Result result = 
verifier.verify(ComponentVerifierExtension.Scope.PARAMETERS, parameters);
 
-        Assert.assertEquals(ComponentVerifierExtension.Result.Status.OK, 
result.getStatus());
+        assertEquals(ComponentVerifierExtension.Result.Status.OK, 
result.getStatus());
     }
 
     @Test
@@ -56,7 +57,7 @@ public class ElasticsearchRestComponentVerifierExtensionTest 
extends CamelTestSu
 
         ComponentVerifierExtension.Result result = 
verifier.verify(ComponentVerifierExtension.Scope.CONNECTIVITY, parameters);
 
-        Assert.assertEquals(ComponentVerifierExtension.Result.Status.ERROR, 
result.getStatus());
+        assertEquals(ComponentVerifierExtension.Result.Status.ERROR, 
result.getStatus());
     }
 
 }
diff --git 
a/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchScrollSearchTest.java
 
b/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchScrollSearchTest.java
index 24b870e..51e70f0 100644
--- 
a/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchScrollSearchTest.java
+++ 
b/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchScrollSearchTest.java
@@ -33,9 +33,14 @@ import org.elasticsearch.client.Request;
 import org.elasticsearch.client.Response;
 import org.elasticsearch.index.query.QueryBuilders;
 import org.elasticsearch.search.builder.SearchSourceBuilder;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-import static 
org.apache.camel.component.elasticsearch.ElasticsearchConstants.*;
+import static 
org.apache.camel.component.elasticsearch.ElasticsearchConstants.PARAM_SCROLL;
+import static 
org.apache.camel.component.elasticsearch.ElasticsearchConstants.PARAM_SCROLL_KEEP_ALIVE_MS;
+import static 
org.apache.camel.component.elasticsearch.ElasticsearchConstants.PROPERTY_SCROLL_ES_QUERY_COUNT;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 public class ElasticsearchScrollSearchTest extends ElasticsearchBaseTest {
 
@@ -48,12 +53,12 @@ public class ElasticsearchScrollSearchTest extends 
ElasticsearchBaseTest {
         for (int i = 0; i < 10; i++) {
             Map<String, String> map = createIndexedData();
             String indexId = template.requestBody("direct:scroll-index", map, 
String.class);
-            assertNotNull("indexId should be set", indexId);
+            assertNotNull(indexId, "indexId should be set");
         }
 
         // perform a refresh
         Response refreshResponse = getClient().performRequest(new 
Request("post", "/" + TWITTER_ES_INDEX_NAME + "/_refresh"));
-        assertEquals("Cannot perform a refresh", 200, 
refreshResponse.getStatusLine().getStatusCode());
+        assertEquals(200, refreshResponse.getStatusLine().getStatusCode(), 
"Cannot perform a refresh");
 
         SearchRequest req = getScrollSearchRequest(TWITTER_ES_INDEX_NAME);
 
@@ -66,18 +71,18 @@ public class ElasticsearchScrollSearchTest extends 
ElasticsearchBaseTest {
         exchange = template.send("direct:scroll-search", exchange);
 
         try (ElasticsearchScrollRequestIterator scrollRequestIterator = 
exchange.getIn().getBody(ElasticsearchScrollRequestIterator.class)) {
-            assertNotNull("response should not be null", 
scrollRequestIterator);
+            assertNotNull(scrollRequestIterator, "response should not be 
null");
 
             List result = new ArrayList();
             scrollRequestIterator.forEachRemaining(result::add);
 
-            assertEquals("response hits should be == 10", 10, result.size());
-            assertEquals("11 request should have been send to Elasticsearch", 
11, scrollRequestIterator.getRequestCount());
+            assertEquals(10, result.size(), "response hits should be == 10");
+            assertEquals(11, scrollRequestIterator.getRequestCount(), "11 
request should have been send to Elasticsearch");
         }
 
         ElasticsearchScrollRequestIterator scrollRequestIterator = 
exchange.getIn().getBody(ElasticsearchScrollRequestIterator.class);
-        assertTrue("iterator should be closed", 
scrollRequestIterator.isClosed());
-        assertEquals("11 request should have been send to Elasticsearch", 11, 
(int) exchange.getProperty(PROPERTY_SCROLL_ES_QUERY_COUNT, Integer.class));
+        assertTrue(scrollRequestIterator.isClosed(), "iterator should be 
closed");
+        assertEquals(11, (int) 
exchange.getProperty(PROPERTY_SCROLL_ES_QUERY_COUNT, Integer.class), "11 
request should have been send to Elasticsearch");
     }
 
     @Test
@@ -86,12 +91,12 @@ public class ElasticsearchScrollSearchTest extends 
ElasticsearchBaseTest {
         for (int i = 0; i < 10; i++) {
             Map<String, String> map = createIndexedData();
             String indexId = 
template.requestBody("direct:scroll-n-split-index", map, String.class);
-            assertNotNull("indexId should be set", indexId);
+            assertNotNull(indexId, "indexId should be set");
         }
 
         // perform a refresh
         Response refreshResponse = getClient().performRequest(new 
Request("post", "/" + SPLIT_TWITTER_ES_INDEX_NAME + "/_refresh"));
-        assertEquals("Cannot perform a refresh", 200, 
refreshResponse.getStatusLine().getStatusCode());
+        assertEquals(200, refreshResponse.getStatusLine().getStatusCode(), 
"Cannot perform a refresh");
 
         MockEndpoint mock = getMockEndpoint("mock:output");
         mock.expectedMessageCount(1);
@@ -105,15 +110,15 @@ public class ElasticsearchScrollSearchTest extends 
ElasticsearchBaseTest {
         // wait for aggregation
         mock.assertIsSatisfied();
         Iterator<Exchange> iterator = mock.getReceivedExchanges().iterator();
-        assertTrue("response should contain 1 exchange", iterator.hasNext());
+        assertTrue(iterator.hasNext(), "response should contain 1 exchange");
         Collection aggregatedExchanges = 
iterator.next().getIn().getBody(Collection.class);
 
-        assertEquals("response hits should be == 10", 10, 
aggregatedExchanges.size());
+        assertEquals(10, aggregatedExchanges.size(), "response hits should be 
== 10");
 
         ElasticsearchScrollRequestIterator scrollRequestIterator = 
exchange.getIn().getBody(ElasticsearchScrollRequestIterator.class);
-        assertTrue("iterator should be closed", 
scrollRequestIterator.isClosed());
-        assertEquals("11 request should have been send to Elasticsearch", 11, 
scrollRequestIterator.getRequestCount());
-        assertEquals("11 request should have been send to Elasticsearch", 11, 
(int)exchange.getProperty(PROPERTY_SCROLL_ES_QUERY_COUNT, Integer.class));
+        assertTrue(scrollRequestIterator.isClosed(), "iterator should be 
closed");
+        assertEquals(11, scrollRequestIterator.getRequestCount(), "11 request 
should have been send to Elasticsearch");
+        assertEquals(11, 
(int)exchange.getProperty(PROPERTY_SCROLL_ES_QUERY_COUNT, Integer.class), "11 
request should have been send to Elasticsearch");
     }
 
     private SearchRequest getScrollSearchRequest(String indexName) {
diff --git 
a/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchSizeLimitTest.java
 
b/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchSizeLimitTest.java
index e5a93b1..dc4d7b1 100644
--- 
a/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchSizeLimitTest.java
+++ 
b/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchSizeLimitTest.java
@@ -23,12 +23,12 @@ import java.util.concurrent.TimeUnit;
 import org.apache.camel.builder.RouteBuilder;
 import org.awaitility.Awaitility;
 import org.elasticsearch.search.SearchHits;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
 
 public class ElasticsearchSizeLimitTest extends ElasticsearchBaseTest {
 
-    @Ignore("Looks like there were some assumption related to test executed 
before")
+    @Disabled("Looks like there were some assumption related to test executed 
before")
     @Test
     public void testSize() {
         //put 4

Reply via email to