@SuppressWarnings("unchecked")
@Test
public void testDisableSharedConnection() throws Exception {
factory.setShareNativeConnection(false);
RedisConnection conn2 = factory.getConnection();
assertNotSame(connection.getNativeConnection(), conn2.getNativeConnection());
// Give some time for native connection to asynchronously initialize, else close doesn't work
Thread.sleep(100);
conn2.close();
assertTrue(conn2.isClosed());
// Give some time for native connection to asynchronously close
Thread.sleep(100);
try {
((RedisAsyncConnection<byte[], byte[]>) conn2.getNativeConnection()).ping();
fail("The native connection should be closed");
} catch (RedisException e) {
// expected
}
}