Example #1
0
 @Test
 public void setResponseLeadsToResponse()
     throws CancellationException, InterruptedException, ExecutionException {
   Response response = mock(Response.class);
   cut.setResponse(response);
   assertThat(cut.get(), is(response));
 }
Example #2
0
 @Test
 public void setThrowableLeadsToThrowable() throws CancellationException, InterruptedException {
   Throwable throwable = mock(Throwable.class);
   cut.setThrowable(throwable);
   try {
     cut.get();
   } catch (ExecutionException e) {
     assertThat(e.getCause(), is(throwable));
     return;
   }
   fail();
 }
Example #3
0
 @Test(expected = CancellationException.class)
 public void setCancelledLeadsToCancelledException()
     throws CancellationException, InterruptedException, ExecutionException {
   cut.setCancelled();
   cut.get();
 }