@@ -0,0 +1,3943 @@
+package com.signalfx.connection;%0A%0Aimport org.apache.http.HttpResponse;%0Aimport org.apache.http.HttpStatus;%0Aimport org.apache.http.ProtocolVersion;%0Aimport org.apache.http.StatusLine;%0Aimport org.apache.http.client.protocol.HttpClientContext;%0Aimport org.apache.http.impl.DefaultHttpResponseFactory;%0Aimport org.apache.http.protocol.HttpContext;%0Aimport org.junit.Test;%0A%0Aimport static org.junit.Assert.assertFalse;%0Aimport static org.junit.Assert.assertTrue;%0A%0Apublic class RetryStrategyTest %7B%0A    @Test%0A    public void shouldSetRetryOnRequestTimeout() %7B%0A        final RetryStrategy retryStrategy = new RetryStrategy(3);%0A%0A        final StatusLine mockStatusLine = generateStatusLineByCode(HttpStatus.SC_REQUEST_TIMEOUT);%0A        final HttpContext mockHttpContext = new HttpClientContext();%0A        final HttpResponse mockResp = DefaultHttpResponseFactory.INSTANCE.newHttpResponse(mockStatusLine, mockHttpContext);%0A%0A        assertTrue(retryStrategy.retryRequest(mockResp, 1, mockHttpContext));%0A    %7D%0A%0A    @Test%0A    public void shouldSetRetryOnGatewayTimeout() %7B%0A        final RetryStrategy retryStrategy = new RetryStrategy(3);%0A%0A        final StatusLine mockStatusLine = generateStatusLineByCode(HttpStatus.SC_GATEWAY_TIMEOUT);%0A        final HttpContext mockHttpContext = new HttpClientContext();%0A        final HttpResponse mockResp = DefaultHttpResponseFactory.INSTANCE.newHttpResponse(mockStatusLine, mockHttpContext);%0A%0A        assertTrue(retryStrategy.retryRequest(mockResp, 1, mockHttpContext));%0A    %7D%0A%0A    @Test%0A    public void shouldSetRetryOnNegativeStatus() %7B%0A        final RetryStrategy retryStrategy = new RetryStrategy(3);%0A%0A        final StatusLine mockStatusLine = generateStatusLineByCode(-1);%0A        final HttpContext mockHttpContext = new HttpClientContext();%0A        final HttpResponse mockResp = DefaultHttpResponseFactory.INSTANCE.newHttpResponse(mockStatusLine, mockHttpContext);%0A%0A        assertTrue(retryStrategy.retryRequest(mockResp, 1, mockHttpContext));%0A    %7D%0A%0A    @Test%0A    public void shouldSetRetryOnInvalidStatusCode() %7B%0A        final RetryStrategy retryStrategy = new RetryStrategy(3);%0A%0A        final StatusLine mockStatusLine = generateStatusLineByCode(598);%0A        final HttpContext mockHttpContext = new HttpClientContext();%0A        final HttpResponse mockResp = DefaultHttpResponseFactory.INSTANCE.newHttpResponse(mockStatusLine, mockHttpContext);%0A%0A        assertTrue(retryStrategy.retryRequest(mockResp, 1, mockHttpContext));%0A    %7D%0A%0A    @Test%0A    public void shouldNotRetryOnOtherStatusCode() %7B%0A        final RetryStrategy retryStrategy = new RetryStrategy(3);%0A%0A        final StatusLine mockStatusLine = generateStatusLineByCode(HttpStatus.SC_BAD_GATEWAY);%0A        final HttpContext mockHttpContext = new HttpClientContext();%0A        final HttpResponse mockResp = DefaultHttpResponseFactory.INSTANCE.newHttpResponse(mockStatusLine, mockHttpContext);%0A%0A        assertFalse(retryStrategy.retryRequest(mockResp, 1, mockHttpContext));%0A    %7D%0A%0A    @Test%0A    public void shouldNotRetryIfRetriesExceeded() %7B%0A        final RetryStrategy retryStrategy = new RetryStrategy(3);%0A%0A        final StatusLine mockStatusLine = generateStatusLineByCode(HttpStatus.SC_GATEWAY_TIMEOUT);%0A        final HttpContext mockHttpContext = new HttpClientContext();%0A        final HttpResponse mockResp = DefaultHttpResponseFactory.INSTANCE.newHttpResponse(mockStatusLine, mockHttpContext);%0A%0A        assertFalse(retryStrategy.retryRequest(mockResp, 4, mockHttpContext));%0A    %7D%0A%0A    private StatusLine generateStatusLineByCode(final int statusCode) %7B%0A        return new StatusLine() %7B%0A            @Override%0A            public ProtocolVersion getProtocolVersion() %7B%0A                return null;%0A            %7D%0A%0A            @Override%0A            public int getStatusCode() %7B%0A                return statusCode;%0A            %7D%0A%0A            @Override%0A            public String getReasonPhrase() %7B%0A                return null;%0A            %7D%0A        %7D;%0A    %7D%0A%7D

Add unit test for new class