()
| 66 | } |
| 67 | |
| 68 | private static void getTimeoutFail() throws InterruptedException, |
| 69 | ExecutionException { |
| 70 | RunnableFuture<?> future = new FutureTask<Object>(new Runnable() { |
| 71 | @Override |
| 72 | public void run() { |
| 73 | // wont run |
| 74 | } |
| 75 | }, null); |
| 76 | |
| 77 | long startTime = System.currentTimeMillis(); |
| 78 | try { |
| 79 | future.get(DELAY_TIME, TimeUnit.MILLISECONDS); |
| 80 | throw new RuntimeException("Exception should have been thrown"); |
| 81 | } catch (TimeoutException e) { |
| 82 | long catchTime = System.currentTimeMillis(); |
| 83 | if (catchTime - startTime < DELAY_TIME) { |
| 84 | throw new RuntimeException("get with timeout did not block long enough"); |
| 85 | } |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | private static void getExecutionExceptionTest() throws InterruptedException, ExecutionException { |
| 90 | FutureTask<Object> future = new FutureTask<Object>(new Runnable() { |
no test coverage detected