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


##########
components/camel-vertx/camel-vertx-http/src/test/java/org/apache/camel/component/vertx/http/VertxHttpRestProducerHeaderFilterTest.java:
##########
@@ -0,0 +1,76 @@
+/*
+ * 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.vertx.http;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.camel.Message;
+import org.apache.camel.RoutesBuilder;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;

Review Comment:
   Small convention point: `camel-vertx-http` is predominantly JUnit — 32 of 
its 35 test classes import `org.junit.jupiter.api.Assertions`, and only 
`VertxHttpTransferExceptionTest` uses AssertJ. `CLAUDE.md` ("Assertions: Use 
AssertJ When Possible") calls this out explicitly:
   
   > Do NOT mix styles within a project/module. Check the assertion style 
already used by the other test classes in the component/module being touched: 
if they are predominantly JUnit assertions, write new tests in that same JUnit 
style rather than introducing AssertJ as an outlier.
   
   So this one is better off in the module's existing JUnit style. Suggestions 
on this line and the three below cover the whole swap.
   
   ```suggestion
   import static org.junit.jupiter.api.Assertions.assertEquals;
   import static org.junit.jupiter.api.Assertions.assertNull;
   ```



##########
components/camel-vertx/camel-vertx-http/src/test/java/org/apache/camel/component/vertx/http/VertxHttpRestProducerHeaderFilterTest.java:
##########
@@ -0,0 +1,76 @@
+/*
+ * 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.vertx.http;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.camel.Message;
+import org.apache.camel.RoutesBuilder;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class VertxHttpRestProducerHeaderFilterTest extends 
VertxHttpTestSupport {
+
+    @Test
+    public void testRestProducerAppliesTheOutboundFilter() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:input");
+        mock.expectedMessageCount(1);
+
+        Map<String, Object> headers = new HashMap<>();
+        headers.put("id", "123");
+        headers.put("Via", "1.1 rogue-proxy");
+        headers.put("Cache-Control", "no-cache");
+        headers.put("X-Custom", "custom-value");

Review Comment:
   Could you add `Content-Type` to this map (e.g. `application/json`) and 
assert below that it **does** still reach the server?
   
   `content-type` is in `HttpUtil.addCommonFilters`, so after this fix it is 
filtered out of the header loop in 
`DefaultVertxHttpBinding.populateRequestHeaders` — the request only keeps it 
because the method sets it explicitly from 
`ExchangeHelper.getContentType(exchange)` a few lines earlier. That makes it 
the one header in the newly-applied set whose survival depends on a second, 
independent code path, and it is exactly what the upgrade guide promises ("the 
`Content-Type` of the request is still taken from the exchange as before"). 
Right now nothing pins that down, so a future change to that explicit block 
would silently break the most user-visible header without failing a test.



##########
components/camel-vertx/camel-vertx-http/src/test/java/org/apache/camel/component/vertx/http/VertxHttpRestProducerHeaderFilterTest.java:
##########
@@ -0,0 +1,76 @@
+/*
+ * 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.vertx.http;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.camel.Message;
+import org.apache.camel.RoutesBuilder;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class VertxHttpRestProducerHeaderFilterTest extends 
VertxHttpTestSupport {
+
+    @Test
+    public void testRestProducerAppliesTheOutboundFilter() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:input");
+        mock.expectedMessageCount(1);
+
+        Map<String, Object> headers = new HashMap<>();
+        headers.put("id", "123");
+        headers.put("Via", "1.1 rogue-proxy");
+        headers.put("Cache-Control", "no-cache");
+        headers.put("X-Custom", "custom-value");
+
+        String out = template.requestBodyAndHeaders("direct:start", null, 
headers, String.class);
+        assertThat(out).isEqualTo("Hello World");
+
+        MockEndpoint.assertIsSatisfied(context);
+
+        Message received = mock.getReceivedExchanges().get(0).getMessage();
+        // excluded on the outbound direction by the common HTTP filter set, 
so they must not reach the wire
+        assertThat(received.getHeader("Via")).isNull();
+        assertThat(received.getHeader("Cache-Control")).isNull();
+        // already consumed by the uri template, so it must not be sent as an 
HTTP header as well
+        assertThat(received.getHeader("id")).isNull();
+        // not filtered on either direction
+        assertThat(received.getHeader("X-Custom")).isEqualTo("custom-value");

Review Comment:
   ```suggestion
           // excluded on the outbound direction by the common HTTP filter set, 
so they must not reach the wire
           assertNull(received.getHeader("Via"));
           assertNull(received.getHeader("Cache-Control"));
           // already consumed by the uri template, so it must not be sent as 
an HTTP header as well
           assertNull(received.getHeader("id"));
           // not filtered on either direction
           assertEquals("custom-value", received.getHeader("X-Custom"));
   ```



##########
components/camel-vertx/camel-vertx-http/src/test/java/org/apache/camel/component/vertx/http/VertxHttpRestProducerHeaderFilterTest.java:
##########
@@ -0,0 +1,76 @@
+/*
+ * 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.vertx.http;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.camel.Message;
+import org.apache.camel.RoutesBuilder;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class VertxHttpRestProducerHeaderFilterTest extends 
VertxHttpTestSupport {
+
+    @Test
+    public void testRestProducerAppliesTheOutboundFilter() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:input");
+        mock.expectedMessageCount(1);
+
+        Map<String, Object> headers = new HashMap<>();
+        headers.put("id", "123");
+        headers.put("Via", "1.1 rogue-proxy");
+        headers.put("Cache-Control", "no-cache");
+        headers.put("X-Custom", "custom-value");
+
+        String out = template.requestBodyAndHeaders("direct:start", null, 
headers, String.class);
+        assertThat(out).isEqualTo("Hello World");

Review Comment:
   ```suggestion
           assertEquals("Hello World", out);
   ```



-- 
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