|
16 | 16 |
|
17 | 17 | package org.springframework.ws.transport.http; |
18 | 18 |
|
19 | | -import static org.assertj.core.api.AssertionsForClassTypes.*; |
20 | | -import static org.springframework.ws.transport.http.HttpComponents5ClientFactory.*; |
21 | | - |
22 | 19 | import jakarta.servlet.http.HttpServlet; |
23 | 20 | import jakarta.servlet.http.HttpServletRequest; |
24 | 21 | import jakarta.servlet.http.HttpServletResponse; |
25 | 22 | import jakarta.xml.soap.MessageFactory; |
26 | | - |
27 | | -import java.io.IOException; |
28 | | -import java.net.URI; |
29 | | -import java.util.HashMap; |
30 | | -import java.util.Map; |
31 | | - |
32 | 23 | import org.apache.hc.client5.http.HttpRoute; |
| 24 | +import org.apache.hc.client5.http.classic.ExecChainHandler; |
33 | 25 | import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; |
| 26 | +import org.apache.hc.client5.http.impl.classic.HttpClientBuilder; |
34 | 27 | import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager; |
35 | 28 | import org.apache.hc.core5.http.HttpHost; |
36 | 29 | import org.eclipse.jetty.server.Connector; |
|
45 | 38 | import org.springframework.ws.transport.WebServiceConnection; |
46 | 39 | import org.springframework.ws.transport.support.FreePortScanner; |
47 | 40 |
|
| 41 | +import java.io.IOException; |
| 42 | +import java.net.URI; |
| 43 | +import java.util.HashMap; |
| 44 | +import java.util.Map; |
| 45 | + |
| 46 | +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; |
| 47 | +import static org.springframework.ws.transport.http.HttpComponents5ClientFactory.getPort; |
| 48 | + |
48 | 49 | class HttpComponents5MessageSenderIntegrationTest |
49 | 50 | extends AbstractHttpWebServiceMessageSenderIntegrationTestCase<HttpComponents5MessageSender> { |
50 | 51 |
|
| 52 | + private static CloseableHttpClient createHttpClientWithAssertion() { |
| 53 | + ExecChainHandler handler = (request, scope, chain) -> { |
| 54 | + assertThat(request.getEntity().getContentType()) |
| 55 | + .describedAs("Exec interceptors are supposed to receive content type. Verify that HttpEntity class is instantiated correctly") |
| 56 | + .isNotBlank(); |
| 57 | + return chain.proceed(request, scope); |
| 58 | + }; |
| 59 | + return HttpClientBuilder.create() |
| 60 | + .addRequestInterceptorFirst(new HttpComponents5MessageSender.RemoveSoapHeadersInterceptor()) |
| 61 | + .addExecInterceptorFirst("logbook-alike exec interceptor", handler) |
| 62 | + .build(); |
| 63 | + } |
| 64 | + |
51 | 65 | @Override |
52 | 66 | protected HttpComponents5MessageSender createMessageSender() { |
53 | | - return new HttpComponents5MessageSender(); |
| 67 | + return new HttpComponents5MessageSender(createHttpClientWithAssertion()); |
54 | 68 | } |
55 | 69 |
|
56 | 70 | @Test // GH-1164 |
|
0 commit comments