You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by zh...@apache.org on 2023/04/14 05:29:38 UTC

[camel-quarkus] branch 2.13.x updated (b89bcca36a -> ac03cf63df)

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

zhfeng pushed a change to branch 2.13.x
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git


    from b89bcca36a Fixup Test also GITHUB_BASE_REF to checkout the right examples branch (#4775)
     new bd5b43664b Ref#4596 Cover different db types for jdbc
     new ac03cf63df Cxf fixes (#4771)

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../cxf/soap/server/it/CxfSoapRoutes.java          |  32 ++----
 .../cxf/soap/it/ws/trust/CxfWsTrustTest.java       |  23 ++--
 integration-tests/jdbc/README.adoc                 |  26 +++++
 integration-tests/jdbc/pom.xml                     |  16 +--
 .../quarkus/component/jdbc/CamelResource.java      | 116 ++++++++++++++++-----
 .../camel/quarkus/component/jdbc/JdbcRoutes.java   |  28 +++--
 .../jdbc/src/main/resources/application.properties |   7 +-
 .../src/main/resources/sql/db2.sql}                |   8 +-
 .../src/main/resources/sql/derby.sql}              |   8 +-
 .../src/main/resources/sql/droptables.sql}         |   7 +-
 .../src/main/resources/sql/h2.sql}                 |   8 +-
 .../src/main/resources/sql/inserts.sql}            |  10 +-
 .../src/main/resources/sql/mariadb.sql}            |   8 +-
 .../src/main/resources/sql/mssql.sql}              |   7 +-
 .../src/main/resources/sql/mysql.sql}              |   8 +-
 .../src/main/resources/sql/oracle.sql}             |  15 +--
 .../src/main/resources/sql/postgresql.sql}         |   8 +-
 .../quarkus/component/jdbc/CamelJdbcTest.java      |  73 ++++++-------
 18 files changed, 240 insertions(+), 168 deletions(-)
 create mode 100644 integration-tests/jdbc/README.adoc
 copy integration-tests/{debezium/src/test/resources/initMysql.sql => jdbc/src/main/resources/sql/db2.sql} (68%)
 copy integration-tests/{debezium/src/test/resources/initMysql.sql => jdbc/src/main/resources/sql/derby.sql} (72%)
 copy integration-tests/{sql/src/main/resources/sql/common/selectProjectsAsBoolean.sql => jdbc/src/main/resources/sql/droptables.sql} (91%)
 copy integration-tests/{debezium/src/test/resources/initMysql.sql => jdbc/src/main/resources/sql/h2.sql} (76%)
 copy integration-tests/{debezium/src/test/resources/initMysql.sql => jdbc/src/main/resources/sql/inserts.sql} (72%)
 copy integration-tests/{debezium/src/test/resources/initMysql.sql => jdbc/src/main/resources/sql/mariadb.sql} (76%)
 copy integration-tests/{sql/src/main/resources/sql/common/selectProjectsAsBoolean.sql => jdbc/src/main/resources/sql/mssql.sql} (76%)
 copy integration-tests/{debezium/src/test/resources/initMysql.sql => jdbc/src/main/resources/sql/mysql.sql} (76%)
 copy integration-tests/{mybatis/src/main/resources/insert.sql => jdbc/src/main/resources/sql/oracle.sql} (68%)
 copy integration-tests/{debezium/src/test/resources/initMysql.sql => jdbc/src/main/resources/sql/postgresql.sql} (76%)


[camel-quarkus] 01/02: Ref#4596 Cover different db types for jdbc

Posted by zh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit bd5b43664bd6288b0fd27f4f1fc2439cfd4826a0
Author: Lucia Drozdova <ld...@redhat.com>
AuthorDate: Thu Apr 6 14:57:04 2023 +0200

    Ref#4596 Cover different db types for jdbc
---
 integration-tests/jdbc/README.adoc                 |  26 +++++
 integration-tests/jdbc/pom.xml                     |  16 +--
 .../quarkus/component/jdbc/CamelResource.java      | 116 ++++++++++++++++-----
 .../camel/quarkus/component/jdbc/JdbcRoutes.java   |  28 +++--
 .../jdbc/src/main/resources/application.properties |   7 +-
 .../jdbc/src/main/resources/sql/db2.sql            |  20 ++++
 .../jdbc/src/main/resources/sql/derby.sql          |  20 ++++
 .../jdbc/src/main/resources/sql/droptables.sql     |  20 ++++
 .../jdbc/src/main/resources/sql/h2.sql             |  20 ++++
 .../jdbc/src/main/resources/sql/inserts.sql        |  22 ++++
 .../jdbc/src/main/resources/sql/mariadb.sql        |  20 ++++
 .../jdbc/src/main/resources/sql/mssql.sql          |  20 ++++
 .../jdbc/src/main/resources/sql/mysql.sql          |  20 ++++
 .../jdbc/src/main/resources/sql/oracle.sql         |  20 ++++
 .../jdbc/src/main/resources/sql/postgresql.sql     |  20 ++++
 .../quarkus/component/jdbc/CamelJdbcTest.java      |  73 ++++++-------
 16 files changed, 387 insertions(+), 81 deletions(-)

diff --git a/integration-tests/jdbc/README.adoc b/integration-tests/jdbc/README.adoc
new file mode 100644
index 0000000000..76b30862b5
--- /dev/null
+++ b/integration-tests/jdbc/README.adoc
@@ -0,0 +1,26 @@
+== JDBC integration tests
+
+=== Default database type
+
+When the tests are executed without any special configuration, dev-service `H2` database is used (more details will follow).
+
+=== Dev-service databases
+
+As is described  in the https://quarkus.io/guides/datasource#dev-services[documentation], several database types could be started in dev-service mode.
+Running the tests against a database in dev-service mode could be achieved by addition of build property `cq.jdbcKind`. Example of usage:
+
+`mvn clean test -f integration-tests/jdbc/ -Dcq.jdbcKind=postgresql`
+
+Following databases could be started in the dev-service mode:
+
+- Postgresql (container) - add `-Dcq.jdbcKind=postgresql`
+- MySQL (container) - add `-Dcq.jdbcKind=mysql`
+- MariaDB (container) - add `-Dcq.jdbcKind=mariadb`
+- H2 (in-process) used by default
+- Apache Derby (in-process) - add `-Dcq.jdbcKind=derby`
+- DB2 (container) (requires license acceptance) - add `-Dcq.jdbcKind=db2`
+- MSSQL (container) (requires license acceptance) - add `-Dcq.jdbcKind=mssql`
+- Oracle (container) - add `-Dcq.jdbcKind=oracle`
+
+For more information about dev-service mode, see https://quarkus.io/guides/datasource#dev-services[documentation].
+
diff --git a/integration-tests/jdbc/pom.xml b/integration-tests/jdbc/pom.xml
index c9fc80fb88..25569965b3 100644
--- a/integration-tests/jdbc/pom.xml
+++ b/integration-tests/jdbc/pom.xml
@@ -31,6 +31,10 @@
     <name>Camel Quarkus :: Integration Tests :: JDBC</name>
     <description>Integration tests for Camel JDBC extension</description>
 
+    <properties>
+        <cq.jdbcKind>h2</cq.jdbcKind>
+    </properties>
+
     <dependencies>
         <dependency>
             <groupId>org.apache.camel.quarkus</groupId>
@@ -54,7 +58,7 @@
         </dependency>
         <dependency>
             <groupId>io.quarkus</groupId>
-            <artifactId>quarkus-jdbc-h2</artifactId>
+            <artifactId>quarkus-jdbc-${cq.jdbcKind}</artifactId>
         </dependency>
         <dependency>
             <groupId>org.apache.camel.quarkus</groupId>
@@ -75,11 +79,6 @@
             <artifactId>quarkus-junit5</artifactId>
             <scope>test</scope>
         </dependency>
-        <dependency>
-            <groupId>io.quarkus</groupId>
-            <artifactId>quarkus-test-h2</artifactId>
-            <scope>test</scope>
-        </dependency>
         <dependency>
             <groupId>io.rest-assured</groupId>
             <artifactId>rest-assured</artifactId>
@@ -117,6 +116,11 @@
                                 </goals>
                             </execution>
                         </executions>
+                        <configuration>
+                            <systemPropertyVariables>
+                                <quarkus.test.arg-line>-Dcq.jdbcKind=${cq.jdbcKind}</quarkus.test.arg-line>
+                            </systemPropertyVariables>
+                        </configuration>
                     </plugin>
                 </plugins>
             </build>
diff --git a/integration-tests/jdbc/src/main/java/org/apache/camel/quarkus/component/jdbc/CamelResource.java b/integration-tests/jdbc/src/main/java/org/apache/camel/quarkus/component/jdbc/CamelResource.java
index 6bdc09f67f..5cace5f098 100644
--- a/integration-tests/jdbc/src/main/java/org/apache/camel/quarkus/component/jdbc/CamelResource.java
+++ b/integration-tests/jdbc/src/main/java/org/apache/camel/quarkus/component/jdbc/CamelResource.java
@@ -16,7 +16,12 @@
  */
 package org.apache.camel.quarkus.component.jdbc;
 
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
 import java.sql.Connection;
+import java.sql.SQLException;
 import java.sql.Statement;
 import java.util.ArrayList;
 import java.util.LinkedHashMap;
@@ -40,12 +45,16 @@ import org.apache.camel.CamelContext;
 import org.apache.camel.ProducerTemplate;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.quarkus.component.jdbc.model.Camel;
+import org.eclipse.microprofile.config.inject.ConfigProperty;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 @Path("/test")
 @ApplicationScoped
 public class CamelResource {
+    private static final Logger LOGGER = LoggerFactory.getLogger(CamelResource.class);
     @Inject
-    @DataSource("camel-ds")
+    @DataSource("cameldb")
     AgroalDataSource dataSource;
 
     @Inject
@@ -54,33 +63,24 @@ public class CamelResource {
     @Inject
     CamelContext context;
 
+    @ConfigProperty(name = "quarkus.datasource.cameldb.db-kind")
+    String dbKind;
+
     @PostConstruct
     void postConstruct() throws Exception {
-        try (Connection con = dataSource.getConnection()) {
-            try (Statement statement = con.createStatement()) {
-                try {
-                    statement.execute("drop table camels");
-                    statement.execute("drop table camelsGenerated");
-                } catch (Exception ignored) {
-                }
-                statement.execute("create table camels (id int primary key, species varchar(255))");
-                statement.execute("create table camelsGenerated (id int primary key auto_increment, species varchar(255))");
-                statement.execute("create table camelsProcessed (id int primary key auto_increment, species varchar(255))");
-                statement.execute("insert into camelsGenerated (species) values ('Camelus status'), ('Camelus linus')");
-                statement.execute("insert into camels (id, species) values (1, 'Camelus dromedarius')");
-                statement.execute("insert into camels (id, species) values (2, 'Camelus bactrianus')");
-                statement.execute("insert into camels (id, species) values (3, 'Camelus ferus')");
-
-                context.getRouteController().startRoute("jdbc-poll");
-            }
-        }
+        Connection conn = dataSource.getConnection();
+        runScripts(conn, "droptables.sql");
+        runScripts(conn, dbKind + ".sql");
+        runScripts(conn, "inserts.sql");
+
+        context.getRouteController().startRoute("jdbc-poll");
     }
 
     @Path("/species/{id}")
     @GET
     @Produces(MediaType.TEXT_PLAIN)
     public String getSpeciesById(@PathParam("id") String id) throws Exception {
-        return template.requestBody("jdbc:camel-ds", "select species from camels where id = " + id, String.class);
+        return template.requestBody("jdbc:cameldb", "select species from camels where id = " + id, String.class);
     }
 
     @SuppressWarnings("unchecked")
@@ -89,14 +89,14 @@ public class CamelResource {
     @Produces(MediaType.TEXT_PLAIN)
     public String getSpeciesByIdWithSelectList(@PathParam("id") String id) throws Exception {
         List<LinkedHashMap<String, Object>> result = template
-                .requestBody("jdbc:camel-ds?outputType=SelectList", "select * from camels where id = " + id, List.class);
+                .requestBody("jdbc:cameldb?outputType=SelectList", "select * from camels where id = " + id, List.class);
 
         if (result.isEmpty()) {
             throw new IllegalStateException("Expected at least 1 camel result but none were found");
         }
 
         LinkedHashMap<String, Object> data = result.get(0);
-        return data.get("SPECIES") + " " + data.get("ID");
+        return data.get(getSpeciesRowName()) + " " + data.get(getIdRowName());
     }
 
     @SuppressWarnings("unchecked")
@@ -104,7 +104,7 @@ public class CamelResource {
     @GET
     @Produces(MediaType.TEXT_PLAIN)
     public String getSpeciesByIdWithDefinedType(@PathParam("id") String id) throws Exception {
-        List<Camel> results = template.requestBody("jdbc:camel-ds?outputClass=" + Camel.class.getName(),
+        List<Camel> results = template.requestBody("jdbc:cameldb?outputClass=" + Camel.class.getName(),
                 "select * from camels where id = " + id, List.class);
 
         if (results.isEmpty()) {
@@ -120,7 +120,7 @@ public class CamelResource {
     @Consumes(MediaType.TEXT_PLAIN)
     @Produces(MediaType.TEXT_PLAIN)
     public String executeStatement(String statement) throws Exception {
-        return template.requestBody("jdbc:camel-ds", statement, String.class);
+        return template.requestBody("jdbc:cameldb", statement, String.class);
     }
 
     @Path("/generated-keys/rows")
@@ -128,7 +128,7 @@ public class CamelResource {
     @Produces(MediaType.APPLICATION_JSON)
     public List generatedKeysRows() throws Exception {
         return template.requestBodyAndHeader("direct://get-generated-keys",
-                "insert into camelsGenerated (species) values ('Camelus testus'), ('Camelus legendarius')",
+                "insert into camelsGenerated (species) values ('Camelus testus')",
                 "CamelRetrieveGeneratedKeys", "true", ArrayList.class);
     }
 
@@ -137,7 +137,7 @@ public class CamelResource {
     @Produces(MediaType.APPLICATION_JSON)
     public String headersFromInsertOrUpdate() throws Exception {
         return template.requestBodyAndHeader("direct://get-headers",
-                "insert into camelsGenerated (species) values ('Camelus status'), ('Camelus linus')",
+                "insert into camelsGenerated (species) values ('Camelus testus')",
                 "CamelRetrieveGeneratedKeys", "true", String.class);
     }
 
@@ -152,16 +152,17 @@ public class CamelResource {
     @GET
     @Produces(MediaType.APPLICATION_JSON)
     public String headersAsParameters() throws Exception {
+        int id = 3;
         return template.requestBodyAndHeader("direct://headers-as-parameters",
                 "select * from camels where id < :?idmax order by id",
-                "idmax", "3", String.class);
+                "idmax", id, String.class);
     }
 
     @Path("/named-parameters/headers-as-parameters-map")
     @GET
     @Produces(MediaType.APPLICATION_JSON)
     public String headersAsParametersMap() throws Exception {
-        Map<String, String> headersMap = Map.of("idmax", "3", "specs", "Camelus bactrianus");
+        Map<String, Object> headersMap = Map.of("idmax", 3, "specs", "Camelus bactrianus");
         return template.requestBodyAndHeader("direct://headers-as-parameters",
                 "select * from camels where id < :?idmax and species = :?specs order by id",
                 "CamelJdbcParameters", headersMap, String.class);
@@ -184,4 +185,63 @@ public class CamelResource {
         return template.requestBody("direct://move-between-datasources", null, String.class);
     }
 
+    private void runScripts(Connection conn, String fileName) throws SQLException, IOException {
+        try (Statement statement = conn.createStatement()) {
+            try (InputStream is = Thread.currentThread().getContextClassLoader()
+                    .getResourceAsStream("sql/" + fileName);
+                    InputStreamReader isr = new InputStreamReader(is);
+                    BufferedReader reader = new BufferedReader(isr)) {
+
+                //execute each line from the sql script as separate statement
+                reader.lines().filter(s -> s != null && !"".equals(s) && !s.startsWith("--")).forEach(s -> {
+                    try {
+                        statement.execute(s);
+                    } catch (SQLException e) {
+                        if (!s.toUpperCase().startsWith("DROP")) {
+                            throw new RuntimeException(e);
+                        } else {
+                            LOGGER.debug(String.format("Command '%s' failed.", s)); //use debug logging
+                        }
+                    }
+                });
+            }
+        }
+
+    }
+
+    @Path("/get-id-key")
+    @GET
+    @Produces(MediaType.TEXT_PLAIN)
+    public String getIdKey() {
+        switch (dbKind) {
+        case "postgresql":
+            return "id";
+        case "oracle":
+            return "ROWID";
+        case "mssql":
+            return "GENERATED_KEYS";
+        case "mariadb":
+            return "insert_id";
+        case "mysql":
+            return "GENERATED_KEY";
+        default:
+            return "ID";
+        }
+    }
+
+    private String getIdRowName() {
+        if (dbKind.equals("h2") || dbKind.equals("oracle") || dbKind.equals("db2")) {
+            return "ID";
+        } else {
+            return "id";
+        }
+    }
+
+    private String getSpeciesRowName() {
+        if (dbKind.equals("h2") || dbKind.equals("oracle") || dbKind.equals("db2")) {
+            return "SPECIES";
+        } else {
+            return "species";
+        }
+    }
 }
diff --git a/integration-tests/jdbc/src/main/java/org/apache/camel/quarkus/component/jdbc/JdbcRoutes.java b/integration-tests/jdbc/src/main/java/org/apache/camel/quarkus/component/jdbc/JdbcRoutes.java
index ad47740886..6d43eafbaa 100644
--- a/integration-tests/jdbc/src/main/java/org/apache/camel/quarkus/component/jdbc/JdbcRoutes.java
+++ b/integration-tests/jdbc/src/main/java/org/apache/camel/quarkus/component/jdbc/JdbcRoutes.java
@@ -21,26 +21,29 @@ import javax.enterprise.context.ApplicationScoped;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
-import org.jboss.logging.Logger;
+import org.eclipse.microprofile.config.inject.ConfigProperty;
 
 @ApplicationScoped
 public class JdbcRoutes extends RouteBuilder {
-    private static final Logger LOG = Logger.getLogger(JdbcRoutes.class);
+
+    @ConfigProperty(name = "quarkus.datasource.cameldb.db-kind")
+    String dbKind;
 
     @Override
     public void configure() {
         from("direct://get-generated-keys")
-                .to("jdbc:camel-ds")
+                .to("jdbc:cameldb")
                 .process(new Processor() {
                     @Override
                     public void process(Exchange exchange) throws Exception {
+                        System.out.println(exchange.getIn().getHeaders());
                         Object in = exchange.getIn().getHeader("CamelGeneratedKeysRows");
                         exchange.getIn().setBody(in);
                     }
                 });
 
         from("direct://get-headers")
-                .to("jdbc:camel-ds")
+                .to("jdbc:cameldb")
                 .process(new Processor() {
                     @Override
                     public void process(Exchange exchange) throws Exception {
@@ -50,18 +53,25 @@ public class JdbcRoutes extends RouteBuilder {
                 });
 
         from("direct://headers-as-parameters")
-                .to("jdbc:camel-ds?useHeadersAsParameters=true");
+                .to("jdbc:cameldb?useHeadersAsParameters=true");
 
         from("timer://interval-polling?delay=2000&repeatCount=1").routeId("jdbc-poll").autoStartup(false)
                 .setBody(constant("select * from camelsGenerated order by id desc"))
-                .to("jdbc:camel-ds")
+                .to("jdbc:cameldb")
                 .to("mock:interval-polling");
 
+        String species;
+        if (dbKind.equals("postgresql") || dbKind.equals("mysql") || dbKind.equals("mariadb") || dbKind.equals("mssql")) {
+            species = "species";
+        } else {
+            species = "SPECIES";
+        }
+
         from("direct://move-between-datasources")
                 .setBody(constant("select * from camels"))
-                .to("jdbc:camel-ds")
+                .to("jdbc:cameldb")
                 .split(body())
-                .setBody(simple("insert into camelsProcessed values('${body[ID]}','${body[SPECIES]}')"))
-                .to("jdbc:camel-ds");
+                .setBody(simple("insert into camelsProcessed (species) values('${body[" + species + "]}')"))
+                .to("jdbc:cameldb");
     }
 }
diff --git a/integration-tests/jdbc/src/main/resources/application.properties b/integration-tests/jdbc/src/main/resources/application.properties
index 778b1490c7..3fae84e7b2 100644
--- a/integration-tests/jdbc/src/main/resources/application.properties
+++ b/integration-tests/jdbc/src/main/resources/application.properties
@@ -18,6 +18,7 @@
 #
 # Quarkus :: DS
 #
-quarkus.datasource.camel-ds.jdbc.url=jdbc:h2:tcp://localhost/mem:test
-quarkus.datasource.camel-ds.db-kind=h2
-quarkus.datasource.camel-ds.jdbc.max-size=8
+quarkus.datasource.cameldb.db-kind=${cq.jdbcKind:h2}
+quarkus.datasource.cameldb.jdbc.max-size=8
+
+quarkus.native.resources.includes=sql/${cq.jdbcKind:h2}.sql,sql/inserts.sql,sql/droptables.sql
\ No newline at end of file
diff --git a/integration-tests/jdbc/src/main/resources/sql/db2.sql b/integration-tests/jdbc/src/main/resources/sql/db2.sql
new file mode 100644
index 0000000000..48e78bc85f
--- /dev/null
+++ b/integration-tests/jdbc/src/main/resources/sql/db2.sql
@@ -0,0 +1,20 @@
+--
+-- 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.
+--
+
+CREATE TABLE camels (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, species VARCHAR(50) NOT NULL,PRIMARY KEY (id))
+CREATE TABLE camelsGenerated (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, species VARCHAR(50) NOT NULL,PRIMARY KEY (id))
+CREATE TABLE camelsProcessed (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, species VARCHAR(50) NOT NULL,PRIMARY KEY (id))
\ No newline at end of file
diff --git a/integration-tests/jdbc/src/main/resources/sql/derby.sql b/integration-tests/jdbc/src/main/resources/sql/derby.sql
new file mode 100644
index 0000000000..1f5485efe6
--- /dev/null
+++ b/integration-tests/jdbc/src/main/resources/sql/derby.sql
@@ -0,0 +1,20 @@
+--
+-- 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.
+--
+
+CREATE TABLE camels (id INT NOT NULL GENERATED ALWAYS AS IDENTITY,species VARCHAR(50) NOT NULL)
+CREATE TABLE camelsGenerated (id INT NOT NULL GENERATED ALWAYS AS IDENTITY,species VARCHAR(50) NOT NULL)
+CREATE TABLE camelsProcessed (id INT NOT NULL GENERATED ALWAYS AS IDENTITY,species VARCHAR(50) NOT NULL)
\ No newline at end of file
diff --git a/integration-tests/jdbc/src/main/resources/sql/droptables.sql b/integration-tests/jdbc/src/main/resources/sql/droptables.sql
new file mode 100644
index 0000000000..7a77034cc8
--- /dev/null
+++ b/integration-tests/jdbc/src/main/resources/sql/droptables.sql
@@ -0,0 +1,20 @@
+--
+-- 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.
+--
+
+drop table camels
+drop table camelsGenerated
+drop table camelsProcessed
\ No newline at end of file
diff --git a/integration-tests/jdbc/src/main/resources/sql/h2.sql b/integration-tests/jdbc/src/main/resources/sql/h2.sql
new file mode 100644
index 0000000000..e54ab07edd
--- /dev/null
+++ b/integration-tests/jdbc/src/main/resources/sql/h2.sql
@@ -0,0 +1,20 @@
+--
+-- 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.
+--
+
+create table camels (id int auto_increment primary key, species varchar(50))
+create table camelsGenerated (id int auto_increment primary key, species varchar(50))
+create table camelsProcessed (id int auto_increment primary key , species varchar(50))
\ No newline at end of file
diff --git a/integration-tests/jdbc/src/main/resources/sql/inserts.sql b/integration-tests/jdbc/src/main/resources/sql/inserts.sql
new file mode 100644
index 0000000000..fce3a151ca
--- /dev/null
+++ b/integration-tests/jdbc/src/main/resources/sql/inserts.sql
@@ -0,0 +1,22 @@
+--
+-- 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.
+--
+
+insert into camelsGenerated (species) values ('Camelus status')
+insert into camelsGenerated (species) values ('Camelus linus')
+insert into camels (species) values ('Camelus dromedarius')
+insert into camels (species) values ('Camelus bactrianus')
+insert into camels (species) values ('Camelus ferus')
\ No newline at end of file
diff --git a/integration-tests/jdbc/src/main/resources/sql/mariadb.sql b/integration-tests/jdbc/src/main/resources/sql/mariadb.sql
new file mode 100644
index 0000000000..e54ab07edd
--- /dev/null
+++ b/integration-tests/jdbc/src/main/resources/sql/mariadb.sql
@@ -0,0 +1,20 @@
+--
+-- 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.
+--
+
+create table camels (id int auto_increment primary key, species varchar(50))
+create table camelsGenerated (id int auto_increment primary key, species varchar(50))
+create table camelsProcessed (id int auto_increment primary key , species varchar(50))
\ No newline at end of file
diff --git a/integration-tests/jdbc/src/main/resources/sql/mssql.sql b/integration-tests/jdbc/src/main/resources/sql/mssql.sql
new file mode 100644
index 0000000000..c603f48434
--- /dev/null
+++ b/integration-tests/jdbc/src/main/resources/sql/mssql.sql
@@ -0,0 +1,20 @@
+--
+-- 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.
+--
+
+create table camels (id int  IDENTITY(1,1) PRIMARY KEY, species varchar(255))
+create table camelsGenerated (id int  IDENTITY(1,1) PRIMARY KEY, species varchar(255))
+create table camelsProcessed (id int  IDENTITY(1,1) PRIMARY KEY, species varchar(255))
\ No newline at end of file
diff --git a/integration-tests/jdbc/src/main/resources/sql/mysql.sql b/integration-tests/jdbc/src/main/resources/sql/mysql.sql
new file mode 100644
index 0000000000..e54ab07edd
--- /dev/null
+++ b/integration-tests/jdbc/src/main/resources/sql/mysql.sql
@@ -0,0 +1,20 @@
+--
+-- 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.
+--
+
+create table camels (id int auto_increment primary key, species varchar(50))
+create table camelsGenerated (id int auto_increment primary key, species varchar(50))
+create table camelsProcessed (id int auto_increment primary key , species varchar(50))
\ No newline at end of file
diff --git a/integration-tests/jdbc/src/main/resources/sql/oracle.sql b/integration-tests/jdbc/src/main/resources/sql/oracle.sql
new file mode 100644
index 0000000000..a127ab480b
--- /dev/null
+++ b/integration-tests/jdbc/src/main/resources/sql/oracle.sql
@@ -0,0 +1,20 @@
+--
+-- 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.
+--
+
+CREATE TABLE camels(id NUMBER GENERATED by default on null as IDENTITY, species VARCHAR2(50) NOT NULL, PRIMARY KEY(id))
+CREATE TABLE camelsGenerated(id NUMBER GENERATED by default on null as IDENTITY, species VARCHAR2(50) NOT NULL, PRIMARY KEY(id))
+CREATE TABLE camelsProcessed(id NUMBER GENERATED by default on null as IDENTITY, species VARCHAR2(50) NOT NULL, PRIMARY KEY(id))
diff --git a/integration-tests/jdbc/src/main/resources/sql/postgresql.sql b/integration-tests/jdbc/src/main/resources/sql/postgresql.sql
new file mode 100644
index 0000000000..b31dc12ef6
--- /dev/null
+++ b/integration-tests/jdbc/src/main/resources/sql/postgresql.sql
@@ -0,0 +1,20 @@
+--
+-- 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.
+--
+
+CREATE TABLE camels (id serial PRIMARY KEY, species VARCHAR ( 50 ) NOT NULL)
+CREATE TABLE camelsGenerated (id serial PRIMARY KEY, species VARCHAR ( 50 ) NOT NULL)
+CREATE TABLE camelsProcessed (id serial PRIMARY KEY, species VARCHAR ( 50 ) NOT NULL)
\ No newline at end of file
diff --git a/integration-tests/jdbc/src/test/java/org/apache/camel/quarkus/component/jdbc/CamelJdbcTest.java b/integration-tests/jdbc/src/test/java/org/apache/camel/quarkus/component/jdbc/CamelJdbcTest.java
index 9fe7dad4af..9c8dce2d81 100644
--- a/integration-tests/jdbc/src/test/java/org/apache/camel/quarkus/component/jdbc/CamelJdbcTest.java
+++ b/integration-tests/jdbc/src/test/java/org/apache/camel/quarkus/component/jdbc/CamelJdbcTest.java
@@ -18,28 +18,29 @@ package org.apache.camel.quarkus.component.jdbc;
 
 import java.util.List;
 
-import io.quarkus.test.common.QuarkusTestResource;
-import io.quarkus.test.h2.H2DatabaseTestResource;
 import io.quarkus.test.junit.QuarkusTest;
 import io.restassured.RestAssured;
 import io.restassured.http.ContentType;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.DisabledIfSystemProperty;
 
-import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.containsStringIgnoringCase;
 import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.equalToIgnoringCase;
 import static org.hamcrest.Matchers.is;
 import static org.hamcrest.Matchers.not;
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 @QuarkusTest
-@QuarkusTestResource(H2DatabaseTestResource.class)
+@DisabledIfSystemProperty(named = "cq.jdbcKind", matches = "derby")
+//https://github.com/quarkusio/quarkus/issues/23083
 public class CamelJdbcTest {
-
     @Test
     void testGetSpeciesById() {
-        RestAssured.when().get("/test/species/1").then().body(is("[{SPECIES=Camelus dromedarius}]"));
-        RestAssured.when().get("/test/species/2").then().body(is("[{SPECIES=Camelus bactrianus}]"));
-        RestAssured.when().get("/test/species/3").then().body(is("[{SPECIES=Camelus ferus}]"));
+        RestAssured.when().get("/test/species/1").then().body(equalToIgnoringCase("[{SPECIES=Camelus dromedarius}]"));
+        RestAssured.when().get("/test/species/2").then().body(equalToIgnoringCase("[{SPECIES=Camelus bactrianus}]"));
+        RestAssured.when().get("/test/species/3").then().body(equalToIgnoringCase("[{SPECIES=Camelus ferus}]"));
     }
 
     @Test
@@ -49,7 +50,7 @@ public class CamelJdbcTest {
 
     @Test
     void testGetSpeciesByIdWithDefinedType() {
-        RestAssured.when().get("/test/species/1/type").then().body(is("Camelus dromedarius 1"));
+        RestAssured.when().get("/test/species/1/type").then().body(equalToIgnoringCase("Camelus dromedarius 1"));
     }
 
     @Test
@@ -57,22 +58,25 @@ public class CamelJdbcTest {
         RestAssured.given()
                 .contentType(ContentType.TEXT).body("select id from camels order by id desc")
                 .post("/test/execute")
-                .then().body(is("[{ID=3}, {ID=2}, {ID=1}]"));
+                .then().body(equalToIgnoringCase("[{ID=3}, {ID=2}, {ID=1}]"));
     }
 
     @Test
     void testCamelRetrieveGeneratedKeysHeader() {
+        String idKey = RestAssured.when()
+                .get("/test/get-id-key")
+                .then()
+                .extract()
+                .body().asString();
+
         List generatedIDs = RestAssured.given()
                 .get("test/generated-keys/rows")
                 .then().extract().body()
-                .jsonPath().getList("ID");
+                .jsonPath().getList(idKey);
 
-        String selectResult = RestAssured.given()
-                .contentType(ContentType.TEXT).body("select id from camelsGenerated")
-                .post("/test/execute")
-                .then().extract().body().asString();
+        assertFalse(generatedIDs.isEmpty());
+        assertNotNull(generatedIDs.get(0));
 
-        generatedIDs.forEach(generatedID -> assertTrue(selectResult.contains(generatedID.toString())));
     }
 
     @Test
@@ -80,19 +84,19 @@ public class CamelJdbcTest {
         RestAssured.given()
                 .get("test/headers/insert")
                 .then()
-                .body(containsString("CamelGeneratedKeysRowCount=2"))
+                .body(containsStringIgnoringCase("CamelGeneratedKeysRowCount=1"))
                 .and()
-                .body(containsString("CamelJdbcUpdateCount=2"))
+                .body(containsStringIgnoringCase("CamelJdbcUpdateCount=1"))
                 .and()
-                .body(containsString("CamelRetrieveGeneratedKeys=true"))
+                .body(containsStringIgnoringCase("CamelRetrieveGeneratedKeys=true"))
                 .and()
-                .body(not(containsString("CamelJdbcRowCount")))
+                .body(not(containsStringIgnoringCase("CamelJdbcRowCount")))
                 .and()
-                .body(not(containsString("CamelJdbcColumnNames")))
+                .body(not(containsStringIgnoringCase("CamelJdbcColumnNames")))
                 .and()
-                .body(not(containsString("CamelJdbcParameters")))
+                .body(not(containsStringIgnoringCase("CamelJdbcParameters")))
                 .and()
-                .body(not(containsString("CamelGeneratedColumns")));
+                .body(not(containsStringIgnoringCase("CamelGeneratedColumns")));
     }
 
     @Test
@@ -100,19 +104,19 @@ public class CamelJdbcTest {
         RestAssured.given()
                 .get("test/headers/select")
                 .then()
-                .body(not(containsString("CamelGeneratedKeysRowCount")))
+                .body(not(containsStringIgnoringCase("CamelGeneratedKeysRowCount")))
                 .and()
-                .body(not(containsString("CamelJdbcUpdateCount")))
+                .body(not(containsStringIgnoringCase("CamelJdbcUpdateCount")))
                 .and()
-                .body(not(containsString("CamelRetrieveGeneratedKeys")))
+                .body(not(containsStringIgnoringCase("CamelRetrieveGeneratedKeys")))
                 .and()
-                .body(not(containsString("CamelJdbcParameters")))
+                .body(not(containsStringIgnoringCase("CamelJdbcParameters")))
                 .and()
-                .body(not(containsString("CamelGeneratedColumns")))
+                .body(not(containsStringIgnoringCase("CamelGeneratedColumns")))
                 .and()
-                .body(containsString("CamelJdbcRowCount"))
+                .body(containsStringIgnoringCase("CamelJdbcRowCount"))
                 .and()
-                .body(containsString("CamelJdbcColumnNames=[ID, SPECIES]"));
+                .body(containsStringIgnoringCase("CamelJdbcColumnNames=[ID, SPECIES]"));
     }
 
     @Test
@@ -120,9 +124,9 @@ public class CamelJdbcTest {
         RestAssured.given()
                 .get("test/named-parameters/headers-as-parameters")
                 .then()
-                .body(containsString("{ID=1, SPECIES=Camelus dromedarius}"))
+                .body(containsStringIgnoringCase("{ID=1, SPECIES=Camelus dromedarius}"))
                 .and()
-                .body(containsString("{ID=2, SPECIES=Camelus bactrianus}"));
+                .body(containsStringIgnoringCase("{ID=2, SPECIES=Camelus bactrianus}"));
     }
 
     @Test
@@ -130,7 +134,7 @@ public class CamelJdbcTest {
         RestAssured.given()
                 .get("test/named-parameters/headers-as-parameters-map")
                 .then()
-                .body(containsString("{ID=2, SPECIES=Camelus bactrianus}"));
+                .body(containsStringIgnoringCase("{ID=2, SPECIES=Camelus bactrianus}"));
     }
 
     @Test
@@ -163,5 +167,4 @@ public class CamelJdbcTest {
                 .then()
                 .body(equalTo(camelsDbResult));
     }
-
 }


[camel-quarkus] 02/02: Cxf fixes (#4771)

Posted by zh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit ac03cf63dff38b00f1bd8f008bf90008333ef541
Author: llowinge <ll...@redhat.com>
AuthorDate: Fri Apr 14 02:20:23 2023 +0200

    Cxf fixes (#4771)
    
    * Use plain CXF endpoint (without bean) for basic server scenarios
    
    * Add negative test to CXF WS Trust
---
 .../cxf/soap/server/it/CxfSoapRoutes.java          | 32 ++++------------------
 .../cxf/soap/it/ws/trust/CxfWsTrustTest.java       | 23 ++++++++++++----
 2 files changed, 23 insertions(+), 32 deletions(-)

diff --git a/integration-test-groups/cxf-soap/cxf-soap-server/src/main/java/org/apache/camel/quarkus/component/cxf/soap/server/it/CxfSoapRoutes.java b/integration-test-groups/cxf-soap/cxf-soap-server/src/main/java/org/apache/camel/quarkus/component/cxf/soap/server/it/CxfSoapRoutes.java
index 45e09365a7..0bb26d65bf 100644
--- a/integration-test-groups/cxf-soap/cxf-soap-server/src/main/java/org/apache/camel/quarkus/component/cxf/soap/server/it/CxfSoapRoutes.java
+++ b/integration-test-groups/cxf-soap/cxf-soap-server/src/main/java/org/apache/camel/quarkus/component/cxf/soap/server/it/CxfSoapRoutes.java
@@ -101,11 +101,13 @@ public class CxfSoapRoutes extends RouteBuilder {
                     exchange.getIn().setBody(String.format(response, requestMsg + " from Camel route"));
                 });
 
-        from("cxf:bean:echoServiceResponseFromRoute")
-                .setBody(exchange -> exchange.getMessage().getBody(String.class) + " from Camel route");
+        from(String.format("cxf:echoServiceResponseFromRoute?serviceClass=%s&address=/echo-route",
+                EchoServiceImpl.class.getName()))
+                        .setBody(exchange -> exchange.getMessage().getBody(String.class) + " from Camel route");
 
-        from("cxf:bean:echoServiceResponseFromImpl")// no body set here; the response comes from EchoServiceImpl
-                .log("${body}");
+        from(String.format("cxf:echoServiceResponseFromImpl?serviceClass=%s&address=/echo-impl",
+                EchoServiceImpl.class.getName()))// no body set here; the response comes from EchoServiceImpl
+                        .log("${body}");
 
     }
 
@@ -165,26 +167,4 @@ public class CxfSoapRoutes extends RouteBuilder {
         return result;
     }
 
-    @Produces
-    @ApplicationScoped
-    @Named
-    CxfEndpoint echoServiceResponseFromRoute() {
-        final CxfEndpoint result = new CxfEndpoint();
-        result.setServiceClass(EchoServiceImpl.class);
-        result.setAddress("/echo-route");
-        result.getFeatures().add(loggingFeature);
-        return result;
-    }
-
-    @Produces
-    @ApplicationScoped
-    @Named
-    CxfEndpoint echoServiceResponseFromImpl() {
-        final CxfEndpoint result = new CxfEndpoint();
-        result.setServiceClass(EchoServiceImpl.class);
-        result.setAddress("/echo-impl");
-        result.getFeatures().add(loggingFeature);
-        return result;
-    }
-
 }
diff --git a/integration-test-groups/cxf-soap/cxf-soap-ws-trust/src/test/java/org/apache/camel/quarkus/component/cxf/soap/it/ws/trust/CxfWsTrustTest.java b/integration-test-groups/cxf-soap/cxf-soap-ws-trust/src/test/java/org/apache/camel/quarkus/component/cxf/soap/it/ws/trust/CxfWsTrustTest.java
index 0c1b496f66..4ce1c0ca81 100644
--- a/integration-test-groups/cxf-soap/cxf-soap-ws-trust/src/test/java/org/apache/camel/quarkus/component/cxf/soap/it/ws/trust/CxfWsTrustTest.java
+++ b/integration-test-groups/cxf-soap/cxf-soap-ws-trust/src/test/java/org/apache/camel/quarkus/component/cxf/soap/it/ws/trust/CxfWsTrustTest.java
@@ -32,6 +32,7 @@ import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.ws.security.SecurityConstants;
 import org.apache.cxf.ws.security.trust.STSClient;
+import org.apache.cxf.ws.security.trust.TrustException;
 import org.assertj.core.api.Assertions;
 import org.hamcrest.CoreMatchers;
 import org.hamcrest.Matchers;
@@ -94,12 +95,7 @@ public class CxfWsTrustTest {
         try {
             BusFactory.setThreadDefaultBus(bus);
 
-            final QName serviceName = new QName("https://quarkiverse.github.io/quarkiverse-docs/quarkus-cxf/test/ws-trust",
-                    "TrustHelloService");
-            final URL wsdlURL = new URL(io.quarkiverse.cxf.test.QuarkusCxfClientTestUtil.getServerUrl()
-                    + "/soapservice/jaxws-samples-wsse-policy-trust/TrustHelloService?wsdl");
-            Service service = Service.create(wsdlURL, serviceName);
-            TrustHelloService proxy = (TrustHelloService) service.getPort(TrustHelloService.class);
+            TrustHelloService proxy = trustHelloService();
 
             final QName stsServiceName = new QName("http://docs.oasis-open.org/ws-sx/ws-trust/200512/", "SecurityTokenService");
             final QName stsPortName = new QName("http://docs.oasis-open.org/ws-sx/ws-trust/200512/", "UT_Port");
@@ -115,6 +111,21 @@ public class CxfWsTrustTest {
 
     }
 
+    @Test
+    public void programmaticStsNotSet() throws Exception {
+        TrustHelloService proxy = trustHelloService();
+        Assertions.assertThatThrownBy(proxy::sayHello).hasCauseInstanceOf(TrustException.class);
+    }
+
+    TrustHelloService trustHelloService() throws Exception {
+        final QName serviceName = new QName("https://quarkiverse.github.io/quarkiverse-docs/quarkus-cxf/test/ws-trust",
+                "TrustHelloService");
+        final URL wsdlURL = new URL(io.quarkiverse.cxf.test.QuarkusCxfClientTestUtil.getServerUrl()
+                + "/soapservice/jaxws-samples-wsse-policy-trust/TrustHelloService?wsdl");
+        Service service = Service.create(wsdlURL, serviceName);
+        return (TrustHelloService) service.getPort(TrustHelloService.class);
+    }
+
     public static void setupWsseAndSTSClient(TrustHelloService proxy, Bus bus, String stsWsdlLocation, QName stsService,
             QName stsPort) {
         Map<String, Object> ctx = ((BindingProvider) proxy).getRequestContext();