### Question:
DefaultBackoffStrategy implements ConnectionBackoffStrategy { @Override public boolean shouldBackoff(final Throwable t) { return t instanceof SocketTimeoutException || t instanceof ConnectException; }  @Override boolean shouldBackoff(final Throwable t); @Override boolean shouldBackoff(final HttpResponse response);  }### Answer:
@Test public void backsOffForSocketTimeouts() { assertTrue(impl.shouldBackoff(new SocketTimeoutException())); }
@Test public void backsOffForConnectionTimeouts() { assertTrue(impl.shouldBackoff(new ConnectException())); }
@Test public void doesNotBackOffForConnectionManagerTimeout() { assertFalse(impl.shouldBackoff(new ConnectionRequestTimeoutException())); }
@Test public void backsOffForServiceUnavailable() { final HttpResponse resp = new BasicHttpResponse(HttpStatus.SC_SERVICE_UNAVAILABLE, "Service Unavailable"); assertTrue(impl.shouldBackoff(resp)); }
@Test public void backsOffForTooManyRequests() { final HttpResponse resp = new BasicHttpResponse(HttpStatus.SC_TOO_MANY_REQUESTS, "Too Many Requests"); assertTrue(impl.shouldBackoff(resp)); }
@Test public void doesNotBackOffForNon429And503StatusCodes() { for(int i = 100; i <= 599; i++) { if (i== HttpStatus.SC_TOO_MANY_REQUESTS || i == HttpStatus.SC_SERVICE_UNAVAILABLE) { continue; } final HttpResponse resp = new BasicHttpResponse(i, "Foo"); assertFalse(impl.shouldBackoff(resp)); } }