gnodet commented on code in PR #26183: URL: https://github.com/apache/camel/pull/26183#discussion_r3955931203
########## 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: The module's 50 existing test classes all use JUnit assertions (`org.junit.jupiter.api.Assertions`); zero use AssertJ. CLAUDE.md calls this out explicitly: match the module's existing style rather than introducing AssertJ as an outlier. Swap the import and all four usages below. ```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"); + + String out = template.requestBodyAndHeaders("direct:start", null, headers, String.class); + assertThat(out).isEqualTo("Hello World"); Review Comment: ```suggestion assertEquals("Hello World", out); ``` ########## 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: Add `Content-Type` here (e.g. `headers.put("Content-Type", "application/json")`) and assert below that it **still arrives** at the server. `content-type` is in `HttpUtil.addCommonFilters`, so after this fix it enters the filter loop in `DefaultVertxHttpBinding.populateRequestHeaders` and would be dropped — except that method sets it explicitly from `ExchangeHelper.getContentType(exchange)` a few lines earlier, before the loop runs. That explicit assignment is what the upgrade guide promises ("the `Content-Type` of the request is still taken from the exchange as before"), but nothing in the test locks this invariant down. A future refactor of `populateRequestHeaders` that removes the explicit assignment would silently break `Content-Type` propagation without failing any 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")); ``` -- 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]
