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

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


The following commit(s) were added to refs/heads/master by this push:
     new 30759ed  Add Nitrite tests
30759ed is described below

commit 30759ede1ee9d1a4b1acd162171c39bcc57c5766
Author: Peter Palaga <ppal...@redhat.com>
AuthorDate: Thu Nov 26 18:41:21 2020 +0100

    Add Nitrite tests
    
    ... and some inital steps for the native support
    Mostly taken from
    https://github.com/JiriOndrusek/camel-quarkus/commits/1298-nitrite-support
    by @JiriOndrusek
---
 .../nitrite/deployment/NitriteProcessor.java       |  15 ++
 extensions-jvm/nitrite/integration-test/pom.xml    |   5 +
 .../quarkus/component/nitrite/it/Employee.java     |  96 ++++++++++
 .../component/nitrite/it/NitriteResource.java      | 110 +++++++++--
 .../quarkus/component/nitrite/it/Operation.java    | 136 ++++++++++++++
 .../quarkus/component/nitrite/it/NitriteTest.java  | 206 ++++++++++++++++++++-
 .../component/nitrite/it/NitriteTestResource.java  |  59 ++++++
 7 files changed, 611 insertions(+), 16 deletions(-)

diff --git 
a/extensions-jvm/nitrite/deployment/src/main/java/org/apache/camel/quarkus/component/nitrite/deployment/NitriteProcessor.java
 
b/extensions-jvm/nitrite/deployment/src/main/java/org/apache/camel/quarkus/component/nitrite/deployment/NitriteProcessor.java
index 1aba65b..2f4311f 100644
--- 
a/extensions-jvm/nitrite/deployment/src/main/java/org/apache/camel/quarkus/component/nitrite/deployment/NitriteProcessor.java
+++ 
b/extensions-jvm/nitrite/deployment/src/main/java/org/apache/camel/quarkus/component/nitrite/deployment/NitriteProcessor.java
@@ -16,12 +16,16 @@
  */
 package org.apache.camel.quarkus.component.nitrite.deployment;
 
+import io.quarkus.deployment.annotations.BuildProducer;
 import io.quarkus.deployment.annotations.BuildStep;
 import io.quarkus.deployment.annotations.ExecutionTime;
 import io.quarkus.deployment.annotations.Record;
 import io.quarkus.deployment.builditem.FeatureBuildItem;
+import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
+import 
io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem;
 import io.quarkus.deployment.pkg.steps.NativeBuild;
 import org.apache.camel.quarkus.core.JvmOnlyRecorder;
+import org.h2.store.fs.FilePathNio;
 import org.jboss.logging.Logger;
 
 class NitriteProcessor {
@@ -44,4 +48,15 @@ class NitriteProcessor {
         recorder.warnJvmInNative(FEATURE); // warn at runtime
     }
 
+    @BuildStep
+    void 
runtimeInitializedClasses(BuildProducer<RuntimeInitializedClassBuildItem> 
runtimeInitializedClasses) {
+        // this class uses a SecureRandom which needs to be initialised at run 
time
+        runtimeInitializedClasses.produce(new 
RuntimeInitializedClassBuildItem("org.dizitart.no2.Security"));
+    }
+
+    @BuildStep
+    void reflectiveClasses(BuildProducer<ReflectiveClassBuildItem> 
reflectiveClasses) {
+        reflectiveClasses.produce(new ReflectiveClassBuildItem(false, false, 
FilePathNio.class));
+    }
+
 }
diff --git a/extensions-jvm/nitrite/integration-test/pom.xml 
b/extensions-jvm/nitrite/integration-test/pom.xml
index c674ce9..e870243 100644
--- a/extensions-jvm/nitrite/integration-test/pom.xml
+++ b/extensions-jvm/nitrite/integration-test/pom.xml
@@ -50,6 +50,11 @@
             <artifactId>quarkus-resteasy</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>io.quarkus</groupId>
+            <artifactId>quarkus-resteasy-jackson</artifactId>
+        </dependency>
+
         <!-- test dependencies -->
         <dependency>
             <groupId>io.quarkus</groupId>
diff --git 
a/extensions-jvm/nitrite/integration-test/src/main/java/org/apache/camel/quarkus/component/nitrite/it/Employee.java
 
b/extensions-jvm/nitrite/integration-test/src/main/java/org/apache/camel/quarkus/component/nitrite/it/Employee.java
new file mode 100644
index 0000000..ed13136
--- /dev/null
+++ 
b/extensions-jvm/nitrite/integration-test/src/main/java/org/apache/camel/quarkus/component/nitrite/it/Employee.java
@@ -0,0 +1,96 @@
+/*
+ * 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.quarkus.component.nitrite.it;
+
+import java.io.Serializable;
+import java.util.Date;
+
+import org.dizitart.no2.IndexType;
+import org.dizitart.no2.objects.Id;
+import org.dizitart.no2.objects.Index;
+import org.dizitart.no2.objects.Indices;
+
+@Indices({
+        @Index(value = "address", type = IndexType.NonUnique),
+        @Index(value = "name", type = IndexType.Unique)
+})
+public class Employee implements Serializable, Cloneable {
+    @Id
+    private long empId;
+
+    private Date joinDate;
+
+    private String name;
+
+    private String address;
+
+    public Employee() {
+    }
+
+    public Employee(long empId, Date joinDate, String name, String address) {
+        this.empId = empId;
+        this.joinDate = joinDate;
+        this.name = name;
+        this.address = address;
+    }
+
+    public long getEmpId() {
+        return empId;
+    }
+
+    public void setEmpId(long empId) {
+        this.empId = empId;
+    }
+
+    public Date getJoinDate() {
+        return joinDate;
+    }
+
+    public void setJoinDate(Date joinDate) {
+        this.joinDate = joinDate;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getAddress() {
+        return address;
+    }
+
+    public void setAddress(String address) {
+        this.address = address;
+    }
+
+    @Override
+    public String toString() {
+        return "Employee{" +
+                "empId=" + empId +
+                ", joinDate=" + joinDate +
+                ", name='" + name + '\'' +
+                ", address='" + address + '\'' +
+                '}';
+    }
+
+    public Object clone() throws CloneNotSupportedException {
+        return super.clone();
+    }
+}
diff --git 
a/extensions-jvm/nitrite/integration-test/src/main/java/org/apache/camel/quarkus/component/nitrite/it/NitriteResource.java
 
b/extensions-jvm/nitrite/integration-test/src/main/java/org/apache/camel/quarkus/component/nitrite/it/NitriteResource.java
index 044594e..9ae0bdd 100644
--- 
a/extensions-jvm/nitrite/integration-test/src/main/java/org/apache/camel/quarkus/component/nitrite/it/NitriteResource.java
+++ 
b/extensions-jvm/nitrite/integration-test/src/main/java/org/apache/camel/quarkus/component/nitrite/it/NitriteResource.java
@@ -18,34 +18,120 @@ package org.apache.camel.quarkus.component.nitrite.it;
 
 import javax.enterprise.context.ApplicationScoped;
 import javax.inject.Inject;
+import javax.ws.rs.Consumes;
 import javax.ws.rs.GET;
+import javax.ws.rs.POST;
 import javax.ws.rs.Path;
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 
-import org.apache.camel.CamelContext;
+import org.apache.camel.ConsumerTemplate;
+import org.apache.camel.Exchange;
+import org.apache.camel.FluentProducerTemplate;
+import org.apache.camel.Message;
+import org.apache.camel.component.nitrite.NitriteConstants;
+import org.dizitart.no2.Document;
+import org.eclipse.microprofile.config.inject.ConfigProperty;
 import org.jboss.logging.Logger;
 
 @Path("/nitrite")
 @ApplicationScoped
 public class NitriteResource {
-
     private static final Logger LOG = Logger.getLogger(NitriteResource.class);
 
-    private static final String COMPONENT_NITRITE = "nitrite";
+    public static final String PROPERTY_DB_FILE = 
"camel.quarkus.nitrite.test.db.file";
+
+    @ConfigProperty(name = PROPERTY_DB_FILE)
+    String dbFile;
+
+    @Inject
+    FluentProducerTemplate producerTemplate;
+
     @Inject
-    CamelContext context;
+    ConsumerTemplate consumerTemplate;
 
-    @Path("/load/component/nitrite")
+    @Path("/repositoryClass")
     @GET
-    @Produces(MediaType.TEXT_PLAIN)
-    public Response loadComponentNitrite() throws Exception {
-        /* This is an autogenerated test */
-        if (context.getComponent(COMPONENT_NITRITE) != null) {
-            return Response.ok().build();
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response getRepositoryClass() throws Exception {
+        final Exchange exchange = 
consumerTemplate.receiveNoWait(String.format("nitrite://%s?repositoryClass=%s",
+                dbFile, Employee.class.getName()));
+        if (exchange == null) {
+            return Response.noContent().build();
         }
-        LOG.warnf("Could not load [%s] from the Camel context", 
COMPONENT_NITRITE);
-        return Response.status(500, COMPONENT_NITRITE + " could not be loaded 
from the Camel context").build();
+        final Message message = exchange.getMessage();
+        return Response
+                .ok(message.getBody())
+                .header(NitriteConstants.CHANGE_TYPE, 
message.getHeader(NitriteConstants.CHANGE_TYPE))
+                .build();
+    }
+
+    @Path("/repositoryClass")
+    @POST
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces(MediaType.APPLICATION_JSON)
+    public Object postRepositoryClass(Employee object) {
+        LOG.debugf("Sending to nitrite: {%s}", object);
+        return producerTemplate.toF("nitrite://%s?repositoryClass=%s",
+                dbFile, Employee.class.getName())
+                .withBody(object)
+                .withHeader(NitriteConstants.OPERATION, null)
+                .request();
+    }
+
+    @Path("/repositoryClassOperation")
+    @POST
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces(MediaType.APPLICATION_JSON)
+    public Object postRepositoryClassOperation(Operation operation) {
+        LOG.debugf("Sending to nitrite: {%s}", operation);
+        return producerTemplate.toF("nitrite://%s?repositoryClass=%s",
+                dbFile, Employee.class.getName())
+                .withBody(operation.getEmployee())
+                .withHeader(NitriteConstants.OPERATION, 
operation.toRepositoryOperation())
+                .request();
+    }
+
+    @Path("/collection")
+    @GET
+    @Produces(MediaType.APPLICATION_JSON)
+    public Object getCollection() throws Exception {
+        final Exchange exchange = 
consumerTemplate.receiveNoWait(String.format("nitrite://%s?collection=collection",
+                dbFile));
+        LOG.debugf("Received from nitrite: %s", exchange == null ? null : 
exchange.getIn().getBody());
+        if (exchange == null) {
+            return Response.noContent().build();
+        }
+        final Message message = exchange.getMessage();
+        return Response
+                .ok(message.getBody())
+                .header(NitriteConstants.CHANGE_TYPE, 
message.getHeader(NitriteConstants.CHANGE_TYPE))
+                .build();
+    }
+
+    @Path("/collection")
+    @POST
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces(MediaType.APPLICATION_JSON)
+    public Object postCollection(Document doc) {
+        LOG.debugf("Sending to nitrite: {%s}", doc);
+        return producerTemplate.toF("nitrite://%s?collection=collection", 
dbFile)
+                .withBody(doc)
+                .withHeader(NitriteConstants.OPERATION, null)
+                .request();
+    }
+
+    @Path("/collectionOperation")
+    @POST
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces(MediaType.APPLICATION_JSON)
+    public Object collectionOperation(Operation operation) {
+        LOG.debugf("Sending to nitrite: {%s}", operation);
+        return producerTemplate.toF("nitrite://%s?collection=collection",
+                dbFile)
+                .withBody(operation.getDocument())
+                .withHeader(NitriteConstants.OPERATION, 
operation.toCollectionOperation())
+                .request();
     }
 }
diff --git 
a/extensions-jvm/nitrite/integration-test/src/main/java/org/apache/camel/quarkus/component/nitrite/it/Operation.java
 
b/extensions-jvm/nitrite/integration-test/src/main/java/org/apache/camel/quarkus/component/nitrite/it/Operation.java
new file mode 100644
index 0000000..4a64294
--- /dev/null
+++ 
b/extensions-jvm/nitrite/integration-test/src/main/java/org/apache/camel/quarkus/component/nitrite/it/Operation.java
@@ -0,0 +1,136 @@
+/*
+ * 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.quarkus.component.nitrite.it;
+
+import org.apache.camel.component.nitrite.operation.CollectionOperation;
+import org.apache.camel.component.nitrite.operation.RepositoryOperation;
+import 
org.apache.camel.component.nitrite.operation.collection.FindCollectionOperation;
+import 
org.apache.camel.component.nitrite.operation.collection.RemoveCollectionOperation;
+import 
org.apache.camel.component.nitrite.operation.collection.UpdateCollectionOperation;
+import org.apache.camel.component.nitrite.operation.common.InsertOperation;
+import 
org.apache.camel.component.nitrite.operation.repository.FindRepositoryOperation;
+import 
org.apache.camel.component.nitrite.operation.repository.RemoveRepositoryOperation;
+import 
org.apache.camel.component.nitrite.operation.repository.UpdateRepositoryOperation;
+import org.dizitart.no2.Document;
+import org.dizitart.no2.filters.Filters;
+import org.dizitart.no2.objects.filters.ObjectFilters;
+
+public class Operation {
+
+    enum Type {
+        update, find, delete, findGt, insert
+    };
+
+    private Type type;
+
+    private String field;
+
+    private Object value;
+
+    private Employee employee;
+    private Document document;
+
+    public Operation() {
+    }
+
+    private Operation(Type type, String field, Object value) {
+        this.type = type;
+        this.field = field;
+        this.value = value;
+    }
+
+    public Operation(Type type, String field, Object value, Employee employee) 
{
+        this(type, field, value);
+        this.employee = employee;
+    }
+
+    public Operation(Type type, String field, Object value, Document document) 
{
+        this(type, field, value);
+        this.document = document;
+    }
+
+    public Type getType() {
+        return type;
+    }
+
+    public void setType(Type type) {
+        this.type = type;
+    }
+
+    public String getField() {
+        return field;
+    }
+
+    public void setField(String field) {
+        this.field = field;
+    }
+
+    public Object getValue() {
+        return value;
+    }
+
+    public void setValue(Object value) {
+        this.value = value;
+    }
+
+    public Employee getEmployee() {
+        return employee;
+    }
+
+    public void setEmployee(Employee employee) {
+        this.employee = employee;
+    }
+
+    public Document getDocument() {
+        return document;
+    }
+
+    public void setDocument(Document document) {
+        this.document = document;
+    }
+
+    public RepositoryOperation toRepositoryOperation() {
+
+        switch (type) {
+        case update:
+            return new UpdateRepositoryOperation(ObjectFilters.eq(field, 
value));
+        case find:
+            return new FindRepositoryOperation(ObjectFilters.eq(field, value));
+        case findGt:
+            return new FindRepositoryOperation(ObjectFilters.gt(field, value));
+        case delete:
+            return new RemoveRepositoryOperation(ObjectFilters.eq(field, 
value));
+        default:
+            throw new UnsupportedOperationException();
+        }
+    }
+
+    public CollectionOperation toCollectionOperation() {
+        switch (type) {
+        case update:
+            return new UpdateCollectionOperation(Filters.eq(field, value));
+        case find:
+            return new FindCollectionOperation(Filters.eq(field, value));
+        case delete:
+            return new RemoveCollectionOperation(Filters.eq(field, value));
+        case insert:
+            return new InsertOperation();
+        default:
+            throw new UnsupportedOperationException();
+        }
+    }
+}
diff --git 
a/extensions-jvm/nitrite/integration-test/src/test/java/org/apache/camel/quarkus/component/nitrite/it/NitriteTest.java
 
b/extensions-jvm/nitrite/integration-test/src/test/java/org/apache/camel/quarkus/component/nitrite/it/NitriteTest.java
index 9d00557..fb39912 100644
--- 
a/extensions-jvm/nitrite/integration-test/src/test/java/org/apache/camel/quarkus/component/nitrite/it/NitriteTest.java
+++ 
b/extensions-jvm/nitrite/integration-test/src/test/java/org/apache/camel/quarkus/component/nitrite/it/NitriteTest.java
@@ -16,19 +16,217 @@
  */
 package org.apache.camel.quarkus.component.nitrite.it;
 
+import java.util.GregorianCalendar;
+
+import io.quarkus.test.common.QuarkusTestResource;
 import io.quarkus.test.junit.QuarkusTest;
 import io.restassured.RestAssured;
+import io.restassured.http.ContentType;
+import org.apache.camel.component.nitrite.NitriteConstants;
+import org.dizitart.no2.Document;
+import org.junit.jupiter.api.MethodOrderer;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestMethodOrder;
+
+import static org.hamcrest.core.Is.is;
 
 @QuarkusTest
+@QuarkusTestResource(NitriteTestResource.class)
+@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
 class NitriteTest {
 
+    private static final Employee sheldon = new Employee(1L, new 
GregorianCalendar(2010, 10, 1).getTime(), "Sheldon",
+            "Alpha Centauri");
+    private static final Employee leonard = new Employee(2L, new 
GregorianCalendar(2015, 10, 1).getTime(), "Leonard", "Earth");
+    private static final Employee irma = new Employee(3L, new 
GregorianCalendar(2011, 10, 1).getTime(), "Irma", "Jupiter");
+
+    @Test
+    public void repositoryClass() throws CloneNotSupportedException {
+        /* Make sure there is no event there before we start inserting */
+        RestAssured.get("/nitrite/repositoryClass")
+                .then()
+                .statusCode(204);
+
+        /* Insert Sheldon */
+        RestAssured.given()
+                .contentType(ContentType.JSON)
+                .body(sheldon)
+                .post("/nitrite/repositoryClass")
+                .then()
+                .statusCode(200)
+                .body("name", is("Sheldon"));
+        RestAssured.get("/nitrite/repositoryClass")
+                .then()
+                .statusCode(200)
+                .header(NitriteConstants.CHANGE_TYPE, "INSERT")
+                .body("name", is("Sheldon"));
+
+        /* Insert Leonard */
+        RestAssured.given()
+                .contentType(ContentType.JSON)
+                .body(leonard)
+                .post("/nitrite/repositoryClass")
+                .then()
+                .statusCode(200)
+                .body("name", is("Leonard"));
+        RestAssured.get("/nitrite/repositoryClass")
+                .then()
+                .statusCode(200)
+                .header(NitriteConstants.CHANGE_TYPE, "INSERT")
+                .body("name", is("Leonard"));
+
+        /* Insert Irma */
+        RestAssured.given()
+                .contentType(ContentType.JSON)
+                .body(irma)
+                .post("/nitrite/repositoryClass")
+                .then()
+                .statusCode(200)
+                .body("name", is("Irma"));
+        RestAssured.get("/nitrite/repositoryClass")
+                .then()
+                .statusCode(200)
+                .header(NitriteConstants.CHANGE_TYPE, "INSERT")
+                .body("name", is("Irma"));
+
+        Employee updatedSheldon = (Employee) sheldon.clone();
+        updatedSheldon.setAddress("Moon");
+        RestAssured.given()
+                .contentType(ContentType.JSON)
+                .body(new Operation(Operation.Type.update, "name", "Sheldon", 
updatedSheldon))
+                .post("/nitrite/repositoryClassOperation")
+                .then()
+                .body("name", is("Sheldon"),
+                        "address", is("Moon"));
+
+        RestAssured.get("/nitrite/repositoryClass")
+                .then()
+                .statusCode(200)
+                .header(NitriteConstants.CHANGE_TYPE, "UPDATE")
+                .body("name", is("Sheldon"),
+                        "address", is("Moon"));
+
+        RestAssured.given()
+                .contentType(ContentType.JSON)
+                .body(new Operation(Operation.Type.find, "address", (Object) 
"Moon", (Employee) null))
+                .post("/nitrite/repositoryClassOperation")
+                .then()
+                .statusCode(200)
+                .body("size()", is(1), // After the update, there is 1 
employee from the Moon
+                        "[0].name", is("Sheldon"));
+
+        RestAssured.given()
+                .contentType(ContentType.JSON)
+                .body(new Operation(Operation.Type.findGt, "empId", (Object) 
0, (Employee) null))
+                .post("/nitrite/repositoryClassOperation")
+                .then()
+                .statusCode(200)
+                .body("size()", is(3));// there are 3 employees in total
+
+        RestAssured.given()
+                .contentType(ContentType.JSON)
+                .body(new Operation(Operation.Type.delete, "address", "Moon", 
(Employee) null))
+                .post("/nitrite/repositoryClassOperation")
+                .then()
+                .statusCode(204);
+
+        RestAssured
+                .get("/nitrite/repositoryClass")
+                .then()
+                .statusCode(200)
+                .header(NitriteConstants.CHANGE_TYPE, "REMOVE")
+                .body("name", is("Sheldon"),
+                        "address", is("Moon"));
+
+        RestAssured.given()
+                .contentType(ContentType.JSON)
+                .body(new Operation(Operation.Type.findGt, "empId", (Object) 
0, (Employee) null))
+                .post("/nitrite/repositoryClassOperation")
+                .then()
+                .statusCode(200)
+                .body("size()", is(2));// there are 2 employees after the 
deletion
+
+    }
+
     @Test
-    public void loadComponentNitrite() {
-        /* A simple autogenerated test */
-        RestAssured.get("/nitrite/load/component/nitrite")
+    public void collection() throws Exception {
+        /* Make sure there is no event there before we start inserting */
+        RestAssured.get("/nitrite/collection")
+                .then()
+                .statusCode(204);
+
+        RestAssured.given()
+                .contentType(ContentType.JSON)
+                .body(Document.createDocument("key1", "value1"))
+                .post("/nitrite/collection")
+                .then()
+                .statusCode(200)
+                .body("key1", is("value1"));
+        RestAssured.get("/nitrite/collection")
+                .then()
+                .statusCode(200)
+                .header(NitriteConstants.CHANGE_TYPE, "INSERT")
+                .body("key1", is("value1"));
+
+        RestAssured.given()
+                .contentType(ContentType.JSON)
+                .body(Document.createDocument("key2", "value2"))
+                .post("/nitrite/collection")
+                .then()
+                .statusCode(200)
+                .body("key2", is("value2"));
+        RestAssured.get("/nitrite/collection")
+                .then()
+                .statusCode(200)
+                .header(NitriteConstants.CHANGE_TYPE, "INSERT")
+                .body("key2", is("value2"));
+
+        RestAssured.given()
+                .contentType(ContentType.JSON)
+                .body(new Operation(Operation.Type.insert, null, null, 
Document.createDocument("key1", "value_beforeUpdate")))
+                .post("/nitrite/collectionOperation")
+                .then()
+                .statusCode(200)
+                .body("key1", is("value_beforeUpdate"));
+        RestAssured.get("/nitrite/collection")
+                .then()
+                .statusCode(200)
+                .header(NitriteConstants.CHANGE_TYPE, "INSERT")
+                .body("key1", is("value_beforeUpdate"));
+
+        RestAssured.given()
+                .contentType(ContentType.JSON)
+                .body(new Operation(Operation.Type.update, "key1", 
"value_beforeUpdate",
+                        Document.createDocument("key1", "value_afterUpdate")))
+                .post("/nitrite/collectionOperation")
+                .then()
+                .statusCode(200)
+                .body("key1", is("value_afterUpdate"));
+        RestAssured.get("/nitrite/collection")
+                .then()
+                .statusCode(200)
+                .header(NitriteConstants.CHANGE_TYPE, "UPDATE")
+                .body("key1", is("value_afterUpdate"));
+
+        RestAssured.given()
+                .contentType(ContentType.JSON)
+                .body(new Operation(Operation.Type.delete, "key1", "value1", 
(Document) null))
+                .post("/nitrite/collectionOperation")
+                .then()
+                .statusCode(204);
+        RestAssured.get("/nitrite/collection")
+                .then()
+                .statusCode(200)
+                .header(NitriteConstants.CHANGE_TYPE, "REMOVE")
+                .body("key1", is("value1"));
+
+        RestAssured.given()
+                .contentType(ContentType.JSON)
+                .body(new Operation(Operation.Type.find, "key1", (Object) 
"value_afterUpdate", (Document) null))
+                .post("/nitrite/collectionOperation")
                 .then()
-                .statusCode(200);
+                .statusCode(200)
+                .body("size()", is(1));// There is only 1 item with value1
     }
 
 }
diff --git 
a/extensions-jvm/nitrite/integration-test/src/test/java/org/apache/camel/quarkus/component/nitrite/it/NitriteTestResource.java
 
b/extensions-jvm/nitrite/integration-test/src/test/java/org/apache/camel/quarkus/component/nitrite/it/NitriteTestResource.java
new file mode 100644
index 0000000..8bce63e
--- /dev/null
+++ 
b/extensions-jvm/nitrite/integration-test/src/test/java/org/apache/camel/quarkus/component/nitrite/it/NitriteTestResource.java
@@ -0,0 +1,59 @@
+/*
+ * 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.quarkus.component.nitrite.it;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Map;
+
+import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;
+import org.apache.camel.util.CollectionHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class NitriteTestResource implements 
QuarkusTestResourceLifecycleManager {
+    private static final Logger LOGGER = 
LoggerFactory.getLogger(NitriteTestResource.class);
+
+    private Path dbFile;
+
+    @Override
+    public Map<String, String> start() {
+
+        try {
+            String filePrefix = getClass().getSimpleName() + "-db-file-";
+            LOGGER.debug("Creating temporary file for Nitrite db ({}*)", 
filePrefix);
+            dbFile = Files.createTempFile(filePrefix, "");
+
+            return CollectionHelper.mapOf(NitriteResource.PROPERTY_DB_FILE, 
dbFile.toString());
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    @Override
+    public void stop() {
+        try {
+            if (dbFile != null) {
+                Files.deleteIfExists(dbFile);
+            }
+        } catch (Exception e) {
+            // ignored
+        }
+    }
+}

Reply via email to