You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pp...@apache.org on 2020/10/13 08:41:06 UTC
[camel-quarkus] branch master updated: PostgresSQL Event native
support fixes #1719
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 69d9d7a PostgresSQL Event native support fixes #1719
69d9d7a is described below
commit 69d9d7ac1f712b0bca1149ce6a10a35c94236ebd
Author: Zineb Bendhiba <be...@gmail.com>
AuthorDate: Thu Oct 8 10:48:53 2020 +0200
PostgresSQL Event native support fixes #1719
---
.../ROOT/pages/reference/extensions/pgevent.adoc | 8 +--
.../partials/reference/components/pgevent.adoc | 6 +-
.../pgevent/deployment/PgeventProcessor.java | 46 ------------
extensions-jvm/pom.xml | 1 -
.../pgevent/deployment/pom.xml | 4 ++
.../pgevent/deployment/PgeventProcessor.java | 68 ++++++++++++++++++
{extensions-jvm => extensions}/pgevent/pom.xml | 1 -
.../pgevent/runtime/pom.xml | 5 ++
.../main/resources/META-INF/quarkus-extension.yaml | 0
extensions/pom.xml | 1 +
.../pgevent}/pom.xml | 76 ++++++++++++++++++--
.../camel/quarkus/component/pgevent/it/MyBean.java | 18 ++---
.../component/pgevent/it/PgeventResource.java | 33 +++++----
.../component/pgevent/it/PgeventRoutes.java | 70 +++++++++++++++++++
.../src/main/resources/application.properties | 24 +++++++
.../component/pgevent/it/PgEventTestResource.java | 81 ++++++++++++++++++++++
.../quarkus/component/pgevent/it/PgeventIT.java | 16 +----
.../quarkus/component/pgevent/it/PgeventTest.java | 23 ++++--
integration-tests/pom.xml | 1 +
tooling/scripts/test-categories.yaml | 3 +-
20 files changed, 381 insertions(+), 104 deletions(-)
diff --git a/docs/modules/ROOT/pages/reference/extensions/pgevent.adoc b/docs/modules/ROOT/pages/reference/extensions/pgevent.adoc
index 32f5aa6..3a393d3 100644
--- a/docs/modules/ROOT/pages/reference/extensions/pgevent.adoc
+++ b/docs/modules/ROOT/pages/reference/extensions/pgevent.adoc
@@ -2,15 +2,15 @@
// This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page
= PostgresSQL Event
:cq-artifact-id: camel-quarkus-pgevent
-:cq-native-supported: false
-:cq-status: Preview
+:cq-native-supported: true
+:cq-status: Stable
:cq-description: Send and receive PostgreSQL events via LISTEN and NOTIFY commands.
:cq-deprecated: false
:cq-jvm-since: 1.1.0
-:cq-native-since: n/a
+:cq-native-since: 1.2.0
[.badges]
-[.badge-key]##JVM since##[.badge-supported]##1.1.0## [.badge-key]##Native##[.badge-unsupported]##unsupported##
+[.badge-key]##JVM since##[.badge-supported]##1.1.0## [.badge-key]##Native since##[.badge-supported]##1.2.0##
Send and receive PostgreSQL events via LISTEN and NOTIFY commands.
diff --git a/docs/modules/ROOT/partials/reference/components/pgevent.adoc b/docs/modules/ROOT/partials/reference/components/pgevent.adoc
index 9f398ee..42474fc 100644
--- a/docs/modules/ROOT/partials/reference/components/pgevent.adoc
+++ b/docs/modules/ROOT/partials/reference/components/pgevent.adoc
@@ -2,11 +2,11 @@
// This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page
:cq-artifact-id: camel-quarkus-pgevent
:cq-artifact-id-base: pgevent
-:cq-native-supported: false
-:cq-status: Preview
+:cq-native-supported: true
+:cq-status: Stable
:cq-deprecated: false
:cq-jvm-since: 1.1.0
-:cq-native-since: n/a
+:cq-native-since: 1.2.0
:cq-camel-part-name: pgevent
:cq-camel-part-title: PostgresSQL Event
:cq-camel-part-description: Send and receive PostgreSQL events via LISTEN and NOTIFY commands.
diff --git a/extensions-jvm/pgevent/deployment/src/main/java/org/apache/camel/quarkus/component/pgevent/deployment/PgeventProcessor.java b/extensions-jvm/pgevent/deployment/src/main/java/org/apache/camel/quarkus/component/pgevent/deployment/PgeventProcessor.java
deleted file mode 100644
index 042e49f..0000000
--- a/extensions-jvm/pgevent/deployment/src/main/java/org/apache/camel/quarkus/component/pgevent/deployment/PgeventProcessor.java
+++ /dev/null
@@ -1,46 +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.pgevent.deployment;
-
-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.pkg.steps.NativeBuild;
-import org.apache.camel.quarkus.core.JvmOnlyRecorder;
-import org.jboss.logging.Logger;
-
-class PgeventProcessor {
-
- private static final Logger LOG = Logger.getLogger(PgeventProcessor.class);
- private static final String FEATURE = "camel-pgevent";
-
- @BuildStep
- FeatureBuildItem feature() {
- return new FeatureBuildItem(FEATURE);
- }
-
- /**
- * Remove this once this extension starts supporting the native mode.
- */
- @BuildStep(onlyIf = NativeBuild.class)
- @Record(value = ExecutionTime.RUNTIME_INIT)
- void warnJvmInNative(JvmOnlyRecorder recorder) {
- JvmOnlyRecorder.warnJvmInNative(LOG, FEATURE); // warn at build time
- recorder.warnJvmInNative(FEATURE); // warn at runtime
- }
-}
diff --git a/extensions-jvm/pom.xml b/extensions-jvm/pom.xml
index 82920b3..1ca96e3 100644
--- a/extensions-jvm/pom.xml
+++ b/extensions-jvm/pom.xml
@@ -116,7 +116,6 @@
<module>ognl</module>
<module>openstack</module>
<module>optaplanner</module>
- <module>pgevent</module>
<module>printer</module>
<module>protobuf</module>
<module>pubnub</module>
diff --git a/extensions-jvm/pgevent/deployment/pom.xml b/extensions/pgevent/deployment/pom.xml
similarity index 94%
rename from extensions-jvm/pgevent/deployment/pom.xml
rename to extensions/pgevent/deployment/pom.xml
index cc2c947..8ff294b 100644
--- a/extensions-jvm/pgevent/deployment/pom.xml
+++ b/extensions/pgevent/deployment/pom.xml
@@ -40,6 +40,10 @@
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-pgevent</artifactId>
</dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-netty-deployment</artifactId>
+ </dependency>
</dependencies>
<build>
diff --git a/extensions/pgevent/deployment/src/main/java/org/apache/camel/quarkus/component/pgevent/deployment/PgeventProcessor.java b/extensions/pgevent/deployment/src/main/java/org/apache/camel/quarkus/component/pgevent/deployment/PgeventProcessor.java
new file mode 100644
index 0000000..fae15c5
--- /dev/null
+++ b/extensions/pgevent/deployment/src/main/java/org/apache/camel/quarkus/component/pgevent/deployment/PgeventProcessor.java
@@ -0,0 +1,68 @@
+/*
+ * 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.pgevent.deployment;
+
+import java.io.IOException;
+import java.sql.Driver;
+import java.util.Set;
+import java.util.stream.Stream;
+
+import com.impossibl.postgres.system.procs.ProcProvider;
+import io.quarkus.deployment.annotations.BuildProducer;
+import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.builditem.FeatureBuildItem;
+import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
+import io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem;
+import io.quarkus.deployment.util.ServiceUtil;
+
+class PgeventProcessor {
+
+ private static final String PGEVENT_SERVICE_BASE = "META-INF/services/";
+
+ private static final String FEATURE = "camel-pgevent";
+
+ @BuildStep
+ FeatureBuildItem feature() {
+ return new FeatureBuildItem(FEATURE);
+ }
+
+ @BuildStep
+ ReflectiveClassBuildItem registerReflectiveClasses() {
+ return new ReflectiveClassBuildItem(false, true, "io.netty.channel.nio.NioEventLoopGroup");
+ }
+
+ @BuildStep
+ void registerNativeImageResources(BuildProducer<ServiceProviderBuildItem> services) {
+ Stream.of(
+ PGEVENT_SERVICE_BASE + ProcProvider.class.getName(),
+ PGEVENT_SERVICE_BASE + Driver.class.getName())
+ .forEach(service -> {
+ try {
+ Set<String> implementations = ServiceUtil.classNamesNamedIn(
+ Thread.currentThread().getContextClassLoader(),
+ service);
+ services.produce(
+ new ServiceProviderBuildItem(ProcProvider.class.getName(),
+ implementations.toArray(new String[0])));
+
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ });
+ }
+
+}
diff --git a/extensions-jvm/pgevent/pom.xml b/extensions/pgevent/pom.xml
similarity index 97%
rename from extensions-jvm/pgevent/pom.xml
rename to extensions/pgevent/pom.xml
index d84b761..5c7c95b 100644
--- a/extensions-jvm/pgevent/pom.xml
+++ b/extensions/pgevent/pom.xml
@@ -35,6 +35,5 @@
<modules>
<module>deployment</module>
<module>runtime</module>
- <module>integration-test</module>
</modules>
</project>
diff --git a/extensions-jvm/pgevent/runtime/pom.xml b/extensions/pgevent/runtime/pom.xml
similarity index 94%
rename from extensions-jvm/pgevent/runtime/pom.xml
rename to extensions/pgevent/runtime/pom.xml
index 18e3462..aa83c39 100644
--- a/extensions-jvm/pgevent/runtime/pom.xml
+++ b/extensions/pgevent/runtime/pom.xml
@@ -34,6 +34,7 @@
<properties>
<camel.quarkus.jvmSince>1.1.0</camel.quarkus.jvmSince>
+ <camel.quarkus.nativeSince>1.2.0</camel.quarkus.nativeSince>
</properties>
<dependencyManagement>
@@ -57,6 +58,10 @@
<groupId>org.apache.camel</groupId>
<artifactId>camel-pgevent</artifactId>
</dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-netty</artifactId>
+ </dependency>
</dependencies>
<build>
diff --git a/extensions-jvm/pgevent/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/pgevent/runtime/src/main/resources/META-INF/quarkus-extension.yaml
similarity index 100%
rename from extensions-jvm/pgevent/runtime/src/main/resources/META-INF/quarkus-extension.yaml
rename to extensions/pgevent/runtime/src/main/resources/META-INF/quarkus-extension.yaml
diff --git a/extensions/pom.xml b/extensions/pom.xml
index ea11b97..a061f30 100644
--- a/extensions/pom.xml
+++ b/extensions/pom.xml
@@ -159,6 +159,7 @@
<module>paho</module>
<module>pdf</module>
<module>pg-replication-slot</module>
+ <module>pgevent</module>
<module>platform-http</module>
<module>quartz</module>
<module>qute</module>
diff --git a/extensions-jvm/pgevent/integration-test/pom.xml b/integration-tests/pgevent/pom.xml
similarity index 57%
rename from extensions-jvm/pgevent/integration-test/pom.xml
rename to integration-tests/pgevent/pom.xml
index 8fa6872..e6565dc 100644
--- a/extensions-jvm/pgevent/integration-test/pom.xml
+++ b/integration-tests/pgevent/pom.xml
@@ -23,13 +23,12 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-build-parent-it</artifactId>
+ <artifactId>camel-quarkus-integration-tests</artifactId>
<version>1.2.0-SNAPSHOT</version>
- <relativePath>../../../poms/build-parent-it/pom.xml</relativePath>
</parent>
- <artifactId>camel-quarkus-pgevent-integration-test</artifactId>
- <name>Camel Quarkus :: PostgresSQL Event :: Integration Test</name>
+ <artifactId>camel-quarkus-integration-test-pgevent</artifactId>
+ <name>Camel Quarkus :: Integration Tests :: PostgresSQL Event</name>
<description>Integration tests for Camel Quarkus PostgresSQL Event extension</description>
<dependencyManagement>
@@ -53,6 +52,14 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-direct</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-bean</artifactId>
+ </dependency>
<!-- test dependencies -->
<dependency>
@@ -65,6 +72,11 @@
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-integration-testcontainers-support</artifactId>
+ <scope>test</scope>
+ </dependency>
<!-- The following dependencies guarantee that this module is built after them. You can update them by running `mvn process-resources -Pformat -N` from the source tree root directory -->
<dependency>
@@ -80,6 +92,32 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-bean-deployment</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-direct-deployment</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
</dependencies>
<build>
@@ -97,4 +135,34 @@
</plugin>
</plugins>
</build>
+
+ <profiles>
+ <profile>
+ <id>native</id>
+ <activation>
+ <property>
+ <name>native</name>
+ </property>
+ </activation>
+ <properties>
+ <quarkus.package.type>native</quarkus.package.type>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>integration-test</goal>
+ <goal>verify</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
</project>
diff --git a/extensions-jvm/pgevent/integration-test/src/test/java/org/apache/camel/quarkus/component/pgevent/it/PgeventTest.java b/integration-tests/pgevent/src/main/java/org/apache/camel/quarkus/component/pgevent/it/MyBean.java
similarity index 70%
copy from extensions-jvm/pgevent/integration-test/src/test/java/org/apache/camel/quarkus/component/pgevent/it/PgeventTest.java
copy to integration-tests/pgevent/src/main/java/org/apache/camel/quarkus/component/pgevent/it/MyBean.java
index 71c010b..bed46a6 100644
--- a/extensions-jvm/pgevent/integration-test/src/test/java/org/apache/camel/quarkus/component/pgevent/it/PgeventTest.java
+++ b/integration-tests/pgevent/src/main/java/org/apache/camel/quarkus/component/pgevent/it/MyBean.java
@@ -16,19 +16,11 @@
*/
package org.apache.camel.quarkus.component.pgevent.it;
-import io.quarkus.test.junit.QuarkusTest;
-import io.restassured.RestAssured;
-import org.junit.jupiter.api.Test;
+import io.quarkus.runtime.annotations.RegisterForReflection;
-@QuarkusTest
-class PgeventTest {
-
- @Test
- public void loadComponentPgevent() {
- /* A simple autogenerated test */
- RestAssured.get("/pgevent/load/component/pgevent")
- .then()
- .statusCode(200);
+@RegisterForReflection
+public class MyBean {
+ public static String getSubscribedEvent(String body) {
+ return body;
}
-
}
diff --git a/extensions-jvm/pgevent/integration-test/src/main/java/org/apache/camel/quarkus/component/pgevent/it/PgeventResource.java b/integration-tests/pgevent/src/main/java/org/apache/camel/quarkus/component/pgevent/it/PgeventResource.java
similarity index 59%
rename from extensions-jvm/pgevent/integration-test/src/main/java/org/apache/camel/quarkus/component/pgevent/it/PgeventResource.java
rename to integration-tests/pgevent/src/main/java/org/apache/camel/quarkus/component/pgevent/it/PgeventResource.java
index d61425a..2350a17 100644
--- a/extensions-jvm/pgevent/integration-test/src/main/java/org/apache/camel/quarkus/component/pgevent/it/PgeventResource.java
+++ b/integration-tests/pgevent/src/main/java/org/apache/camel/quarkus/component/pgevent/it/PgeventResource.java
@@ -20,11 +20,10 @@ import javax.enterprise.context.ApplicationScoped;
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 javax.ws.rs.PathParam;
import javax.ws.rs.core.Response;
-import org.apache.camel.CamelContext;
+import org.apache.camel.ProducerTemplate;
import org.jboss.logging.Logger;
@Path("/pgevent")
@@ -33,19 +32,25 @@ public class PgeventResource {
private static final Logger LOG = Logger.getLogger(PgeventResource.class);
- private static final String COMPONENT_PGEVENT = "pgevent";
@Inject
- CamelContext context;
+ ProducerTemplate producerTemplate;
- @Path("/load/component/pgevent")
@GET
- @Produces(MediaType.TEXT_PLAIN)
- public Response loadComponentPgevent() throws Exception {
- /* This is an autogenerated test */
- if (context.getComponent(COMPONENT_PGEVENT) != null) {
- return Response.ok().build();
- }
- LOG.warnf("Could not load [%s] from the Camel context", COMPONENT_PGEVENT);
- return Response.status(500, COMPONENT_PGEVENT + " could not be loaded from the Camel context").build();
+ @Path("{event}")
+ public Response publishEvent(@PathParam("event") String event) {
+ LOG.infof("publish event %s", event);
+ String response = producerTemplate.requestBody("direct:pgevent-pub", event, String.class);
+ LOG.infof("message received : %s", response);
+ return Response.accepted(response).build();
}
+
+ @GET
+ @Path("datasource/{event}")
+ public Response publishEventWithDatasource(@PathParam("event") String event) {
+ LOG.infof("publish event %s", event);
+ String response = producerTemplate.requestBody("direct:pgevent-datasource", event, String.class);
+ LOG.infof("message received : %s", response);
+ return Response.accepted(response).build();
+ }
+
}
diff --git a/integration-tests/pgevent/src/main/java/org/apache/camel/quarkus/component/pgevent/it/PgeventRoutes.java b/integration-tests/pgevent/src/main/java/org/apache/camel/quarkus/component/pgevent/it/PgeventRoutes.java
new file mode 100644
index 0000000..61fdc82
--- /dev/null
+++ b/integration-tests/pgevent/src/main/java/org/apache/camel/quarkus/component/pgevent/it/PgeventRoutes.java
@@ -0,0 +1,70 @@
+/*
+ * 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.pgevent.it;
+
+import javax.inject.Named;
+import javax.ws.rs.Produces;
+
+import com.impossibl.postgres.jdbc.PGDataSource;
+import org.apache.camel.builder.RouteBuilder;
+import org.eclipse.microprofile.config.inject.ConfigProperty;
+
+public class PgeventRoutes extends RouteBuilder {
+ @ConfigProperty(name = "database.host")
+ String host;
+ @ConfigProperty(name = "database.port")
+ Integer port;
+ @ConfigProperty(name = "database.name")
+ String databaseName;
+ @ConfigProperty(name = "database.user")
+ String user;
+ @ConfigProperty(name = "database.password")
+ String password;
+
+ @Override
+ public void configure() throws Exception {
+ // producer for simple pub-sub
+ from("direct:pgevent-pub")
+ .to("pgevent://{{database.host}}:{{database.port}}/{{database.name}}/testchannel?user={{database.user}}&pass={{database.password}}");
+
+ //consumer for simple pub-sub
+ from("pgevent://{{database.host}}:{{database.port}}/{{database.name}}/testchannel?user={{database.user}}&pass={{database.password}}")
+ .log("Message got ${body}")
+ .bean(MyBean.class);
+
+ // producer with datasource
+ from("direct:pgevent-datasource")
+ .to("pgevent:///postgres/testchannel?datasource=#pgDataSource");
+
+ // consumer with datasource
+ from("pgevent:///postgres/testchannel?datasource=#pgDataSource")
+ .log("Message got ${body}")
+ .bean(MyBean.class);
+ }
+
+ @Produces
+ @Named("pgDataSource")
+ public PGDataSource loadDataSource() throws Exception {
+ PGDataSource dataSource = new PGDataSource();
+ dataSource.setHost(host);
+ dataSource.setPort(port);
+ dataSource.setDatabaseName(databaseName);
+ dataSource.setUser(user);
+ dataSource.setPassword(password);
+ return dataSource;
+ }
+}
diff --git a/integration-tests/pgevent/src/main/resources/application.properties b/integration-tests/pgevent/src/main/resources/application.properties
new file mode 100644
index 0000000..727f522
--- /dev/null
+++ b/integration-tests/pgevent/src/main/resources/application.properties
@@ -0,0 +1,24 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+# Change the following properties to work with your PostgreSQL instance.
+# The default values work with the PostgreSQL docker image https://hub.docker.com/_/postgres/.
+# docker run -ti --rm -e POSTGRES_PASSWORD=mysecretpassword -p 5432:5432 postgres
+database.name=postgres
+database.user=postgres
+database.password=mysecretpassword
+database.host=localhost
+database.port=5432
\ No newline at end of file
diff --git a/integration-tests/pgevent/src/test/java/org/apache/camel/quarkus/component/pgevent/it/PgEventTestResource.java b/integration-tests/pgevent/src/test/java/org/apache/camel/quarkus/component/pgevent/it/PgEventTestResource.java
new file mode 100644
index 0000000..4d8bdb1
--- /dev/null
+++ b/integration-tests/pgevent/src/test/java/org/apache/camel/quarkus/component/pgevent/it/PgEventTestResource.java
@@ -0,0 +1,81 @@
+/*
+ * 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.pgevent.it;
+
+import java.util.Map;
+
+import org.apache.camel.quarkus.testcontainers.ContainerResourceLifecycleManager;
+import org.apache.camel.util.CollectionHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testcontainers.containers.GenericContainer;
+import org.testcontainers.containers.output.Slf4jLogConsumer;
+import org.testcontainers.containers.wait.strategy.Wait;
+
+public class PgEventTestResource implements ContainerResourceLifecycleManager {
+
+ protected static final String CONTAINER_NAME = "pg-event";
+ protected static final String POSTGRES_USER = "postgres";
+ protected static final String POSTGRES_PASSWORD = "mysecretpassword";
+ protected static final String POSTGRES_DB = "postgres";
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(PgEventTestResource.class);
+ private static final int POSTGRES_PORT = 5432;
+ private static final String POSTGRES_IMAGE = "postgres:13.0";
+
+ private GenericContainer container;
+
+ @Override
+ public Map<String, String> start() {
+ container = createContainer();
+ container.start();
+ return CollectionHelper.mapOf(
+ "database.port",
+ container.getMappedPort(POSTGRES_PORT).toString(),
+ "database.host",
+ container.getHost());
+ }
+
+ @Override
+ public void stop() {
+ if (container != null) {
+ container.stop();
+ }
+ }
+
+ private GenericContainer createContainer() {
+ GenericContainer container = new GenericContainer(POSTGRES_IMAGE)
+ .withCommand("postgres -c wal_level=logical")
+ .withExposedPorts(POSTGRES_PORT)
+ .withNetworkAliases(CONTAINER_NAME)
+ .withEnv("POSTGRES_USER", POSTGRES_USER)
+ .withEnv("POSTGRES_PASSWORD", POSTGRES_PASSWORD)
+ .withEnv("POSTGRES_DB", POSTGRES_DB)
+ .withLogConsumer(new Slf4jLogConsumer(LOGGER))
+ .waitingFor(Wait.forListeningPort());
+ return container;
+ }
+
+ public Integer getMappedPort() {
+ return container.getMappedPort(POSTGRES_PORT);
+ }
+
+ public String getHost() {
+ return container.getHost();
+ }
+
+}
diff --git a/extensions-jvm/pgevent/integration-test/src/test/java/org/apache/camel/quarkus/component/pgevent/it/PgeventTest.java b/integration-tests/pgevent/src/test/java/org/apache/camel/quarkus/component/pgevent/it/PgeventIT.java
similarity index 70%
copy from extensions-jvm/pgevent/integration-test/src/test/java/org/apache/camel/quarkus/component/pgevent/it/PgeventTest.java
copy to integration-tests/pgevent/src/test/java/org/apache/camel/quarkus/component/pgevent/it/PgeventIT.java
index 71c010b..9a43bbf 100644
--- a/extensions-jvm/pgevent/integration-test/src/test/java/org/apache/camel/quarkus/component/pgevent/it/PgeventTest.java
+++ b/integration-tests/pgevent/src/test/java/org/apache/camel/quarkus/component/pgevent/it/PgeventIT.java
@@ -16,19 +16,9 @@
*/
package org.apache.camel.quarkus.component.pgevent.it;
-import io.quarkus.test.junit.QuarkusTest;
-import io.restassured.RestAssured;
-import org.junit.jupiter.api.Test;
+import io.quarkus.test.junit.NativeImageTest;
-@QuarkusTest
-class PgeventTest {
-
- @Test
- public void loadComponentPgevent() {
- /* A simple autogenerated test */
- RestAssured.get("/pgevent/load/component/pgevent")
- .then()
- .statusCode(200);
- }
+@NativeImageTest
+class PgeventIT extends PgeventTest {
}
diff --git a/extensions-jvm/pgevent/integration-test/src/test/java/org/apache/camel/quarkus/component/pgevent/it/PgeventTest.java b/integration-tests/pgevent/src/test/java/org/apache/camel/quarkus/component/pgevent/it/PgeventTest.java
similarity index 59%
rename from extensions-jvm/pgevent/integration-test/src/test/java/org/apache/camel/quarkus/component/pgevent/it/PgeventTest.java
rename to integration-tests/pgevent/src/test/java/org/apache/camel/quarkus/component/pgevent/it/PgeventTest.java
index 71c010b..cd4acea 100644
--- a/extensions-jvm/pgevent/integration-test/src/test/java/org/apache/camel/quarkus/component/pgevent/it/PgeventTest.java
+++ b/integration-tests/pgevent/src/test/java/org/apache/camel/quarkus/component/pgevent/it/PgeventTest.java
@@ -16,19 +16,34 @@
*/
package org.apache.camel.quarkus.component.pgevent.it;
+import io.quarkus.test.common.QuarkusTestResource;
+import io.quarkus.test.common.http.TestHTTPEndpoint;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import org.junit.jupiter.api.Test;
+import static org.hamcrest.Matchers.equalTo;
+
@QuarkusTest
+@QuarkusTestResource(PgEventTestResource.class)
+@TestHTTPEndpoint(PgeventResource.class)
class PgeventTest {
@Test
- public void loadComponentPgevent() {
- /* A simple autogenerated test */
- RestAssured.get("/pgevent/load/component/pgevent")
+ public void testPublish() {
+ RestAssured.given()
+ .get("/Test Camel PGEvent")
.then()
- .statusCode(200);
+ .statusCode(202)
+ .body(equalTo("Test Camel PGEvent"));
}
+ @Test
+ public void testPublishWithDatasource() {
+ RestAssured.given()
+ .get("/datasource/Test Camel PGEvent with datasource")
+ .then()
+ .statusCode(202)
+ .body(equalTo("Test Camel PGEvent with datasource"));
+ }
}
diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml
index f4352fb..a51902f 100644
--- a/integration-tests/pom.xml
+++ b/integration-tests/pom.xml
@@ -132,6 +132,7 @@
<module>opentracing</module>
<module>pdf</module>
<module>pg-replication-slot</module>
+ <module>pgevent</module>
<module>platform-http</module>
<module>platform-http-engine</module>
<module>quartz</module>
diff --git a/tooling/scripts/test-categories.yaml b/tooling/scripts/test-categories.yaml
index 4ea4150..774f1e3 100644
--- a/tooling/scripts/test-categories.yaml
+++ b/tooling/scripts/test-categories.yaml
@@ -42,6 +42,7 @@ core-main-validation:
- json-validator
- validator
database:
+ - arangodb
- couchdb
- debezium
- influxdb
@@ -49,9 +50,9 @@ database:
- jpa
- kudu
- mongodb
+ - pgevent
- pg-replication-slot
- sql
- - arangodb
dataformats:
- avro
- base64