2525import redis .clients .jedis .ClientSetInfoConfig ;
2626import redis .clients .jedis .DefaultJedisClientConfig ;
2727import redis .clients .jedis .HostAndPort ;
28- import redis .clients .jedis .JedisPool ;
29- import redis .clients .jedis .JedisPoolConfig ;
28+ import redis .clients .jedis .Jedis ;
3029
3130/**
3231 * Common for all Redis tests.
@@ -42,7 +41,7 @@ public class RedisCommonAbstractTest extends GridCommonAbstractTest {
4241 protected static final int PORT = 6379 ;
4342
4443 /** Pool. */
45- protected static JedisPool pool ;
44+ protected static RedisPool pool ;
4645
4746 /** Default Redis cache name. */
4847 private static final String DFLT_CACHE_NAME = "redis-ignite-internal-cache-0" ;
@@ -51,29 +50,19 @@ public class RedisCommonAbstractTest extends GridCommonAbstractTest {
5150 @ Override protected void beforeTestsStarted () throws Exception {
5251 startGrids (gridCount ());
5352
54- JedisPoolConfig jedisPoolCfg = new JedisPoolConfig ();
55-
56- jedisPoolCfg .setMaxWaitMillis (20000 );
57- jedisPoolCfg .setMaxIdle (100 );
58- jedisPoolCfg .setMinIdle (1 );
59- jedisPoolCfg .setNumTestsPerEvictionRun (10 );
60- jedisPoolCfg .setTestOnBorrow (true );
61- jedisPoolCfg .setTestOnReturn (true );
62- jedisPoolCfg .setTestWhileIdle (true );
63- jedisPoolCfg .setTimeBetweenEvictionRunsMillis (30000 );
64-
65- DefaultJedisClientConfig clientCfg = DefaultJedisClientConfig .builder ()
66- .connectionTimeoutMillis (10000 )
67- .socketTimeoutMillis (10000 )
68- .clientSetInfoConfig (ClientSetInfoConfig .DISABLED )
69- .build ();
70-
71- pool = new JedisPool (jedisPoolCfg , new HostAndPort (HOST , PORT ), clientCfg );
53+ pool = new RedisPool (
54+ new HostAndPort (HOST , PORT ),
55+ DefaultJedisClientConfig .builder ()
56+ .connectionTimeoutMillis (10000 )
57+ .socketTimeoutMillis (10000 )
58+ .clientSetInfoConfig (ClientSetInfoConfig .DISABLED )
59+ .build ()
60+ );
7261 }
7362
7463 /** {@inheritDoc} */
7564 @ Override protected void afterTestsStopped () throws Exception {
76- pool . destroy () ;
65+ pool = null ;
7766 }
7867
7968 /** {@inheritDoc} */
@@ -91,7 +80,7 @@ public class RedisCommonAbstractTest extends GridCommonAbstractTest {
9180
9281 cfg .setConnectorConfiguration (redisCfg );
9382
94- CacheConfiguration ccfg = defaultCacheConfiguration ();
83+ CacheConfiguration < String , String > ccfg = defaultCacheConfiguration ();
9584
9685 ccfg .setStatisticsEnabled (true );
9786 ccfg .setIndexedTypes (String .class , String .class );
@@ -125,4 +114,31 @@ protected int gridCount() {
125114
126115 assertTrue (jcache ().localSize () == 0 );
127116 }
117+
118+ /**
119+ * Lightweight Redis connection factory.
120+ */
121+ protected static class RedisPool {
122+ /** Redis address. */
123+ private final HostAndPort addr ;
124+
125+ /** Client config. */
126+ private final DefaultJedisClientConfig cfg ;
127+
128+ /**
129+ * @param addr Redis address.
130+ * @param cfg Client config.
131+ */
132+ RedisPool (HostAndPort addr , DefaultJedisClientConfig cfg ) {
133+ this .addr = addr ;
134+ this .cfg = cfg ;
135+ }
136+
137+ /**
138+ * @return Redis client.
139+ */
140+ Jedis getResource () {
141+ return new Jedis (addr , cfg );
142+ }
143+ }
128144}
0 commit comments