List of usage examples for org.apache.commons.pool2.impl SoftReferenceObjectPool close
@Override public void close()
From source file:com.lambdaworks.redis.support.ConnectionPoolSupportTest.java
@Test public void softRefPoolShouldWorkWithWrappedConnections() throws Exception { SoftReferenceObjectPool<StatefulRedisConnection<String, String>> pool = ConnectionPoolSupport .createSoftReferenceObjectPool(() -> client.connect()); StatefulRedisConnection<String, String> connection = pool.borrowObject(); RedisCommands<String, String> sync = connection.sync(); sync.ping();/* ww w . j ava 2 s . co m*/ sync.close(); pool.close(); }
From source file:com.lambdaworks.redis.support.ConnectionPoolSupportTest.java
@Test public void softReferencePoolShouldWorkWithPlainConnections() throws Exception { SoftReferenceObjectPool<StatefulRedisConnection<String, String>> pool = ConnectionPoolSupport .createSoftReferenceObjectPool(() -> client.connect(), false); borrowAndReturn(pool);/*from w w w. j a va 2 s.c o m*/ StatefulRedisConnection<String, String> connection = pool.borrowObject(); assertThat(Proxy.isProxyClass(connection.getClass())).isFalse(); pool.returnObject(connection); pool.close(); }
From source file:io.lettuce.core.support.ConnectionPoolSupportTest.java
@Test public void softRefPoolShouldWorkWithWrappedConnections() throws Exception { SoftReferenceObjectPool<StatefulRedisConnection<String, String>> pool = ConnectionPoolSupport .createSoftReferenceObjectPool(() -> client.connect()); StatefulRedisConnection<String, String> connection = pool.borrowObject(); assertThat(channels).hasSize(1);/*from ww w. j av a 2s .com*/ RedisCommands<String, String> sync = connection.sync(); sync.ping(); connection.close(); pool.close(); Wait.untilTrue(channels::isEmpty).waitOrTimeout(); assertThat(channels).isEmpty(); }
From source file:io.lettuce.core.support.ConnectionPoolSupportTest.java
@Test public void softReferencePoolShouldWorkWithPlainConnections() throws Exception { SoftReferenceObjectPool<StatefulRedisConnection<String, String>> pool = ConnectionPoolSupport .createSoftReferenceObjectPool(() -> client.connect(), false); borrowAndReturn(pool);/* w w w .ja v a 2 s . co m*/ StatefulRedisConnection<String, String> connection = pool.borrowObject(); assertThat(Proxy.isProxyClass(connection.getClass())).isFalse(); pool.returnObject(connection); connection.close(); pool.close(); }
From source file:com.lambdaworks.redis.support.ConnectionPoolSupportTest.java
@Test public void tryWithResourcesReturnsSoftRefConnectionToPool() throws Exception { SoftReferenceObjectPool<StatefulRedisConnection<String, String>> pool = ConnectionPoolSupport .createSoftReferenceObjectPool(() -> client.connect()); StatefulRedisConnection<String, String> usedConnection = null; try (StatefulRedisConnection<String, String> connection = pool.borrowObject()) { RedisCommands<String, String> sync = connection.sync(); sync.ping();/*from www . j av a2 s . c om*/ usedConnection = connection; } try { usedConnection.isMulti(); fail("Missing RedisException"); } catch (RedisException e) { assertThat(e).hasMessageContaining("deallocated"); } pool.close(); }