mirror of
https://github.com/spring-cloud/spring-cloud-netflix.git
synced 2026-09-17 07:43:44 +00:00
Add test verifying newClient() rebuilds after shutdown
Signed-off-by: Prahlad Bhakat <prahladbhakat05@gmail.com>
This commit is contained in:
+16
@@ -92,4 +92,20 @@ class RestClientTransportClientFactoryShutdownTests {
|
||||
return ((HttpComponentsClientHttpRequestFactory) requestFactory).getHttpClient();
|
||||
}
|
||||
|
||||
@Test
|
||||
void newClientAfterShutdownShouldCreateANewCachedRequestFactory() {
|
||||
factory.newClient(endpoint());
|
||||
Object httpClientBeforeShutdown = cachedHttpClient(factory);
|
||||
|
||||
factory.shutdown();
|
||||
|
||||
factory.newClient(endpoint());
|
||||
Object httpClientAfterShutdown = cachedHttpClient(factory);
|
||||
|
||||
// shutdown() clears the cached request factory, so a subsequent newClient()
|
||||
// call must lazily build a fresh one rather than reusing the client that was
|
||||
// just closed.
|
||||
assertThat(httpClientAfterShutdown).isNotSameAs(httpClientBeforeShutdown);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user