You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ja...@apache.org on 2024/01/04 11:32:50 UTC
(camel-quarkus) branch main updated: Use Quarkus Derby DevServices for SQL integration test
This is an automated email from the ASF dual-hosted git repository.
jamesnetherton pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/main by this push:
new 61232e9ee0 Use Quarkus Derby DevServices for SQL integration test
61232e9ee0 is described below
commit 61232e9ee046b471cd27853ce079450cd1a28226
Author: James Netherton <ja...@gmail.com>
AuthorDate: Thu Jan 4 09:31:58 2024 +0000
Use Quarkus Derby DevServices for SQL integration test
Fixes #5633
---
integration-tests-support/pom.xml | 1 -
.../sql-derby-support/README.adoc | 3 -
.../sql-derby-support/pom.xml | 42 ----------
integration-tests/sql/.gitignore | 1 +
integration-tests/sql/pom.xml | 24 ------
.../quarkus/component/sql/it/SqlDbInitializer.java | 6 --
.../storedproc/derby/NumberAddStoredProcedure.java | 10 +--
.../sql/src/main/resources/sql/derby/initDb.sql | 2 +-
.../src/main/resources/sql/derby/initDb_docker.sql | 20 -----
.../component/sql/it/DerbyTestResource.java | 96 ----------------------
.../camel/quarkus/component/sql/it/SqlTest.java | 3 -
pom.xml | 1 -
poms/bom-test/pom.xml | 5 --
13 files changed, 6 insertions(+), 208 deletions(-)
diff --git a/integration-tests-support/pom.xml b/integration-tests-support/pom.xml
index 3860e58fb3..b4a30c3ff6 100644
--- a/integration-tests-support/pom.xml
+++ b/integration-tests-support/pom.xml
@@ -51,7 +51,6 @@
<module>kafka</module>
<module>mongodb</module>
<module>process-executor-support</module>
- <module>sql-derby-support</module>
<module>test-support</module>
<module>mock-backend</module>
<module>wiremock</module>
diff --git a/integration-tests-support/sql-derby-support/README.adoc b/integration-tests-support/sql-derby-support/README.adoc
deleted file mode 100644
index 5b0da368d7..0000000000
--- a/integration-tests-support/sql-derby-support/README.adoc
+++ /dev/null
@@ -1,3 +0,0 @@
-== SQL integration tests
-
-This module creates jar with stored procedure used in test from `sql` module (for derby database).
\ No newline at end of file
diff --git a/integration-tests-support/sql-derby-support/pom.xml b/integration-tests-support/sql-derby-support/pom.xml
deleted file mode 100644
index 6e104dda61..0000000000
--- a/integration-tests-support/sql-derby-support/pom.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<?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">
- <parent>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-integration-tests-support</artifactId>
- <version>3.7.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
- <modelVersion>4.0.0</modelVersion>
-
- <artifactId>camel-quarkus-integration-tests-support-sql-derby</artifactId>
- <name>Camel Quarkus :: Integration Tests :: Support :: Sql Derby</name>
-
- <properties>
- <cq.sqlJdbcKind>h2</cq.sqlJdbcKind>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-sql</artifactId>
- </dependency>
- </dependencies>
-</project>
diff --git a/integration-tests/sql/.gitignore b/integration-tests/sql/.gitignore
new file mode 100644
index 0000000000..1298c5f0fe
--- /dev/null
+++ b/integration-tests/sql/.gitignore
@@ -0,0 +1 @@
+derby.log
diff --git a/integration-tests/sql/pom.xml b/integration-tests/sql/pom.xml
index 01ec2d33ce..a89176655f 100644
--- a/integration-tests/sql/pom.xml
+++ b/integration-tests/sql/pom.xml
@@ -75,11 +75,6 @@
<artifactId>awaitility</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-integration-tests-support-sql-derby</artifactId>
- <scope>test</scope>
- </dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
@@ -195,25 +190,6 @@
<value>derby</value>
</property>
</activation>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <phase>process-sources</phase>
- <goals>
- <goal>copy-dependencies</goal>
- </goals>
- <configuration>
- <includeArtifactIds>camel-quarkus-integration-tests-support-sql-derby</includeArtifactIds>
- <outputDirectory>target/test-classes/derby/</outputDirectory>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
diff --git a/integration-tests/sql/src/main/java/org/apache/camel/quarkus/component/sql/it/SqlDbInitializer.java b/integration-tests/sql/src/main/java/org/apache/camel/quarkus/component/sql/it/SqlDbInitializer.java
index f711727736..fa2b9c24ea 100644
--- a/integration-tests/sql/src/main/java/org/apache/camel/quarkus/component/sql/it/SqlDbInitializer.java
+++ b/integration-tests/sql/src/main/java/org/apache/camel/quarkus/component/sql/it/SqlDbInitializer.java
@@ -43,13 +43,7 @@ public class SqlDbInitializer {
String dbKind;
public void initDb() throws SQLException, IOException {
-
runScripts("initDb.sql");
-
- if (SqlHelper.useDocker()) {
- //docker execution may require more sql scripts
- runScripts("initDb_docker.sql");
- }
}
private void runScripts(String fileName) throws SQLException, IOException {
diff --git a/integration-tests-support/sql-derby-support/src/main/java/test/AddNumsProcedure.java b/integration-tests/sql/src/main/java/org/apache/camel/quarkus/component/sql/it/storedproc/derby/NumberAddStoredProcedure.java
similarity index 82%
rename from integration-tests-support/sql-derby-support/src/main/java/test/AddNumsProcedure.java
rename to integration-tests/sql/src/main/java/org/apache/camel/quarkus/component/sql/it/storedproc/derby/NumberAddStoredProcedure.java
index efbfaa2d50..9c454c9642 100644
--- a/integration-tests-support/sql-derby-support/src/main/java/test/AddNumsProcedure.java
+++ b/integration-tests/sql/src/main/java/org/apache/camel/quarkus/component/sql/it/storedproc/derby/NumberAddStoredProcedure.java
@@ -14,18 +14,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package test;
+package org.apache.camel.quarkus.component.sql.it.storedproc.derby;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
-public class AddNumsProcedure {
-
- public static void testProc(int a, int b) throws SQLException {
- String sql = "insert into ADD_NUMS_RESULTS (id, value) VALUES (1, " + (a + b) + ")";
-
+public class NumberAddStoredProcedure {
+ public static void addNumbers(int a, int b) throws SQLException {
+ String sql = "INSERT INTO ADD_NUMS_RESULTS (id, value) VALUES (1, " + (a + b) + ")";
try (Connection con = DriverManager.getConnection("jdbc:default:connection");
PreparedStatement ps = con.prepareStatement(sql)) {
ps.execute();
diff --git a/integration-tests/sql/src/main/resources/sql/derby/initDb.sql b/integration-tests/sql/src/main/resources/sql/derby/initDb.sql
index 11712b6f08..40f4617e9b 100644
--- a/integration-tests/sql/src/main/resources/sql/derby/initDb.sql
+++ b/integration-tests/sql/src/main/resources/sql/derby/initDb.sql
@@ -40,4 +40,4 @@ CREATE TABLE aggregation_completed (id VARCHAR(255) NOT NULL, exchange BLOB NOT
DROP TABLE ADD_NUMS_RESULTS
CREATE TABLE ADD_NUMS_RESULTS (id INT PRIMARY KEY, value INT NOT NULL)
-CREATE PROCEDURE ADD_NUMS(IN a INTEGER, IN b INTEGER) PARAMETER STYLE JAVA LANGUAGE JAVA EXTERNAL NAME 'test.AddNumsProcedure.testProc'
+CREATE PROCEDURE ADD_NUMS(IN a INTEGER, IN b INTEGER) PARAMETER STYLE JAVA LANGUAGE JAVA EXTERNAL NAME 'org.apache.camel.quarkus.component.sql.it.storedproc.derby.NumberAddStoredProcedure.addNumbers'
diff --git a/integration-tests/sql/src/main/resources/sql/derby/initDb_docker.sql b/integration-tests/sql/src/main/resources/sql/derby/initDb_docker.sql
deleted file mode 100644
index a0d87ad3c1..0000000000
--- a/integration-tests/sql/src/main/resources/sql/derby/initDb_docker.sql
+++ /dev/null
@@ -1,20 +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.
---
-
-CALL sqlj.install_jar('/dbs/storedProcedure.jar', 'AddNumsProcedure' , 0)
-
-CALL syscs_util.syscs_set_database_property('derby.database.classpath', 'APP.ADDNUMSPROCEDURE')
diff --git a/integration-tests/sql/src/test/java/org/apache/camel/quarkus/component/sql/it/DerbyTestResource.java b/integration-tests/sql/src/test/java/org/apache/camel/quarkus/component/sql/it/DerbyTestResource.java
deleted file mode 100644
index 256f736464..0000000000
--- a/integration-tests/sql/src/test/java/org/apache/camel/quarkus/component/sql/it/DerbyTestResource.java
+++ /dev/null
@@ -1,96 +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.quarkus.component.sql.it;
-
-import java.io.File;
-import java.net.URL;
-import java.util.Collections;
-import java.util.Map;
-
-import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;
-import org.apache.camel.util.CollectionHelper;
-import org.eclipse.microprofile.config.ConfigProvider;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testcontainers.containers.GenericContainer;
-import org.testcontainers.containers.wait.strategy.Wait;
-import org.testcontainers.utility.MountableFile;
-import org.testcontainers.utility.TestcontainersConfiguration;
-
-/**
- * Derby test resource starts derby container in case that SQL_USE_DERBY_DOCKER is set to true.
- * It uses fixed port number obtained from SQL_USE_DERBY_PORT.
- */
-public class DerbyTestResource<T extends GenericContainer> implements QuarkusTestResourceLifecycleManager {
- private static final Logger LOGGER = LoggerFactory.getLogger(DerbyTestResource.class);
- private static final String DERBY_IMAGE_NAME = ConfigProvider.getConfig().getValue("derby.container.image", String.class);
- private GenericContainer container;
-
- @Override
- public Map<String, String> start() {
- //should be started only for derby in docker
- // derby dev service does not work - it is still in process, see https://quarkus.io/guides/databases-dev-services
- if (!SqlHelper.useDocker()) {
- return Collections.emptyMap();
- }
-
- LOGGER.info(TestcontainersConfiguration.getInstance().toString());
-
- try {
- URL derby = Thread.currentThread().getContextClassLoader().getResource("derby");
- File[] jars = new File(derby.toURI())
- .listFiles((d, n) -> n.startsWith("camel-quarkus-integration-tests-support-sql-derby"));
- if (jars.length != 1) {
- String msg = "There has to be one jar in target/test-classes with the name \"camel-quarkus-integration-test-sql-derby-stored-procedure-*.jar\", which contains stored procedure for the derby db.";
- LOGGER.error(msg);
- throw new IllegalStateException(msg);
- }
-
- container = new GenericContainer("az82/docker-derby")
- .withExposedPorts(1527)
- .withCopyFileToContainer(
- MountableFile.forClasspathResource("derby/" + jars[0].getName()),
- "/dbs/storedProcedure.jar")
- .waitingFor(Wait.forListeningPort());
-
- container.start();
-
- return CollectionHelper.mapOf("quarkus.datasource.jdbc.url",
- "jdbc:derby://localhost:" + container.getMappedPort(1527) + "/DOCKERDB;create=true");
-
- } catch (Exception e) {
- LOGGER.error("Container does not start", e);
- throw new RuntimeException(e);
- }
- }
-
- protected void startContainer() throws Exception {
- container.start();
- }
-
- @Override
- public void stop() {
- try {
- if (container != null) {
- container.stop();
- }
- } catch (Exception e) {
- // ignored
- }
- }
-}
diff --git a/integration-tests/sql/src/test/java/org/apache/camel/quarkus/component/sql/it/SqlTest.java b/integration-tests/sql/src/test/java/org/apache/camel/quarkus/component/sql/it/SqlTest.java
index 9db910560d..2f62442563 100644
--- a/integration-tests/sql/src/test/java/org/apache/camel/quarkus/component/sql/it/SqlTest.java
+++ b/integration-tests/sql/src/test/java/org/apache/camel/quarkus/component/sql/it/SqlTest.java
@@ -20,7 +20,6 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
-import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.http.ContentType;
@@ -33,12 +32,10 @@ import org.hamcrest.collection.IsMapContaining;
import org.hamcrest.text.IsEqualIgnoringCase;
import org.junit.jupiter.api.Test;
-import static io.restassured.RestAssured.given;
import static org.awaitility.Awaitility.await;
import static org.hamcrest.Matchers.*;
@QuarkusTest
-@QuarkusTestResource(DerbyTestResource.class)
class SqlTest {
@Test
diff --git a/pom.xml b/pom.xml
index fedecb5f15..5beebad2cb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -218,7 +218,6 @@
<consul.container.image>docker.io/hashicorp/consul:1.16</consul.container.image>
<couchbase.container.image>docker.io/couchbase/server:7.2.0</couchbase.container.image>
<couchdb.container.image>docker.io/couchdb:2.3.1</couchdb.container.image>
- <derby.container.image>docker.io/az82/docker-derby:10.16</derby.container.image>
<eclipse-mosquitto.container.image>docker.io/eclipse-mosquitto:1.6.15</eclipse-mosquitto.container.image>
<eclipse-temurin.container.image>eclipse-temurin:17-ubi9-minimal</eclipse-temurin.container.image>
<elasticsearch.container.image>docker.io/elasticsearch:8.8.1</elasticsearch.container.image>
diff --git a/poms/bom-test/pom.xml b/poms/bom-test/pom.xml
index 9e4a72b515..a3e9dbccea 100644
--- a/poms/bom-test/pom.xml
+++ b/poms/bom-test/pom.xml
@@ -208,11 +208,6 @@
<artifactId>camel-quarkus-integration-tests-support-mongodb</artifactId>
<version>${camel-quarkus.version}</version>
</dependency>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-integration-tests-support-sql-derby</artifactId>
- <version>${camel-quarkus.version}</version>
- </dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-integration-wiremock-support</artifactId>