@Test
public void testInvalidRedis() throws IOException, ECFileCacheException {

  if (eraseRedis) {
    System.out.println("some redis data unreachable, do not run this case: " +
        ((new Exception()).getStackTrace())[0].getMethodName());
    return;
  }
  Map<Integer, DecoratedJedisPool> keyedPool = client.getRedisAccess().getKeyedPool();
  Map<Integer, DecoratedJedisPool> storedKeyedPool = new HashMap<Integer, DecoratedJedisPool>(keyedPool);
  // cache data ok when offline redis instance little than 3
  keyedPool.put(0, null);
  keyedPool.put(1, null);
  testPutGetDeleteImpl();
  // cache data fail when offline redis instance more than 3
  keyedPool.put(0, null);
  keyedPool.put(1, null);
  keyedPool.put(2, null);
  keyedPool.put(3, null);
  try {
    testPutGetDeleteImpl();
    Assert.fail("should not reach here");
  } catch (ECFileCacheException e) {
    Assert.assertTrue(StringUtils.contains(e.getMessage(), "fail count > CODING_BLOCK_NUM."));
  }
  // restore redis 3
  keyedPool.put(3, storedKeyedPool.get(3));
  // allocate cacheKey if remove little than three redis
  keyedPool.remove(0);
  keyedPool.remove(1);
  keyedPool.remove(2);
  testPutGetDeleteImpl();
  // can not allocate cacheKey if remove more than three redis
  keyedPool.remove(3);
  try {
    testPutGetDeleteImpl();
    Assert.fail("should not reach here");
  } catch (ECFileCacheException e) {
    Assert.assertTrue(StringUtils.startsWith(e.getMessage(), "can not allocate offset id for cacheKey"));
  }
  // restore client pool
  for (int i = 0; i < 5; ++i) {
    keyedPool.put(i, storedKeyedPool.get(i));
  }
  for (int i = 0; i < 5; ++i) {
    Assert.assertNotNull(keyedPool.get(i));
  }
}