ppalaga commented on a change in pull request #3066:
URL: https://github.com/apache/camel-quarkus/pull/3066#discussion_r703284001



##########
File path: integration-tests/sql/README.adoc
##########
@@ -0,0 +1,45 @@
+== SQL 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 `SQL_JDBC_DB_KIND`. Example of usage:

Review comment:
       Nitpick: ALL_CAPS_SNAKE_CASE is rather unusual for Maven properties. I 
think camel case is the most common. If it is a property owned by this project, 
then namespacing with `cq.` might be a good idea. `cq.sqlJdbcKind` maybe?
   
   ALL_CAPS_SNAKE_CASE is the right choice for env vars.

##########
File path: 
integration-tests/sql/src/main/java/org/apache/camel/quarkus/component/sql/it/SqlRoutes.java
##########
@@ -114,7 +123,9 @@ private Path createTmpFileFrom(String file) throws 
IOException {
             while ((c = is.read()) >= 0) {
                 baos.write(c);
             }
-            fos.write(baos.toByteArray());
+            String content = new String(baos.toByteArray());
+            content = content.replaceAll("projectsViaClasspath", 
"projectsViaFile");
+            fos.write(content.getBytes());

Review comment:
       ```suggestion
               fos.write(content.getBytes(StandardCharsets.UTF_8));
   ```

##########
File path: integration-tests/sql/pom.xml
##########
@@ -143,6 +139,125 @@
                 </plugins>
             </build>
         </profile>
+        <profile>
+            <id>h2</id>
+            <activation>
+                <activeByDefault>true</activeByDefault>
+                <property>
+                    <name>!SQL_JDBC_DB_KIND</name>
+                </property>
+            </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>io.quarkus</groupId>
+                    <artifactId>quarkus-jdbc-h2</artifactId>
+                </dependency>
+            </dependencies>
+        </profile>
+        <profile>
+            <id>postgresql</id>
+            <activation>
+                <property>
+                    <name>SQL_JDBC_DB_KIND</name>
+                    <value>postgresql</value>
+                </property>
+            </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>io.quarkus</groupId>
+                    <artifactId>quarkus-jdbc-postgresql</artifactId>

Review comment:
       Worth trying, but it might fool IDEs and other tools that do not expect 
expressions here.

##########
File path: 
integration-tests/sql/src/test/java/org/apache/camel/quarkus/component/sql/it/SqlTest.java
##########
@@ -67,6 +71,7 @@ public void testSqlComponent() {
     }
 
     @Test
+    @DisabledIfSystemProperty(named = "SQL_JDBC_DB_KIND", matches = 
"[^h][^2].*")

Review comment:
       If you think this can be made to work for other DBs, please file an 
issue and paste the link here.

##########
File path: integration-tests/sql/README.adoc
##########
@@ -0,0 +1,45 @@
+== SQL 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 `SQL_JDBC_DB_KIND`. Example of usage:
+
+`mvn clean test -f integration-tests/sql/ -DSQL_JDBC_DB_KIND=postgresql`
+
+Following databases could be started in the dev-service mode:
+
+- Postgresql (container) - add `-DSQL_JDBC_DB_KIND=postgresql`
+- MySQL (container) - add `-DSQL_JDBC_DB_KIND=mysql`
+- MariaDB (container) - add `-DSQL_JDBC_DB_KIND=mariadb`
+- H2 (in-process) used by default
+- Apache Derby (in-process) - add `-DSQL_JDBC_DB_KIND=derby`
+- DB2 (container) (requires license acceptance) - add `-DSQL_JDBC_DB_KIND=db2`
+- MSSQL (container) (requires license acceptance) - add 
`-DSQL_JDBC_DB_KIND=mssql`
+
+For more information about dev-service mode, see 
https://quarkus.io/guides/datasource#dev-services[documentation].

Review comment:
       Indeed the list impressive!

##########
File path: 
integration-tests/sql/src/main/java/org/apache/camel/quarkus/component/sql/it/SqlRoutes.java
##########
@@ -114,7 +123,9 @@ private Path createTmpFileFrom(String file) throws 
IOException {
             while ((c = is.read()) >= 0) {
                 baos.write(c);
             }
-            fos.write(baos.toByteArray());
+            String content = new String(baos.toByteArray());

Review comment:
       ```suggestion
               String content = new String(baos.toByteArray(), 
StandardCharsets.UTF_8);
   ```
   
   You never know what the current machine's default charset is.

##########
File path: 
integration-tests/sql/src/main/java/org/apache/camel/quarkus/component/sql/it/SqlHelper.java
##########
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.sql.it;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public class SqlHelper {
+
+    private static Set<String> BOOLEAN_AS_NUMBER = new HashSet<>() {
+        {
+            add("db2");
+            add("mssql");
+            add("oracle");
+
+        }
+    };

Review comment:
       This is OK in a test, but it's good to know that double bracket 
initialization may have a performance impact due to introducing a new type 
https://www.youtube.com/watch?v=wgJWs14YcEs&t=1504s More about [ mono | bi | 
poly | mega ]morphic call sites 
https://www.youtube.com/watch?v=wgJWs14YcEs&t=483s
   `new HashSet<>(Arrays.asList("db2", "mssql", "oracle"))` might be generally 
a better choice




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to