@Test
public void testRead() throws Exception {

  ExecutorService executeService = Executors.newFixedThreadPool(2);
  ReaderWriterLock lock = new ReaderWriterLock();
  Reader reader1 = spy(new Reader("Reader 1", lock.readLock()));
  Reader reader2 = spy(new Reader("Reader 2", lock.readLock()));
  executeService.submit(reader1);
  Thread.sleep(150);
  executeService.submit(reader2);
  executeService.shutdown();
  try {
    executeService.awaitTermination(10, TimeUnit.SECONDS);
  } catch (InterruptedException e) {
    LOGGER.error("Error waiting for ExecutorService shutdown", e);
  }
  // Read operation will hold the read lock 250 milliseconds, so here we prove that multiple reads
  // can be performed in the same time.
  assertTrue(appender.logContains("Reader 1 begin"));
  assertTrue(appender.logContains("Reader 2 begin"));
  assertTrue(appender.logContains("Reader 1 finish"));
  assertTrue(appender.logContains("Reader 2 finish"));
}