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 2022/03/01 07:26:03 UTC

[camel-quarkus] 02/03: Test for Debezium mysql - passing additionalProperties results in wrong properties beeing passed #3488

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

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

commit f947139e7427eccdc0d606aebbf4655caf3bcf11
Author: JiriOndrusek <on...@gmail.com>
AuthorDate: Mon Feb 21 15:51:05 2022 +0100

    Test for Debezium mysql - passing additionalProperties results in wrong properties beeing passed #3488
---
 .../common/it/AbstractDebeziumResource.java        | 29 +++++++++++++++++++++-
 .../common/it/postgres/DebeziumPostgresTest.java   | 15 +++++++++++
 2 files changed, 43 insertions(+), 1 deletion(-)

diff --git a/integration-tests/debezium/src/main/java/org/apache/camel/quarkus/component/debezium/common/it/AbstractDebeziumResource.java b/integration-tests/debezium/src/main/java/org/apache/camel/quarkus/component/debezium/common/it/AbstractDebeziumResource.java
index ff49301..0e74a9b 100644
--- a/integration-tests/debezium/src/main/java/org/apache/camel/quarkus/component/debezium/common/it/AbstractDebeziumResource.java
+++ b/integration-tests/debezium/src/main/java/org/apache/camel/quarkus/component/debezium/common/it/AbstractDebeziumResource.java
@@ -16,11 +16,20 @@
  */
 package org.apache.camel.quarkus.component.debezium.common.it;
 
+import java.util.Map;
+import java.util.stream.Collectors;
+
 import javax.inject.Inject;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
 
+import org.apache.camel.CamelContext;
 import org.apache.camel.ConsumerTemplate;
 import org.apache.camel.Exchange;
 import org.apache.camel.component.debezium.DebeziumConstants;
+import org.apache.camel.component.debezium.DebeziumEndpoint;
 import org.eclipse.microprofile.config.Config;
 import org.eclipse.microprofile.config.inject.ConfigProperty;
 
@@ -41,10 +50,23 @@ public abstract class AbstractDebeziumResource {
     @Inject
     Config config;
 
+    @Inject
+    CamelContext camelContext;
+
     public AbstractDebeziumResource(Type type) {
         this.type = type;
     }
 
+    @Path("/getAdditionalProperties")
+    @GET
+    @Produces(MediaType.APPLICATION_JSON)
+    public Map<String, String> getAdditionalProperties() {
+        DebeziumEndpoint endpoint = (DebeziumEndpoint) camelContext.getEndpoint(getEndpointUrl()
+                + "&additionalProperties.database.connectionTimeZone=CET");
+        return endpoint.getConfiguration().getAdditionalProperties().entrySet().stream()
+                .collect(Collectors.toMap(Map.Entry::getKey, e -> (String) e.getValue()));
+    }
+
     String getEndpoinUrl(String hostname, String port, String username, String password, String databaseServerName,
             String offsetStorageFileName) {
         return type.getComponent() + ":localhost?"
@@ -90,6 +112,11 @@ public abstract class AbstractDebeziumResource {
     }
 
     private Exchange receiveAsExchange() {
+        String endpoint = getEndpointUrl();
+        return consumerTemplate.receive(endpoint, TIMEOUT);
+    }
+
+    protected String getEndpointUrl() {
         String endpoint = getEndpoinUrl(
                 config.getValue(type.getPropertyHostname(), String.class),
                 config.getValue(type.getPropertyPort(), String.class),
@@ -97,6 +124,6 @@ public abstract class AbstractDebeziumResource {
                 config.getValue(type.getPropertyPassword(), String.class),
                 "qa",
                 config.getValue(type.getPropertyOffsetFileName(), String.class));
-        return consumerTemplate.receive(endpoint, TIMEOUT);
+        return endpoint;
     }
 }
diff --git a/integration-tests/debezium/src/test/java/org/apache/camel/quarkus/component/debezium/common/it/postgres/DebeziumPostgresTest.java b/integration-tests/debezium/src/test/java/org/apache/camel/quarkus/component/debezium/common/it/postgres/DebeziumPostgresTest.java
index c610735..4a7148a 100644
--- a/integration-tests/debezium/src/test/java/org/apache/camel/quarkus/component/debezium/common/it/postgres/DebeziumPostgresTest.java
+++ b/integration-tests/debezium/src/test/java/org/apache/camel/quarkus/component/debezium/common/it/postgres/DebeziumPostgresTest.java
@@ -22,6 +22,7 @@ import java.sql.SQLException;
 
 import io.quarkus.test.common.QuarkusTestResource;
 import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
 import org.apache.camel.quarkus.component.debezium.common.it.AbstractDebeziumTest;
 import org.apache.camel.quarkus.component.debezium.common.it.Type;
 import org.eclipse.microprofile.config.Config;
@@ -30,8 +31,12 @@ import org.jboss.logging.Logger;
 import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.MethodOrderer;
+import org.junit.jupiter.api.Order;
+import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.TestMethodOrder;
 
+import static org.hamcrest.Matchers.is;
+
 @QuarkusTest
 @QuarkusTestResource(DebeziumPostgresTestResource.class)
 @TestMethodOrder(MethodOrderer.OrderAnnotation.class)
@@ -51,6 +56,16 @@ class DebeziumPostgresTest extends AbstractDebeziumTest {
         connection = DriverManager.getConnection(jdbcUrl);
     }
 
+    @Test
+    @Order(4)
+    public void testAdditionalProperty() {
+        //https://github.com/apache/camel-quarkus/issues/3488
+        RestAssured.get(Type.postgres.getComponent() + "/getAdditionalProperties")
+                .then()
+                .statusCode(200)
+                .body("'database.connectionTimeZone'", is("CET"));
+    }
+
     @AfterAll
     public static void cleanUp() throws SQLException {
         if (connection != null) {