use of com.mongodb.client.syncadapter.SupplyingCallback in project mongo-java-driver by mongodb.
the class DefaultConnectionPoolTest method shouldThrowOnPoolClosed.
@Test
public void shouldThrowOnPoolClosed() {
provider = new DefaultConnectionPool(SERVER_ID, connectionFactory, ConnectionPoolSettings.builder().maxSize(1).maxWaitTime(50, MILLISECONDS).build(), mockSdamProvider());
provider.close();
String expectedExceptionMessage = "The server at 127.0.0.1:27017 is no longer available";
MongoServerUnavailableException exception;
exception = assertThrows(MongoServerUnavailableException.class, () -> provider.get());
assertEquals(expectedExceptionMessage, exception.getMessage());
SupplyingCallback<InternalConnection> supplyingCallback = new SupplyingCallback<>();
provider.getAsync(supplyingCallback);
exception = assertThrows(MongoServerUnavailableException.class, supplyingCallback::get);
assertEquals(expectedExceptionMessage, exception.getMessage());
}
Aggregations