/** @throws Exception */ @Test(expected = WrapRuntimeException.class) public void getQuietlyWhenExceptionOccurred() throws Exception { String value = "hoge"; FakeFuture<String> future = new FakeFuture<String>(value) { @Override public String get() throws InterruptedException, ExecutionException { throw new ExecutionException(new Exception("Hoge")); } }; FutureUtil.getQuietly(future); }
/** @throws Exception */ @Test(expected = Error.class) public void getWhenErrorOccurred() throws Exception { String value = "hoge"; FakeFuture<String> future = new FakeFuture<String>(value) { @Override public String get() throws InterruptedException, ExecutionException { throw new ExecutionException(new Error("Hoge")); } }; FutureUtil.get(future); }
/** @throws Exception */ @Test public void getQuietly() throws Exception { String value = "hoge"; FakeFuture<String> future = new FakeFuture<String>(value); assertThat(FutureUtil.getQuietly(future), is(value)); }