@Test(dataProvider = "codes")
public void test409DoesBackoffAndRetryForCode(String code) {
AWSUtils utils = createMock(AWSUtils.class);
BackoffLimitedRetryHandler backoffLimitedRetryHandler = createMock(BackoffLimitedRetryHandler.class);
HttpCommand command = createMock(HttpCommand.class);
HttpRequest putBucket = HttpRequest.builder().method(PUT)
.endpoint("https://adriancole-blobstore113.s3.amazonaws.com/").build();
HttpResponse operationAborted = HttpResponse.builder().statusCode(CONFLICT.getStatusCode())
.payload(Payloads.newStringPayload(String.format("<Error><Code>%s</Code></Error>", code))).build();
expect(command.getCurrentRequest()).andReturn(putBucket);
AWSError error = new AWSError();
error.setCode(code);
expect(utils.parseAWSErrorFromContent(putBucket, operationAborted)).andReturn(error);
expect(backoffLimitedRetryHandler.shouldRetryRequest(command, operationAborted)).andReturn(Boolean.TRUE);
replay(utils, backoffLimitedRetryHandler, command);
AWSClientErrorRetryHandler retry = new AWSClientErrorRetryHandler(utils, backoffLimitedRetryHandler,
ImmutableSet.<String> of("RequestTimeout", "OperationAborted", "SignatureDoesNotMatch"));