@SuppressWarnings("unchecked")
  @Test
  public void testIOE() throws IOException, InterruptedException {
    this.bc.cacheBlock(this.plainKey, plainCacheable);
    RAMQueueEntry rqe = q.remove();
    RAMQueueEntry spiedRqe = Mockito.spy(rqe);
    Mockito.doThrow(new IOException("Mocked!")).when(spiedRqe).writeToCache(Mockito.any(),
      Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any());
    this.q.add(spiedRqe);
    doDrainOfOneEntry(bc, wt, q);
    assertTrue(bc.blocksByHFile.isEmpty());
    assertTrue(bc.getBackingMap().isEmpty());
    // Cache disabled when ioes w/o ever healing.
    assertTrue(!bc.isCacheEnabled());
  }
Do IOE. Take the RAMQueueEntry that was on the queue, doctor it to throw exception, then put it
back and process it.
hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestBucketWriterThread.java