Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Invalid
-
None
-
None
-
None
-
Unknown
Description
I have this test with a custom header filter strategy:
@Test void testCustomHeadersFilter() throws Exception { final int port = AvailablePortFinder.getNextAvailable(); final CamelContext context = new DefaultCamelContext() DefaultHeaderFilterStrategy hfs = new DefaultHeaderFilterStrategy(); hfs.setOutFilterPattern("(?i)(My)[\\.|a-z|A-z|0-9]*"); hfs.setInFilterPattern("(?i)(My)[\\.|a-z|A-z|0-9]*"); context.getRegistry().bind("myFilterStrategy", hfs); //NettyHttpComponent c = context.getComponent("netty4-http", NettyHttpComponent.class); //c.setHeaderFilterStrategy(hfs); context.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from("direct:source") .setHeader("CamelHeader") .constant("CamelHeaderValue") .setHeader("MyHeader") .constant("MyHeaderValue") .toF("netty4-http:http://localhost:%d?headerFilterStrategy=#myFilterStrategy", port) .to("mock:source"); fromF("netty4-http:http://localhost:%d", port) .setBody().constant("test"); } }); context.start(); MockEndpoint mock = context.getEndpoint("mock:source", MockEndpoint.class); mock.expectedMessageCount(1); context.createProducerTemplate().sendBody("direct:source", "test"); mock.assertIsSatisfied(); assertThat(mock.getExchanges().get(0).getMessage().getHeaders()).doesNotContainKey("MyHeader"); assertThat(mock.getExchanges().get(0).getMessage().getHeaders()).containsEntry("CamelHeader", "CamelHeaderValue"); }
This test fails because:
java.lang.AssertionError: Expecting: <{"CamelHttpResponseCode"=200, "CamelHttpResponseText"="OK", "connection"="keep-alive", "content-length"="4"}> to contain: <[MapEntry[key="CamelHeader", value="CamelHeaderValue"]]> but could not find: <[MapEntry[key="CamelHeader", value="CamelHeaderValue"]]>
which is strange as:
- CamelHeader is supposed to be present
- MyHeader is not present
so it seems that the default netty filter is also used.
If the header filter strategy is applied on component level, then the test succeed.