  @Test
  public void testServerErrorRecovery() throws InterruptedException, ExecutionException, TimeoutException {

    MockResponse success = new MockResponse().setResponseCode(200)
                                             .setBody(fixture("fixtures/response-success.json"));

    MockResponse error = new MockResponse().setResponseCode(503);

    server.enqueue(error);
    server.enqueue(error);
    server.enqueue(error);
    server.enqueue(success);

    Sender                    sender = new Sender("foobarbaz", mapper, 4, server.getUrl("/gcm/send").toExternalForm());
    CompletableFuture<Result> future = sender.send(Message.newBuilder().withDestination("1").build());

    Result result = future.get(10, TimeUnit.SECONDS);

    assertEquals(server.getRequestCount(), 4);
    assertTrue(result.isSuccess());
    assertFalse(result.isThrottled());
    assertFalse(result.isUnregistered());
    assertEquals(result.getMessageId(), "1:08");
    assertNull(result.getError());
    assertNull(result.getCanonicalRegistrationId());
  }