예제 #1
0
 @Test
 public void setIsDoneReturnsTrueIffResponse() {
   Response response = mock(Response.class);
   assertThat(cut.isDone(), is(false));
   cut.setResponse(response);
   assertThat(cut.isDone(), is(true));
 }
예제 #2
0
 @Test
 public void setIsDoneReturnsTrueIffThrowable() {
   Throwable throwable = mock(Throwable.class);
   assertThat(cut.isDone(), is(false));
   cut.setThrowable(throwable);
   assertThat(cut.isDone(), is(true));
 }
예제 #3
0
 @Test
 public void setResponseLeadsToResponse()
     throws CancellationException, InterruptedException, ExecutionException {
   Response response = mock(Response.class);
   cut.setResponse(response);
   assertThat(cut.get(), is(response));
 }
예제 #4
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();
 }
예제 #5
0
 @Test
 public void setIsDoneReturnsFalseIfCancelled() {
   cut.setCancelled();
   assertThat(cut.isDone(), is(false));
 }
예제 #6
0
 @Test
 public void isCancelledReturnsTrueIffCancelled() {
   assertThat(cut.isCancelled(), is(false));
   cut.setCancelled();
   assertThat(cut.isCancelled(), is(true));
 }
예제 #7
0
 @Test(expected = CancellationException.class)
 public void setCancelledLeadsToCancelledException()
     throws CancellationException, InterruptedException, ExecutionException {
   cut.setCancelled();
   cut.get();
 }
예제 #8
0
 @Test
 public void cancelReturnsFalse() {
   assertThat(cut.cancel(true), is(false));
   assertThat(cut.cancel(false), is(false));
 }