davsclaus commented on code in PR #27528:
URL: https://github.com/apache/camel/pull/27528#discussion_r4215823854


##########
components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlProducerInParameterNamesTest.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * 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.component.sql;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit6.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase;
+import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
+import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/**
+ * Each :#in: parameter is expanded to the number of its own values, also when 
its name is the start of the name of a
+ * later :#in: parameter, or when it is an expression with characters that are 
special in a regular expression.
+ */
+class SqlProducerInParameterNamesTest extends CamelTestSupport {
+
+    EmbeddedDatabase db;
+
+    @Override
+    public void doPreSetup() throws Exception {
+        db = new EmbeddedDatabaseBuilder()
+                .setName(getClass().getSimpleName())
+                .setType(EmbeddedDatabaseType.H2)
+                .addScript("sql/createAndPopulateDatabase6.sql").build();
+    }
+
+    @Override
+    public void doPostTearDown() throws Exception {
+        if (db != null) {
+            db.shutdown();
+        }
+    }
+
+    @Test
+    void testNameIsStartOfLaterName() {
+        Map<String, Object> headers = Map.of("project", List.of("Camel", 
"AMQ"), "projectLicense", List.of("ASF", "XXX"));

Review Comment:
   Optional: with two values on both sides, the test would still pass if every 
IN list were expanded with the first parameter's count. Different sizes also 
prove that each list gets the count of its own parameter (Camel with 
ASF/XXX/YYY is 3 rows in `createAndPopulateDatabase6.sql`):
   
   ```suggestion
           Map<String, Object> headers = Map.of("project", List.of("Camel"), 
"projectLicense", List.of("ASF", "XXX", "YYY"));
   ```
   
   (and `assertEquals(3, rows.size());` on the line below).



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to