Example #1
0
  /** @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);
  }
Example #2
0
  /** @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);
  }
Example #3
0
 /** @throws Exception */
 @Test
 public void getQuietly() throws Exception {
   String value = "hoge";
   FakeFuture<String> future = new FakeFuture<String>(value);
   assertThat(FutureUtil.getQuietly(future), is(value));
 }