BaseTimestampOracle { public Pair<Long, Long> getRequestIdWithTimestamp() throws IOException { return getRequestIdWithTimestamp(0); } BaseTimestampOracle(Configuration conf); Pair<Long, Long> getRequestIdWithTimestamp(); void close(); abstract long getTimestamps(int n);  }
@Test public void testGetTimestampWithBatchImplTimeout() throws Exception { 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); } 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); }