@Test
public void testGetTimestampWithBatchImplTimeout() throws Exception {

  // test single thread
  createBatchOracleWithTimeoutImpl(1, 100, 150);
  long startTs = System.currentTimeMillis();
  try {
    timestampOracle.getRequestIdWithTimestamp();
    Assert.fail();
  } catch (Exception e) {
    Assert.assertTrue(e.getCause() instanceof TimeoutException);
  } finally {
    long consume = System.currentTimeMillis() - startTs;
    Assert.assertTrue(consume >= 100 && consume < 150);
  }
  
  // test multi thread
  createBatchOracleWithTimeoutImpl(1, 100, 150);
  createGetThreads(3, 1);
  startGetThreads(true);
  waitGetThreads();
  Assert.assertTrue(getRootCause(getThreads[0].results[0]) instanceof TimeoutException);
  Assert.assertTrue(getRootCause(getThreads[1].results[0]) instanceof TimeoutException);
  Assert.assertTrue(getRootCause(getThreads[2].results[0]) instanceof RejectedExecutionException);
}