This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 94bd9ec21ef [CAMEL-19613] ArangoDB component (#10718)
94bd9ec21ef is described below
commit 94bd9ec21ef7964faea9b07b623d60abf46c8a0b
Author: Adriano Machado <[email protected]>
AuthorDate: Wed Jul 19 04:45:43 2023 -0400
[CAMEL-19613] ArangoDB component (#10718)
Co-authored-by: Adriano Machado <[email protected]>
---
components/camel-arangodb/pom.xml | 7 +++
.../component/arangodb/ArangoDbComponentTest.java | 26 +++++++++--
.../integration/ArangoCollectionFindByKeyIT.java | 9 ++--
.../arangodb/integration/BaseArangoDb.java | 46 ++++++++++++++++---
.../arangodb/integration/BaseDocumentEntity.java | 52 ----------------------
.../component/arangodb/integration/BaseGraph.java | 2 +-
6 files changed, 74 insertions(+), 68 deletions(-)
diff --git a/components/camel-arangodb/pom.xml
b/components/camel-arangodb/pom.xml
index 7ce79edcaac..c559f280b31 100644
--- a/components/camel-arangodb/pom.xml
+++ b/components/camel-arangodb/pom.xml
@@ -60,6 +60,13 @@
</dependency>
<!-- test infra -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test-infra-core</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ <type>test-jar</type>
+ </dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-test-infra-arangodb</artifactId>
diff --git
a/components/camel-arangodb/src/test/java/org/apache/camel/component/arangodb/ArangoDbComponentTest.java
b/components/camel-arangodb/src/test/java/org/apache/camel/component/arangodb/ArangoDbComponentTest.java
index 56abb2ca3fd..069c9ad60de 100644
---
a/components/camel-arangodb/src/test/java/org/apache/camel/component/arangodb/ArangoDbComponentTest.java
+++
b/components/camel-arangodb/src/test/java/org/apache/camel/component/arangodb/ArangoDbComponentTest.java
@@ -16,16 +16,31 @@
*/
package org.apache.camel.component.arangodb;
-import org.apache.camel.test.junit5.CamelTestSupport;
+import org.apache.camel.CamelContext;
+import org.apache.camel.test.infra.core.CamelContextExtension;
+import org.apache.camel.test.infra.core.DefaultCamelContextExtension;
+import org.apache.camel.test.infra.core.api.CamelTestSupportHelper;
+import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
-public class ArangoDbComponentTest extends CamelTestSupport {
+class ArangoDbComponentTest implements CamelTestSupportHelper {
+
+ @RegisterExtension
+ public static final CamelContextExtension camelContextExtension = new
DefaultCamelContextExtension();
+
+ protected CamelContext context;
+
+ @BeforeEach
+ void beforeEach() {
+ this.context = camelContextExtension.getContext();
+ }
@Test
- public void createEndpointWithMinimalConfiguration() throws Exception {
+ void createEndpointWithMinimalConfiguration() throws Exception {
ArangoDbComponent component = context.getComponent("arangodb",
ArangoDbComponent.class);
ArangoDbEndpoint endpoint = (ArangoDbEndpoint) component
.createEndpoint("arangodb:testDb?documentCollection=myCollection");
@@ -39,4 +54,9 @@ public class ArangoDbComponentTest extends CamelTestSupport {
assertThrows(IllegalArgumentException.class, () -> component
.createEndpoint("arangodb?documentCollection=myCollection"));
}
+
+ @Override
+ public CamelContextExtension getCamelContextExtension() {
+ return camelContextExtension;
+ }
}
diff --git
a/components/camel-arangodb/src/test/java/org/apache/camel/component/arangodb/integration/ArangoCollectionFindByKeyIT.java
b/components/camel-arangodb/src/test/java/org/apache/camel/component/arangodb/integration/ArangoCollectionFindByKeyIT.java
index 5fa8a69102d..51357f41b23 100644
---
a/components/camel-arangodb/src/test/java/org/apache/camel/component/arangodb/integration/ArangoCollectionFindByKeyIT.java
+++
b/components/camel-arangodb/src/test/java/org/apache/camel/component/arangodb/integration/ArangoCollectionFindByKeyIT.java
@@ -23,6 +23,7 @@ import com.arangodb.util.RawJson;
import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.infra.core.annotations.ContextFixture;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledIfSystemProperty;
@@ -37,17 +38,15 @@ public class ArangoCollectionFindByKeyIT extends
BaseArangoDb {
private BaseDocument myObject;
- @Override
- protected CamelContext createCamelContext() {
- CamelContext ctx = super.createCamelContext();
+ @ContextFixture
+ public void createCamelContext(CamelContext ctx) {
+ super.createCamelContext(ctx);
myObject = new BaseDocument();
myObject.setKey("myKey");
myObject.addAttribute("foo", "bar");
collection.insertDocument(myObject);
-
- return ctx;
}
@Override
diff --git
a/components/camel-arangodb/src/test/java/org/apache/camel/component/arangodb/integration/BaseArangoDb.java
b/components/camel-arangodb/src/test/java/org/apache/camel/component/arangodb/integration/BaseArangoDb.java
index d781b957c42..6959d3fa5c6 100644
---
a/components/camel-arangodb/src/test/java/org/apache/camel/component/arangodb/integration/BaseArangoDb.java
+++
b/components/camel-arangodb/src/test/java/org/apache/camel/component/arangodb/integration/BaseArangoDb.java
@@ -20,16 +20,28 @@ import com.arangodb.ArangoCollection;
import com.arangodb.ArangoDB;
import com.arangodb.ArangoDatabase;
import org.apache.camel.CamelContext;
-import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.test.infra.arangodb.services.ArangoDBService;
import org.apache.camel.test.infra.arangodb.services.ArangoDBServiceFactory;
-import org.apache.camel.test.junit5.CamelTestSupport;
+import org.apache.camel.test.infra.core.CamelContextExtension;
+import org.apache.camel.test.infra.core.TransientCamelContextExtension;
+import org.apache.camel.test.infra.core.annotations.ContextFixture;
+import org.apache.camel.test.infra.core.annotations.RouteFixture;
+import org.apache.camel.test.infra.core.api.CamelTestSupportHelper;
+import org.apache.camel.test.infra.core.api.ConfigurableRoute;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.extension.RegisterExtension;
-public class BaseArangoDb extends CamelTestSupport {
+public abstract class BaseArangoDb implements ConfigurableRoute,
CamelTestSupportHelper {
+ @Order(1)
@RegisterExtension
public static ArangoDBService service =
ArangoDBServiceFactory.createService();
+ @Order(2)
+ @RegisterExtension
+ public static final CamelContextExtension camelContextExtension = new
TransientCamelContextExtension();
protected static final String DATABASE_NAME = "dbTest";
protected static final String COLLECTION_NAME = "camelTest";
@@ -39,11 +51,15 @@ public class BaseArangoDb extends CamelTestSupport {
protected ArangoDB arangoDb;
protected ArangoDatabase arangoDatabase;
protected ArangoCollection collection;
+ protected ProducerTemplate template;
- @Override
- protected CamelContext createCamelContext() {
- CamelContext ctx = new DefaultCamelContext();
+ @BeforeEach
+ void beforeEach() {
+ this.template = getCamelContextExtension().getProducerTemplate();
+ }
+ @ContextFixture
+ public void createCamelContext(CamelContext ctx) {
arangoDb = new ArangoDB.Builder().host("localhost", 8529).build();
// drop any existing database to start clean
@@ -59,6 +75,22 @@ public class BaseArangoDb extends CamelTestSupport {
ctx.getRegistry().bind("arangoDB", arangoDb);
ctx.getPropertiesComponent().setLocation("classpath:arango.test.properties");
- return ctx;
}
+
+ @Override
+ @RouteFixture
+ public void createRouteBuilder(CamelContext context) throws Exception {
+ final RouteBuilder routeBuilder = createRouteBuilder();
+
+ if (routeBuilder != null) {
+ context.addRoutes(routeBuilder);
+ }
+ }
+
+ @Override
+ public CamelContextExtension getCamelContextExtension() {
+ return camelContextExtension;
+ }
+
+ protected abstract RouteBuilder createRouteBuilder() throws Exception;
}
diff --git
a/components/camel-arangodb/src/test/java/org/apache/camel/component/arangodb/integration/BaseDocumentEntity.java
b/components/camel-arangodb/src/test/java/org/apache/camel/component/arangodb/integration/BaseDocumentEntity.java
deleted file mode 100644
index 9e7ba1eb5e9..00000000000
---
a/components/camel-arangodb/src/test/java/org/apache/camel/component/arangodb/integration/BaseDocumentEntity.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.arangodb.integration;
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-public abstract class BaseDocumentEntity {
-
- @JsonProperty("_key")
- @JsonInclude(JsonInclude.Include.NON_NULL)
- private String key;
-
- @JsonProperty("_id")
- @JsonInclude(JsonInclude.Include.NON_NULL)
- private String id;
-
- @JsonProperty("_rev")
- @JsonInclude(JsonInclude.Include.NON_NULL)
- private String rev;
-
- public BaseDocumentEntity(String key) {
- this.key = key;
- }
-
- public String getKey() {
- return key;
- }
-
- public String getId() {
- return id;
- }
-
- public String getRev() {
- return rev;
- }
-
-}
diff --git
a/components/camel-arangodb/src/test/java/org/apache/camel/component/arangodb/integration/BaseGraph.java
b/components/camel-arangodb/src/test/java/org/apache/camel/component/arangodb/integration/BaseGraph.java
index b885a7d94d4..d95f778ace7 100644
---
a/components/camel-arangodb/src/test/java/org/apache/camel/component/arangodb/integration/BaseGraph.java
+++
b/components/camel-arangodb/src/test/java/org/apache/camel/component/arangodb/integration/BaseGraph.java
@@ -32,7 +32,7 @@ import com.arangodb.model.CollectionCreateOptions;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
-public class BaseGraph extends BaseArangoDb {
+public abstract class BaseGraph extends BaseArangoDb {
protected static ArangoCollection edgesCollection;
protected static ArangoCollection verticesCollection;