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