Class RequestFactoryUtil
-
Method Summary
Modifier and TypeMethodDescriptionstatic org.springframework.http.client.HttpComponentsClientHttpRequestFactorywrap(ISmileTestHttpClient theClient) Wraps an existingSmileTestHttpClientfor use with Spring'sRestClient, so that the Spring-based clients share one connection pool and one cookie store with everything else issued through the sameSmileTestHttpClient.
-
Method Details
-
wrap
@Nonnull public static org.springframework.http.client.HttpComponentsClientHttpRequestFactory wrap(@Nonnull ISmileTestHttpClient theClient) Wraps an existingSmileTestHttpClientfor use with Spring'sRestClient, so that the Spring-based clients share one connection pool and one cookie store with everything else issued through the sameSmileTestHttpClient. Sharing the cookie store is what lets a login performed by one client be seen by the next.Ownership stays with whoever built the
SmileTestHttpClient, but only by convention: Spring'sHttpComponentsClientHttpRequestFactory#destroy()closes whatever client it was handed, regardless of who created it. Nothing callsdestroy()here because these factories are built by hand rather than as Spring beans ? so do not register the returned factory as a bean, or container shutdown will close a pool the harness is still using.Takes the
ISmileTestHttpClienthandle rather than the concrete class so that the client a test already holds ?SmileHarness.getHttpClient()returns that handle ? can be passed straight in. The handle issealedtoSmileTestHttpClient, so the narrowing below is total and there is no unwrappable handle to reject.
-