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

nfilotto pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-karaf.git


The following commit(s) were added to refs/heads/main by this push:
     new 1de3ddee Ref #419: Add camel-bindy integration test (#420)
1de3ddee is described below

commit 1de3ddee73d7282109c2b44d4b07e3e4f840b3f1
Author: François de Parscau <116000379+f2p...@users.noreply.github.com>
AuthorDate: Sat Jul 13 10:13:13 2024 +0200

    Ref #419: Add camel-bindy integration test (#420)
---
 tests/features/camel-bindy/pom.xml                 |  40 +++++
 .../karaf/camel/test/CamelBindyRouteSupplier.java  |  52 +++++++
 .../java/org/apache/karaf/camel/test/Order.java    | 168 +++++++++++++++++++++
 .../apache/karaf/camel/itest/CamelBindyITest.java  |  39 +++++
 tests/features/pom.xml                             |   1 +
 5 files changed, 300 insertions(+)

diff --git a/tests/features/camel-bindy/pom.xml 
b/tests/features/camel-bindy/pom.xml
new file mode 100644
index 00000000..9e1aae95
--- /dev/null
+++ b/tests/features/camel-bindy/pom.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0";
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.camel.karaf</groupId>
+        <artifactId>camel-karaf-features-test</artifactId>
+        <version>4.6.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>camel-bindy-test</artifactId>
+    <name>Apache Camel :: Karaf :: Tests :: Features :: Bindy</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-bindy</artifactId>
+            <version>${camel-version}</version>
+        </dependency>
+    </dependencies>
+</project>
\ No newline at end of file
diff --git 
a/tests/features/camel-bindy/src/main/java/org/apache/karaf/camel/test/CamelBindyRouteSupplier.java
 
b/tests/features/camel-bindy/src/main/java/org/apache/karaf/camel/test/CamelBindyRouteSupplier.java
new file mode 100644
index 00000000..ffed028f
--- /dev/null
+++ 
b/tests/features/camel-bindy/src/main/java/org/apache/karaf/camel/test/CamelBindyRouteSupplier.java
@@ -0,0 +1,52 @@
+/*
+ * 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.karaf.camel.test;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.dataformat.bindy.csv.BindyCsvDataFormat;
+import org.apache.camel.model.RouteDefinition;
+import 
org.apache.karaf.camel.itests.AbstractCamelSingleFeatureResultMockBasedRouteSupplier;
+import org.osgi.service.component.annotations.Component;
+
+@Component(
+        name = "karaf-camel-bindy-test",
+        immediate = true,
+        service = CamelBindyRouteSupplier.class
+)
+public class CamelBindyRouteSupplier extends 
AbstractCamelSingleFeatureResultMockBasedRouteSupplier {
+
+    public static final String CSV = 
"1,B2,Keira,Knightley,ISIN,XX23456789,BUY,Share,400.25,EUR,14-01-2009,17-02-2011
 23:21:59\r\n";
+
+    @Override
+    protected boolean consumerEnabled() {
+        return false;
+    }
+
+    @Override
+    protected void configureProducer(RouteBuilder builder, RouteDefinition 
producerRoute) {
+
+        BindyCsvDataFormat camelDataFormat = new 
BindyCsvDataFormat(Order.class);
+
+        producerRoute.process(ex -> ex.getIn().setBody(CSV))
+                .unmarshal(camelDataFormat)
+                .marshal(camelDataFormat)
+                .log("Decoded: ${body}")
+                .toF("mock:%s", getResultMockName());
+    }
+
+
+}
+
diff --git 
a/tests/features/camel-bindy/src/main/java/org/apache/karaf/camel/test/Order.java
 
b/tests/features/camel-bindy/src/main/java/org/apache/karaf/camel/test/Order.java
new file mode 100644
index 00000000..409352b6
--- /dev/null
+++ 
b/tests/features/camel-bindy/src/main/java/org/apache/karaf/camel/test/Order.java
@@ -0,0 +1,168 @@
+/*
+ * 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.karaf.camel.test;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+import org.apache.camel.dataformat.bindy.annotation.CsvRecord;
+import org.apache.camel.dataformat.bindy.annotation.DataField;
+
+@CsvRecord(separator = ",")
+public class Order {
+
+    @DataField(pos = 1)
+    private int orderNr;
+
+    @DataField(pos = 2)
+    private String clientNr;
+
+    @DataField(pos = 3, defaultValue = "Joe")
+    private String firstName;
+
+    @DataField(pos = 4)
+    private String lastName;
+
+    @DataField(pos = 5)
+    private String instrumentCode;
+
+    @DataField(pos = 6)
+    private String instrumentNumber;
+
+    @DataField(pos = 7)
+    private String orderType;
+
+    @DataField(name = "Name", pos = 8)
+    private String instrumentType;
+
+    @DataField(pos = 9, precision = 2)
+    private BigDecimal amount;
+
+    @DataField(pos = 10)
+    private String currency;
+
+    @DataField(pos = 11, pattern = "dd-MM-yyyy")
+    private Date orderDate;
+
+    @DataField(pos = 12, pattern = "dd-MM-yyyy HH:mm:ss", timezone = "GMT+4")
+    private Date orderDateTime;
+
+    public int getOrderNr() {
+        return orderNr;
+    }
+
+    public void setOrderNr(int orderNr) {
+        this.orderNr = orderNr;
+    }
+
+    public String getClientNr() {
+        return clientNr;
+    }
+
+    public void setClientNr(String clientNr) {
+        this.clientNr = clientNr;
+    }
+
+    public String getFirstName() {
+        return firstName;
+    }
+
+    public void setFirstName(String firstName) {
+        this.firstName = firstName;
+    }
+
+    public String getLastName() {
+        return lastName;
+    }
+
+    public void setLastName(String lastName) {
+        this.lastName = lastName;
+    }
+
+    public String getInstrumentCode() {
+        return instrumentCode;
+    }
+
+    public void setInstrumentCode(String instrumentCode) {
+        this.instrumentCode = instrumentCode;
+    }
+
+    public String getInstrumentNumber() {
+        return instrumentNumber;
+    }
+
+    public void setInstrumentNumber(String instrumentNumber) {
+        this.instrumentNumber = instrumentNumber;
+    }
+
+    public String getOrderType() {
+        return orderType;
+    }
+
+    public void setOrderType(String orderType) {
+        this.orderType = orderType;
+    }
+
+    public String getInstrumentType() {
+        return instrumentType;
+    }
+
+    public void setInstrumentType(String instrumentType) {
+        this.instrumentType = instrumentType;
+    }
+
+    public BigDecimal getAmount() {
+        return amount;
+    }
+
+    public void setAmount(BigDecimal amount) {
+        this.amount = amount;
+    }
+
+    public String getCurrency() {
+        return currency;
+    }
+
+    public void setCurrency(String currency) {
+        this.currency = currency;
+    }
+
+    public Date getOrderDate() {
+        return orderDate;
+    }
+
+    public void setOrderDate(Date orderDate) {
+        this.orderDate = orderDate;
+    }
+
+    public Date getOrderDateTime() {
+        return orderDateTime;
+    }
+
+    public void setOrderDateTime(Date orderDateTime) {
+        this.orderDateTime = orderDateTime;
+    }
+
+    @Override
+    public String toString() {
+        return "Model : " + Order.class.getName() + " : " + this.orderNr + ", 
" + this.orderType + ", "
+               + String.valueOf(this.amount) + ", " + this.instrumentCode + ", 
"
+               + this.instrumentNumber + ", " + this.instrumentType + ", " + 
this.currency + ", " + this.clientNr + ", "
+               + this.firstName + ", " + this.lastName + ", "
+               + String.valueOf(this.orderDate) + ", " + 
String.valueOf(this.orderDateTime);
+    }
+}
diff --git 
a/tests/features/camel-bindy/src/test/java/org/apache/karaf/camel/itest/CamelBindyITest.java
 
b/tests/features/camel-bindy/src/test/java/org/apache/karaf/camel/itest/CamelBindyITest.java
new file mode 100644
index 00000000..a9ae661f
--- /dev/null
+++ 
b/tests/features/camel-bindy/src/test/java/org/apache/karaf/camel/itest/CamelBindyITest.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed 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.karaf.camel.itest;
+
+import org.apache.camel.component.mock.MockEndpoint;
+import 
org.apache.karaf.camel.itests.AbstractCamelSingleFeatureResultMockBasedRouteITest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
+
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
+public class CamelBindyITest extends 
AbstractCamelSingleFeatureResultMockBasedRouteITest {
+
+    public static final String CSV = 
"1,B2,Keira,Knightley,ISIN,XX23456789,BUY,Share,400.25,EUR,14-01-2009,17-02-2011
 23:21:59\r\n";
+
+    @Override
+    public void configureMock(MockEndpoint mock) {
+        mock.expectedBodiesReceived(CSV);
+    }
+
+    @Test
+    public void testResultMock() throws Exception {
+        assertMockEndpointsSatisfied();
+    }
+}
\ No newline at end of file
diff --git a/tests/features/pom.xml b/tests/features/pom.xml
index 76500cde..e79e6981 100644
--- a/tests/features/pom.xml
+++ b/tests/features/pom.xml
@@ -53,6 +53,7 @@
         <module>camel-azure-storage-blob</module>
         <module>camel-barcode</module>
         <module>camel-base64</module>
+        <module>camel-bindy</module>
         <module>camel-core</module>
         <module>camel-ehcache</module>
         <module>camel-elasticsearch</module>

Reply via email to