@Test
	@SuppressWarnings("unchecked")
	public void shouldRetryAndRecoverAfter3FailedAttemptsByCallingRecoveryCallback() throws Exception {
		RetryTemplate retry = new RetryTemplate();
		retry.setListeners(new RetryListener[] {retryListenerMock});
		template.setRetryOperations(retry);
		template.setRecoveryCallback(recoveryCallback);
		// 1st call
		doThrow(new JedisException("dummy"))
				// 2nd call
				.doThrow(new JedisException("dummy"))
						// 3rd call
				.doThrow(new JedisException("dummy")).when(redisConnectionMock).set((byte[]) any(), (byte[]) any());
		template.opsForValue().set("a", "b");
		verify(retryListenerMock, times(3))
				.onError(any(RetryContext.class), any(RetryCallback.class), any(Throwable.class));
		verify(recoveryCallback, times(1)).recover(any(RetryContext.class));
	}
@author Christoph Strobl
@author Thomas Darimont
spring-xd-analytics/src/test/java/org/springframework/xd/analytics/metrics/redis/RedisRetryTemplateTests.java