testDeleter.setMaxErrors(1); testDeleter.executeOneIteration(containerName, ListContainerOptions.Builder.recursive(), semaphore,
@SuppressWarnings("unchecked") public void testExceptionThrownAfterMaxRetries() { IMocksControl mockControl = createControl(); ListeningExecutorService executorService = mockControl .createMock(ListeningExecutorService.class); DeleteAllKeysInList testDeleter = createMockBuilder( DeleteAllKeysInList.class).withConstructor(executorService, blobstore, retryHandler, maxParallelDeletes).createMock(); // Fail the first future that is created for deleting blobs. EasyMock.<ListenableFuture<?>> expect( executorService.submit(isA(Callable.class))) .andReturn( Futures.<Void> immediateFailedFuture(new RuntimeException())) .once(); EasyMock.expectLastCall().andReturn(Futures.<Void> immediateFuture(null)) .anyTimes(); replay(executorService); testDeleter.setMaxErrors(1); boolean blobRunTimeExceptionThrown = false; try { testDeleter.execute(containerName, ListContainerOptions.Builder.recursive()); } catch (BlobRuntimeException be) { blobRunTimeExceptionThrown = true; } assertTrue(blobRunTimeExceptionThrown, "Expected a BlobRunTimeException"); }