Class RequestFactoryUtil

java.lang.Object
ca.cdr.test.app.clients.common.RequestFactoryUtil

public class RequestFactoryUtil extends Object
  • Method Details

    • wrap

      @Nonnull public static org.springframework.http.client.HttpComponentsClientHttpRequestFactory wrap(@Nonnull ISmileTestHttpClient theClient)
      Wraps an existing SmileTestHttpClient for use with Spring's RestClient, so that the Spring-based clients share one connection pool and one cookie store with everything else issued through the same SmileTestHttpClient. 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's HttpComponentsClientHttpRequestFactory#destroy() closes whatever client it was handed, regardless of who created it. Nothing calls destroy() 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 ISmileTestHttpClient handle 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 is sealed to SmileTestHttpClient, so the narrowing below is total and there is no unwrappable handle to reject.