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 94664f57 Ref #421: Add camel-drill integration test (#422)
94664f57 is described below

commit 94664f5756d7becff39931a2638342d12384e68c
Author: Stefan Tataru <stefan.tatar...@gmail.com>
AuthorDate: Sat Jul 13 10:14:17 2024 +0200

    Ref #421: Add camel-drill integration test (#422)
---
 features/src/main/feature/camel-features.xml       |  4 +-
 tests/features/camel-drill/pom.xml                 | 42 +++++++++++++
 .../karaf/camel/test/CamelDrillRouteSupplier.java  | 48 +++++++++++++++
 .../apache/karaf/camel/itest/CamelDrillITest.java  | 68 ++++++++++++++++++++++
 tests/features/pom.xml                             |  1 +
 5 files changed, 162 insertions(+), 1 deletion(-)

diff --git a/features/src/main/feature/camel-features.xml 
b/features/src/main/feature/camel-features.xml
index f42e432c..bd5cce3a 100644
--- a/features/src/main/feature/camel-features.xml
+++ b/features/src/main/feature/camel-features.xml
@@ -941,7 +941,9 @@
     <feature name='camel-drill' version='${project.version}' start-level='50'>
         <feature version='${camel-osgi-version-range}'>camel-core</feature>
         <feature version='${camel-osgi-spring-version}'>spring-jdbc</feature>
-        <bundle 
dependency='true'>wrap:mvn:org.apache.drill.exec/drill-jdbc-all/${apache-drill-version}$Export-Package=org.apache.drill.jdbc.*;version=${apache-drill-version}</bundle>
+        <!-- force SPI-Provider to a single value because it's not needed = * 
causes class not found exceptions,
+        the bundled jar does not contain all necessary jersey dependencies -->
+        <bundle 
dependency='true'>wrap:mvn:org.apache.drill.exec/drill-jdbc-all/${apache-drill-version}$Export-Package=org.apache.drill.jdbc.*;version=${apache-drill-version}&amp;SPI-Provider=java.sql.Driver</bundle>
         
<bundle>mvn:org.apache.camel.karaf/camel-drill/${project.version}</bundle>
     </feature>
     <feature name='camel-dropbox' version='${project.version}' 
start-level='50'>
diff --git a/tests/features/camel-drill/pom.xml 
b/tests/features/camel-drill/pom.xml
new file mode 100644
index 00000000..7d3c328e
--- /dev/null
+++ b/tests/features/camel-drill/pom.xml
@@ -0,0 +1,42 @@
+<?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-drill-test</artifactId>
+    <name>Apache Camel :: Karaf :: Tests :: Features :: Drill</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.testcontainers</groupId>
+            <artifactId>testcontainers</artifactId>
+            <version>${testcontainers-version}</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+</project>
\ No newline at end of file
diff --git 
a/tests/features/camel-drill/src/main/java/org/apache/karaf/camel/test/CamelDrillRouteSupplier.java
 
b/tests/features/camel-drill/src/main/java/org/apache/karaf/camel/test/CamelDrillRouteSupplier.java
new file mode 100644
index 00000000..3bfddb29
--- /dev/null
+++ 
b/tests/features/camel-drill/src/main/java/org/apache/karaf/camel/test/CamelDrillRouteSupplier.java
@@ -0,0 +1,48 @@
+/*
+ * 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.model.RouteDefinition;
+import 
org.apache.karaf.camel.itests.AbstractCamelSingleFeatureResultMockBasedRouteSupplier;
+import org.apache.karaf.camel.itests.CamelRouteSupplier;
+import org.osgi.service.component.annotations.Component;
+
+@Component(
+        name = "karaf-camel-drill-test",
+        immediate = true,
+        service = CamelRouteSupplier.class
+)
+public class CamelDrillRouteSupplier extends 
AbstractCamelSingleFeatureResultMockBasedRouteSupplier {
+
+    private final static String SELECT_QUERY = "select * from 
cp.`employee.json` limit 3";
+
+    @Override
+    protected boolean consumerEnabled() {
+        return false;
+    }
+
+    @Override
+    protected void configureProducer(RouteBuilder builder, RouteDefinition 
producerRoute) {
+        producerRoute.setHeader("DrillHost", 
builder.constant(System.getProperty("drill.host")))
+            .setHeader("DrillPort", 
builder.constant(System.getProperty("drill.port")))
+            .setHeader("CamelDrillQuery", builder.constant(SELECT_QUERY))
+            
.toD("drill://${header.DrillHost}?port=${header.DrillPort}&mode=DRILLBIT")
+            .log("Query Result: ${body}")
+            .setBody(builder.constant("OK"))
+            .toF("mock:%s", getResultMockName());
+    }
+}
\ No newline at end of file
diff --git 
a/tests/features/camel-drill/src/test/java/org/apache/karaf/camel/itest/CamelDrillITest.java
 
b/tests/features/camel-drill/src/test/java/org/apache/karaf/camel/itest/CamelDrillITest.java
new file mode 100644
index 00000000..48c55312
--- /dev/null
+++ 
b/tests/features/camel-drill/src/test/java/org/apache/karaf/camel/itest/CamelDrillITest.java
@@ -0,0 +1,68 @@
+/*
+ * 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.apache.karaf.camel.itests.CamelKarafTestHint;
+import org.apache.karaf.camel.itests.GenericContainerResource;
+import org.apache.karaf.camel.itests.PaxExamWithExternalResource;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
+import org.testcontainers.containers.GenericContainer;
+import org.testcontainers.containers.wait.strategy.Wait;
+
+@CamelKarafTestHint(externalResourceProvider = 
CamelDrillITest.ExternalResourceProviders.class)
+@RunWith(PaxExamWithExternalResource.class)
+@ExamReactorStrategy(PerClass.class)
+public class CamelDrillITest extends 
AbstractCamelSingleFeatureResultMockBasedRouteITest {
+
+    private static final int ORIGINAL_JDBC_PORT = 31010;
+
+    @Override
+    public void configureMock(MockEndpoint mock) {
+        mock.expectedBodiesReceived("OK");
+    }
+
+    @Test
+    public void testResultMock() throws Exception {
+        assertMockEndpointsSatisfied();
+    }
+
+    public static final class ExternalResourceProviders {
+        public static GenericContainerResource<DrillContainer> 
createDrillStorageBlobContainer() {
+
+            DrillContainer drillContainer = new 
DrillContainer("apache/drill:1.21.1");
+            return new GenericContainerResource<>(drillContainer, resource -> {
+                resource.setProperty("drill.host", drillContainer.getHost());
+                resource.setProperty("drill.port", 
Integer.toString(drillContainer.getMappedPort(ORIGINAL_JDBC_PORT)));
+            });
+        }
+    }
+
+    public static class DrillContainer extends 
GenericContainer<DrillContainer> {
+
+        public DrillContainer(final String containerName) {
+            super(containerName);
+
+            withExposedPorts(ORIGINAL_JDBC_PORT)
+                .waitingFor(Wait.forListeningPort())
+                // prevent the container from stopping prematurely in non 
interactive sessions
+                // see https://github.com/apache/drill/issues/2829 for more 
details
+                .withCreateContainerCmdModifier(cmd -> cmd.withTty(true));
+        }
+    }
+}
\ No newline at end of file
diff --git a/tests/features/pom.xml b/tests/features/pom.xml
index e79e6981..2aa76be8 100644
--- a/tests/features/pom.xml
+++ b/tests/features/pom.xml
@@ -55,6 +55,7 @@
         <module>camel-base64</module>
         <module>camel-bindy</module>
         <module>camel-core</module>
+        <module>camel-drill</module>
         <module>camel-ehcache</module>
         <module>camel-elasticsearch</module>
         <module>camel-fastjson</module>

Reply via email to