### Question:
AIMDBackoffManager implements BackoffManager { @Override public void backOff(final HttpRoute route) { synchronized(connPerRoute) { final int curr = connPerRoute.getMaxPerRoute(route); final Long lastUpdate = getLastUpdate(lastRouteBackoffs, route); final long now = clock.getCurrentTime(); if (now - lastUpdate.longValue() < coolDown.toMilliseconds()) { return; } connPerRoute.setMaxPerRoute(route, getBackedOffPoolSize(curr)); lastRouteBackoffs.put(route, Long.valueOf(now)); } } AIMDBackoffManager(final ConnPoolControl<HttpRoute> connPerRoute);   AIMDBackoffManager(final ConnPoolControl<HttpRoute> connPerRoute, final Clock clock); @Override void backOff(final HttpRoute route); @Override void probe(final HttpRoute route); void setBackoffFactor(final double d); void setCoolDown(final TimeValue coolDown); void setPerHostConnectionCap(final int cap);  }### Answer:
@Test public void halvesConnectionsOnBackoff() { connPerRoute.setMaxPerRoute(route, 4); impl.backOff(route); assertEquals(2, connPerRoute.getMaxPerRoute(route)); }
@Test public void doesNotBackoffBelowOneConnection() { connPerRoute.setMaxPerRoute(route, 1); impl.backOff(route); assertEquals(1, connPerRoute.getMaxPerRoute(route)); }
@Test public void backoffDoesNotAdjustDuringCoolDownPeriod() { connPerRoute.setMaxPerRoute(route, 4); final long now = System.currentTimeMillis(); clock.setCurrentTime(now); impl.backOff(route); final long max = connPerRoute.getMaxPerRoute(route); clock.setCurrentTime(now + 1); impl.backOff(route); assertEquals(max, connPerRoute.getMaxPerRoute(route)); }
@Test public void backoffStillAdjustsAfterCoolDownPeriod() { connPerRoute.setMaxPerRoute(route, 8); final long now = System.currentTimeMillis(); clock.setCurrentTime(now); impl.backOff(route); final long max = connPerRoute.getMaxPerRoute(route); clock.setCurrentTime(now + 10 * 1000L); impl.backOff(route); assertTrue(max == 1 || max > connPerRoute.getMaxPerRoute(route)); }